Laxkit  0.0.7.1
Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions
Laxkit::TreeSelector Class Reference

Collapsible tree view. More...

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

List of all members.

Classes

class  ColumnInfo

Public Member Functions

 TreeSelector (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=0, const char *mes=0, unsigned long long nmstyle=0, MenuInfo *minfo=NULL)
 Constructor.
virtual ~TreeSelector ()
 Destructor, increment count on menu.
virtual int init ()
 Set some values that are derived from other values (pagesize, highlight, shadow, ...).
virtual void Refresh ()
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *d)
 Character input.
virtual int LBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Left button down.
virtual int LBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Left button up.
virtual int RBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Right button and drag drags the screen around (with potential autoscrolling)
virtual int RBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Nothing but remove tag from buttondown.
virtual int WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Scroll screen down.
virtual int WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Scroll screen up.
virtual int MouseMove (int x, int y, unsigned int state, const LaxMouse *d)
 Left might select depending on style. Right button drags. +R fast drags.
virtual int Idle (int tid)
 Autoscroll if necessary**** todo.
virtual int MoveResize (int nx, int ny, int nw, int nh)
 Calls ScrolledWindow::MoveResize(nx,ny,nw,nh).
virtual int Resize (int nw, int nh)
 Calls ScrolledWindow::Resize(nw,nh).
virtual int FocusOn (const FocusChangeData *e)
 Focus on draws the char over item.
virtual int FocusOff (const FocusChangeData *e)
 Focus off draws the char over item.
virtual int movescreen (int dx, int dy)
 Try to move the screen by dx pixels and dy pixels.
virtual int SetFirst (int which, int x, int y)
 Make visible item with index which be near window coordinate x,y.
virtual int Curitem ()
 Return curitem, which is the last item whose state was toggled.
virtual const MenuItemItem (int c)
virtual MenuInfoMenu ()
virtual int InstallMenu (MenuInfo *nmenu)
virtual int Expand (int which)
 Expand which visible item. If already expanded, then do nothing.
virtual int Collapse (int which)
virtual int Select (int which)
 Programs call this to select index which of visible items.
virtual int Deselect (int which)
virtual int RebuildCache ()
virtual MenuItemGetSelected (int i)
 Return the ith selelected item. i must be in range [0..NumSelected()-1].
virtual int NumSelected ()
 Return how many items are currently selected.
virtual void SetLineHeight (int ntotalheight, int newleading, char forcearrange)
 Set the new line height and leading.
virtual void Sync ()
 This is meant to be called when the window is going, but you just added or removed a bunch of stuff.
virtual void Sort (int t, int detail)
 Sort the items alphabetically by the name.
virtual int AddItems (const char **i, int n, int startid)
 Add a bunch of items all at once.
virtual int AddItem (const char *i, LaxImage *img, int nid, int newstate)
 Add item with text i to the top index of menuitems.
virtual int AddColumn (const char *i, LaxImage *img, int width)
 Add a new column for details of items.
virtual void ClearColumns ()
virtual void RemapColumns ()
- Public Member Functions inherited from Laxkit::ScrolledWindow
 ScrolledWindow (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=0, const char *nsend=NULL, PanController *pan=NULL)
virtual int send ()
 Send what? huh?***.
virtual int UseThisWindow (anXWindow *nwindow)
 Use nwindow as the nested window.
virtual int Event (const EventData *e, const char *mes)
- Public Member Functions inherited from Laxkit::PanUser
 PanUser (PanController *npan=NULL)
 Create with a new panner.
virtual ~PanUser ()
 Removes this from panner tellstack. Delete panner if necessary.
virtual PanControllercreateNewPanner (PanController *pan=NULL)
 Create a new panner that is a copy of pan if given.
virtual void UseThisPanner (PanController *npanner)
 Replace the current panner with npanner, which can be NULL to mean make a new one.
- 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 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 close ()
 Called by anXApp from anXApp::destroywindow() when a window is to be destroyed.
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 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 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

PtrStack< ColumnInfocolumns
int sort_detail
int sort_descending
int gap
unsigned long highlight
 Highlight color of beveled graphics.
unsigned long shadow
 Shadow color of beveled graphics.
unsigned long long menustyle
int padg
 The pad to place between text and other graphic elements.
int pad
 The pad around the inside border of the window.
