GUI for linux c - c

is it possible to develop a GUI in linux c??
how can be do that??

If you want to develop GUI applications for Linux with pure C you can use GTK+. IF C++ is an option you also have Qt.

There are many graphical toolkits for linux such as GTK, Qt, wxWidgets, and FLTK. They have bindings for many languages such as C and Python. I suggest you google around to see what you like. If you want a RAD you may want to check out things like glade and qt creator.

Yes. Use a GUI toolkit such as GTK+ that uses C, or find a wrapper for one of the various C++ toolkits.

XForms is a graphical user interface toolkit for X based on the X11 Xlib library. I.e., it allows you to create windows, containing all kinds of widgets (buttons, sliders, browsers, menus etc.) with a few lines of code and then attach actions to the widgets, i.e., have some function called when a button is pressed. To make this even easier XForms comes with a program called fdesign that allows you to design a GUI for a program directly on the screen and which then writes out the necessary C code for it.
XForms is written in C and has a C API, i.e., you can use it directly from a C program. It should work with X11 R4, R5, R6 & R7 and under all kinds of operating systems of the UNIX family (including MacOS X) as well as at least OpenVMS, OS/2 und Windows NT 4.0. In addition, the library is extensible and new objects can easily be created and added to the library.
http://xforms-toolkit.org

I would recommend FLTK. It may be difficult to write complex interface with it. But FLTK, as its name implies, is very small and fairly fast. What is more important, it is cross-platform, working nicely on the three major OS: linux, windows and mac. In my view, GTK/Qt/wxWidgets are far too heavy. If you statically link to these library, you will end up with a huge executable which eat up the memory; if you dynamically link to them, users have to install the library before hand, which is always troublesome.
EDIT: I just realize that this is a "C" question. Then the best choice should be GTK. If you need graphics but not interface/widgets (e.g. menu, scrollbar and so on), opengl is also nice.

Related

How does one add <graphics.h> into GCC on a Windows computer for C? [duplicate]

I have been searching to get the source code of the header file <graphics.h> and its associated library in order to integrate it with my C++ program.
At the same time, I am interested in those cross-platform libraries that works on more than one compiler. Just to be more explicit, I am talking about those libraries that are used for drawing shapes, lines, and curves in C++.
<graphics.h> is very old library. It's better to use something that is new
Here are some 2D libraries (platform independent) for C/C++
SDL
GTK+
Qt
Also there is a free very powerful 3D open source graphics library for C++
OGRE
<graphics.h> is not a standard header. Most commonly it refers to the header for Borland's BGI API for DOS and is antiquated at best.
However it is nicely simple; there is a Win32 implementation of the BGI interface called WinBGIm. It is implemented using Win32 GDI calls - the lowest level Windows graphics interface. As it is provided as source code, it is perhaps a simple way of understanding how GDI works.
WinBGIm however is by no means cross-platform. If all you want are simple graphics primitives, most of the higher level GUI libraries such as wxWidgets and Qt support that too. There are simpler libraries suggested in the possible duplicate answers mentioned in the comments.
There is a modern port for this Turbo C graphics interface, it's called WinBGIM, which emulates BGI graphics under MinGW/GCC.
I haven't it tried but it looks promising. For example initgraph creates a window, and
from this point you can draw into that window using the good old functions, at the end closegraph deletes the window. It also has some more advanced extensions (eg. mouse handling and double buffering).
When I first moved from DOS programming to Windows I didn't have internet, and I begged for something simple like this. But at the end I had to learn how to create windows and how to handle events and use device contexts from the offline help of the Windows SDK.
The Borland Graphics Interface, the library fronted by the graphics.h header, has been re-implemented atop SDL. This brings support for modern hardware and operating systems (multiple operating systems, in fact, since SDL is fairly portable).
It can be downloaded here prebuilt for a variety of common desktop targets.
Or if you wish to (or must) build it from source, here is a github mirror.
Note that it is a port of a very old software library and will run atop modern tools, so you should check with the instructor if you intend to use it for class assignments. It would be irritating to fail an assignment because you used idioms that require support from a modern compiler and find that they do not compile on a marking system from the 1980s.
You may find it better to get and develop with a virtual machine clone of the marking system to prevent nasty surprises.
graphics.h appears to something once bundled with Borland and/or Turbo C++, in the 90's.
http://www.daniweb.com/software-development/cpp/threads/17709/88149#post88149
It's unlikely that you will find any support for that file with modern compiler. For other graphics libraries check the list of "related" questions (questions related to this one). E.g., "A Simple, 2d cross-platform graphics library for c or c++?".

