Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends
Laxkit::anXWindow Class Reference

This is the basic window unit for the Laxkit. More...

Inheritance diagram for Laxkit::anXWindow:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 anXWindow (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsend)
 Constructor.
virtual ~anXWindow ()
 anXWindow destructor. Its X window should have been XDestroy'd before here.
virtual const charwhattype ()
virtual const charWindowTitle (int which=0)
 Return basically the name of the window.
virtual void WindowTitle (const char *newtitle)
 Change the title of the window. This text would usually be displayed in the bar provided by a window manager.
virtual const chartooltip (int mouseid=0)
 By default, return win_tooltip.
virtual const chartooltip (const char *newtooltip)
 Replace the current tooltip, return the current tooltip (after replacing).
virtual anXWindowfindChildWindowByTitle (const char *title)
 Find the first immediate child window that has win_title==title.
virtual anXWindowfindChildWindowByName (const char *name)
 Find the first immediate child window that has win_name==name.
virtual int Grayed ()
 Return whether this window is grayed.
virtual int Grayed (int g)
 Set the gray state of this window. Returns Grayed(void).
virtual int preinit ()
virtual int init ()
 Empty placeholeder. Just returns 0.
virtual int close ()
 Called by anXApp from anXApp::destroywindow() when a window is to be destroyed.
virtual int Idle (int tid=0)
 anXWindow::Idle() is an empty placeholeder. Just returns 1.
virtual void Refresh ()
 anXWindow::Refresh() is an empty placeholeder. Just calls Needtodraw(0) and returns 0.
virtual DisplayerMakeCurrent ()
virtual int Needtodraw ()
 Default is to return needtodraw.
virtual void Needtodraw (int nntd)
 If 0, then the window does not need refreshing. Otherwise it does.
virtual int deletenow ()
 Return whether the window is allowed to be deleted.
virtual int setWinStyle (unsigned int stylebit, int newvalue)
 Control various window related basic styling of win_style.
virtual int getWinStyle (unsigned int stylebit)
 Currently, simply return win_style&stylebit.
virtual void installColors (WindowColors *newcolors)
 Dec_count old and inc_count new.
virtual ShortcutHandlerGetShortcuts ()
 Return a ShortcutHandler that contains stacks of bound shortcuts and possible window actions.
virtual int PerformAction (int action_number)
virtual int Event (const EventData *data, const char *mes)
 Default event handler.
virtual int ExposeChange (ScreenEventData *e)
 Default behavior on Expose events is to call Needtodraw(1).
virtual int DeviceChange (const DeviceEventData *e)
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *kb)
 Input of character data or control character presses.
virtual int KeyUp (unsigned int ch, unsigned int state, const LaxKeyboard *kb)
 Called when a key is released.
virtual int MouseMove (int x, int y, unsigned int state, const LaxMouse *m)
 Empty placeholder, just returns 1.
virtual int ButtonDown (int button, int x, int y, unsigned int state, int count, const LaxMouse *m)
virtual int ButtonUp (int button, int x, int y, unsigned int state, const LaxMouse *m)
virtual int LBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Default is just to return 1.
virtual int LBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Default is just to return 1.
virtual int MBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Default is just to return 1.
virtual int MBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Default is just to return 1.
virtual int RBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Default is just to return 1.
virtual int RBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Default is just to return 1.
virtual int WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d)
 The wheel mouse rolling up. Default is just to return 1.
virtual int WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 The wheel mouse rolling down. Default is just to return 1.
virtual int FocusOn (const FocusChangeData *e)
 Increment win_active, and highlights the window's border, if the event refers to this window.
virtual int FocusOff (const FocusChangeData *e)
 Decrements win_active, and de-highlights the window's border if win_active==0, if event is a real focus off.
virtual int MoveResize (int nx, int ny, int nw, int nh)
 Move and resize the window.
virtual int Resize (int nw, int nh)
 Resize with new nw, and nh.
virtual void contentChanged ()
 Windows may call this when their contents change.
virtual void selectionChanged ()
 Windows may call this when their selections change.
virtual anXWindowGetController ()
 Return the window most relevant for tab control loops.
virtual int SelectNextControl (const LaxDevice *d)
 Transfer focus to nextcontrol.
virtual int SelectPrevControl (const LaxDevice *d)
 Transfer the focus to prevcontrol.
virtual void ControlActivation (int on)
 Do special activation or not when controls are activated by tabbing.
virtual int AddPrevControl (anXWindow *prev)
virtual int AddNextControl (anXWindow *next)
virtual int ConnectControl (anXWindow *towhat, int after=1)
 Connect towhat to this. Used for tab loops.
virtual int CloseControlLoop ()
 Close a tab loop.
virtual void SetOwner (anXWindow *nowner, const char *mes=NULL, unsigned int send_mask=0)
 Set the new owner and control message.
virtual void SetOwner (unsigned long nowner_id, const char *mes=NULL, unsigned int send_mask=0)
virtual void dump_out (FILE *f, int indent, int what, anObject *context)
 Simple dumping function.
