Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
Laxkit::BoxSelector Class Reference

Abstract base class for selectors based on boxed items. More...

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

List of all members.

Public Member Functions

 BoxSelector (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 *nsendmes, int nid=0, int npad=0)
 Constructor.
virtual const charwhattype ()
virtual void sync ()
 Set the w/h, then calls SquishyBox::sync().
virtual int init ()
 Default BoxSelector init only calls sync().
virtual int Event (const EventData *e, const char *mes)
 Catch EnterNotify and LeaveNotify.
virtual int MoveResize (int nx, int ny, int nw, int nh)
 Call anXWindow::MoveResize, and set arrangedstate=0.
virtual int Resize (int nw, int nh)
 Call anXWindow::Resize, and set arrangedstate=0.
virtual void Refresh ()
 Draw the boxes.
virtual int MouseMove (int x, int y, unsigned int state, const LaxMouse *d)
 Keeps track of where mouse is, whether or not a button is pressed.
virtual int LBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Find what box is down in (set lbdown to index of it), and toggle it.
virtual int LBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Select which box mouse is in, if it is the same as it was clicked down on.
virtual int WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Toggle curbox. ***needs work selecting!=toggling.
virtual int WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Toggle curbox.
virtual int SelectN (int whichindex)
 Select a box based on its index.
virtual int Select (int whichID)
 Select a box based on box->id, and return curbox.
virtual int MouseInWhich (int x, int y)
 Checks what box the mouse is in, including box pad.
virtual void drawbox (int which)=0
 Draw the box on the screen.
virtual int send ()
 Send a message to the owner.
- Public Member Functions inherited from 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.
virtual ~anXWindow ()
 anXWindow destructor. Its X window should have been XDestroy'd before here.
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 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 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 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 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 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 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 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 Member Functions inherited from Laxkit::RowColBox
 RowColBox (unsigned int nflags, int nx, int nw, int npw, int nws, int nwg, int nhalign, int nhgap, int ny, int nh, int nph, int nhs, int nhg, int nvalign, int nvgap)
 Main RowColBox constructor.
virtual void Push (SquishyBox *box, char islocal=0, int where=-1)
 Push box onto wholelist with islocal.
virtual int Pop (int which=-1)
 Remove box with index which from wholelist.
virtual void Flush ()
 Flush list, and if list does not exist, then create a new list.
virtual int arrangeBoxes (int distributetoo=0)
 Set up SquishyBox::list to contain rows and columns based on boxes in wholelist.
virtual int distributeBoxes (int setmetrics=0)
 Assign the x,y,w,h of the child boxes.
- Public Member Functions inherited from Laxkit::ListBox
 ListBox (unsigned int flag=0)
 Create box as either BOX_VERTICAL or BOX_HORIZONTAL. Other flag values are ignored.
 ListBox (unsigned int nflags, int nx, int nw, int npw, int nws, int nwg, int nhalign, int nhgap, int ny, int nh, int nph, int nhs, int nhg, int nvalign, int nvgap)
virtual int WrapToExtent ()
 Sets this->pw,s,g/ph,s,g to be the sum of the metrics of the boxes in list.
virtual int figureDimensions (ListBox *target, int *nextrow=NULL, SquishyBox **boxes=NULL, int n=0, double *squishx=NULL, double *squishy=NULL)
 Finds pw,s,g/ph,s,g based on the boxes in list.
- Public Member Functions inherited from Laxkit::SquishyBox
 SquishyBox (unsigned int nflags, int nx, int nw, int npw, int nws, int nwg, int nhalign, int nhgap, int ny, int nh, int nph, int nhs, int nhg, int nvalign, int nvgap)
 SquishyBox Constructor.
virtual int hideBox (int yeshide)
 hideBox(0) makes the box visible, otherwise, make it hidden. Returns state after call.
virtual int hidden ()
 Return whether the box is hidden or not.
virtual void sync (int xx, int yy, int ww, int hh)
 Sync the box to x,y,w,h.
virtual int x ()
virtual int w ()
virtual int pw ()
virtual int ws ()
virtual int wg ()
virtual int halign ()
virtual int hgap ()
virtual int y ()
virtual int h ()
virtual int ph ()
virtual int hs ()
virtual int hg ()
virtual int valign ()
virtual int vgap ()
virtual int x (int val)
virtual int w (int val)
virtual int pw (int val)
virtual int ws (int val)
virtual int wg (int val)
virtual int halign (int val)
virtual int hgap (int val)
virtual int y (int val)
virtual int h (int val)
virtual int ph (int val)
virtual int hs (int val)
virtual int hg (int val)
virtual int valign (int val)
virtual int vgap (int val)
virtual int fpenalty ()
virtual int fpenalty (int val)
virtual int lpenalty ()
virtual int lpenalty (int val)