int leading
 The height of lines are leading+(text height).
int iwidth
 The width of the sub menu indicator graphic of a menu item. (only one width, not per item)
- Public Attributes inherited from Laxkit::ScrolledWindow
IntRectangle inrect
 The rectangle that thewindow resides in.
IntRectangle outrect
 The rectangle that holds all of thewindow and scrollers.
int scrollwidth
PanPopuppanpopup
anXWindowthewindow
Scrollerxscroller
Scrolleryscroller
- Public Attributes inherited from Laxkit::PanUser
PanControllerpanner
- 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

Protected Member Functions

virtual void adjustinrect ()
 Remove the pads from inrect.
virtual void findoutrect ()
 Set outrect to be the window minus space for title.
virtual double getitemextent (MenuItem *mitem, double *w, double *h, double *gx, double *tx)
 Find extent of text+graphic+(pad between graphic and text).
virtual double getgraphicextent (MenuItem *mitem, double *w, double *h)
virtual void drawitem (MenuItem *mitem, IntRectangle *itemspot)
 Draw the item in the provided area..
virtual void drawitem (int c)
 Draw the item with the index value c.
virtual void drawsep (const char *name, IntRectangle *rect)
 Draw a separator (default is just a win_colors->grayedfg colored line) across rect widthwise.
virtual void drawSubIndicator (MenuItem *mitem, int x, int y, int selected)
 Draws a submenu indicator centered on x,y, and width=iwidth, height=textheight+leading.
virtual void drawitemname (MenuItem *mitem, IntRectangle *rect)
 Draw the item icon and name in rect, AND all detail items within rect.
virtual void drawtitle ()
 Draw the menu title if present. Default is print it out at top of window (not inrect).
virtual int findmaxwidth (int s, int e, int *h_ret)
 Find the maximum width of (text+ padg+ graphic subw) of items in range [s,e].
virtual int findColumnWidth (int which)
virtual int send (int deviceid)
 Send message to owner.
virtual void addselect (int i, unsigned int state)
 This is called on a mouse down or a space press.
virtual int findItem (int x, int y, int *onsub, int *column)
 Find the index of the item at window coordinates (x,y).
virtual int findRect (int c, IntRectangle *itemspot)
 Find screen rectangle item c goes in.
virtual void arrangeItems ()
 Basically RebuildCache(), then update the panner.
virtual void syncWindows (int useinrect=0)
 Called same for ScrolledWindow, then arrangeItems.
virtual int makeinwindow ()
 Make sure that ccuritem is visible by shifting screen so it is.
virtual int numItems ()
 Default is to return the number of items in menu->menuitems stack.
virtual MenuItemitem (int i, char skipcache=0)
 Return the item corresponding to screen index i.
virtual int addToCache (int indent, MenuInfo *menu, int cury)
 Add items to visibleitems stack. Called from RebuildCache.
virtual int DrawItems (int indent, MenuInfo *item, int &n, flatpoint offset)
virtual void drawItemContents (MenuItem *i, int offsetx, int offsety, int fill=1)
virtual void drawarrow (int x, int y, int r, int type)
 Draw the arrows for menus, really just THING_Triangle_Up, Down, Left, Right for submenus.
virtual void editInPlace (int which)
 Set up the edit in place mode.

Protected Attributes

ButtonDownInfo buttondown
int mousedragmode
 Flag for whether the mouse has been dragged since a button was down.
MenuInfomenu
 Stores the actual menu items.
int offsetx
int offsety
int firstinw
int textheight
 The height of lines are leading+(text height).
int lineheight
int pagesize
 3/4 of inrect.height.
int timerid
MenuItemcurmenuitem
 The MenuItem corresponding to curitem.
int curitem
 The last selected or deselected item.
int ccuritem
 The item which one has cursored to.
PtrStack< MenuItemselection
charsearchfilter
int showsearch
int needtobuildcache
MenuInfo visibleitems

Private Member Functions

void base_init ()

Detailed Description

Collapsible tree view.

#include <lax/treeselector.h>

There is a separate highlighting corresponding to a current item on which the next action will be performed. For instance, say you press up or down, you are not necessarily selecting the items that are up or down, but if you then press space, then that curitem is selected. This 'user focused' item is stored in ccuritem. The last item to have its state actually changed is stored in curitem.