virtual LaxFiles::Attributedump_out_atts (LaxFiles::Attribute *att, int what, anObject *context)
virtual void dump_in_atts (LaxFiles::Attribute *att, int flag, anObject *context)
- Public Member Functions inherited from Laxkit::Tagged
virtual int HasTag (const char *tag, int casematters)
 Return whether the tag exists.
virtual int NumberOfTags ()
 Return the number of tags, strangely enough.
virtual const charGetTag (int i)
 Return const pointer to the tag text for tag number i, where i==0 is the first tag.
virtual charGetAllTags ()
 Return a new char[] with a space separated list of all the tags.
virtual int InsertTags (const char *tags, int casematters)
 Insert tags from a string such as 'tag1 tag2 tag3 "tag with spaces" tag4'.
virtual int InsertTag (const char *tag, int casematters)
 Insert tag if it doesn't exist already.
virtual int RemoveTag (const char *tag)
 The tag must be an exact match.
virtual int RemoveTag (int i)
 Remove tag number i. i must be in range [0..NumberOfTags()-1].
virtual void FlushTags ()
- Public Member Functions inherited from LaxFiles::DumpUtility
virtual void dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att)
 Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts.
virtual ~DumpUtility ()
 Empty virtual destructor.
- Public Member Functions inherited from Laxkit::aDrawable
 aDrawable (Drawable d=0)
virtual int DrawableType ()
virtual int ValidDrawable ()

Public Attributes

WindowColorswin_colors
anXAppapp
charwin_name
 An arbitrary string to be used as an id.
charwin_title
 The title of the window.
anXWindowwin_parent
int win_screen
unsigned long win_style
int win_x
int win_y
int win_w
int win_h
unsigned int win_border
int win_pointer_shape
 Identifier for a stock mouse shape.
char win_on
 Nonzero if the window is mapped.
char win_active
 Should be positive when the window has a keyboard focus, 0 otherwise.
unsigned long win_owner
 Who gets control messages from this window.
unsigned int win_owner_send_mask
charwin_sendthis
 The type of message that gets sent to owner.
anXWindownextcontrol
anXWindowprevcontrol
- Public Attributes inherited from Laxkit::Tagged
int sorttags

Protected Member Functions

virtual int deletekid (anXWindow *w)
 Purges child anXWindows from window's child stack.
virtual void SwapBuffers ()
 Swap buffers. This should be called from Refresh() if VIEWPORT_BACK_BUFFER is set in win_style.
virtual void SetupBackBuffer ()
 Initialize the backbuffer.

Protected Attributes

charwin_tooltip
 Convenience variable to hold the window's tooltip, if any.
int needtodraw
RefPtrStack< anXWindow_kids
 Stack of children of the window.
- Protected Attributes inherited from Laxkit::Tagged
PtrStack< charlist_of_tags

Friends

class anXApp

Detailed Description

This is the basic window unit for the Laxkit.

anXWindow is the barest form of a window class available in the Laxkit. Most people will not use this class directly, using all the various subclasses instead. If you design your own windows basically from scratch, you would subclass anXWindow.

anXWindow::event() routes the X events to the corresponding member functions. Any X events not dealt with there are ignored, but classes derived from anXWindow can redefine event to catch those. Just be sure to also call anXWindow::event() to ensure proper focusing and such. Dealt with is resizing the window when the user resizes via the mouse dragging window manager decorations, and also implements the delete protocol when the 'x' (provided by your window manager, unrelated to Laxkit) is clicked. It tells anXApp to destroy this window only if deletenow() returns 1. If deletenow() returns 2, then the window is just unmapped. If deletenow() returns 3, the window is kept mapped.

Event handling functions must return 0 if they actually deal with an event. If a nonzero value is returned, then typically the event will be propagated to the window's parent.

anXWindow Styles

The base style of a window is stored in win_style. Currently, anXWindow reserves the right to uses bits 0..15. Derived classes can use any other bits in win_style if they want. All the bits taken by anXWindow can be screened for with ANXWIN_MASK (==0xffff).

