Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FX::FXApp Class Reference

The Application object is the central point of a FOX user-interface. More...

#include <FXApp.h>

Inheritance diagram for FX::FXApp:
FX::FXObject

Public Types

enum  { ID_QUIT =1, ID_DUMP, ID_HOVER, ID_LAST }
 Messages applications understand. More...
 

Public Member Functions

long onCmdQuit (FXObject *, FXSelector, void *)
 
long onCmdDump (FXObject *, FXSelector, void *)
 
long onCmdHover (FXObject *, FXSelector, void *)
 
 FXApp (const FXString &name="Application", const FXString &vendor=FXString::null)
 Construct application object; the name and vendor strings are used as keys into the registry database for this application's settings. More...
 
void setAppName (const FXString &name)
 Change application name.
 
const FXStringgetAppName () const
 Get application name.
 
void setVendorName (const FXString &name)
 Change vendor name.
 
const FXStringgetVendorName () const
 Get vendor name.
 
FXbool hasInputMethod () const
 Return true if input method support.
 
void setDefaultVisual (FXVisual *vis)
 Change default visual.
 
FXVisualgetDefaultVisual () const
 Get default visual.
 
FXVisualgetMonoVisual () const
 Get monochrome visual.
 
void setRootWindow (FXRootWindow *rt)
 Set root Window.
 
FXRootWindowgetRootWindow () const
 Get root Window.
 
FXWindowgetFocusWindow () const
 Return window at the end of the focus chain.
 
FXWindowgetCursorWindow () const
 Get the window under the cursor, if any.
 
FXWindowgetActiveWindow () const
 Get the active toplevel window, if any.
 
FXPopupgetPopupWindow () const
 Get current popup window, if any.
 
FXWindowgetSelectionWindow () const
 Return window currently owning primary selection.
 
FXWindowgetClipboardWindow () const
 Return window currently owning the clipboard.
 
FXWindowgetDragWindow () const
 Return drag window if a drag operation is in progress.
 
FXWindowfindWindowWithId (FXID xid) const
 Find window from id.
 
FXWindowfindWindowAt (FXint rx, FXint ry, FXID window=0) const
 Find window from root x,y, starting from given window.
 
void setNormalFont (FXFont *font)
 Change default font.
 
FXFontgetNormalFont () const
 Return default font.
 
void beginWaitCursor ()
 Begin of wait-cursor block; wait-cursor blocks may be nested.
 
void endWaitCursor ()
 End of wait-cursor block.
 
void setWaitCursor (FXCursor *cur)
 Change to a new wait cursor.
 
FXCursorgetWaitCursor () const
 Return current wait cursor.
 
void setDefaultCursor (FXDefaultCursor which, FXCursor *cur)
 Change default cursor.
 
FXCursorgetDefaultCursor (FXDefaultCursor which) const
 Obtain a default cursor.
 
FXDragType registerDragType (const FXString &name) const
 Register new DND type.
 
FXString getDragTypeName (FXDragType type) const
 Get drag type name.
 
void setTranslator (FXTranslator *trans)
 Change message translator. More...
 
FXTranslatorgetTranslator () const
 Return message translator.
 
void * getDisplay () const
 Return pointer.
 
virtual FXbool openDisplay (const FXchar *dpy=nullptr)
 Connection to display; this is called by init()
 
virtual FXbool closeDisplay ()
 Close connection to the display.
 
FXptr addTimeout (FXObject *tgt, FXSelector sel, FXTime ns=1000000000, FXptr ptr=nullptr)
 Add timeout message sel to be sent to target object tgt after an interval of ns nanoseconds; the timer fires only once after the interval expires. More...
 
FXptr addDeadline (FXObject *tgt, FXSelector sel, FXTime due=forever, FXptr ptr=nullptr)
 Add deadline timeout message sel to be sent to target object tgt when the due time, expressed in nanoseconds since Epoch (Jan 1, 1970), is reached. More...
 
FXptr removeTimeout (FXObject *tgt, FXSelector sel=0)
 Remove timeout identified by target object tgt and message sel; if sel=0, remove all timeouts which reference object tgt. More...
 
FXbool hasTimeout (FXObject *tgt, FXSelector sel=0) const
 Return true if a timeout with target object tgt and message sel has been set; if sel=0, return true if any timeout has been set with target object tgt.
 