This class uses a PanController such that the panner wholebox (min and max) is the bounding box of all the items, and the selbox (start and end) is inrect. However, any shifting changes the panner's selbox, but this does not trigger any change in inrect.

   TODO
   *** RemoveItem
   *** when mouseover up arrow or autoscroll up, moving down should not shiftscreen
   *** scrollbar (x/y) versus up/down arrows and right click dragging??
   *** neat from fltk:
            Add("File")
            Add("File/Save")
            Add("File/Save As")....
 

Constructor & Destructor Documentation

Laxkit::TreeSelector::TreeSelector ( 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 = 0,
const char mes = 0,
unsigned long long  nmstyle = 0,
MenuInfo usethismenu = NULL 
)

Constructor.

If usethismenu is NULL, then a new MenuInfo is created. If usethismenu is not NULL, then its count is incremented.

Sets up colors, and pushes 0 onto the columns stack.

Parameters:
nstyleHolds the usual anXWindow style flags
nmstyleHolds the menu style defines
usethismenuPass in a MenuInfo class, increment its count

References Laxkit::anObject::inc_count(), and menu.


Member Function Documentation

int Laxkit::TreeSelector::AddItem ( const char i,
LaxImage img,
int  nid,
int  newstate 
)
virtual

Add item with text i to the top index of menuitems.

You can specify an initial state, such as LAX_GRAY, etc. Automatically sorts if sort is the style.

Returns the number of items in the stack, or -1 if error.

Does not synchronize the display. You must do that manually later on, unless init() hasn't been called yet. init() synchronizes the display.

References Laxkit::MenuInfo::AddItem(), menu, and numItems().

Referenced by AddItems().

int Laxkit::TreeSelector::AddItems ( const char **  i,
int  n,
int  startid 
)
virtual

Add a bunch of items all at once.

Returns number of items added

Todo:
***this is cheap, should be optimized for large arrays?? add in one lump, then sort??

References AddItem().

void Laxkit::TreeSelector::addselect ( int  i,
unsigned int  state 
)
protectedvirtual

This is called on a mouse down or a space press.

Sets the state of the affected items, and also draws the results on the window. A plain select will deselect all, and select just i. A control select will toggle whether an item is on or off, without deselecting all the others. A shift select will turn on any items in the range that are off. A control-shift select will make all in the range [curitem,i] have the same state as curitem.

An item's state is only modified if it is already LAX_ON or LAX_OFF.

Does not send the control message from here.

References ccuritem, curitem, curmenuitem, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::findindex(), item(), Laxkit::PtrStack< T >::n, Laxkit::PtrStack< T >::pushnodup(), Laxkit::PtrStack< T >::remove(), Laxkit::MenuItem::state, and Laxkit::anXWindow::WindowTitle().

Referenced by CharInput(), LBUp(), MouseMove(), and Select().

int Laxkit::TreeSelector::addToCache ( int  indent,
MenuInfo mmenu,
int  cury 
)
protectedvirtual

Add items to visibleitems stack. Called from RebuildCache.

Note the first item essentially has x,y at 0,0.

References Laxkit::MenuInfo::AddItemAsIs(), getitemextent(), Laxkit::MenuItem::GetSubmenu(), Laxkit::MenuItem::hidden(), and iwidth.

Referenced by RebuildCache().

void Laxkit::TreeSelector::adjustinrect ( )
protectedvirtual

Remove the pads from inrect.

This is called last thing from ScrolledWindow::syncWindows(), where inrect is set to be within scrollers. Also sets pagesize=(inrect.height+leading)/(textheight+leading)

This and arrangeItems are the only places where pagesize gets set.

Reimplemented from Laxkit::ScrolledWindow.

References Laxkit::ScrolledWindow::inrect, leading, pad, pagesize, and textheight.

int Laxkit::TreeSelector::CharInput ( unsigned int  ch,
const char buffer,
int  len,
unsigned int  state,
const LaxKeyboard d 
)
virtual

Character input.

Currently:

  enter      ???send/select currently selected items
  space      addselect(ccuritem)
  pgup/down, Jump ccuritem 1 page up or down
  up/down,   Move ccuritem 1 item up or down
  'a'        If none selected, select all, else deselect any selected.
  '/'        (***imp me!) start search mode?– have either sep search mode
                   or make all selecting keys above be control-key, not just key
                   so can use normal typing as progressive search
  *** need to have type to search, or hotkeys
 