When the window is created and this flag is set, then the window will be created
as being tagged as kind of a subprocess of its owner window. In terms of Xlib,
the transient_for hint will be set, referencing the window's owner.
#define ANXWIN_TRANSIENT
Do not let the window have a little "x" decoration on it to let users close it easily.
#define ANXWIN_NOT_DELETEABLE
If this is present, then this window and all its descendents must be considered to
be grayed, meaning you can't interact with it.
#define ANXWIN_GRAYED
Based on a key returned by whattype(), when this type of window is closed, it will
save information about itself in anXApp. See anXApp::Resource() for more info.
#define ANXWIN_REMEMBER
Flag this window as being capable of receiving (and maybe sending)
drag-n-drop events.
#define ANXWIN_XDND_AWARE
A window with this style will gain the input focus whenever it
receives and EnterNotify event. If this style is not set,
you must click in a window to make the focus be that window.
#define ANXWIN_HOVER_FOCUS
This is for windows that do not want to be alerted to any input events of any kind.
#define ANXWIN_NO_INPUT
Makes the window with no decorations. In terms of Xlib, this is a window
with the WM_TRANSIENT_FOR property set, together with override_redirect of the
XSetWindowAttributes struct. These make your window manager ignore the window, and
any focusing has to be done manually. Note that the window will exist on all desktops.
#define ANXWIN_BARE
Center the window when initially mapped
#define ANXWIN_CENTER
Create an window in fullscreen mode
#define ANXWIN_FULLSCREEN
Convenience flag to automatically enable closing windows by hitting the escape key.
Works with deletenow()/close()
#define ANXWIN_ESCAPABLE
Any window with this set is slated for destruction, and should not be messed with in any way.
#define ANXWIN_DOOMED
Set up a window to be double buffered. This by default will use the X Double Buffer Extension
to create the buffer, which can be swapped win SwapBuffers().
#define ANXWIN_DOUBLEBUFFER
If this window is a top level window, and the mouse is clicked down somewhere outside the window
and outside of any connected top level controls, then destroy this window and its connected top
level controls.
#define ANXWIN_OUT_CLICK_DESTROYS
Todo:
implement ANXWIN_BARE to have no decorations, but move with the desktop?

Constructor & Destructor Documentation

Laxkit::anXWindow::anXWindow ( anXWindow parnt,
const char nname,
const char ntitle,
unsigned long  nstyle,
int  xx,
int  yy,
int  ww,
int  hh,
int  brder,
anXWindow prev,
unsigned long  nowner,
const char nsend 
)

Constructor.

Just assigns all the passed in variables to their given values, and everything else to 0/NULL.

If brder<0, then set win_border to app->default_inactiveborder.

  These attributes are set here:
   win_xatts.border_pixel=app->color_inactiveborder;
   win_xattsmask|=CWEventMask|CWBorderPixel; // set to 0 in anXWindow
   win_xatts.event_mask|=FocusChangeMask|StructureNotifyMask|ResizeRedirectMask|
                          ExposureMask|EnterWindowMask|LeaveWindowMask;
 

See Xlib Primer for Laxkit for what other events Constructors can set for.

  Constructor, appends itself to the (incomplete) tab loop in prev.
  Later, it is assumed that that loop in prev is not yet a closed loop, ie that
  some prev->prev->... is NULL.
 
Parameters:
prevprevcontrol gets set to this.
nownerWho gets control messages from this window
nsendThe control message to send

References ConnectControl(), and newstr().

Laxkit::anXWindow::~anXWindow ( )
virtual

anXWindow destructor. Its X window should have been XDestroy'd before here.

App->destroywindow() must be called for this window for the X window to be properly destroyed. The anXApp::destroyqueued() provokes the actual deleting by calling win->deletekid(whateverwindow).

If nextcontrol or prevcontrol exist, then take this out of that control loop by connecting those two.


Member Function Documentation

int anXWindow::CharInput ( unsigned int  ch,
const char buffer,
int  len,
unsigned int  state,
const LaxKeyboard kb 
)
virtual

Input of character data or control character presses.

If key>0 and key<=0x10ffff, then key is the USC code of a character. In this case, buffer will contain the utf8 representation of key. If key>0x1000000, then key can be compared to various Laxkit defined keys, such as LAX_Pgdown, LAX_Del, etc. In this case, currently, key&0xffffff is the Xlib keysym of the key. Also in this case, buffer will be NULL.

If key==0 but buffer!=NULL, then buffer contains multiple utf8 characters, all of which should be considered input. This will have resulted from input that was somehow composed from key sequences at a higher level.

len is the length in bytes of buffer, if any.

state will be a combination of ShiftMask, ControlMask, AltMask, MetaMask, KeypadMask, CapsLockMask, and NumLockMask. Numpad keys will have the KeypadMask bit set in state. You can check what combination of shift, control, alt, and meta masks are presest by examining state&LAX_STATE_MASK.

See laxdefs.h for various definitions for keys and LAX_STATE_MASK.

Currently, no distinction is made between left and right control, alt, or meta keys. If you really, really need the distinction, you can intercept the key events in anXWindow::event(), or complain to the developers.

Default behavior for this function is for tab press to make the input focus go to the nextcontrol (if it is not NULL), shift-tab transfers focus to prevcontrol (if not NULL). See SelectNextControl() and SelectPrevControl().

Reimplemented in Laxkit::TreeSelector, Laxkit::MenuSelector, LaxInterfaces::ViewportWindow, Laxkit::SplitWindow, Laxkit::FileDialog, Laxkit::PrintDialog, Laxkit::Scroller, Laxkit::ButtonBase, Laxkit::ColorBox, Laxkit::LineEdit, Laxkit::DateSelector, Laxkit::ImageDialog, LaxInterfaces::ViewerWindow, Laxkit::SliderPopup, Laxkit::PromptEdit, Laxkit::SimplePrint, Laxkit::PopupMenu, and Laxkit::InputDialog.

Referenced by Laxkit::ColorBox::CharInput().

int Laxkit::anXWindow::close ( )
virtual

Called by anXApp from anXApp::destroywindow() when a window is to be destroyed.