What is the win32 equivalent for mac?

The below link shows examples on how the Windows API works:
Module 1. Your First Windows Program
I am quite interested in how the Mac API looks like.
After doing some reading, I read a lot of things like XCode (Environment), Cocoa Framework, etc. However, I dont see any information about something like the Win32 API.
Doesn't Apple have a low level C API that is not based on Obective-C but just plain old C?
Your link points to a tutorial for the GUI components of Windows. In that case, the equivalent for OS X is indeed the Cocoa framework, which consists of the Foundation and AppKit libraries, which are Objective-C libraries.
Cocoa's control drawing is entirely local to the application. Therefore, the only way to build applications using controls is with Objective-C. Nothing stops you from building a C API on top of that; similar tactics have been used to build libraries like Qt or bindings to languages like Python and Ruby.
There is no plain C GUI API in OS X. There are low-level APIs (part of the Quartz graphics framework, aka the Core Graphics API) for dealing with the window manager to open the top-level windows, but these are either very complicated or completely undocumented. And even then, you'd be responsible for doing all the controls and input handling yourself. Update Some of the basic facilities that applications build on top of are also available through C APIs, namely Core Foundation, Core Graphics, Core Text, and Grand Central Dispatch. But these are still not enough to use Cocoa; Cocoa is just built on top of them.
There is also the Carbon API, which is a C API, but was intended for transitioning pre-OS X applications to OS X and is thus not suitable for new application development. In fact, I'm not even sure it is even supported anymore.
So you have two options if you want to write a GUI program for OS X in plain C:
find a wrapper library
give up and learn Objective-C, which sits on top of plain C anyway
If online tutorials, including Apple's official ones, don't suit you, the Big Nerd Ranch books on Cocoa development are good. Note that their beginner-oriented books are transitioning to the Swift language, but they have a separate book dedicated to teaching Objective-C as well.
You'll also need to know that OS X applications almost exclusively design their user interfaces using a graphical designer called Interface Builder, akin to the form designers in Visual Studio. With the Windows API, you can still get away with doing things by code, and a lot of people do so; with OS X, doing everything programmatically is difficult (but still possible).

Allegro5 with C - making program

I'm making program using Allegro5, but I'm not familiar with the library yet. I just want to know what is possible with this library.
I have to do 'color correction of image' (contrast, brightness, etc.) and I thought about:
-making buttons (like in normal windows program),
-scrollbars,
-file loader - I click on the button and I'm allowed to jump through directories on my hard drive and pick image file i want to edit in my program
-opening windows in allegro window (for the preview or something)
etc.
I want to use for that as much OOP as I can (i know, it's C). Is it possible to do all of that in C and Allegro5, or i need windows libraries and other stuff as well?
Thanks in advance for your replies. :)
Yes, you can do all of those things, but Allegro 5 is primarily designed for games and not GUI applications. It has support for native menus (5.1 series) and dialogs, but you're on your own regarding buttons, sliders, etc. (There are some third party GUI libraries available, but none of them would look like a native application.)
So if your program is basically a GUI application, then you're probably best off using something like Qt or GTK as your foundation, and only using a graphics library as needed.

Developing a simple windowed app for Linux

