Hello everyone,
if someone doesn't want to use an IDE (just an editor, a compiler and a debugger) what is the best way to impelement a GUI by hand?
I think about a WinAPI-Application in plain C or C++.
Hello everyone,
if someone doesn't want to use an IDE (just an editor, a compiler and a debugger) what is the best way to impelement a GUI by hand?
I think about a WinAPI-Application in plain C or C++.
If all you have is the Windows API, you'll be using your text editor to create the UI widgets in code. There's no XAML or other intermediate language or markup involved. If you want to do layout, you'd use pencil and paper or a graphical tool like Visio to mock up the UI so you can do the math about where you want everything to be.
Or alternatively, you can just stick a rusty screwdriver in between your little toe and your little toenail. That might be less painful.
EDIT: Other posters have talked about using other frameworks like Qt or using layout panels and such. But the question asked about the Windows API and C/C++. That brings us back to Petzold. Not the crap he's written recently, but the "Programming Windows" stuff. Great in its day, and it was pretty much the way things were done 15 years ago, but I'd never go back without a very, very good reason to!
All a GUI editor does is write code that reflects the properties of those items that you placed on the form. Without a GUI editor, you will need to write all of the code yourself.
I am not sure if I'm answering your question, but I usually design a GUI using a pencil and a piece of paper.
I draw out the layout of the interface, then in faint lines draw boxes around the DIV tags and how control-sets that are grouped together.
Then I code the HTML from that. I find it more effective to use a pencil than a mouse in some circumstances.
You can write .rc files by hand for dialog boxes. For the main window frame and views etc you will need to write code by hand. You can get a jumpstart on that code if you use one of Visual Studio's wizards to stub in the project.
Mock it on paper or whereever you want.
Be precise on margin, width, left alignement ...
Once you get a precise idea of the position of each element on the screen, you "just" have to translate it.
It's that a punition or something ?
Most of the answers are plain wrong IMHO. You don't give precise coordinates without GUI editor using Pencil and Paper, that would be too much bad way.
I used to create Forms using hand, but I used wxWidgets and sizer, it pretty easy to create forms using hands, just add a sizer and the control.
Also there are various notations to do that in wxWidgets By Jorg http://www.xs4all.nl/~jorgb/wb, where you just specify form layout in one line, and it will generate the code. I can't find the link.
The experience of developing a GUI is very different deppending on the graphical toolkit you're using. In Windows the most typical (and I think that low level) is MFC API, but it's not the only possibility, as you can also use a higher approach with tools like GTK+ or Tk. Of course, you'll need to install the libraries on Windows.
For example, in GTK+, you can use XML files to describe most of the GUI, which could be easier than making them hard-coded. Also you can make a VBox object and add other objects to it, and automatically the objects will be positioned one below the previous, instead of having to measure and describe its XY position.
Making a GUI without a visual editor is perfectly possible (I have made some), but having a visual editor is almost always a great great advantage. But, with actual technology, it's better to use the higher level possible tool available. Programming any GUI on C/C++ with raw MFCs and without visual editor could be really hard.
I recommend you at least taking a look on GTK+ (http://www.gtk.org/) You can use it from C++ (also other languages like Python and C#) and it's not very difficult to use withouta visual editor. It has visual editors, also, if you'll change your mind.
It is hard work so I recommend using a text editor that supports text substitution macros and creating your own "syntax" for handling repetitive tasks. Some good text editors allow you to define your own "intellisense" and have Win32 API intellisense already built in.
Qt has layouts that allows you to easily implement a basic GUI without resorting to hand-laying out your GUI.
You'll need to learn the API's for your particular windowing system. Under MS Windows this would be the Windows API if you're going down as low as possible, or perhaps using MFC in C++. In any case it's a process of try it and fix it and try it again and fix it some more, etc, ad nauseum. I had to do this years ago under X/Windows and it was slow and painful. You might want to try it once just to prove you can do it, but in my experience it's neither productive or necessary.
Use Visio or some other programmable diagramming tool.
Write an exporter that converts your drawing into the C code for your library. Win32 if that's your flavor.
One day of work writing this exporter will save you hours of "compile-run-checkifitswhereiwantittobe".
I think the best way to design a GUI is to use a mark-up language like Mozilla XUL. However, Mozilla implemented XUL to be used with the Gecko engine, not for native Windows applications. That's why I am creating my own implementation on top of Windows, if you are interested you can check it out: XULWin.