Reimplemented from Laxkit::anXWindow.

References addselect(), arrangeItems(), ccuritem, Collapse(), Laxkit::PtrStack< T >::e, Expand(), Laxkit::PtrStack< T >::flush(), item(), makeinwindow(), movescreen(), Laxkit::PtrStack< T >::n, numItems(), pagesize, Laxkit::PtrStack< T >::push(), Laxkit::ScrolledWindow::send(), and Laxkit::MenuItem::state.

int Laxkit::TreeSelector::Collapse ( int  which)
virtual
int Laxkit::TreeSelector::Curitem ( )
inlinevirtual

Return curitem, which is the last item whose state was toggled.

Note that this is not necessarily ccuritem which is what one might go to with the arrow keys without actually selecting.

References curitem.

int Laxkit::TreeSelector::Deselect ( int  which)
virtual
void Laxkit::TreeSelector::drawarrow ( int  x,
int  y,
int  r,
int  type 
)
protectedvirtual

Draw the arrows for menus, really just THING_Triangle_Up, Down, Left, Right for submenus.

Centers around x,y within a box of side 2*r. This function is also used for the up and down arrows when the menu contents extend beyond the screen.

References Laxkit::draw_thing().

Referenced by drawSubIndicator().

void Laxkit::TreeSelector::drawitem ( MenuItem mitem,
IntRectangle itemspot 
)
protectedvirtual

Draw the item in the provided area..

All the things that go on an item line:
[graphic icon][text][submenu indicator]

This does not fill background. Only draw it item contents.

If the item is a separator, call drawsep() and return. Now the actual item text and icon fill the remaining space.

Todo:
*** set clip to intersection of itemspot and inrect??

References drawitemname(), drawsep(), and Laxkit::MenuItem::state.

Referenced by drawItemContents().

void Laxkit::TreeSelector::drawitem ( int  c)
protectedvirtual

Draw the item with the index value c.

All the things that go on an item line:
[status graphic=whether highlighted][check toggle][graphic icon][text][submenu indicator]

First, determine if this item is actually on screen, and find the area to draw it in. Return if not on screen. If it is found, then find the item and call drawitem(theitem,thebounds).

References drawItemContents(), item(), and numItems().

void Laxkit::TreeSelector::drawItemContents ( MenuItem i,
int  offsetx,
int  offsety,
int  fill = 1 
)
protectedvirtual

Item contents are in the dimensions contained in i, with specified offset, which means this function draws inside a rectangle with upper left corner at (i->x+offsetx, i->y+offsety), width==i->w, and height==i->h.

Checks bounds, so no drawing if off screen.

If bounds ok, and fill!=0, draw background.

Finally, call drawitem(MenuItem*,IntRectangle*).

References ccuritem, Laxkit::coloravg(), drawitem(), Laxkit::fill_rectangle(), Laxkit::PtrStack< T >::findindex(), Laxkit::ScrolledWindow::inrect, item(), and Laxkit::MenuInfo::menuitems.

Referenced by drawitem(), and DrawItems().

int Laxkit::TreeSelector::DrawItems ( int  indent,
MenuInfo mmenu,
int n,
flatpoint  offset 
)
protectedvirtual

Recursively draw all unhidden items in mmenu. Note that this will be the same as visibleitems, but it uses menu directly, not visibleitems.

Essentially draws a background, then drawItemContents() for that item.

References ccuritem, Laxkit::coloravg(), Laxkit::draw_line(), drawItemContents(), drawSubIndicator(), Laxkit::fill_rectangle(), Laxkit::MenuItem::GetSubmenu(), Laxkit::MenuItem::hidden(), item(), and iwidth.

Referenced by Refresh().

void Laxkit::TreeSelector::editInPlace ( int  which)
protectedvirtual

Set up the edit in place mode.

Todo:
*** imp me!

Referenced by LBUp().

int Laxkit::TreeSelector::Expand ( int  which)
virtual

Expand which visible item. If already expanded, then do nothing.

Return 1 for expanded, 0 for can't or error.

References Laxkit::PtrStack< T >::e, Laxkit::MenuInfo::howmany(), Laxkit::MenuInfo::menuitems, and Laxkit::MenuItem::state.