This function is called before the Xlib window is destroyed, so windows can do any specific cleanup that still depends on that window value here.

If win_parent==NULL and win_style&ANXWIN_REMEMBER, then call app->Resource() with a new Attribute found via dump_out_atts().

The Laxkit does not do anything with the default return value, but 0 should mean success.

Todo:
is win_parent check really necessary? maybe just rely on ANXWIN_REMEMBER?

Referenced by Laxkit::anXApp::destroywindow().

int Laxkit::anXWindow::CloseControlLoop ( )
virtual

Close a tab loop.

Usually this will be called from the init() function of some frame class to signal an end to a tab loop.

This just connects the most previous control that is NULL to the most next control that is NULL. Assumes that for each control in the current loop, thatcontrol->nextcontrol->prevcontrol==thatcontrol if thatcontrol is not NULL, some thing for prevcontrol. If controls were added strictly through the anXWindow control loop functions, this will be true.

Reimplemented in Laxkit::LineInput.

Referenced by Laxkit::LineInput::CloseControlLoop(), Laxkit::ImageDialog::init(), Laxkit::FileDialog::init(), and Laxkit::SimplePrint::SimplePrint().

int Laxkit::anXWindow::ConnectControl ( anXWindow towhat,
int  after = 1 
)
virtual

Connect towhat to this. Used for tab loops.

If towhat is passed in as NULL, then detach this from its loop, connecting next and prev.

Actually this function connects towhat->GetController() and this->GetController(). This is so the focus goes to, for instance, the editing part of a LineInput, rather than the LineInput itself, which is just a container.

If towhat is part of an open loop, then the bounds of that loop are squeezed in between this and either nextcontrol or prevcontrol, depending on whether after==1 or not. If towhat is part of a closed loop, then that loop is cut between towhat and towhat->prevcontrol.

Return 0 for successful attachment or detachment. 1 for when there was nothing to attach, that is, GetController() for this or towhat returned NULL.

References GetController(), and WindowTitle().

Referenced by anXWindow(), and Laxkit::FileDialog::init().

void Laxkit::anXWindow::contentChanged ( )
virtual

Windows may call this when their contents change.

This would be when a text edit has more text entered, for instance.

If (win_owner_send_mask & LAX_onContentChange), then the default here would trigger sending a SimpleEvent of type onContentChange to win_owner.

void Laxkit::anXWindow::ControlActivation ( int  on)
virtual

Do special activation or not when controls are activated by tabbing.

This would be done in FocusOn()/FocusOff(), but XI2 seems to send a ton of useless Enter/Leave events upon a button down.

int Laxkit::anXWindow::deletekid ( anXWindow w)
protectedvirtual

Purges child anXWindows from window's child stack.

You should not call this function directly. This normally is called from anXApp::destroyqueued. anXApp is responsible for maintaining anXWindow's _kids stack.

Removes only if w is a direct kid, not grand kid or more.

Referenced by Laxkit::anXApp::destroyqueued().

int Laxkit::anXWindow::deletenow ( )
inlinevirtual

Return whether the window is allowed to be deleted.

Return 1 means ok to unmap AND delete, Return 2 means unmap only. Return 3 to neither unmap nor delete.

This function is called during processing of the delete protocol

void Laxkit::anXWindow::dump_in_atts ( LaxFiles::Attribute att,
int  flag,
anObject context 
)
virtual

Default is to read in win_x, win_y, win_w, win_h, win_tooltip, win_flags.

Todo:
at some point, must ensure that the dimensions read in are in part on screen.. though this is really an anXApp::addwindow() task.

Implements LaxFiles::DumpUtility.

Reimplemented in Laxkit::CurveWindow, Laxkit::RulerWindow, Laxkit::Scroller, Laxkit::MessageBar, Laxkit::DateSelector, and Laxkit::Button.

References deletestrs(), Laxkit::PtrStack< T >::e, LaxFiles::IntAttribute(), isblank(), Laxkit::PtrStack< T >::n, and splitspace().

void Laxkit::anXWindow::dump_out ( FILE *  f,
int  indent,
int  what,
anObject context 
)
virtual

Simple dumping function.

Default is to dump out an Attribute retrieved from dump_out_atts(), so subclasses need only redefine dump_out_atts() and dump_in_atts() for all the DumpUtility functions to work.

Implements LaxFiles::DumpUtility.

References LaxFiles::Attribute::dump_out().

Attribute * Laxkit::anXWindow::dump_out_atts ( LaxFiles::Attribute att,
int  what,
anObject context 
)
virtual

Append to att if att!=NULL, else return a new Attribute whose name is whattype().

Default is to add attributes for win_x, win_y, win_w, and win_h.

Todo:
maybe someday have option to overwrite existing attributes in att, but this opens up potential problems due to possible nesting. How deep would the replace function?

Reimplemented from LaxFiles::DumpUtility.

Reimplemented in Laxkit::CurveWindow, Laxkit::RulerWindow, Laxkit::Scroller, Laxkit::MessageBar, Laxkit::DateSelector, and Laxkit::Button.