FXTime remainingTimeout (FXObject *tgt, FXSelector sel=0) const
 Return the time (in nanoseconds) remaining until the timer identified by target object tgt and message sel will fire. More...
 
FXptr addChore (FXObject *tgt, FXSelector sel, FXptr ptr=nullptr)
 Add a chore message sel to be sent to target object tgt when the system becomes idle, i.e. More...
 
FXptr removeChore (FXObject *tgt, FXSelector sel=0)
 Remove chore identified by target object tgt and message sel; if sel=0, remove all idle processing messages which reference object tgt. More...
 
FXbool hasChore (FXObject *tgt, FXSelector sel=0) const
 Return true if a chore with target object tgt and message sel has been set; if sel=0, return true if any chore has been set with target object tgt.
 
void addSignal (FXint sig, FXObject *tgt, FXSelector sel, FXbool immediate=false, FXuint flags=0)
 Add signal processing message to be sent to target object when the signal sig is raised; flags are to be set as per POSIX definitions. More...
 
void removeSignal (FXint sig)
 Remove signal message for signal sig.
 
FXbool addInput (FXObject *tgt, FXSelector sel, FXInputHandle fd, FXuint mode=INPUT_READ, FXptr ptr=nullptr)
 Add a file descriptor fd to be watched for activity as determined by mode, where mode is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT). More...
 
FXbool removeInput (FXInputHandle fd, FXuint mode=INPUT_READ)
 Remove input message and target object for the specified file descriptor and mode, which is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT). More...
 
FXbool getKeyState (FXuint keysym) const
 Return key state of given key.
 
FXbool peekEvent ()
 Peek to determine if there's an event.
 
FXbool runOneEvent (FXTime blocking=forever)
 Perform one event dispatch; return true if event was dispatched.
 
FXint run ()
 Run the main application event loop until stop() is called, and return the exit code passed as argument to stop().
 
FXint runUntil (FXuint &condition)
 Run an event loop till some flag becomes non-zero, and then return.
 
FXint runWhileEvents (FXTime blocking=0)
 Run non-modal event loop while events arrive within blocking nanoseconds. More...
 
FXint runModalWhileEvents (FXWindow *window=nullptr, FXTime blocking=0)
 Run modal event loop while events arrive within blocking nanoseconds. More...
 
FXint runModal ()
 Run modal event loop, blocking keyboard and mouse events to all windows until stopModal is called.
 
FXint runModalFor (FXWindow *window)
 Run a modal event loop for the given window, until stop() or stopModal() is called. More...
 
FXint runModalWhileShown (FXWindow *window)
 Run modal while window is shown, or until stop() or stopModal() is called. More...
 
FXint runPopup (FXWindow *window)
 Run popup menu while shown, until stop() or stopModal() is called. More...
 
FXbool isModal (FXWindow *window) const
 True if the window is modal.
 
FXWindowgetModalWindow () const
 Return window of current modal loop.
 
FXModality getModality () const
 Return mode of current modal loop.
 
void stop (FXint value=0)
 Terminate the outermost event loop, and all inner modal loops; All more deeper nested event loops will be terminated with code equal to 0, while the outermost event loop will return code equal to value.
 
void stopModal (FXWindow *window, FXint value=0)
 Break out of the matching modal loop, returning code equal to value. More...
 
void stopModal (FXint value=0)
 Break out of the innermost modal loop, returning code equal to value.
 
void refresh ()
 Schedule SEL_UPDATE refreshes on the entire widget tree, to be performed at some future time.
 
void forceRefresh ()
 Perform SEL_UPDATE refreshes on the entire widget tree immediately.
 
void flush (FXbool sync=false)
 Flush drawing commands to display; if sync then wait till drawing commands have been performed.
 
void repaint ()
 Paint all windows marked for repainting. More...
 
FXint getArgc () const
 Get argument count.
 
const FXchar *const * getArgv () const
 Get argument vector.
 
FXbool isInitialized () const
 Has application been initialized.
 
virtual void init (int &argc, char **argv, FXbool connect=true)
 Initialize application. More...
 
virtual void exit (FXint code=0)
 Exit application. More...
 
FXRegistryreg ()
 Return a reference to the registry. More...
 
FXMutexmutex ()
 Return a reference to the application-wide mutex. More...
 