Referenced by CharInput(), and LBUp().

int Laxkit::TreeSelector::findItem ( int  x,
int  y,
int onsub,
int column 
)
protectedvirtual

Find the index of the item at window coordinates (x,y).

The value returned is not necessarily an actual element index. It could be -1, or >=menuitems.n.

References Laxkit::PtrStack< T >::e, item(), and Laxkit::PtrStack< T >::n.

Referenced by LBDown(), LBUp(), and MouseMove().

int Laxkit::TreeSelector::findmaxwidth ( int  s,
int  e,
int h_ret 
)
protectedvirtual

Find the maximum width of (text+ padg+ graphic subw) of items in range [s,e].

Clamp s and e to [0,numItems()-1]. Return -1 if e<s.

If the corresponding style (like for submenu indicator for instance) is not set in menustyle, then that width is not included.

Return the maximum height in h_ret.

References Laxkit::getextent(), item(), iwidth, numItems(), and padg.

Referenced by arrangeItems().

int Laxkit::TreeSelector::findRect ( int  c,
IntRectangle itemspot 
)
protectedvirtual

Find screen rectangle item c goes in.

Return 1 for rectangle found, otherwise 0 for unable to find (for instance when called before necessary initialization done).

References item().

Referenced by makeinwindow(), and movescreen().

int Laxkit::TreeSelector::FocusOff ( const FocusChangeData e)
virtual

Focus off draws the char over item.

Also, if TREESEL_FOCUS_OFF_DESTROYS, then an off focus destroys this window.

Reimplemented from Laxkit::anXWindow.

References Laxkit::anXWindow::WindowTitle().

double Laxkit::TreeSelector::getitemextent ( MenuItem mitem,
double *  w,
double *  h,
double *  gx,
double *  tx 
)
protectedvirtual

Find extent of text+graphic+(pad between graphic and text).

If the graphic extent is 0, then the pad is not included. w and h must not be NULL! Note that the y extent is the actual y extent of the graphic+text. The actual space on the window that the line takes up is still textheight+leading.

Returns the x extent.

Parameters:
mitemthe index, MUST already be in bounds
wPut the x extent here
hPut the y extent here
gxWhere the graphic would start, relative to whole item
txWhere the text would start, relative to whole item

References Laxkit::getextent(), and padg.

Referenced by addToCache(), and drawitemname().

int Laxkit::TreeSelector::Idle ( int  tid)
virtual

Autoscroll if necessary**** todo.

Todo:
*** must autoscroll when mouse over arrow and FOLLOW_MOUSE

Reimplemented from Laxkit::anXWindow.

int Laxkit::TreeSelector::init ( )
virtual

Set some values that are derived from other values (pagesize, highlight, shadow, ...).

Sets leading to have a little bit extra if TREESEL_CHECKBOXES and not otherwise specified. Also sets the shadow and highlight colors, and determines the pagesize.

Reimplemented from Laxkit::ScrolledWindow.

References arrangeItems(), Laxkit::coloravg(), highlight, Laxkit::ScrolledWindow::inrect, iwidth, leading, padg, pagesize, Laxkit::rgbcolor(), shadow, textheight, and Laxkit::anXWindow::WindowTitle().

MenuItem * Laxkit::TreeSelector::item ( int  i,
char  skipcache = 0 
)
protectedvirtual

Return the item corresponding to screen index i.

This is not necessarily a direct index into the menu->menuitems stack, though that is the default behavior of this function.

If open menus are displayed with this menu, like in a tree, then this function must be redefined to access the thing associated with screen index i.

This function does not implement a search cache, but provides the tag for subclasses to use if they want.

Todo:
maybe have option to force remapping==bypassing any search cache??

References Laxkit::PtrStack< T >::e, Laxkit::MenuInfo::menuitems, and Laxkit::PtrStack< T >::n.

Referenced by addselect(), arrangeItems(), CharInput(), Collapse(), Deselect(), drawitem(), drawItemContents(), drawitemname(), DrawItems(), findItem(), findmaxwidth(), findRect(), LBDown(), LBUp(), movescreen(), Select(), send(), and SetFirst().

int Laxkit::TreeSelector::LBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const LaxMouse d 
)
virtual

Left button down.

If TREESEL_OUT_CLICK_DESTROYS is set, then app->destroywindow(this) when clicking down outside the window.