Public Attributes

unsigned long highlight
unsigned long shadow
int pad
int padi
int bevel
int curbox
 The box most recently selected.
- Public Attributes inherited from Laxkit::anXWindow
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
- Public Attributes inherited from Laxkit::RowColBox
unsigned int elementflags
- Public Attributes inherited from Laxkit::ListBox
PtrStack< SquishyBoxlist
- Public Attributes inherited from Laxkit::SquishyBox
int m [14]
int padinset
 Pad to inset the child boxes.
int fpen
 The penalty in the flow direction.
int lpen
 The penalty perpendicular to the flow direction.
unsigned long flags

Protected Member Functions

virtual void togglebox (int which, int db=1)
 Toggles box with index (not id) which on/off. Note this does NOT select/deselect the box.
- Protected Member Functions inherited from Laxkit::anXWindow
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 Member Functions inherited from Laxkit::RowColBox
virtual ListBoxnewSubBox ()
 Return a new box that holds a whole row or column.
virtual void filterflags ()
 Take what is in flags, and remake flags to be reasonable for a RowColBox.

Protected Attributes

ButtonDownInfo buttondown
- Protected Attributes inherited from Laxkit::anXWindow
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
- Protected Attributes inherited from Laxkit::RowColBox
PtrStack< SquishyBoxwholelist
 The master list of boxes.
int arrangedstate

Detailed Description

Abstract base class for selectors based on boxed items.

In most cases, derived classes need only define drawbox(which) and also provide an AddWhateverBox(whatever) that ultimately does something like wholelist.push(TheNewBox). That whatever box must be derived from SelBox. Arrangement and clicking of wholelist is handled here. For an example of class that needs to redefine others, StrIconSelector has to Free the pixmaps in its destructor before ~BoxSelector is called.

This class is similar to RowFrame in that it is also derived from RowColBox, but uses manual tracking of the mouse over wholelist, rather than having separate windows. It is to be used for selecting things, not for holding windows as in RowFrame.

#define BOXSEL_COLUMNS (1<<16)
#define BOXSEL_VERTICAL (1<<16)
#define BOXSEL_ROWS (1<<17)
#define BOXSEL_HORIZONTAL (1<<17)
#define BOXSEL_CENTER (1<<19|1<<22)
#define BOXSEL_LEFT (1<<18)
#define BOXSEL_HCENTER (1<<19)
#define BOXSEL_RIGHT (1<<20)
#define BOXSEL_TOP (1<<21)
#define BOXSEL_VCENTER (1<<22)
#define BOXSEL_BOTTOM (1<<23)
// how to fill gaps between boxes
// these refer to filling whole window
#define BOXSEL_STRETCH (1<<24|1<<25)
#define BOXSEL_STRETCHX (1<<24)
#define BOXSEL_STRETCHY (1<<25)
#define BOXSEL_SPACE (1<<26|1<<27)
#define BOXSEL_SPACEX (1<<26)
#define BOXSEL_SPACEY (1<<27)
// these refer to filling extra (width in cols) or (height in rows)
#define BOXSEL_STRETCH_IN_ROW (1<<28)
#define BOXSEL_STRETCH_IN_COL (1<<28)
// make the panel look flat, mouse over highlights, selected ones are elevated.
// Otherwise default is all are either up or down, or flat if grayed
#define BOXSEL_FLAT (1<<29)
#define BOXSEL_ONE_ONLY (1<<30)

Constructor & Destructor Documentation

Laxkit::BoxSelector::BoxSelector ( 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 nsendmes,
int  nid = 0,
int  npad = 0 
)

Constructor.

Uses default SquishyBox constructor, and manually changes flags.

Parameters:
npadpadinset of *this is set to npad

References curbox, Laxkit::anXWindow::installColors(), and Laxkit::SquishyBox::padinset.


Member Function Documentation

void Laxkit::BoxSelector::drawbox ( int  which)
pure virtual

Draw the box on the screen.

If box->mousecount is greater that zero, then that many mice are currently over the box. Whether the box is actually on or not is read from box->state&(LAX_ON|LAX_OFF).