References LaxFiles::Attribute::push().

int Laxkit::anXWindow::Event ( const EventData data,
const char mes 
)
virtual

Default event handler.

Events dispatched here automatically are mouse, device, and keyboard events other than LAX_onFocusOn and LAX_onFocusOff events. The events are relayed to the proper LBDown(), RBDown(), etc.

None of the events that reach this function are strictly necessary for the functioning of a window at a low level. If you need to override LAX_onFocusOn and LAX_onFocusOff events, you must redefine FocusOn() and FocusOff().

Returns 0 for event accepted, or 1 for ignored.

Reimplemented from Laxkit::EventReceiver.

Reimplemented in Laxkit::MenuSelector, LaxInterfaces::ViewportWindow, Laxkit::ColorSliders, Laxkit::SplitWindow, Laxkit::FileDialog, Laxkit::BoxSelector, Laxkit::PaletteWindow, Laxkit::PrintDialog, Laxkit::RulerWindow, Laxkit::ButtonBase, Laxkit::PanWindow, Laxkit::ScrolledWindow, LaxInterfaces::ViewerWindow, Laxkit::ImageDialog, Laxkit::LineInput, Laxkit::MultiLineEdit, Laxkit::SimplePrint, Laxkit::MessageBox, Laxkit::InputDialog, LaxInterfaces::ViewportWithStack, Laxkit::NumInputSlider, Laxkit::ToolTip, and Laxkit::Overwrite.

Referenced by Laxkit::anXApp::processSingleDataEvent().

int Laxkit::anXWindow::ExposeChange ( ScreenEventData e)
inlinevirtual

Default behavior on Expose events is to call Needtodraw(1).

For smart refreshing, windows would redefine this to record which areas of the window need to be updated. Imlib2, by the way, provides for this via imlib_updates.

References Needtodraw().

anXWindow * Laxkit::anXWindow::findChildWindowByName ( const char name)
virtual

Find the first immediate child window that has win_name==name.

If name==NULL, NULL is returned, not the first window that has a NULL name.

If win_name==NULL, then win_title is compared against instead.

Note that this does not check kids of child windows.

Referenced by Laxkit::FileDialog::BuildBookmarks(), Laxkit::InputDialog::CharInput(), LaxInterfaces::ViewportWithStack::Event(), Laxkit::InputDialog::Event(), LaxInterfaces::ViewerWindow::Event(), Laxkit::ShortcutWindow::SetSearch(), and Laxkit::ShortcutWindow::UpdateSearch().

anXWindow * Laxkit::anXWindow::findChildWindowByTitle ( const char title)
virtual

Find the first immediate child window that has win_title==title.

If title==NULL, NULL is returned, not the first window that has a NULL title.

Note that this does not check kids of child windows.

This will only check against win_title. See also findChildWindowByName().

int Laxkit::anXWindow::FocusOn ( const FocusChangeData e)
virtual

Increment win_active, and highlights the window's border, if the event refers to this window.

The default here is to activate for any focus on from any keyboard.

If it is an actual focus on, then app->xim_ic is updated for this window. Also the border color is changed to app->color_activeborder.

Todo:
*** update this for multiple keyboard inputs.. right now, there is only one x input context at any one time, stored in anXApp::xim_ic. really I don't understand x input contexts, or any more modern way of doing it, so until then, this'll have to do.

Reimplemented in Laxkit::TreeSelector, Laxkit::MenuSelector, Laxkit::LineEdit, Laxkit::LineInput, and Laxkit::TextXEditBaseUtf8.

Referenced by Laxkit::anXApp::processSingleDataEvent().

anXWindow * Laxkit::anXWindow::GetController ( )
virtual

Return the window most relevant for tab control loops.

For instance, a LineInput has a label, and a LineEdit embedded in it. For the purposes of adding to a tab loop, the LineEdit should be connected, and not the LineInput. So the LineInput::GetController() returns its LineEdit rather than itself, which is the default.

Referenced by ConnectControl().

ShortcutHandler * Laxkit::anXWindow::GetShortcuts ( )
virtual

Return a ShortcutHandler that contains stacks of bound shortcuts and possible window actions.

NULL means there are none defined for this window.

Windows that do use shortcuts, and want them stored in an easy manner should use the ShortcutManager system, accessed with GetDefaultShortcutManager(). They can then install a single list of shortcuts and actions bound to the window type name, and any future window instances can borrow those.

int Laxkit::anXWindow::getWinStyle ( unsigned int  stylebit)
virtual

Currently, simply return win_style&stylebit.

Todo:
like setWinStyle(), this is rather limited and needs further thought...
int Laxkit::anXWindow::Grayed ( void  )
virtual

Return whether this window is grayed.

If this window does not have gray set, but an ancestor window does, then it is considered gray. The return value is the level back one must go before the next grayed window. 1==this window, 2==win_parent is grayed, and so on.

0 means not grayed.

Reimplemented in Laxkit::ButtonBase.

int Laxkit::anXWindow::Idle ( int  tid = 0)
inlinevirtual