Reimplemented from Laxkit::anXWindow.

References Laxkit::ButtonDownInfo::down(), Laxkit::PtrStack< T >::e, findItem(), item(), mousedragmode, Laxkit::PtrStack< T >::n, and textheight.

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

Left button up.

If clicked on an arrow, then shift screen. If on item, then addselect(that item). Send the control message if TREESEL_SEND_ON_UP is set.

Todo:
*** lbdown/up no drag on an already selected item should initiate EDIT_IN_PLACE
Todo:
*** mousedragmode==2 means a rearrangement might be required

Reimplemented from Laxkit::anXWindow.

References addselect(), arrangeItems(), Collapse(), editInPlace(), Expand(), findItem(), Laxkit::ButtonDownInfo::isdown(), item(), mousedragmode, numItems(), Laxkit::ScrolledWindow::send(), and Laxkit::ButtonDownInfo::up().

int Laxkit::TreeSelector::makeinwindow ( )
protectedvirtual

Make sure that ccuritem is visible by shifting screen so it is.

Returns 1 if x shifted, 2 if y, 3 if both.

References ccuritem, findRect(), Laxkit::ScrolledWindow::inrect, and Laxkit::PanController::Shift().

Referenced by CharInput().

int Laxkit::TreeSelector::MouseMove ( int  x,
int  y,
unsigned int  state,
const LaxMouse d 
)
virtual

Left might select depending on style. Right button drags. +R fast drags.

Todo:
*** should implement speedy shifting with shift/cntl-RB drag
Todo:
*** also, if right-click shifting, and is off screen, do a sort of auto scrolling, like if mouse above, then move if mouse moving up, but not if mouse is moving down?? or on timer?

Reimplemented from Laxkit::anXWindow.

References addselect(), Laxkit::ButtonDownInfo::any(), ccuritem, Laxkit::PtrStack< T >::e, findItem(), Laxkit::ButtonDownInfo::getextrainfo(), Laxkit::ButtonDownInfo::isdown(), mousedragmode, Laxkit::ButtonDownInfo::move(), movescreen(), Laxkit::PtrStack< T >::n, and numItems().

int Laxkit::TreeSelector::movescreen ( int  dx,
int  dy 
)
virtual

Try to move the screen by dx pixels and dy pixels.

Also resets ccuritem so that it refers to an item that is actually visible.

Returns whether shifting occured. 1=x, 2=y, 3=x and y

References ccuritem, findRect(), Laxkit::PanController::GetCurPos(), Laxkit::ScrolledWindow::inrect, item(), Laxkit::PtrStack< T >::n, numItems(), Laxkit::PanController::Shift(), and textheight.

Referenced by CharInput(), MouseMove(), SetFirst(), WheelDown(), and WheelUp().

int Laxkit::TreeSelector::numItems ( )
protectedvirtual

Default is to return the number of items in menu->menuitems stack.

A tree class, for instance would return the number of items plus the items from any open submenus.

References Laxkit::MenuInfo::menuitems, and Laxkit::PtrStack< T >::n.

Referenced by AddItem(), CharInput(), drawitem(), findmaxwidth(), LBUp(), MouseMove(), movescreen(), Select(), and send().

int Laxkit::TreeSelector::RBDown ( int  x,
int  y,
unsigned int  state,
int  count,
const LaxMouse d 
)
virtual

Right button and drag drags the screen around (with potential autoscrolling)

Todo:
perhaps someday have a hook so that right click on an item calls up some menu? like copy to, delete item, etc..

Reimplemented from Laxkit::anXWindow.

References Laxkit::ButtonDownInfo::down().

int Laxkit::TreeSelector::RebuildCache ( )
virtual

Update visibleitems. Called from Refresh() if needtobuildcache!=0.

References addToCache(), Laxkit::MenuInfo::Flush(), and menu.

Referenced by arrangeItems(), and Refresh().

void Laxkit::TreeSelector::Refresh ( )
virtual
int Laxkit::TreeSelector::Select ( int  which)
virtual

Programs call this to select index which of visible items.

This has the same effect as left button down on it.

Returns index of the new curitem.

References addselect(), curitem, item(), numItems(), and Laxkit::MenuItem::state.

int Laxkit::TreeSelector::send ( int  deviceid)
protectedvirtual

Send message to owner.

