Frequently Asked Questions |
Questions.
Why does FOX look so much like Windows?
Has FOX been ported to the Apple Macintosh?
Which Systems are supported by FOX?
Why do I get an `illegal icon specified' message when I change some Widget's icon?
Compiling FOX as a DLL under VC++ gives me a unresolved external symbol.?
When do I call flush(), forceRefresh(), refresh() and update() after a change?
When I construct a window at the beginning it works but when I construct it later it doesn't.
The FOX web-site is now GIF-Free!
DialogBox with its own MenuBar dumps core.
How does FXStream serialize an FXObject?
Why did FOX choose the message-map based callback paradigm?
Why does a AUTOGRAY disable, but not enable the Button?
I get compiler errors in Visual C++ when inclusing FXArray or FXElement.
My Motif application complains with messages about failing to allocate colors.
File fxpngio.cpp does not compile on IRIX 6.5.
Developing FOX Applications under Windows.
Why are there various flavors of running an event loop?
Why do I need to declare a default contructor in my classes?
Answers.
Why does FOX look so much like Windows?
FOX looks much like Windows in part because of historical reasons, and
in part because it is intentional. Having FOX look similar to Windows
means the users of a FOX application will be able to bring to bear their
prior experience on Windows, and therefore they will be able to be productive
much quicker.
But let there be no mistake about it:- for software developers, FOX
looks very differently internally.
Has FOX been ported to the Apple Macintosh?
First off, a Macintosh running some flavor of UNIX/Linux and X11 will almost certainly be able to run FOX. Running natively on the Macintosh Operating System, of course, is going to take a good deal more work.
However, FOX is written to be very portable; it basically relies only on core system
facilities such as drawing primitives, mouse/keyboard event inputs, and some
operating system facilities.
This means that FOX could be ported to other systems such as the Macintosh.
The author currently does not own a Macintosh, nor has access too one.
Therefore, unless some hardware is donated to the FOX Project for this purpose,
chances are slim that a software port will happen any time soon.
Which Systems are supported by FOX?
There are two main ports of FOX:- UNIX/X11 and MS-Windows. Specifically, FOX is known to work on the following systems:
These are the systems we know about. Since FOX uses GNU autoconfigure, chances are good that most UNIX/X11 combinations can be made to work. If you're running FOX under a system not mentioned above, please drop me a line so we can add it to the list.
With the imminent arrival of 64-bit PC's, this is a pertinent question. Currently, FOX is being developed on lots of different systems in parallel; some of these are 64 bit workstations, such as Digital Unix/COMPAQ Tru64 AXP CPU based systems. Thus, the source code of FOX itself is definitely 64-bit clean.
Why do I get an `illegal icon specified' message when I change some Widget's icon?
Basically, an Icon [Widget, Image, Font, etc] comprises a part which lives in your program [the client-side], and a part which lives in the X-Server or GDI subsystem [the server-side].
The C++ CTOR only builds the part in the client side. The server side part of the Icon [Widget, Image, etc] is realized when you call create() on it. For convenience, all reachable resources may be created with a single call to FXApp::create(). The call to FXApp::create() traverses the entire Widget tree and creates all Windows, Icons, and other resources that are needed to realize that Widget tree on the screen.
The reasons for all this are:
Because of this, when you construct an FXIcon later on, then you need to call FXIcon::create() manually, as the icon was not a part of the Widget tree at the time the Widget tree was first realized.
Compiling FOX as a DLL under VC++ gives me a unresolved external symbol?
If you build a project under VC++ to compile a FOX application, do not forget to specify -DFOXDLL on the compiler command line. Without it, you will get an error like: error LNK2001: unresolved external symbol "public: static struct FXMetaClass const FXApp::metaClass" (?metaClass@FXApp@@2UFXMetaClass@@B). Or words to that effect.
Of course, you can also build FOX as a static library, in which case there is no problem.
When do I call flush(), forceRefresh(), refresh() and update() after a change?
Under normal circumstances, the display on the screen is kept up-to-date automatically. However, FOX uses a lazy screen refreshing technique. The lazy technique allows your callback routine to make lots of changes in the GUI, then update the screen in one fell swoop. This obviates the need that some other toolkits have for freeze/thaw API's.
There are several aspects to this: repainting the screen, i.e. processing expose or repaint events, performing layout computations, and performing GUI updating.
The order in which these are performed are repaints, layout, and gui-updates. Contrary to intuition, delaying the expensive operations such as repainting instead of doing them right away is actually faster.
Sometimes, you want to force the display to refresh without returning from a callback; this can be effected with the following routines:
When I construct a window at the beginning it works but when I construct it later it doesn't
When you construct a window before calling FXpp::create(), the window will be created when all windows are created. If however you construct a window later on, then you need to call window->create() yourself.
Please refer to the section about creating icons for a more detailed explanation.
When deriving classes from FOX Widgets such as FXDialogBox, make sure you're messages are numbered so as to not conflict with those of the base classes. The most simple way is to continue numbering from where the base class left of; I suggest the following C++ trick:
class MyDialog : public FXDialogBox { ... enum{ ID_CLICKED_YES=FXDialogBox::ID_LAST, ID_CLICKED_NO, ID_CLICKED_OK, ID_CLICKED_CANCEL, ID_CLICKED_QUIT, ID_CLICKED_SAVE, ID_LAST }; ... };
As you see, the implementor of the base class can insert additional message ID's but the numbering is automatically kept straight by the compiler. Also, if you're own class is being derived from then this derived class can start counting from MyDialog::ID_LAST and not worry about any messages being inserted into MyDialog.
The FOX web-site is now GIF-Free!
The FOX web site is now GIF-Free! Please take a look at the Burn All Gifs site to see why we've done this.
FOX does not contain any GIF compression, only decompression; from what I've read, LZW decompression is not subject to the patent [hence ability gzip support for the old ``compressed'' files]. I feel that there is therefore no need to remove the FOX support for GIF icons/images, and therefore any existing investment should you have in large icon collections would be protected.
Should you still harbor any qualms about using GIF's in your project, you could of course always use BMP icons. Typically, GIF icons are about half the size of BMP icons.
For more, see The Case Against Software Patents.
DialogBox with its own MenuBar dumps core.
When invoking a command, my application displays a DialogBox which has its own MenuBar. Then the DialogBox runs modally for a while, and upon completion it is deleted. Some time after that the application core dumps; what gives?
The answer to the problem is that MenuPane is a self contained widget which
is not owned by the MenuTitle or MenuCascade; this way, the MenuPane may
be reused for example as a right-mouse popup menu.
However, as the DialogBox is deleted, some of the MenuCommands still refer to it.
Typically, it is caught during GUI update:- when MenuCommand is being updated,
it will try to send a SEL_UPDATE to the demised DialogBox, and will print out a
message such as ``MenuCommand::onUpdate: references a deleted target object at
0001bcfed''.
In a few cases, some other message is sent to the target first, and the application
will core dump because the target object is no longer valid.
Solution: the destructor of your DialogBox should explicitly delete
the MenuPane's constructed in the DialogBox.
In fact, the DialogBox's destructor should probably destroy all resources previously allocated
in the DialogBox's constructor, such as icons, images, bitmaps, and so on.
Although it is safe to do so, there is no need to delete any Widgets, however.
How does FXStream serialize an FXObject?
When you serialize a pointer to an object, like for example:
// Declarations FXStream stream; FXDocument *document; // Serialize stream.open(FXStreamSave); stream << document; stream.close(); // Deserialize stream.open(FXStreamLoad); stream >> document; stream.close();What really happens when you serialize a pointer to an object is the following:
When you deserialize an object is:
Sometimes, a special container object is referred by other objects, but should not itself be serialized. In this case, you may want to use the constructor:
FXStream stream(container);instead. This will add the pointer container to the internal table of stream, so that any subsequent encounter of the same pointer value will generate a reference number only.
Why did FOX choose the message-map based callback paradigm?
There are several different mechanisms to connect Widgets, the sources of events, and
their targets, or the application code that you write.
I have evaluated several different callback mechanisms, each have their different
strengths and weaknesses.
Why does a AUTOGRAY disable, but not enable the Button?
AUTOGRAY and AUTOHIDE are very useful features when messages are being delegated around, like for example in an Multiple Document Interface [MDI] application. In an MDI application, the target which actually ends up handling the message may be different from one moment to the next. When no target handles the message (e.g. when all FXMDIChild windows have been deleted), an FXButton which is set to BUTTON_AUTOGRAY will be disabled automatically. When there is a target, this target should enable or disable the button as appropriate. The FXButton does not automatically enable itself when there is a target that handles the message, as it is not necessarily the case that the button should be enabled when it does.
I get compiler errors in Visual C++ when inclusing FXArray or FXElement
FOX uses the placement version of the C++ new operator. Declarations for this operator may be made available to your program by:
#include < new >just before including FXArray and FXElement. FXArray and FXElement are not automatically included into fx.h because these files rely on a proper template implementation of your compiler; also, FOX widgets do not need these headers.
My Motif application complains with messages about failing to allocate colors
This typically happens on PseudoColor systems, i.e. systems which use a colormap or color palette. Even many high end SGI systems run the Motif GUI in PseudoColor mode [these systems support multiple hardware colormaps]. FOX normally allocates about half of the available colormap [125 colors, to be exact]. Under normal circumstances, this leaves plenty of colors for other applications. However, sometimes of course it can happen that other X11 applications require more colors than are available. Fortunately, FOX can be told to use a different number of colors. There are several ways to do this:
[SETTINGS] maxcolors = 64Of course you may specify any number you like.
FXVisual *vis = application->getDefaultVisual(); vis->setMaxColors(27);Of course you will need to do this prior to a call to application->create().
File fxpngio.cpp does not compile on IRIX 6.5
FOX uses GNU autoconfigure to determine the whereabouts of various files. It so happens that IRIX 6.5 ships with an older release of the PNG library. You can do two things:
ftp://ftp.libpng.org/pub/png/
Developing FOX Applications under Windows.
Developing FOX applications under Windows warrants a lot of extra information. You can find this here.
Why are there various flavors of running an event loop?
FOX applications are event driven applications. All FOX applications therefore spend almost all their time in an event loop, waiting for events [such as keyboard and mouse events] from a user. Depending on the situation, there are several types of event loops possible:
Recursive invocations of the event loop are very useful, because they allow you to temporarily
resume processing of events without returning from your message handler.
The runModalFor() is especially useful if your message handler needs to display a temporary
dialog box, acquire some information from a user, and then continue processing the user
input all without returning to the main event loop.
Why do I need to declare a default contructor in my classes?
The FXObject-derived classes need to have the FXDECLARE() macro in the header (.h) file and the
FXIMPLEMENT() macro in the implementation (.cpp) file. The FXDECLARE macro declares
a static const member variable called metaClass, which is a table describing this class. It provides some
form of runtime type information. It also declares a virtual function getMetaClass() which can be used to
obtain a pointer to an objects metaclass variable; this way, one can interrogate the type of
an object.
In addition, it declares a static member function called
manufacture() which will construct an object of this class using the default constructor.
Finally, it declares two convenience functions for serialization of pointers to objects of this class.
The FXIMPLEMENT macro is used to define and fill-in the table declared using FXDECLARE. It defines
the static member function manufacture(), the virtual member function getMetaClass(),
and fills in the static member variable metaClass. If the object handles messages, it also
fills in a pointer to the message table.
A default constructor needs to be defined in your class because the manufacture() function needs to use the default contructor to create a properly initialized object of this type. This is needed by the deserialization system so that it can allocate and initialize an object prior to loading values for the persistent member variables.