void beep ()
 Beep the speaker.
 
FXTime getTypingSpeed () const
 Obtain application-wide timing constants, in nanoseconds.
 
FXTime getClickSpeed () const
 
FXTime getScrollSpeed () const
 
FXTime getScrollDelay () const
 
FXTime getBlinkSpeed () const
 
FXTime getAnimSpeed () const
 
FXTime getMenuPause () const
 
FXTime getToolTipPause () const
 
FXTime getToolTipTime () const
 
FXTime getAutoHideDelay () const
 
void setTypingSpeed (FXTime speed)
 Change application-wide timing constants, in nanoseconds.
 
void setClickSpeed (FXTime speed)
 
void setScrollSpeed (FXTime speed)
 
void setScrollDelay (FXTime delay)
 
void setBlinkSpeed (FXTime speed)
 
void setAnimSpeed (FXTime speed)
 
void setMenuPause (FXTime pause)
 
void setToolTipPause (FXTime pause)
 
void setToolTipTime (FXTime time)
 
void setAutoHideDelay (FXTime time)
 
void setDragDelta (FXint delta)
 Access drag hysteresis.
 
FXint getDragDelta () const
 
void setWheelLines (FXint lines)
 Access mouse wheel scroll lines.
 
FXint getWheelLines () const
 
void setScrollBarSize (FXint size)
 Access scroll bar slot size.
 
FXint getScrollBarSize () const
 
FXColor getBorderColor () const
 Obtain default colors.
 
FXColor getBaseColor () const
 
FXColor getHiliteColor () const
 
FXColor getShadowColor () const
 
FXColor getBackColor () const
 
FXColor getForeColor () const
 
FXColor getSelforeColor () const
 
FXColor getSelbackColor () const
 
FXColor getTipforeColor () const
 
FXColor getTipbackColor () const
 
FXColor getSelMenuTextColor () const
 
FXColor getSelMenuBackColor () const
 
void setBorderColor (FXColor color)
 Change default colors.
 
void setBaseColor (FXColor color)
 
void setHiliteColor (FXColor color)
 
void setShadowColor (FXColor color)
 
void setBackColor (FXColor color)
 
void setForeColor (FXColor color)
 
void setSelforeColor (FXColor color)
 
void setSelbackColor (FXColor color)
 
void setTipforeColor (FXColor color)
 
void setTipbackColor (FXColor color)
 
void setSelMenuTextColor (FXColor color)
 
void setSelMenuBackColor (FXColor color)
 
FXuint getWindowCount () const
 Get number of existing windows.
 
virtual void create ()
 Create application's windows.
 
virtual void destroy ()
 Destroy application's windows.
 
virtual void detach ()
 Detach application's windows.
 
virtual void save (FXStream &store) const
 Save.
 
virtual void load (FXStream &store)
 Load.
 
void dumpWidgets () const
 Dump widget information.
 
virtual ~FXApp ()
 Destroy the application and all reachable resources.
 
- Public Member Functions inherited from FX::FXObject
const FXchar * getClassName () const
 Get class name of some object.
 
FXbool isMemberOf (const FXMetaClass *metaclass) const
 Check if object is member of metaclass.
 
virtual long tryHandle (FXObject *sender, FXSelector sel, void *ptr)
 Try handle message safely, catching certain exceptions.
 
virtual long onDefault (FXObject *, FXSelector, void *)
 Called for unhandled messages.
 
virtual ~FXObject ()
 Virtual destructor.
 

Static Public Member Functions

static FXAppinstance ()
 Return application instance.
 

Static Public Attributes

static const FXuchar copyright []
 Copyright information.
 

Protected Member Functions

virtual FXbool getNextEvent (FXRawEvent &ev, FXTime blocking=forever)
 Return true if an event arrives within blocking nanoseconds.
 
virtual FXbool dispatchEvent (FXRawEvent &ev)
 Dispatch raw event.
 

Friends

class FXId
 
class FXBitmap
 
class FXImage
 
class FXIcon
 
class FXCursor
 
class FXDrawable
 
class FXWindow
 
class FXShell
 
class FXRootWindow
 
class FXTopWindow
 
class FXMainWindow
 
class FXPopup
 
class FXFont
 
class FXVisual
 
class FXGLVisual
 
class FXGLContext
 
class FXDC
 