Implemented in Laxkit::IconSelector.

Referenced by Event(), MouseMove(), Refresh(), SelectN(), and togglebox().

int Laxkit::BoxSelector::init ( )
virtual

Default BoxSelector init only calls sync().

! Wraps the window to the bounding box of the laid out wholelist. ! This is meant to be called after Arrange, and before init, and before adding to a frame,

Also sets the hightlight and shadow colors.

Reimplemented from Laxkit::anXWindow.

Reimplemented in Laxkit::TabFrame.

References Laxkit::coloravg(), Laxkit::rgbcolor(), and sync().

int Laxkit::BoxSelector::LBUp ( int  x,
int  y,
unsigned int  state,
const LaxMouse d 
)
virtual

Select which box mouse is in, if it is the same as it was clicked down on.

Selects with SelectN(lbdown), and resets lbdown to -1.

Reimplemented from Laxkit::anXWindow.

References Laxkit::ButtonDownInfo::isdown(), MouseInWhich(), SelectN(), and Laxkit::ButtonDownInfo::up().

void Laxkit::BoxSelector::Refresh ( )
virtual

Draw the boxes.

TODO: smart refreshing to only draw a list of changes?

Reimplemented from Laxkit::anXWindow.

Reimplemented in Laxkit::TabFrame.

References drawbox(), Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, sync(), Laxkit::RowColBox::wholelist, and Laxkit::anXWindow::win_on.

int Laxkit::BoxSelector::Select ( int  whichID)
virtual

Select a box based on box->id, and return curbox.

This searchs for whichID in boxes, and then returns SelectN(thatbox).

References curbox, Laxkit::PtrStack< T >::e, Laxkit::SelBox::id, Laxkit::PtrStack< T >::n, SelectN(), and Laxkit::RowColBox::wholelist.

int Laxkit::BoxSelector::SelectN ( int  whichindex)
virtual

Select a box based on its index.

This acts the same as a mouse clicking it or selecting with space bar. Derived classes would redefine this to react to which box selected, such as wanting selection of "normal font" to clear all the other boxes. Box state should already have been toggled, and have the correct value before this function is called. This is because LBDown/Up makes a show of selecting a box without actually selecting it (previews what it would look like after selecting).

If whichindex is NULL or is grayed, then nothing is done. If BOXSEL_ONE_ONLY, then all the boxes are cleared and redrawn, and the new box selected and drawn.

Returns curbox.

Reimplemented in Laxkit::TabFrame.

References curbox, drawbox(), Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, Laxkit::SelBox::state, togglebox(), and Laxkit::RowColBox::wholelist.

Referenced by LBUp(), and Select().

int Laxkit::BoxSelector::send ( )
virtual

Send a message to the owner.

A SimpleMessage is filled thus:

    info1=curbox; // current box*** if LAX_ON only?? or first on box?
    info2=(curbox>=0?wholelist.e[c]->id:0); // id of curbox
    info3=n; // num that are on
    info4=0; // ***num that are newly changed
 

Remember that curbox can by -1 meaning no current box.

References curbox, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, Laxkit::anXApp::SendMessage(), Laxkit::RowColBox::wholelist, Laxkit::anXWindow::win_owner, and Laxkit::anXWindow::win_sendthis.

void Laxkit::BoxSelector::sync ( )
virtual

Set the w/h, then calls SquishyBox::sync().

This is called from init() and from the SquishyBox arranger. If win_w or win_h are 0, then they are set to BOX_SHOULD_WRAP instead to force a wrap. Then ***not yet*** if style is BOXSEL_ONE_ONLY, then sync ensures that there is, in fact, one selected. Finally, SquishyBox::sync() is called.

Reimplemented from Laxkit::ListBox.

References Laxkit::PtrStack< T >::n, and Laxkit::RowColBox::wholelist.

Referenced by init(), Laxkit::TabFrame::Refresh(), and Refresh().

void Laxkit::BoxSelector::togglebox ( int  which,
int  db = 1 
)
protectedvirtual

Toggles box with index (not id) which on/off. Note this does NOT select/deselect the box.

Does nothing if state is not LAX_ON or LAX_OFF. If db, then also call drawbox(which).

References drawbox(), Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, Laxkit::SelBox::state, and Laxkit::RowColBox::wholelist.

Referenced by LBDown(), SelectN(), WheelDown(), and WheelUp().


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

Mon Feb 17 2014 11:52:59, Laxkit