anXWindow::Idle() is an empty placeholeder. Just returns 1.

This function will be called if there is a timer that ticks off. The timer's id is passed as tid.

If Idle returns 1, then the timer is removed. If Idles returns 0, the timer is left active. This makes it very easy to turn off any residual mouse timers with a check to see if any buttons are still down, and if so, return 1.

Reimplemented in Laxkit::TreeSelector, Laxkit::MenuSelector, Laxkit::LineEdit, Laxkit::MultiLineEdit, Laxkit::Scroller, Laxkit::ItemSlider, Laxkit::PopupMenu, and Laxkit::ToolTip.

int Laxkit::anXWindow::init ( )
inlinevirtual

Empty placeholeder. Just returns 0.

When anXApp::addwindow() is called with this window, init() is called after the window is allocated (in Xlib, this is with XCreatWindow()), but before the window is mapped (made visible). Normally, windows will create and install child windows via app->addwindow() from init(), since the anXWindow will now have a valid allocation.

The following is relevant for Laxkit using Xlib.

Also, if a window wants to set anything in win_hints or win_sizehints, they should do so here or before init() somewhere. anXApp::addwindow() sets all other relevant hints after this init returns, and before the window is mapped. Setting the win_sizehints with USPosition and USSize causes the window to be popped up in a definite place, rather than thrown about willy nilly by the window manager.

As a convenience, if init() returns 1 then it is assumed that win_w and/or win_h are not the same as before init() was called. anXApp::addwindow() then sets up win_sizehints accordingly, before the window is mapped. If the window has ANXWIN_CENTER set, then the x and y in win_sizehints are also set accordingly, and win_x and win_y are set to the recomputed x and y.

Reimplemented in Laxkit::TreeSelector, Laxkit::MenuSelector, LaxInterfaces::ViewportWindow, Laxkit::SplitWindow, Laxkit::FileDialog, Laxkit::BoxSelector, Laxkit::RulerWindow, Laxkit::RowFrame, Laxkit::ScrolledWindow, Laxkit::TabFrame, Laxkit::ImageDialog, LaxInterfaces::ViewerWindow, Laxkit::LineInput, Laxkit::TextXEditBaseUtf8, Laxkit::MultiLineEdit, Laxkit::ItemSlider, Laxkit::StackFrame, and Laxkit::SimplePrint.

Referenced by Laxkit::anXApp::addwindow().

int anXWindow::KeyUp ( unsigned int  ch,
unsigned int  state,
const LaxKeyboard kb 
)
inlinevirtual

Called when a key is released.

See anXWindow::CharInput() for what the ch actually corresponds to. This function is different than CharInput() in that there is no composed character passed in. One would use this function to check whether a shift (LAX_Shift) or control (LAX_Control) key is released, for instance.

int anXWindow::LBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const LaxMouse d 
)
inlinevirtual
Displayer * Laxkit::anXWindow::MakeCurrent ( )
virtual

Default is to return the default Displayer via GetDefaultDisplayer(). Also calls dp->MakeCurrent(this). Subclasses that use other custom displayers should redefine if necessary.

References Laxkit::dp, Laxkit::GetDefaultDisplayer(), and Laxkit::Displayer::MakeCurrent().

Referenced by Laxkit::RulerWindow::Refresh().

int Laxkit::anXWindow::MBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const LaxMouse d 
)
inlinevirtual

Default is just to return 1.

Count is usually 1, but double click is 2, triple click==3, etc.

Reimplemented in LaxInterfaces::ViewportWindow, and Laxkit::ColorBox.

int Laxkit::anXWindow::MoveResize ( int  nx,
int  ny,
int  nw,
int  nh 
)
virtual
void Laxkit::anXWindow::Needtodraw ( )
inlinevirtual

Default is to return needtodraw.

This function is consulted during the event loop, during the refresh and idle stage. If it returns nonzero, then Refresh() is called.

Reimplemented in LaxInterfaces::ViewportWindow.

Referenced by Laxkit::FileDialog::Event(), ExposeChange(), Laxkit::FileDialog::getDirectory(), Refresh(), and Laxkit::anXApp::refresh().

int Laxkit::anXWindow::Needtodraw ( int  nntd)
inlinevirtual

If 0, then the window does not need refreshing. Otherwise it does.

My hat's off to Fltk for using overloaded functions to either set or retrieve values! What a great idea!

int Laxkit::anXWindow::PerformAction ( int  action_number)
virtual

This method exists to aid standardizing access to shortcut actions from potential scripting. Return 1 for not found or otherwise not done, or 0 for success. Default is return 1.

int Laxkit::anXWindow::preinit ( )
virtual

When anXApp::addwindow() is called with this window, preinit() is called before the window is allocated (in xlib, this is with XCreatWindow()). Derived classes would redefine this to do some last minute tinkering before the window is allocated. Windows get another chance to do tinkering when init() is called after allocating, but before being made visible (aka mapped).

In win_style&ANXWIN_REMEMBER and win_w and/or win_h==0, then look up the anXApp::Resource() corresponding to this->whattype(), and set the win_x,y,w,h to the corresponding values.