class FXDCWindow
 
class FXDragCorner
 
class FXDockHandler
 
class FXComposeContext
 

Detailed Description

The Application object is the central point of a FOX user-interface.

It manages the event queue, timers, signals, chores, and input sources. Each FOX application should have exactly one Application object, which is the ultimate owner of the entire widget tree; when the application object is deleted, all the widgets and other reachable resources of the widget tree are also deleted. When the Application is initialized using init(), it parses the command line arguments meant for it, and opens the display. The run() function is used to run the application; this function does not return until the user is ready to quit the application. During run(), the application processes events from the various windows and dispatches them to the appropriate handlers. Finally, a call to exit() terminates the application. The Application object also manages a registry of configuration data, which is read during init() and written back at the exit(); thus, all configurations changed by the user normally persist to the next invocation of the application. Since different organizations and different applications each need to keep their own set of configuration data, an application name and vendor name can be passed in the Application object's constructor to identify a particular application's configuration data.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Messages applications understand.

Enumerator
ID_DUMP 

Terminate the application normally.

ID_HOVER 

Dump the current widget tree.

Constructor & Destructor Documentation

◆ FXApp()

FX::FXApp::FXApp ( const FXString name = "Application",
const FXString vendor = FXString::null 
)

Construct application object; the name and vendor strings are used as keys into the registry database for this application's settings.

Only one single application object can be constructed.

Member Function Documentation

◆ addChore()

FXptr FX::FXApp::addChore ( FXObject tgt,
FXSelector  sel,
FXptr  ptr = nullptr 
)

Add a chore message sel to be sent to target object tgt when the system becomes idle, i.e.

there are no events to be processed. The void* ptr is user data which will be passed into the void* ptr of the message handler. If a chore with the same target and message already exists, it will be rescheduled. Returns the data pointer from the original chore, if any.

◆ addDeadline()

FXptr FX::FXApp::addDeadline ( FXObject tgt,
FXSelector  sel,
FXTime  due = forever,
FXptr  ptr = nullptr 
)

Add deadline timeout message sel to be sent to target object tgt when the due time, expressed in nanoseconds since Epoch (Jan 1, 1970), is reached.

This is the preferred way to schedule regularly occuring events, as the exact time of issue will not suffer accumulating errors as with the addTimeout() method. However, it is important to ensure that the due time is sufficiently far into the future, as otherwise the system may be swamped executing nothing but timeout messages. Return data pointer from original timeout, if any.

◆ addInput()

FXbool FX::FXApp::addInput ( FXObject tgt,
FXSelector  sel,
FXInputHandle  fd,
FXuint  mode = INPUT_READ,
FXptr  ptr = nullptr 
)

Add a file descriptor fd to be watched for activity as determined by mode, where mode is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT).

A message of type SEL_IO_READ, SEL_IO_WRITE, or SEL_IO_EXCEPT will be sent to the target when the specified activity is detected on the file descriptor; the void* ptr is user data which will be passed into the void* ptr of the mesage handler; often you will want to pass the file descriptor fd itself as the value for ptr so that the message handler knows which file descriptor is involved.

◆ addSignal()

void FX::FXApp::addSignal ( FXint  sig,
FXObject tgt,
FXSelector  sel,
FXbool  immediate = false,
FXuint  flags = 0 
)

Add signal processing message to be sent to target object when the signal sig is raised; flags are to be set as per POSIX definitions.

When immediate is true, the message will be sent to the target right away; this should be used with extreme care as the application is interrupted at an unknown point in its execution.

◆ addTimeout()

FXptr FX::FXApp::addTimeout ( FXObject tgt,
FXSelector  sel,
FXTime  ns = 1000000000,
FXptr  ptr = nullptr 
)

Add timeout message sel to be sent to target object tgt after an interval of ns nanoseconds; the timer fires only once after the interval expires.

The void* ptr is user data which will be passed into the void* ptr of the message handler. If a timer with the same target and message already exists, it will be rescheduled. Note: the smallest interval that one can wait is actually much larger than a nanosecond; on Unix systems, the smallest interval is about 1000 ns, whereas on Windows, it is about 1000000 ns. Return data pointer from original timeout, if any.

◆ exit()

virtual void FX::FXApp::exit ( FXint  code = 0)
virtual

Exit application.

Closes the display and writes the registry.