Okay, I'd like to write a simple C app for Linux (say Ubuntu with Gnome) that would do the following:
Open a Window
Draw something in that window using a main loop, e.g. the current loop number. I don't want to use controls, but to draw directly on the window surface
Close the window & the app
I can do that in Windows, but I've no idea how I could do that in Linux.
Thanks!
Unless you want a full-blown GUI (in which case I'd recommend Qt or GTK), then SDL is a very popular and extremely simple free cross-platform library that gives you a drawing surface and some simple IO facilities. It's natively C, but has bindings to a large number of other languages.
There are various "Hello World" examples for X11 programming.
Using GTK+:
http://library.gnome.org/devel/gtk-tutorial/2.13/c39.html
Using Qt:
http://doc.qt.nokia.com/latest/tutorials-widgets-toplevel.html
Using wxWidgets:
http://www.wxwidgets.org/docs/tutorials/hello.htm
There are a lot more toolkits: Fox, FLTK, Tk, EFL ...
So far these have all been cross-platform, so let's have a look at X11-specific exampls:
This is using Xlib:
http://en.literateprograms.org/Special:Downloadcode/Hello_World_(C,_Xlib)
And this is using Xcb:
http://xcb.freedesktop.org/tutorial/basicwindowsanddrawing/
If you only want to draw something, why not just use OpenGL and GLUT. The latter provides simple methods to create a window with an OpenGL context.
Setting up a GLUT application is very straighforward and there are lots of tutorials out there , e.g. Lighthouse3d.com. This tutorial works with visual studio, but it's not hard to translate this to compiling an application on Linux.
Alternatively, you could also work with Qt, which is a more advanced and easy to use GUI toolkit, and which would not necessarily require you to write OpenGL code.
Since you mentioned C, there is Glade if you want to make use of GTK+ for a nice little editor that allows you to draw controls onto a window.
Alternatively if you have access to a C++ compiler you can have a look at Qt which provides similar functionality.
Well, if you're familiar with making gui apps in windows I'm going to take a guess that you've done it with .net or something similar. An easy transition would be to use mono. A cross platform .NET development platform - http://mono-project.com/Main_Page
There's also has a variety gui toolkits to use: http://www.mono-project.com/Gui_Toolkits
If you want to draw directly onto the window, have you considered X11?
It's not going to be as nice as working with a toolkit like GTK or Qt, but it's about as low level as you can get in the windowing system.
I don't have any experience with programming straight X11, so I can't recommend any starting material.

Is there any crossplatform GUI library for C language? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Cross Platform C library for GUI Apps?
Is there any crossplatform GUI library for C language? (I mean at least win mac lin) If there is any XML-like GUI editing model, any GUI editing crossplatform visual programms it'l be grate!)
Take a look at the IUP Toolkit. It is written largely in C, and is also easily bound to Lua.
I use Gtk a lot it is consistent and nice to use. It was formerly used as a common platform for Gimp but became widely used and is the base toolkit for the Gnome desktop under Linux.
The GUI editor I use is Glade under Linux. The code generated can be recompiled without change under Windows. GLib is an underlying library that abstracts files, network, provides basic types and collections. As long as you use Glib, you are mostly OS independent.
I forgot to mention that glade stores the user interface in XML and generates code out of it. On the glade page I saw there is a windows version there but I cannot tell much about its behaviour. Under Linux it's fairly OK to use and quite stable.
Tk is a GUI library written in C. It comes with a scripting language named Tcl. These can be embedded in your C program. They are very mature and relatively lightweight. You can call the GUI toolkit from C, though it's much easier to do your GUI in Tcl and import it into your C program.
Applications written in Tcl, Tk and C are highly portable, and easy to distribute. The language is BSD style, which is a lot more liberal than GNU licenses.
On the Mac and Windows, Tk uses native widgets whenever possible, making your apps look right for each of those platforms.
GTK is a cross-platform GUI for C (not C++, though there are wrappers for it and many languages).

Resources