The return value is currently ignored in the default anXApp, but 0 should mean success.

Just for reference, the following code can be used to make a window get mapped initially to a particular place on the screen. This is basically what is done with windows that have ANXWIN_CENTER set in win_style.

// adjusting the x/y and flags|=USPosition or PPosition might make the window open properly??
// check this:
// USPosition/USSize means the user wants it this way, and thats that.
// PPosition/PSize means the client set it without user involvement?? what does that mean?
if (!xlib_win_sizehints) xlib_win_sizehints=XAllocSizeHints();
if (xlib_win_sizehints && !w->win_parent) {
xlib_win_sizehints->x=win_x;
xlib_win_sizehints->y=win_y;
xlib_win_sizehints->width=win_w;
xlib_win_sizehints->height=win_h;
xlib_win_sizehints->min_width=10;
xlib_win_sizehints->max_width=500;
xlib_win_sizehints->min_height=10;
xlib_win_sizehints->max_height=500;
xlib_win_sizehints->width_inc=1; //pixel increments to allow window resizing
xlib_win_sizehints->height_inc=1;
xlib_win_sizehints->flags=PMinSize|PResizeInc|USPosition|USSize;
//XSetWMNormalHints(dpy,win,win_sizehints); this is called in addwindow, before mapping
}
Todo:
must incorporate _NET_FRAME_EXTENTS with ANXWIN_REMEMBER

Reimplemented in Laxkit::FileDialog, Laxkit::PrintDialog, Laxkit::ImageDialog, and Laxkit::MessageBox.

Referenced by Laxkit::anXApp::addwindow().

int Laxkit::anXWindow::RBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const LaxMouse d 
)
inlinevirtual

Default is just to return 1.

Count is usually 1, but double click is 2, triple click==3, etc.

Reimplemented in Laxkit::TreeSelector, Laxkit::MenuSelector, LaxInterfaces::ViewportWindow, Laxkit::SplitWindow, Laxkit::ColorBox, Laxkit::Scroller, Laxkit::SliderPopup, Laxkit::MultiLineEdit, and Laxkit::PopupMenu.

void Laxkit::anXWindow::Refresh ( )
inlinevirtual
int Laxkit::anXWindow::Resize ( int  nw,
int  nh 
)
virtual

Resize with new nw, and nh.

This function will normally be called automatically, in response to an event, and not when the user wants to resize a window. If you need to resize a window yourself, you should probably use MoveResize().

This will call XResizeWindow(app->dpy,window,nw,nh), and update win_w and win_h.

If this is called from event(), note that the window is under override redirect as per ICCCM.

Todo:
i want to remove this one, and only have MoveResize, but when I just have this function call MoveResize, it screws up RowFrame!! what the F? override_redirect funkiness? see icccm 4.2.9

Reimplemented in Laxkit::TreeSelector, Laxkit::MenuSelector, LaxInterfaces::ViewportWindow, Laxkit::SplitWindow, Laxkit::ColorSliders, Laxkit::PaletteWindow, Laxkit::BoxSelector, Laxkit::PanWindow, Laxkit::RowFrame, Laxkit::ScrolledWindow, Laxkit::Scroller, Laxkit::MultiLineEdit, Laxkit::LineInput, Laxkit::TextXEditBaseUtf8, Laxkit::StackFrame, and Laxkit::FuncFrame.

void Laxkit::anXWindow::selectionChanged ( )
virtual

Windows may call this when their selections change.

This would be when more or less text gets selected in a text edit, for instance.

If (win_owner_send_mask & onSelectionChange), then this would trigger sending a SimpleEvent of type onSelectionChange to win_owner.

int Laxkit::anXWindow::SelectNextControl ( const LaxDevice d)
virtual

Transfer focus to nextcontrol.

Todo:
*** must focus the right keyboard!! and at the right time!!!!

Referenced by Laxkit::LineEdit::CharInput().

void Laxkit::anXWindow::SetOwner ( anXWindow nowner,
const char mes = NULL,
unsigned int  send_mask = 0 
)
virtual

Set the new owner and control message.

Sets win_owner whether or not nowner==NULL. Sets win_sendthis only if mes!=NULL.

If send_mask!=0, then set win_owner_send_mask to it.

References makestr(), and WindowTitle().

Referenced by Laxkit::SimplePrint::init(), Laxkit::LineInput::init(), Laxkit::FileDialog::init(), LaxInterfaces::ViewportWindow::UseTheseRulers(), and LaxInterfaces::ViewportWindow::UseTheseScrollers().

void Laxkit::anXWindow::SetupBackBuffer ( )
protectedvirtual

Initialize the backbuffer.

This is a convenience function for windows that have ANXWIN_DOUBLEBUFFER set. If that is not set in win_style, then no back buffer is set up.

By default, this will be called by anXApp after it calls anXWindow::init(). As long as ANXWIN_DOUBLEBUFFER is set, then normally windows do not need to call this themselves.

All it does is this:
xlib_backbuffer=XdbeAllocateBackBufferName(app->dpy,window,XdbeBackground);