◆ init()

virtual void FX::FXApp::init ( int &  argc,
char **  argv,
FXbool  connect = true 
)
virtual

Initialize application.

Parses and removes common command line arguments, reads the registry. Finally, if connect is true, it opens the display.

◆ mutex()

FXMutex& FX::FXApp::mutex ( )
inline

Return a reference to the application-wide mutex.

Normally, the main user interface thread holds this mutex, insuring that no other threads are modifying data during the processing of user interface messages. However, whenever the main user interface thread blocks for messages, it releases this mutex, to allow other threads to modify the same data. When a new message becomes available, the main user interface thread regains the mutex prior to dispatching the message. Other threads should hold this mutex only for short durations, so as to not starve the main user interface thread.

◆ reg()

FXRegistry& FX::FXApp::reg ( )
inline

Return a reference to the registry.

The registry keeps settings and configuration information for an application, which are automatically loaded when the application starts up, and saved when the application terminates.

◆ remainingTimeout()

FXTime FX::FXApp::remainingTimeout ( FXObject tgt,
FXSelector  sel = 0 
) const

Return the time (in nanoseconds) remaining until the timer identified by target object tgt and message sel will fire.

If the timer is past due, 0 is returned. If there is no such timer, the constant forever (LLONG_MAX) is returned. If sel=0, return the earliest timeout that will be received by target object tgt.

◆ removeChore()

FXptr FX::FXApp::removeChore ( FXObject tgt,
FXSelector  sel = 0 
)

Remove chore identified by target object tgt and message sel; if sel=0, remove all idle processing messages which reference object tgt.

Returns the data pointer from the original chore, if any.

◆ removeInput()

FXbool FX::FXApp::removeInput ( FXInputHandle  fd,
FXuint  mode = INPUT_READ 
)

Remove input message and target object for the specified file descriptor and mode, which is a bitwise OR of (INPUT_READ, INPUT_WRITE, INPUT_EXCEPT).

Omitting the last parameter will delete all the handlers associated with the file descriptor.

◆ removeTimeout()

FXptr FX::FXApp::removeTimeout ( FXObject tgt,
FXSelector  sel = 0 
)

Remove timeout identified by target object tgt and message sel; if sel=0, remove all timeouts which reference object tgt.

Return data pointer from original timeout, if any.

◆ repaint()

void FX::FXApp::repaint ( )

Paint all windows marked for repainting.

On return all the applications windows have been painted.

◆ runModalFor()

FXint FX::FXApp::runModalFor ( FXWindow window)

Run a modal event loop for the given window, until stop() or stopModal() is called.

Except for the modal window and its children, user input to all windows is blocked; if the modal window is NULL all user input is blocked.

◆ runModalWhileEvents()

FXint FX::FXApp::runModalWhileEvents ( FXWindow window = nullptr,
FXTime  blocking = 0 
)

Run modal event loop while events arrive within blocking nanoseconds.

Returns 1 when all events in the queue have been handled, and 0 when the event loop was terminated due to stop() or stopModal(). Except for the modal window and its children, user input to all windows is blocked; if the modal window is NULL, all user input is blocked.

◆ runModalWhileShown()

FXint FX::FXApp::runModalWhileShown ( FXWindow window)

Run modal while window is shown, or until stop() or stopModal() is called.

Except for the modal window and its children, user input to all windows is blocked; if the modal window is NULL all user input is blocked.

◆ runPopup()

FXint FX::FXApp::runPopup ( FXWindow window)

Run popup menu while shown, until stop() or stopModal() is called.

Also returns when entering previous cascading popup menu.

◆ runWhileEvents()

FXint FX::FXApp::runWhileEvents ( FXTime  blocking = 0)

Run non-modal event loop while events arrive within blocking nanoseconds.

Returns when no new events arrive in this time, and no timers, or chores are outstanding.

◆ setTranslator()

void FX::FXApp::setTranslator ( FXTranslator trans)

Change message translator.

The new translator will be owned by FXApp.

◆ stopModal()

void FX::FXApp::stopModal ( FXWindow window,
FXint  value = 0 
)

Break out of the matching modal loop, returning code equal to value.

All deeper nested event loops are terminated with code equal to 0.


The documentation for this class was generated from the following file:

Copyright © 1997-2022 Jeroen van der Zijp