I've written a code in linux OS which produces prog.out as output file.
Now I've to write GUI for the code.
what are best ways to write it?
PS - I wanted to choose between Java Swings and openGL.
Which is best for writing a simple GUI and integrating it with my C- Application
Thanks in advance
OpenGL is a rendering library, not a UI toolkit. Comparing it to Swing doesn't make sense. And you can't choose Swing for a C application, unless you'd rather do the UI in Java and interact with a C "backend".
For a pure C solution, the best choice would probably be the GTK+ toolkit.
Try Anjuta...
http://projects.gnome.org/anjuta/
If you are prepared to use another language (you mention Java) then you may find C++ and Qt to be a good fit. Linking to the existing C code will be trivial and Qt works well on a great many platforms should you ever wish to support other platforms in addition to Linux.
Related
I'm learning C (I just finished Chapter 2 or Unit 2) of the C Programming Language, I skimmed to the end and saw that at no point anything was said about how to create a GUI, and from what I've looked up, it seems I have to use a framework, but I hate the idea of that. How would I create a GUI without a framework? How exactly do these frameworks work and what language are they written in? I'm not making a massive application, even if it takes me a week, would it be feasible to write a GUI application (in C) to do something simple like creating a window?
You can build your own framework based on OpenGL or Xlib. Or use good graphics library like Motif or CGUI. Or use something awful like GTK.
Not the best road to take. I would suggest a cross platform library, like GTK+.
Yeah, no go.
C can't do anything except manage memory and possibly do software interrupts (if you do pointer hacking).
You need a library to do anything.
GUI is very complex, you can't do anything "simple" with it. It's a problem I face every single day.
If you want a window in C, you need X11, GTK, Windows API, Video hacking, or other fun stuff.
Oh, and Video hacking is a no go, OS will throw an exception if you even try to touch video memory without its permission.
Oh, and the "simple button" you speak of, in Windows API is actually a Window itself, not very simple.
You can make a basic framework using the WINAPI
There is a great tutorial here.
The problem with using C and primitive frameworks like WINAPI is that manging layout and state becomes exceedingly difficult.
If you targeting a normal operating system, the C only requirement becomes unreasonable. I recommend you go with C++ and Qt and compile your C code in a C++ compiler.
Hello StackOverflow Community,
I am writing a MicroMouse Simulator in C language. And I wanted something to visualize the way the maze is being solved like this -- http://www.youtube.com/watch?v=N9TkDgJNJso
I've been researching a way to accomplish this, but I haven't found anything with enough documentation to accomplish my goal.
I don't want to implement this using ASCII symbols, to me it doesn't look professional.
Is there any good GUI interfaces that I could use in C to help me accomplish this? And if so, how would I use it? I don't mind having to code in another language like Java or Python to accomplish my goal.
I saw the video that you want to make. After watching the video I feel you don't need a GUI library for this simulator program.
Here is a list of libraries that you can use.
1.OpenGL This is a 3D graphics API which also can be used for 2D and can be used with both c/c++
2.SDL This library is easy to understand for a beginner. For your program this library is better and can be used with both c/c++.
3.winBGIm This is same as the graphics.h that you found and can be used both c/c++ but it is only for windows.
If you are looking for GUI library then here's a short list.
1.GTK This is written in c and is a popular GUI library for c. You can find a GUI editor for gtk forms called glade which enables quick & easy development of user interfaces.
2.WxWidgets This is written in c++ so you have to use c++ rather than c.
3.FLTK
There are many more libraries besides these which you can find in google. You said
I do not mind having to code in another language like Java or Python to accomplish my goal.
Then for java you can use swing and If you are windows developer then use the windows form application in visual c++; then development of your program will be very easy.
SDL is one of candidate for C in order to make GUI Simulation. Lazyfoo is one of the best site I found for beginner.
SDL is strongly portable. It's written in C and there're a lot of documentation and tutorials.
So being new to the C language i want to program a simple window or GUI. are there any good web pages or books i could get to learn how to do this? I've searched around on the net and haven't come up with anything! or if someone could send me on the right track like what to #include and maybe some important commands that i will need that would be awesome! thanks!
Check out GTK. You didn't say what OS you are using. GTK is cross platform, but easiest to use on Linux.
You need a gui toolkit, you can either use one built into your OS (eg the Win32 API on windows) or pick a platform independant one
Qt http://qt.nokia.com/ is probably the most popular full featured one, or you can start with something quicker and easy like http://www.fltk.org/
I'm developing a win32 app in the C Programming Language. This is my first experience with the native win32 apis and they seem to be completely brutally unreadable (simple window).
I was wondering if there was a wrapper for the entire API that I could use, instead of having to smash my head with this stuff.
Other frameworks/libs won't do since I want to work with Windows' native api.
Thanks!
Other GUI frameworks/libs won't do since I want to work with Windows' native api.
If you want to work with the Win32 API... you have to work with the Win32 API. You'll want to get your hands on a copy of Petzold (http://www.charlespetzold.com/pw5/) and go from there. The example you posted is not incredibly complex, once you have seen the explanation for what the code does you will probably be less worried.
MFC/ATL/Qt/wxWidgets will all allow you to get handles to the controls if you need to customise anything.
Is there any particular reason you want to work with the native Win32 API?
Once you understand the code its not that complicated; the main issue is that you need to deal with all the boiler plate stuff yourself and which is where you lose more time. I don't know your situation, but would using a framework like MFC be acceptible? The same window in C is relatively easier in MFC as shown here and it hides some of the boilerplate code. Also there are a few cross platform options such as Qt4, but not sure if those will be acceptible or not.
If you're using pure C, then none of the common frameworks (MFC, ATL, etc) will help you. There might be other libraries (TCL?) but it's going to be fairly evil.
Even today not all of the tutorials online utilize the Message Crackers in Windowsx.h. Make sure you're familiar with those, they will save you some grief and help make your app easier to migrate.
WinForms on the .Net framework is a nice (nearly comprehensive) wrapper around the Win32 windows api.
In the C/C++ world, the ATL api is a (somewhat) higher level alternative to using the raw apis
Rad Studio which include C++ Builder and the VCL can be a good choice
I want to write a standalone GUI based app for administering one of the most popular enterprise middleware products from a very big company. But that big company already has a admin tool and its free.
But guess what , its very very slow , since its written on the java/Eclipse platform.
I want to write a very fast responsive GUI tool natively for windows.
I do not have much experience programming for windows , So what library(open source preferably) i can use on windows to get the job done.
Note: I need to write it in C, Not C++ , But if i dont have any choice I guess i can do with C++.
So I basically need to write a GUI app in C with some good GUI library.
Please help me out.
Thanks.
Edit : I do not know OOP and don't prefer using it.
Edit : So my choice is down to Win32API and Qt.
my requirement is that of a simple GUI , nothing fancy. I will be using simple windows ,buttons and menus. But I may need to do some processing , which means GUI should not take up much resources.
Based on this I m thinking of using Win32 API , even if I have to take the pain to hopefully satisfy the users.
its very very slow , since its written
on the java/Eclipse platform.
Are you sure that this is the reason for the application's slowness? I am no
fan of Java, but before you reach any conclusion, have you made sure that
writing the software in c makes it noticably faster? It could be that the
application is slow for reasons that are not under the control of the GUI programmer,
such as a slow database or bad network latencies.
Also, I don't mean to be rude here, but do
I want to write a very fast responsive
GUI tool natively for windows.
and
I do not have much experience
programming for windows
not contradict each other?
If you want to write a C GUI app, stick to Win32 or GTK+.
Win32 is blazingly fast, and will let you access everything available to Windows. Take a look at this tutorial.
GTK+ is extremely easy to use, cross platform, and provides tons of extra functionality. Start by downloading the all-in-one bundle, and move onto a tutorial and the documentation.
Personally I'd recommend going straight to Python if you need quick, responsive GUIs, and just need to wrap some lower level stuff.
Why are you limiting yourself to C? Windows Forms and WPF and SIlverLight are all viable UI frameworks that are responsive and have tons of books. There's a reason you can't find much info about writing GUI apps in C - people don't do it.
For plain C, cross platform, native look, simple, scriptable UI, I suggest to have a look at IUP: http://www.tecgraf.puc-rio.br/iup/
If you really have to use C then you can use GTK+. Otherwise, I'd suggest a C++ library like QT or wxWidgets. However, that being said I still think it would be preferable to build a .NET (Windows Forms or WPF) solution. They should provide a better UI experience than Java/Swing.
If you really want to do it in C, you could use the Win32 API. But it's hell working with it. The Object Oriented variant isn't much better either, but it takes away a bit of the pain (MFC).
I strongly recommend you to use C++ with the Qt library, which is both cross-platform and open-source (LGPL). C++ Qt GUI applications are as fast as native Win32 applications, although they take more memory. And you can't even start comparing the productivity gains - Qt is a great library, terrifically designed for GUI programming with tons of other useful tools.
Most GUI toolkits are written in C++, so restricting yourself to C will limit your options somewhat. One option that is cross platform and written in C is GTK; it's originally for X, but runs on Windows as well.
edit: Of course, you could always just program directly against the Windows API (formerly know as Win32) itself. For simple GUIs, it's not too bad.
GUI components map very well into Object oriented paradigm. Using C for GUI applications is a bad idea, I've been there and it's much more confortable to do it in an propper OO fashion with C++. Of course you can sort of do OO with C but it's ugly to say the least.
In my opinion, more than the GUI frameworks you need to really work on the design of the application you building.
For a normal GUI in C/C++ Win32 provides enough of controls for a decent looking application with good response time.
What you should really focus on is how to make it multi-thread based upon the time your modules take for execution.
Consider this small example: You have a DataBase connection monitoring in your GUI which is probed every second. Another module may be sending some big files to other applications. Now if an application is single threaded, your GUI is bound to have response problem. If you database connection is very slow due to some network/db issue your app will hang irrespective of the GUI frameworks or hardware chosen, if it was a single threaded app.
But if you write a good design and dedicate a separate thread for GUI handling and other threads for handing background tasks, you will have a really good GUI response. That way you can perform other tasks in background and GUI gets updated when notification is obtained. Remember, it wont happen magically and you need to sync you threads and update GUI.
Also, avoid creating threads for each and every task. You need to check things which can take more time like sending big files or faster tasks like checking/reading if config file exists or not.
By using third party GUI frameworks you are increasing your dependencies in your application and you would require to ship additional dlls etc with you main application. With win32 things are pretty neat.