I'm having a problem for a SDL project, I'd like to show text on the window and allow the user to input text. As much as I know, there is no simple way to achieve that. Do you hava any suggestion?
Note: I use C programming langage. I know there is a library called SDL_ttf which doesn't seems to make the job I want.
I have to be honest, as I was reading your question, SDL_ttf immediately sprang to mind. It's not too hard to use and there are plenty of docs available.
What it sounds like you are looking for, is a library that provides a simple console interface, where your main programming interaction is to write(...) and read(...) text and it handles display, scrolling and so on.
This project has a lot of code showing how to implement a simple 'console' in SDL, and it does use SDL_ttf to do so.
I'm not convinced you are going to avoid it, unless you grab someone's library that hides it away from you like this one but you are going to have less control over the display and interactivity this provides.
I must go with benosteen, SDL_ttf is a really good option. For my part, I used this tutorial to make it work in my project. It's really simple and straightforward.
EDIT:
I had some troubles with the Blending functionality of SDL_ttf, but I managed to make it work after QuasarDonkey found the problem in this question.
Have a look for a straight forward example on how to use it and create text surface.
Related
Recently I started to have a look at the GTK library in C, and wanted to create GUI application. In fact, I want to create an image application, but I don't know how to make my application looking exactly the same as my drawing, I've looked throught the gtk3-demo and also the widget factory but problems remains;
How to create GUI application, how do I know which container should I use, how do I know what kind of widget ? etc... So I have a picture of what I want to do, but I have absolutly no idea how. What is the process, what question should I ask myself in order to get my GUI application done ? Drawing of my application link
I would very much recommend you play with the Gtk3 GUI using python. You can interactively create windows, containers. Even later, it is much faster to develop the GUI in python, as many have already experienced.
Most of the Gtk3 C/C++ tutorials are available in Python too.
Glade is excellent in many cases - particularly if you want only standard behaviour of the widgets. If you even slightly wander from that straight path, things can get complicated quickly.
If it is really necessary, there are several ways to incorporate C/C++ functions into the Python GUI to make those critical apps go faster.
How are user interfaces developed from the ground up in low level languages like C or C++? We usually make GUIs using libraries or APIs. But I'm interested in understanding the fundamentals of how these libraries are implemented and how they create a Window from just coding only.
There is a surprising amount of stuff to make a simple GUI control like a button work.
Quite a few years ago I was on a project developing a Pacemaker Programmer (custom computer) where we needed to write a GUI application but the OS we were using only had text-based output support. We purchased a product called the Zinc Application Framework that could do that for and since it was designed to work on anything, we had access to the source code (and I peeked).
There are simple thinks like you would not even think about. Like, what if the button is partially covered by another window. Then you have do the divide the button into both an visible and hidden region so you can display the correct part. Remember, a screen is only one set of pixels. Now, I am sure a graphics card or a library/protocal like direct-X might do that for you; but, it has to get done and you wanted to know the details.
Zinc was a very Object Oriented design so the part I described is part of the window drawing component that the button did not need to know about. Also, it used a lot of inheritance (written in C++) to build class upon class; so, the total functionality of a button was spread all over the place. Ex: A button and a check box are very similar except in the way they are displayed; so, the classes the realize them share the same base classes.
If you are really interested and are willing to spend the hours to understand it, there should be open-source Windowing/GUI code you could look at. X-Windows comes to mind. I wish I could show you the Zinc code because I am sure it was much simpler.
One of interesting readings on this topic i read was document of wayland http://wayland.freedesktop.org/docs/html/ch01.html. It explains on X Window System and wayland architecture. To begin with, may be interested.
I want to start a Process Manager project in C and it's suppose to have a Graphical User Interface. It's my first GUI project and I have no idea about it. After some searches I found that I should use winapi32 libraries.
My question is:
Should I write my project like a Console-based one and then I add GUI to it or I should think about GUI at beginning of my project?
I would like to say that it's best to write the application as a command line application, then write a wrapper in GUI. This way you get the most flexible application with a total separation between the GUI and functionality.
But I won't say it! :-)
From my experience it's very difficult to totally seperate the GUI from the application, and thus you should built it with GUI in mind. Your code must open windows, report progress, react upon GUI events, so you must be well familiar with the GUI system you use.
But you must also maintain a separation between the GUI and the functionality as much as you can. For example, make your callbacks short, and direct the funcionality to non-GUI parts of the application. If you need to report progress during long calculation, pass a callback to the calculation algorithm instead of mixing GUI progress commands within the algorithm.
You also must bear in mind that most (if not all) GUI system can do GUI commands only within the main application thread, and build the program accodingly.
So in summary - yes, think about GUI at the beginning, it will be easier this way, but also keep a good separation between the GUI and the functionality,
Why changing the program during development? Just design it like it should be in the end.
You could design your program in a way that enables you to use both, text and graphical user interface. Offer an abstracted interface to the core functionality and use it from the text and the graphical interface.
If you want start top-down and not bottom-up you should choose whatever you prefer to start with a text or graphical interface that calls stub-versions of your interface.
Why write your project like a console-based one, since it's gonna end up with a GUI?
If there are any things you want to try it out first (like you don't know how to do a,b or c), sure you can implement that as a side project.
But as far as your main Project goes, that's what I'd do :
Carefully plan and design
What is it gonna do?
How are you gonna do it?
What should the User Interface contain in order to fully accomodate what you need
Coding
Test and Debug.
Repeat 2 & 3 until perfectly satisfied.
Hint :
A. I wouldn't suggest you to add your GUI to an existing console app, 'coz this will most likely lead to messy code and/or a messy UI.
;-)
B. Always study before trying to implement anything. You simply can't imagine how much your knowledge of what can be done
influences what you can do (and most likely what you'll end up doing).
If you want to make an user interface, you can use QTCreator or Visual Studio forms projects...
QT is an excellent way to make cross-platforms and cute interfaces... Visual Studio forms are usable only in windows platforms.
When you're working with any of these technologies you have to put "componentes" in a "window" a then code them...
hi every one i want ask that i have made a program and i have store a data in csv file. now i want a gui which includes buttons which upon pressing opens a a file and plot a graph.is there a way through which i can add gui in my program using gcc.and also i want to ask how can i make a moving graph just like ECG.
thank alot.
Have you looked into using a toolkit like GTK+, if not i would suggest you check it out. GTK+ is written natively in C so i think it should work for you.
Rephrasing your quesiton:
You have a C program that stores data in a csv file. You wish to display this information as a graph but don't know how to build a GUI or graphical display. Further, you want animation (it would be good if you linked to what "ECG" is) probably to display temporal aspects.
If I have this right, I suggest you learn the GTK and Cairo libraries and use those to build your GUI. Build GUI's is tedious and unrewarding work (to me), particularly in C. I'd think hard about if you really want to bother making a GUI instead of doing something simple like calling out to gnuplot to build the graph as a file that the user can open, though this won't get you any animation.
I suggest you switch your project to C++ and use Qt for your GUI.
If gcc is not a requirement, then check out SciPy or Octave.
I'm planning to write my first program (it'll be in C#), and I need help with a decision. I know I'll want to use custom controls in the final version of the program (probably these), but someone advised me to use standard WinForm controls until the program is running right. They said once things are running right, then I could replace the UI with the custom controls I want. Is this the best way for me to do it? Or should I use the custom UI controls from the beginning?
About me:
-Never written a program
-Have some light Access/VBA experience and classroom C++ Logic and non-UI programming
-If it matters, I don't know exactly how to do it yet but I do plan to try to keep the logic and the UI as separate as I possibly can. I know that needs to be a priority.
Thanks.
It depends on some factors:
The complexity: a simple custom-draw control can easily replace the standard winform control but generally custom controls add new features and tend to have differents methods and properties. In this case, switching to the custom control is not a simple task.
Your experience: Since you are pretty new to this, using a custom control can add another level of difficulty. Generally, these controls offers more options than the winform controls. So, it would be wise to start with the simple winform controls.
Since this is your first project, I tend to agree with your friend. While there is nothing inherently wrong with starting with third party controls, you will find that there is much more documentation and help available for the built in controls. In your early development efforts, you will likely hit many stumbling blocks, regardless of the choices that you make. Therefore, starting out with the most well-travelled course may make things easier for you starting out.
Once you have a little more experience debugging some of the issues that you will inevitably experience while learning a GUI framework, then it would make more sense to start bringing in glitzy third party controls.
Just use the standard controls. Keep it simple, Keep it simple, keep it simple. Also know that if you are still programming next year (hopefully on other projects), you will look back at this code in shame -- but that is a good thing.
Never written a program? I would not advise using any third party libs at this point, you are still learning. If you want the benefit of custom controls, why not write them yourself? You get the custom behavior and you actually learn how this stuff works.
Also, this statement is a bit of a red flag:
-If it matters, I don't know exactly how to do it yet but I do plan to try to keep the logic and the UI as separate as I possibly can. I know that needs to be a priority.
Design patterns are great, but until you get some experience it is hard to understand why they are so great. Start like everyone else writing 'bad' code and then come back to the design patterns. That way you will truly realize why they are so important (rather than just being told that they are). Don't try to grok the advanced stuff before being full competent with the fundamentals.