If !(menustyle&TREESEL_SEND_STRINGS) Sends SimpleMessage with:

info1 = curitem (which might be -1 for nothing)
info2 = id of curitem
info3 = nitems selected
info4 = menuitem->info

Otherwise, sends a list of the selected strings in a StrsEventData, with info=curitem.

Todo:

*** there needs to be option to send id or list of ids..

maybe send device id of the device that triggered the send

References curitem, Laxkit::PtrStack< T >::e, Laxkit::MenuItem::info, item(), Laxkit::PtrStack< T >::n, newstr(), numItems(), Laxkit::anXApp::SendMessage(), Laxkit::anXWindow::win_owner, Laxkit::anXWindow::win_sendthis, and Laxkit::anXWindow::WindowTitle().

int Laxkit::TreeSelector::SetFirst ( int  which,
int  x,
int  y 
)
virtual

Make visible item with index which be near window coordinate x,y.

Returns 0 for success, or 1 for bad item.

References Laxkit::MenuInfo::howmany(), item(), and movescreen().

void Laxkit::TreeSelector::SetLineHeight ( int  ntotalheight,
int  newleading,
char  forcearrange 
)
virtual

Set the new line height and leading.

textheight is set to ntotalheight-newleading. If forcearrange==1 then also syncWindows() which also causes adjustinrect() and arrangeItems() to be called. If forcearrange==2, then do not call syncWindows, instead call arrangeItems(0). If forcearrange==3, then call arrangeItems(1). This last one is when you are seeking setup in preparation for wrapping a window's boundaries to the items extent.

Usually from outside the class, a program would just call SetLineHeight(h,l), and this would call arrangeItems(). init() needs to set some other stuff before arranging, so it calls with forcearrange==0.

References arrangeItems(), iwidth, leading, padg, syncWindows(), and textheight.

void Laxkit::TreeSelector::Sort ( int  t,
int  detail 
)
virtual

Sort the items alphabetically by the name.

t is passed on to MenuInfo::sortstyle. t==0 means do the default sorting.

Todo:
*** should be able to sort only a subset, for instance all items between separators.

References menu, and Laxkit::MenuInfo::sort().

void Laxkit::TreeSelector::syncWindows ( int  useinrect = 0)
protectedvirtual

Called same for ScrolledWindow, then arrangeItems.

Has the effect of resizing scrollers, and remapping inrect and outrect.

Reimplemented from Laxkit::ScrolledWindow.

References arrangeItems().

Referenced by SetLineHeight().

int Laxkit::TreeSelector::WheelDown ( int  x,
int  y,
unsigned int  state,
int  count,
const LaxMouse d 
)
virtual

Scroll screen up.

Control OR shift mask shifts by whole page lengths. Shift AND Control shifts by 3 times whole page lengths.

Reimplemented from Laxkit::anXWindow.

References leading, movescreen(), pagesize, and textheight.

int Laxkit::TreeSelector::WheelUp ( int  x,
int  y,
unsigned int  state,
int  count,
const LaxMouse d 
)
virtual

Scroll screen down.

Control OR Shift mask shifts by whole page lengths. Shift AND Control shifts by 3 times whole page lengths.

Reimplemented from Laxkit::anXWindow.

References leading, movescreen(), pagesize, and textheight.


Member Data Documentation

int Laxkit::TreeSelector::leading

The height of lines are leading+(text height).

Any highlighting does not include the leading pixels.

Referenced by adjustinrect(), drawitemname(), drawSubIndicator(), drawtitle(), init(), SetLineHeight(), WheelDown(), and WheelUp().

int Laxkit::TreeSelector::mousedragmode
protected

Flag for whether the mouse has been dragged since a button was down.

If it is a simple move, then mousedragmode==1. If the menuselector is REARRANGEABLE, and items are in the process of being moved, then mousedragmode==2.

Referenced by LBDown(), LBUp(), and MouseMove().

int Laxkit::TreeSelector::textheight
protected

The height of lines are leading+(text height).

Any highlighting only includes the textheight pixels.

Referenced by adjustinrect(), drawSubIndicator(), drawtitle(), findoutrect(), init(), LBDown(), movescreen(), Refresh(), SetLineHeight(), WheelDown(), and WheelUp().


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

Mon Feb 17 2014 11:53:00, Laxkit