Referenced by Laxkit::anXApp::addwindow().

int Laxkit::anXWindow::setWinStyle ( unsigned int  stylebit,
int  newvalue 
)
virtual

Control various window related basic styling of win_style.

The default is to set and unset style bit in win_style, as long as stylebit is not within ANXWIN_MASK. Warning: do not randomly call this function unless you know what you're doing, as most predefined windows have specific ways to manage win_style.

Return 0 for style updated, and 1 for not.

Todo:
must rethink window styling to make it more reasonable and adaptable. maybe better to have stylebit be more like an enum, so as to lock style types in laxkit namespace, rather then have a million goofy defines. It would then be up to the window to interperet the newvalue and set accordingly.

Referenced by Laxkit::Button::dump_in_atts(), Laxkit::DateSelector::dump_in_atts(), Laxkit::Scroller::dump_in_atts(), Laxkit::RulerWindow::dump_in_atts(), and Laxkit::MenuButton::MenuButton().

void Laxkit::anXWindow::SwapBuffers ( )
protectedvirtual

Swap buffers. This should be called from Refresh() if VIEWPORT_BACK_BUFFER is set in win_style.

Default is to call XdbeSwapBuffers(app->dpy,&swapinfo,1) with swapinfo.swap_window=window and swapinfo.swap_action=XdbeBackground.

Reimplemented in Laxkit::ShortcutTreeSelector.

Referenced by LaxInterfaces::ViewportWithStack::Refresh(), Laxkit::RulerWindow::Refresh(), LaxInterfaces::ViewportWindow::Refresh(), and Laxkit::TreeSelector::Refresh().

const char * Laxkit::anXWindow::tooltip ( int  mouseid = 0)
virtual

By default, return win_tooltip.

By default, mouseid is ignored. Derived classes may redefine this function to take into account which mouse is requesting a tooltip.

Reimplemented in Laxkit::ColorBox.

Referenced by Laxkit::ImageDialog::init(), Laxkit::FileDialog::init(), Laxkit::FileDialog::OkButton(), Laxkit::LineInput::tooltip(), and Laxkit::anXApp::tooltipcheck().

const char * Laxkit::anXWindow::tooltip ( const char newtooltip)
virtual

Replace the current tooltip, return the current tooltip (after replacing).

If tooltips are active, the anXApp calls tooltip() to find the tip for this window. Thus, the window can redefine this function if there are multiple tooltips for some reason.

Note that calling tooltip(NULL) will remove the tooltip.

Reimplemented in Laxkit::LineInput.

References makestr().

const char * Laxkit::anXWindow::WindowTitle ( int  which = 0)
virtual

Member Data Documentation

RefPtrStack< anXWindow > Laxkit::anXWindow::_kids
protected

Stack of children of the window.

Consider this to be readonly. Class anXApp maintains it by pushing during addwindow, anXWindow should not access _kids directly. anXWindow is ultimately responsible for destruction of child windows via deletekid() which is called by anXApp. The app is responsible for destruction of anxwindow->xlib_window and topwindows. These things are typically done without extra user intervention, as long as the normal app->addwindow/app->destroywindow system is used.

Referenced by Laxkit::anXApp::addwindow(), Laxkit::anXApp::deactivatekids(), Laxkit::anXApp::find_subwindow_by_id(), Laxkit::anXApp::findDropCandidate(), Laxkit::anXApp::refresh(), Laxkit::anXApp::reparent(), and Laxkit::anXApp::resetkids().

char * Laxkit::anXWindow::win_name

An arbitrary string to be used as an id.

This can be used by programmers to help keep track of windows rather than win_title, since win_title is most likely to change.

Referenced by Laxkit::CheckBox::CheckBox(), Laxkit::Button::dump_out_atts(), Laxkit::RowFrame::findWindow(), Laxkit::RowFrame::findWindowIndex(), Laxkit::LineInput::LineInput(), and Laxkit::anXApp::reparent().

int Laxkit::anXWindow::win_pointer_shape

Identifier for a stock mouse shape.

Currently, if this value is less than 200, then try to use an X cursor based on that number, with 0 being the default shape.

See laxmouseshapes.h for other values.

Referenced by Laxkit::anXApp::addwindow(), Laxkit::LineEdit::LineEdit(), and Laxkit::MultiLineEdit::MultiLineEdit().

char * Laxkit::anXWindow::win_title

The title of the window.

If the window is a top level window, then this is the text that is displayed by the window manager.

Referenced by Laxkit::PrintDialog::addOptions(), Laxkit::anXApp::addwindow(), Laxkit::RowFrame::findWindow(), Laxkit::RowFrame::findWindowIndex(), and Laxkit::SplitWindow::Refresh().

char * Laxkit::anXWindow::win_tooltip
protected

Convenience variable to hold the window's tooltip, if any.

The app retrieves win_tooltip with a call to tooltip(). It does not access win_tooltip directly

Referenced by Laxkit::ColorBox::tooltip().


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

Mon Feb 17 2014 11:52:58, Laxkit