#include "fx.h"
/ *
This is a classic example. As you can see, use Fox to do the same thing.
Not much more code than the corresponding console program!
The following items need to pay attention:
- Each FOX application requires a (also only one) Application object (FXAPP).
- Before doing anything, you need to initialize the Application object. You need to put Argc and Argv
These two parameters are passed to it so that fox can handle specific command line parameters (eg, -display).
- You need at least a top window; in this program is FXmainWindow.
- Fox components only need to be simply centered in the correct order.
Here, we create FXButton as a "main" child.
- A simple call to FXAPP :: Create () will automatically create each part.
If CREATE () is not called, the part will only exist there, but it does not appear on the screen.
- Finally, the FxApp :: run () function will start the main event loop. It will not be returned until the program runs.
* /
// Program entry point
INT main (int Argc, char ** argv) {
// Each Fox GUI program requires one, and only one Application object is needed.
// Application object automatically handles some transactions shared between components;
// For example, it is responsible for sending an event, saving all windows, and so on.
// We need to pass the "name" and "vendor)" to Application,
// These two are used to find registration information databases (used to save registration information, such as
// fonts and colors.
FXAPP Application ("Hello", "Foxtest");
// We initialize the application here. We need to pass the command line parameters to Fox so that it is one
/ Some specific processing. It also displays the window and reads the configuration file to make some configurations take effect.
Application.init (Argc, Argv);
// The main window is created below. We need to pass the window title and icon as a parameter to it (if
// It also supports some window features, such as boundary, off buttons, and drag function.
FXMainWindow * main = new fxmainwindow (& Application, "Hello", NULL, NULL, DECOR_ALL);
/ / Here we have created a button. It has a label above, but there is no icon.
// '&' symbols provide a shortcut for this button so that we can use the keyboard to control it.
// The button will send an id_quit message to the Application object, which is implemented by default to exit the application.
New FXButton (Main, "& Hello, World!", NULL, & Application, FxApp :: id_quit);
// This sentence "implements" the part tree. This is necessary because the GUI is a client-server system.
// That is, there are actually two systems being run, one client (in this program, is "Hello World"),
// and a server (X11 Server or Windows GDI). We can create C parts objects,
/ / But we also want to tell the server to display the window. In addition to windows, there are many other resources.
// If icon, font, etc. need to be created. This function calls will be recursively access the entire part tree and then create. Application.create ();
// Obviously: This sentence will display our window in the center of the screen.
Main-> show (placement_screen);
// Until now, we really make our program run. It will not return until we exit the program.
// Function Run () is a simple loop that receives events from users, and then waits for the next event.
// Until we click Exit button.
Return Application.run ();
}