Laxkit
0.0.7.1
|
This class is the control unit for programs. More...
Public Member Functions | |
anXApp () | |
Constructor. Sets anXApp::app==this. | |
virtual | ~anXApp () |
Destructor. | |
virtual const char * | whattype () |
virtual int | Theme (const char *theme) |
virtual int | Backend (const char *which) |
virtual int | init (int argc, char **argv) |
Init the app. The default is to call initX() if donotusex==0, otherwise wall initNoX(). | |
virtual int | initX (int argc, char **argv) |
Init the app. Open an X connection and set default stuff that depends on that. | |
virtual int | initNoX (int argc, char **argv) |
Init the app without accessing X. | |
virtual int | run () |
This is the main event loop. | |
virtual int | close () |
Shut down the app manually. | |
virtual void | quit () |
Called anytime from anybody, tells the application to shut down. | |
virtual int | Tooltips (int on) |
Upkeep anXApp::ttcount. | |
virtual int | has (int what) |
Easy check for whether there are various capabilities in the application. | |
virtual LaxFiles::Attribute * | Resource (const char *name) |
Return pointer to the resource named name. | |
virtual int | Resource (LaxFiles::Attribute *resource) |
Append to or replace a resource. | |
virtual int | DefaultIcon (const char *file) |
Set the default icon to the image in file. | |
virtual int | DefaultIcon (LaxImage *image, int absorb_count) |
Use this data and mask for the default icon for windows. | |
virtual int | ScreenInfo (int screen, int *x, int *y, int *width, int *height, int *mmwidth, int *mmheight, int *depth, int *virt) |
Return information about a screen, based on information in xscreeninfo which gets defined in init(). | |
virtual const char * | Locale () const |
virtual void | Locale (const char *) |
virtual void | bump () |
Force dealing with any pending messages. | |
virtual EventReceiver * | findEventObj (unsigned long id) |
Return the object with id in eventreceivers stack. | |
virtual int | RegisterEventReceiver (EventReceiver *e) |
virtual int | UnregisterEventReceiver (EventReceiver *e) |
virtual int | SendMessage (EventData *data, unsigned long toobj=0, const char *mes=0, unsigned long fromobj=0) |
Send arbitrary data to a window. | |
virtual int | rundialog (anXWindow *ndialog, anXWindow *wingroup=NULL, char absorb_count=1) |
Run a (top-level) dialog window that blocks inputs to other windows (runs a so called modal dialog) | |
virtual int | addwindow (anXWindow *w, char mapit=1, char absorb_count=1) |
Add a window, optionally map it, optionally decrement its count. | |
virtual int | mapwindow (anXWindow *w) |
Maps a window and sends MapNotify events to it and its subwindows. | |
virtual int | unmapwindow (anXWindow *w) |
Unmaps a window and sends UnmapNotify events to it and its subwindows. | |
virtual int | reparent (anXWindow *kid, anXWindow *newparent) |
Reparent kid to be a child of newparent. | |
virtual int | setfocus (anXWindow *win, clock_t t=0, const LaxKeyboard *kb=NULL) |
Try to set the keyboard focus to win. If t==0 then use the current time. | |
virtual int | destroywindow (anXWindow *w) |
Tell the anXApp that w should be destroyed. | |
virtual void | postmessage (const char *str) |
Anything can call app->postmessage when they want to make some status statement. | |
virtual int | CopytoBuffer (const char *stuff, int len) |
Copy stuff to the X cutbuffer. | |
virtual char * | GetBuffer () |
Get a new'd copy of stuff from the X cutbuffer. | |
virtual anXWindow * | findDropCandidate (anXWindow *ref, int x, int y, anXWindow **drop, Window *xlib_window_ret) |
Find a window to potentially drop things into. | |
virtual int | SetMaxTimeout (int timeoutmax) |
virtual int | addtimer (anXWindow *win, int strt, int next, int duration) |
Add a timer. Return the timer id. | |
virtual int | addmousetimer (anXWindow *win) |
Add a timer with the default mouse button delays. Returns timer id. | |
virtual int | removetimer (anXWindow *w, int timerid) |
This removes a timer manually. | |
Public Member Functions inherited from Laxkit::anObject | |
anObject () | |
Set object_id=getUniqueNumber(). | |
virtual | ~anObject () |
Empty virtual destructor. | |
virtual anObject * | duplicate (anObject *ref=NULL) |
virtual int | inc_count () |
Increment the data's count by 1. Returns count. | |
virtual int | dec_count () |
Decrement the count of the data, deleting if count is less than or equal to 0. | |
virtual int | the_count () |
Public Attributes | |
anXWindow * | currentfocus |
const char * | backend |
char * | app_profile |
The default application profile, if any. | |
int | buttoncount |
Number of times a mouse button has been pressed in succession. | |
FontManager * | fontmanager |
LaxFont * | defaultlaxfont |
char * | controlfontstr |
The default font string. It is a fontconfig pattern string. | |
char * | textfontstr |
The default font for text inside text edits. It is a fontconfig pattern string. | |
DeviceManager * | devicemanager |
int | tooltips |
Number of milliseconds to wait once a mouse enters a window before popping up a tooltip. | |
PtrStack< LaxDevice > | tooltipmaybe |
WindowColors * | color_panel |
WindowColors * | color_menu |
WindowColors * | color_edits |
WindowColors * | color_buttons |
unsigned long | color_tooltip_bg |
unsigned long | color_tooltip_fg |
unsigned long | color_activeborder |
unsigned long | color_inactiveborder |
int | default_border_width |
int | default_padx |
int | default_pady |
int | default_bevel |
unsigned int | dblclk |
Milliseconds within which a button has to be pressed again to be a double click, or triple, etc. | |
unsigned int | firstclk |
Number of clock ticks to wait before throwing another click for when a button is held down. | |
unsigned int | idleclk |
Number of clock ticks to wait between clicks after the first click when a button is held down. | |
char * | load_dir |
char * | save_dir |
Public Attributes inherited from Laxkit::anObject | |
int | suppress_debug |
DeleteRefCountedFunc | deleteMe |
Called when the count is decremented to 0. | |
unsigned long | object_id |
char * | object_idstr |
Static Public Attributes | |
static anXApp * | app = NULL |
In the constructor, this variable is set to this. |
Protected Member Functions | |
void | newToolTip (const char *text, int mouseid) |
Create and add a new tooltip, ensuring there is only one per mouse up at any one time. | |
virtual void | setupdefaultcolors () |
Set the builtin Laxkit colors. | |
virtual int | getlaxrc (const char *filename, const char *profile) |
Read in the given rc file, or the default if filename==NULL. | |
virtual void | dump_in_rc (LaxFiles::Attribute *att, const char *profile) |
virtual void | dump_out_rc (FILE *f, const char *profile, int indent, int what) |
Output an rc file based on current colors. | |
virtual void | dump_in_colors (LaxFiles::Attribute *att) |
virtual void | destroyqueued () |
Called after all pending events have been processed, deletes all windows that have been anXApp::destroywindow()'d. | |
virtual void | resetkids (anXWindow *w) |
Quick way to code setting window and win_on=0 for w and all subwindows,. | |
virtual void | deactivatekids (anXWindow *ww) |
virtual void | idle (anXWindow *w) |
Handles idling (non-timer calls) for the window and its children. | |
virtual int | refresh (anXWindow *w) |
Handles refreshing for window w and its children. | |
virtual int | processdataevents () |
Process the queue of EventData objects. | |
virtual int | processSingleDataEvent (EventReceiver *obj, EventData *ee) |
virtual int | checkOutClicks (EventReceiver *obj, MouseEventData *ee) |
See if a mouse down event is down outside of any top windows in outclickwatch or any controls connected to them. | |
virtual int | managefocus (anXWindow *ww, EventData *ev) |
Called from event loop, is supposed to do reasonable things with focus related events. | |
virtual void | tooltipcheck (EventData *event, anXWindow *ww) |
Does tooltip related checking on events. |
Protected Attributes | |
char * | default_language |
LaxImage * | default_icon |
char * | default_icon_file |
char * | copybuffer |
char | dontstop |
unsigned long | dialog_mask |
Mask used for screening events when dialogs are up. | |
LaxFiles::Attribute | resources |
A simple resource holder. | |
PtrStack< anXWindow > | dialogs |
Stack of dialogs. See rundialog(). | |
RefPtrStack< anXWindow > | topwindows |
Stack of top level windows. These windows have no parent. | |
RefPtrStack< anXWindow > | outclickwatch |
RefPtrStack< anXWindow > | todelete |
Stack of windows to delete after the event queue is depleted. | |
PtrStack< EventReceiver > | eventreceivers |
EventData * | dataevents |
EventData * | dataevente |
PtrStack< TimerInfo > | timers |
Stack of timers. | |
pthread_mutex_t | event_mutex |
int | maxtimeout |
Wait time to check for new messages, in microseconds. | |
int | ttcount |
Special tag for whether tooltips are temporarily disabled. | |
Protected Attributes inherited from Laxkit::anObject | |
int | _count |
The reference count of the object. |
Private Member Functions | |
virtual anXWindow * | findwindow_by_id (unsigned long id) |
Find the anXWindow having the given object_id. | |
virtual anXWindow * | find_subwindow_by_id (anXWindow *w, unsigned long id) |
Find the anXWindow having win, and ancestor w. |
This class is the control unit for programs.
All the lowest level state required to run an X program is kept and maintained in this class and in anXWindow. Also, fonts are kept here via a reference counting FontManager instance, and outside functions can get some common color functions such as converting a 3 number (int,int,int) color specification to a pixel value that can be used with the various Xlib functions.
A typical main() function looks like the following. Derived classes can redefine the init function to be more interesting:
If at any point the program wants to stop running, then app->quit() should be called, which sets dontstop=0, and forces a break out of the run loop.
NOTES
Apparently between XCreating a window and the initial mapping, XResizes don't have any effect: seems the XResize goes through (check return value!), but then a ConfigureNotify is sent with old values. Can you explain this?
Laxkit::anXApp::anXApp | ( | ) |
Constructor. Sets anXApp::app==this.
Sets load_dir and save_dir to the current directory.
Initializes various variables not dependent on an X connection nor on a laxrc file.
References newstr().
|
virtual |
Destructor.
Calls close(), and generally deallocates any remaining things.
Add a timer with the default mouse button delays. Returns timer id.
Please note that the timer is not automatically destroyed when the button is up.
Referenced by Laxkit::Scroller::LBDown(), and Laxkit::Scroller::RBDown().
Add a timer. Return the timer id.
strt,next are in milliseconds, they get converted to clock ticks in TimerInfo.
Once a timer is established, after the specified time, then a windows anXWindow::Idle() function will be called, with the associated timer id.
A duration of -1 means about 1000 hours, so basically forever.
win | The window to create the timer for |
strt | Time to wait for the first timer event (milliseconds) |
next | Time to wait for each successive timer event (milliseconds) |
duration | How long the timer should last (milliseconds) |
References Laxkit::getUniqueNumber(), and Laxkit::anXWindow::WindowTitle().
Referenced by Laxkit::PopupMenu::MouseMove(), and Laxkit::ToolTip::ToolTip().
Add a window, optionally map it, optionally decrement its count.
In the course of adding the window, the following steps are taken:
If w==NULL or w->xlib_window already exists (just checks for nonzero value) then do nothing and return 1.
If the window is a child of a window that has not been addwindow'd, that is, parent->xlib_window==0, then the the window is not created here. It is merely inserted into the parent->_kids stack. No preinit(), etc are called now, they are called when the child->xlib_window is actually created, which will be when addwindow() is called on the parent. When the parent is addwindow'd, then the kids are all also addwindow'd using the same mapit value. Sometimes a child is already XCreated, but the parent is not. In that case, the child is XReparenteWindow'd to the newly created parent here.
First, w->preinit() is called.
Second, XCreateWindow is called. If win_w or win_h are zero, the window is created with 1 instead of 0, but win_w and win_h still are set to 0. This is because calling with 0 causes problems with Xlib.
Any reparenting that has to be done on any child windows listed in the w->_kids stack is done at this point, before w->init() is called. If the kid->xlib_window doesn't exist, addwindow(kid) is called. Only the immediate children are addwindow'd here. If all the kids are already addwindow'd, but the kid has non-addwindow'd kids, those are not addwindow'd. Hopefully this is ok.....
Third, w->init() is called, which normally is where a window's children are addwindow'd
Fourth, XMapWindow is called on the window, if mapit!=0.
Returns 0 on success, nonzero on error
References Laxkit::anXWindow::_kids, Laxkit::anObject::dec_count(), Laxkit::PtrStack< T >::e, Laxkit::anXWindow::init(), Laxkit::load_image, Laxkit::PtrStack< T >::n, Laxkit::anXWindow::preinit(), Laxkit::anXWindow::SetupBackBuffer(), Laxkit::anXWindow::win_on, Laxkit::anXWindow::win_owner, Laxkit::anXWindow::win_pointer_shape, Laxkit::anXWindow::win_title, and Laxkit::anXWindow::WindowTitle().
Referenced by Laxkit::ColorSliders::EditHex(), Laxkit::FileDialog::FileDialog(), Laxkit::LineInput::init(), Laxkit::ScrolledWindow::init(), Laxkit::NumInputSlider::LBDown(), Laxkit::TabFrame::mapWindow(), Laxkit::ColorBox::PopupColorSelector(), Laxkit::StackFrame::Sync(), and Laxkit::RowFrame::Sync().
If they have been compiled in, which can be one of: "imlib" "cairo" "gl"
Return 0 for success, or 1 for cannot use.
|
virtual |
Force dealing with any pending messages.
Sometimes messages sent via SendMessage() do not also make the application actually deal with those messages.
|
protectedvirtual |
See if a mouse down event is down outside of any top windows in outclickwatch or any controls connected to them.
destroywindow() if the mouse is down outside of any of them.
References Laxkit::translate_window_coordinates(), and Laxkit::anXWindow::WindowTitle().
|
virtual |
Shut down the app manually.
This will remove any resources that have been allocated. If dpy==NULL, then of course just remove those bits that are not dependent on an x connection.
This function is provided just in case you want to shut down, then do other stuff for some reason. It is also called from the destructor.
References Laxkit::SetDefaultDisplayer().
Copy stuff to the X cutbuffer.
len<0 means make len=strlen(stuff)
References makenstr().
Referenced by Laxkit::TextXEditBaseUtf8::Copy(), and Laxkit::SliderPopup::RBDown().
|
protectedvirtual |
*** whats up with this? is it still used?? //quick fix for window manager not sending FocusOut //to a sub-window if focus leaves its top window
References Laxkit::anXWindow::_kids, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, and Laxkit::anXWindow::win_active.
Set the default icon to the image in file.
This only works after anXApp has opened an X connection, and should be done before any windows are added. You must also call InitLaxImlib() before calling this. This function does nothing if Imlib2 is not available.
Top level windows get their icon hint set to this.
Returns 0 for success, or nonzero for error.
must implement checking for appropriate size for icons, currently just assumes 48x48 is proper, and that is what is in file...
must implement freedesktop _NET_WM_ICON. currently just does xwmhints
must implement some way to avoid direct dependence on Imlib
References makestr().
Use this data and mask for the default icon for windows.
Top level windows get their icon hint set to this.
References Laxkit::anObject::inc_count().
|
protectedvirtual |
Called after all pending events have been processed, deletes all windows that have been anXApp::destroywindow()'d.
This may only be called from app::run(), outside of event handler else beware delete race conditions. Assumes only parents or topwindows in todelete, that is, for any window listed in todelete, there must not be a descendent of that window also listed in todelete. This should be so if they were tagged for delete only from destroywindow(). Also assumes window is already XDestroyWindow'd, which should have happened in destroywindow().
References Laxkit::anXWindow::deletekid(), and Laxkit::anXWindow::WindowTitle().
Tell the anXApp that w should be destroyed.
Meant to be called from within windows any old time. Means window did delete protocol, or just wants to be destroyed.
First w->close() is called, then anXWindow::xlib_window and its subwindows are XDestroyWindowed here and set to 0, and any associated timers and tooltip checking removed, but the anXWindow instance is really destroyed at end of event loop in run(), or in app->close(). Windows are ultimately responsible for deleting sub-anxwindows, via win->deletekid(), which is usually called by app in destroyqueued(), so the user typically doesn't have to do anything special. Also, if the stated window is a dialog, then it is naturally removed from the dialog stack.
References Laxkit::anObject::_count, Laxkit::Displayer::ClearDrawable(), Laxkit::anXWindow::close(), Laxkit::GetDefaultDisplayer(), Laxkit::IsWindowChild(), and Laxkit::anXWindow::WindowTitle().
Referenced by Laxkit::PopupMenu::addselect(), Laxkit::SplitWindow::Change(), Laxkit::InputDialog::CharInput(), Laxkit::PopupMenu::CharInput(), Laxkit::SimplePrint::CharInput(), Laxkit::LineEdit::CharInput(), Laxkit::MenuSelector::CharInput(), Laxkit::FileDialog::ClearFinalButton(), Laxkit::ImageDialog::closeWindow(), Laxkit::FileDialog::closeWindow(), Laxkit::Overwrite::Event(), Laxkit::ToolTip::Event(), Laxkit::NumInputSlider::Event(), Laxkit::InputDialog::Event(), Laxkit::MessageBox::Event(), Laxkit::SimplePrint::Event(), Laxkit::LineInput::Event(), Laxkit::PrintDialog::Event(), Laxkit::MenuSelector::Event(), Laxkit::MenuSelector::FocusOff(), Laxkit::ToolTip::Idle(), Laxkit::SplitWindow::joinwindow(), Laxkit::MenuSelector::LBDown(), Laxkit::MenuSelector::LBUp(), Laxkit::PopupMenu::RBUp(), Laxkit::SplitWindow::RemoveCurbox(), Laxkit::StackFrame::ReplaceWin(), Laxkit::MultiLineEdit::UseTheseScrollers(), Laxkit::ScrolledWindow::UseThisWindow(), and Laxkit::PopupMenu::~PopupMenu().
|
protectedvirtual |
Used to scan in laxrc color values.
References Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, and LaxFiles::SimpleColorAttribute().
|
protectedvirtual |
Used to scan in laxrc values.
References Laxkit::PtrStack< T >::e, LaxFiles::IntAttribute(), isblank(), makestr(), Laxkit::PtrStack< T >::n, and LaxFiles::ULongAttribute().
|
protectedvirtual |
Output an rc file based on current colors.
If what==-1, then dump out with comments.
If profile!=NULL, then write out "profile name" where name is the profile string, and everything is indented a further 2 spaces. Else everything is dumped out with current indent.
Find the anXWindow having win, and ancestor w.
called from a loop over topwindows in run.
Perhaps this should be a window function?
References Laxkit::anXWindow::_kids, Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.
|
virtual |
Find a window to potentially drop things into.
x,y are coordinates in ref. If ref==NULL, then they are coordinates of the root window.
If drop!=NULL, then assume you only want a window that this application knows about. Otherwise, also search for any window that X knows about. The window that is found is returned in drop.
Ultimately this will be used for more full featured drag and drop.
cannot find windows that X knows about that the application doesn't, so cannot drop to other programs (yet)!
this needs work... especially when there are windows on different screens.. laxkit in general does not handle multiple screens well (ie, at all)..
***** this ignores stacking order!!!
References Laxkit::anXWindow::_kids, Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.
|
virtual |
Get a new'd copy of stuff from the X cutbuffer.
Referenced by Laxkit::TextXEditBaseUtf8::Paste().
Read in the given rc file, or the default if filename==NULL.
This does not reset all values, but does overwrite any values found.
The default is LAX_CONFIG_DIRECTORY/laxrc, or ./laxrc if that fails.
Return 0 for success, nonzero for error, such as file not readable.
References LaxFiles::Attribute::dump_in().
Easy check for whether there are various capabilities in the application.
This can test for whether various capabilities have been compiled into the Laxkit, or is otherwise available.
By default, you can check for:
LAX_HAS_IMLIB2 LAX_HAS_CAIRO LAX_HAS_GL LAX_HAS_XINPUT2
|
protectedvirtual |
Init the app without accessing X.
Responsibilities here include:
Currently, no options are recognized, but that may change.
References Laxkit::set_color_shift_info().
Init the app. Open an X connection and set default stuff that depends on that.
Responsibilities here include:
Currently, no options are recognized, but that may change.
References Laxkit::GetDefaultDisplayer(), Laxkit::getUniqueNumber(), Laxkit::InitLaxCairo(), Laxkit::InitLaxImlib(), Laxkit::newCoreXlibDeviceManager(), and Laxkit::set_color_shift_info().
|
virtual |
Set the string representing the default language. Use "" for system default. Then calls setlocale(LC_ALL,default_language).
References makestr().
Called from event loop, is supposed to do reasonable things with focus related events.
Window ww is found for event e.
Catches LAX_onButtonDown and LAX_onMouseIn. Always focus on a window that is clicked in. Set focus on any window with with ANXWIN_HOVER_FOCUS when the mouse enters.
Returns 0 if it does not absorb event, 1 if it does.
Maps a window and sends MapNotify events to it and its subwindows.
Clients only wishing to map the top window can do so with XMapWindow. This function merely calls XMapSubwindows(), then XMapWindow().
Referenced by Laxkit::TabFrame::mapWindow().
|
virtual |
Anything can call app->postmessage when they want to make some status statement.
Builtin default is to do nothing. (well, cout something in debug version)
Referenced by Laxkit::ColorBox::MouseMove(), LaxInterfaces::ViewerWindow::PostMessage(), LaxInterfaces::ViewportWindow::postmessage(), LaxInterfaces::PointWarpInterface::UseThis(), and LaxInterfaces::PatchInterface::UseThis().
|
protectedvirtual |
Process the queue of EventData objects.
Accumulated messages, whether from SendMessage() or through other means, are dispatched to the target windows.
|
protectedvirtual |
Return nonzero for event could not be sent, or 0 for event sent or otherwise processed. The event is not deleted after processing here.
If obj==NULL, then use findEventObj(data->to).
References Laxkit::EventReceiver::Event(), Laxkit::anXWindow::Event(), Laxkit::anXWindow::FocusOff(), and Laxkit::anXWindow::FocusOn().
|
inlinevirtual |
Called anytime from anybody, tells the application to shut down.
This basically forces a break out of the event loop, thus ending the program.
Handles refreshing for window w and its children.
Called from a loop over topwindows in run. Calls w->Refresh() only if (w->Needtodraw() && w->win_on). The window must clear needtodraw itself.
Returns the number of windows saying they still need to be refreshed.
References Laxkit::anXWindow::_kids, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::findindex(), Laxkit::PtrStack< T >::n, Laxkit::anXWindow::Needtodraw(), Laxkit::anXWindow::Refresh(), Laxkit::anXWindow::win_on, and Laxkit::anXWindow::WindowTitle().
|
virtual |
Return 0 for success, nonzero for not registered.
This removes a timer manually.
Timers can be created with a number of ticks to last, and the timer is automatically removed when there are no more ticks. Users can also choose to manually remove timers here.
If timerid==0, then remove any timer of w.
Referenced by Laxkit::PopupMenu::Idle(), Laxkit::ItemSlider::Idle(), Laxkit::Scroller::Idle(), Laxkit::ItemSlider::MouseMove(), and Laxkit::Scroller::RBUp().
Reparent kid to be a child of newparent.
Attempts to reparent to a window that has ANXWIN_DOOMED in win_style will fail.
To reparent as a top level window, the newparent should be NULL.
If the parent is not created yet (parent->xlib_window==0), then only the anXWindow::win_parent is adjusted. The window is not addwindow'd. If the calling code addwindows the child before addwindowing the parent, then the child window is simply put in the parent window's _kids stack. When the parent is addwindow'd, all the windows in _kids will be addwindow'd then. If the kid's xlib_window is already created, but the parent is not, then the X window is XReparentWindow'd in addwindow.
If the parent->xlib_window exists, but the kid->xlib_window does not, then the kid is addwindow'd here.
The kid keeps its x,y,w,h after it gets reparented.
Return 1 on error, 0 on success.
maybe after reparenting, check to make sure window is on screen if it becomes top level
*** not sure, but there might problem when newparent is a child of kid...
implement reparenting to different screens
References Laxkit::anObject::_count, Laxkit::anXWindow::_kids, Laxkit::anObject::dec_count(), Laxkit::PtrStack< T >::findindex(), Laxkit::anObject::inc_count(), Laxkit::RefPtrStack< T >::remove(), and Laxkit::anXWindow::win_name.
Referenced by Laxkit::SplitWindow::Add(), Laxkit::TabFrame::AddWin(), Laxkit::StackFrame::AddWin(), Laxkit::RowFrame::AddWin(), Laxkit::SplitWindow::Change(), Laxkit::StackFrame::ReplaceWin(), Laxkit::SplitWindow::splitthewindow(), Laxkit::ScrolledWindow::UseThisWindow(), and LaxInterfaces::ViewerWindow::ViewerWindow().
|
protectedvirtual |
Quick way to code setting window and win_on=0 for w and all subwindows,.
Called from destroywindow(), this just has the effect of removing the windows from the event queue. Actual X Window destroying is done in destrowindow(), which calls this function after it XDestroys the windows.
This will set ANXWIN_DOOMED in w->win_style and all of w's children.
References Laxkit::anXWindow::_kids, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, and Laxkit::anXWindow::win_on.
|
virtual |
Return pointer to the resource named name.
The returned Attribute objects are not copies or reference counted, so calling code should do something with it quick, in case the resource is otherwise deleted. The calling code should NOT delete the returned Attribute.
This is currently used by various dialogs to store their window size and position settings, stored by their class name. Also used to store file bookmarks as a resource named "Bookmarks".
References LaxFiles::Attribute::find().
Referenced by Laxkit::FileDialog::BuildBookmarks(), and Laxkit::FileDialog::newBookmark().
|
virtual |
Append to or replace a resource.
IMPORTANT: resource must be a pointer to a totally new instance, not something already contained in resources. LaidoutApp takes possession of resource, meaning it becomes responsible for deleting it.
Completely replace the existing resource with the one given. If the resource did not previously exist, then install the resource.
Return 0 for success, or nonzero for error.
References LaxFiles::Attribute::find(), and Laxkit::PtrStack< T >::remove().
|
virtual |
This is the main event loop.
If dpy==NULL, then this will immediately return 1.
Return 0 for successful run. Return nonzero for unsuccessful, such as when dpy==NULL.
|
virtual |
Run a (top-level) dialog window that blocks inputs to other windows (runs a so called modal dialog)
A dialog is a top level window that eventually that discards messages that are masked in dialog_mask that belong to other windows, or windows that are not descended from dialog. Often times a dialog will bring up another dialog like a message box or another popup menu, and anXApp maintains a stack of such dialogs. If the dialog already is on the stack, then move it to the top.
Usually either the owner of the dialog or the dialog itself is responsible for extracting and/or delivering any state from the dialog and destroywindow'ing the dialog. After that point, event processing returns to normal.
rundialog() addwindow's the dialog if it is a toplevel, sets up the event handler to toss out those other messages, and returns 1. Please note that the event screener potentially could upset windows that keep track of button down/up; for instance when a dialog is popped up when the button is pressed down, rather than on a button up. Any generated events are screened from this point until destroywindow() is called on the dialog.
Sometimes multiple dialogs should be receiving all events. In that case, wingroup should point to a window that is already on the dialogs stack. Events are routed only through the top of the stack, and to windows on the stack that are of the same group.
If the dialog is not toplevel (ie win_parent!=NULL), nothing is added and 0 is returned.
The dialog is added to the application via addwindow(ndialog,1,wislocal)
.
Returns 0 for success, or nonzero for error.
Referenced by Laxkit::PopupMenu::addselect(), Laxkit::ImageDialog::Event(), Laxkit::FileDialog::Event(), Laxkit::PanPopup::LBDown(), Laxkit::PaletteWindow::LBDown(), Laxkit::SliderPopup::makePopup(), Laxkit::MenuButton::makePopup(), Laxkit::SplitWindow::RBDown(), LaxInterfaces::ViewportWindow::RBDown(), Laxkit::RulerWindow::RBUp(), Laxkit::ImageDialog::RegeneratePreview(), LaxInterfaces::ImagePatchInterface::runImageDialog(), LaxInterfaces::ImageInterface::runImageDialog(), Laxkit::QuickFileOpen::send(), and Laxkit::FileDialog::send().
|
virtual |
Return information about a screen, based on information in xscreeninfo which gets defined in init().
Return the width, height, and depth information about a screen, if the corresponding pointers are not NULL. The mmwidth and mmheight are in millimeters. These are usually returned by the monitor, and may or may not be accurate.
Return how many of the requested variables were found (this 0 for none found).
Referenced by Laxkit::PanWindow::centerOnMouse(), LaxInterfaces::ViewerWindow::SetRealUnits(), and Laxkit::MenuSelector::WrapToPosition().
|
virtual |
Send arbitrary data to a window.
Applications can derive classes from EventData to easily pass arbitrary chunks of data between windows. This data will be deleted by anXApp eventually. So once SendMessage() is called, the calling code should forget about the data.
anXWindows receive these messages through anXWindow::Event(const EventData *data,const char *mes) If the window accepts it, then it must return 0. If nonzero is returned from the window, then the message has not been dealt with, and it is propagated to its parent.
If towindow, mes, or sendwindow are not 0, then those fields of data are set. data->send_time is automatically set to the current time (milliseconds since boot).
Data passed in here are added to a list of data to send. These are processed in processdataevents(). If the target window does not exist at that time, the data is deleted.
Messages are recorded in a thread safe way with event_mutex.
References makestr().
Referenced by Laxkit::Overwrite::Event(), Laxkit::InputDialog::Event(), Laxkit::MessageBox::Event(), Laxkit::LineInput::Event(), Laxkit::RulerWindow::Event(), Laxkit::FileDialog::Event(), Laxkit::SimplePrint::Print(), Laxkit::ItemSlider::send(), Laxkit::DateSelector::send(), Laxkit::ColorBox::send(), Laxkit::SliderPopup::send(), Laxkit::LineEdit::send(), Laxkit::ImageDialog::send(), Laxkit::ButtonBase::send(), Laxkit::Scroller::send(), Laxkit::PaletteWindow::send(), Laxkit::FileDialog::send(), Laxkit::BoxSelector::send(), Laxkit::TreeSelector::send(), Laxkit::MenuSelector::send(), Laxkit::CurveWindow::send(), LaxInterfaces::ColorPatchInterface::sendcolor(), and LaxInterfaces::GradientInterface::sendcolor().
|
virtual |
Try to set the keyboard focus to win. If t==0 then use the current time.
This assumes that win is available to actually accept the focus.
Return 0 for success. -1 for win is not able to accept focus. 1 for window is IsUnviewable or IsUnmapped, and so cannot set focus to it (trying to do so will crash the program). Must be IsViewable as returned in map_state in the Xlib function XGetWindowAttributes().
If devicemanager!=NULL, then actually set the focus with DeviceManager::SetFocus(). Otherwise, fall back on Xlib call XSetInputFocus(), which will set a generic core pointer focus.
Referenced by Laxkit::InputDialog::CharInput(), Laxkit::PopupMenu::CharInput(), Laxkit::MenuSelector::Event(), Laxkit::NumInputSlider::LBDown(), Laxkit::SliderPopup::makePopup(), Laxkit::MenuButton::makePopup(), and Laxkit::PopupMenu::MouseMove().
|
protectedvirtual |
Set the builtin Laxkit colors.
If app_profile is "Dark" then set a dark color scheme. If app_profile is NULL or "Light", then set a more usual gray/white scheme.
References Laxkit::rgbcolor().
This should be called immediately after contstructor. It merely sets app_profile to theme. app_profile is used later on to determine default color options.
Default is to simply return 0.
References makestr().
Does tooltip related checking on events.
Currently called from run() via processSingleDataEvent() while processing events. Checks for enter events and initializes whether to potentially popup a tooltip soon and turns off check when leave event or on events from related devices.
In settimeout(), there is a check for whether it is time to pop up a tip, and a new ToolTip window is created if necessary.
|- time entered a window |——————-anXApp::tooltips————————–| |–a little initial movement allowed–|—–non-move time—–| <- end of allowed time ttthreshhold–|
See also settimeout().
References Laxkit::anObject::dec_count(), Laxkit::anObject::inc_count(), Laxkit::anXWindow::tooltip(), Laxkit::LaxMouse::ttendlimit, Laxkit::LaxMouse::ttthreshhold, and Laxkit::LaxMouse::ttwindow.
Upkeep anXApp::ttcount.
Inc if (on) else dec. ttcount will never be less than 0. Returns ttcount==0, that is, whether tooltips are active.
Unmaps a window and sends UnmapNotify events to it and its subwindows.
Clients only wishing to unmap the top window can do so with XUnmapWindow. This function merely calls that, then XUnmapSubwindows().
Referenced by Laxkit::SplitWindow::LBDown(), Laxkit::TabFrame::mapWindow(), and Laxkit::SplitWindow::Maximize().
|
static |
In the constructor, this variable is set to this.
This can be used by any helper functions to access anything in an application's anXApp instance (of which there should be only one).
Referenced by LaxInterfaces::anInterface::anInterface(), Laxkit::DisplayerXlib::ClearClip(), Laxkit::DisplayerXlib::ClearDrawable(), Laxkit::DisplayerXlib::CreateSurface(), Laxkit::CoreXlibKeyboard::eventFilter(), Laxkit::DisplayerXlib::font(), Laxkit::CoreXlibPointer::getInfo(), Laxkit::CoreXlibPointer::grabDevice(), Laxkit::FontManagerXlib::MakeFont(), Laxkit::FontManagerXlib::MakeFontFromFile(), Laxkit::FontManagerXlib::MakeFontFromStr(), Laxkit::CoreXlibPointer::selectForWindow(), Laxkit::CoreXlibKeyboard::selectForWindow(), Laxkit::ImageDialog::send(), Laxkit::CoreXlibKeyboard::SetFocus(), Laxkit::CoreXlibPointer::setMouseShape(), Laxkit::DisplayerXlib::StartDrawing(), Laxkit::DisplayerXlib::textout_line(), Laxkit::CoreXlibPointer::ungrabDevice(), and Laxkit::DisplayerXlib::~DisplayerXlib().
char * Laxkit::anXApp::app_profile |
int Laxkit::anXApp::buttoncount |
Number of times a mouse button has been pressed in succession.
anXApp keeps this to check on the simplest case of a single button being pressed rapidly. Any other buttons also being pressed during the same time period will reset this counter.
|
protected |
Normally empty string "". You can change this with Locale(const char*) to be some specific language. Otherwise, uses the current language settings for your environment.
|
protected |
Mask used for screening events when dialogs are up.
The default is not allow input and focus events, and let other events like expose and enter/exit events pass.
|
protected |
Wait time to check for new messages, in microseconds.
If bump() doesn't seem to work, set this to something nonzero to force breaking out of select().
|
protected |
A simple resource holder.
This is used by, for instance, FileDialog to remember where the dialog was on the screen if the dialog is closed and opened.
If you want an application to remember such settings between starting and stopping, then your class derived from anXApp must implement its own file save and load. This is simply a matter of choosing a file to save to, and calling resources.dump_out(FILE*,int) and resources.dump_in(file,0,NULL).
|
protected |
Stack of windows to delete after the event queue is depleted.
Windows are pushed onto here from destroywindow(), and they are actually deleted from destroyqueued().
int Laxkit::anXApp::tooltips |
Number of milliseconds to wait once a mouse enters a window before popping up a tooltip.
If 0, then tooltips are disabled.
|
protected |
Special tag for whether tooltips are temporarily disabled.
Calls to Tooltips() increment and decrement this. During pointer grabs, for instance, tooltips would wreck havoc, so this flag is to temporarily disable them.
ttcount==0 means use tooltips, and any other value means do not use tooltips.