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

Basically an extended IconSlider to include a popup MenuSelector. More...

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

List of all members.

Public Member Functions

 SliderPopup (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 *nsendthis, MenuInfo *nitems=NULL, int ilocal=1)
virtual ~SliderPopup ()
 Delete items if it is local.
virtual void Refresh ()
 Draw the item text, and the little popup arrow.
virtual int Event (const EventData *e, const char *mes)
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *d)
virtual int RBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 copy curselection to clipboard
virtual int LBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Pop up a MenuSelector with the items in it via popup() when click on arrow.
virtual int SelectPrevious ()
 Select the previous item.
virtual int SelectNext ()
 Select the next item.
virtual const charGetCurrentItem ()
 Returns const pointer to the item name.
virtual int GetCurrentItemIndex ()
virtual int DeleteItem (int id)
 Delete item with this id, and return the number of items left.
virtual int AddSep (const char *name=NULL, int where=-1)
 Currently adds a grayed separator with name="", id=0, no submenu, (but it is still legal to add a submenu!!)
virtual int AddItem (const char *newitem, int nid)
 Just return AddItem(newitem,NULL,nid).
virtual int AddItem (const char *newitem, LaxImage *icon, int nid)
 Return the number of items. icon's count is not incremented.
virtual int AddItems (const char **newitems, int n, int startid)
 Adds a bunch of text only items.
virtual int SetState (int which, int extrastate, int on)
 Add extra state flags to an item, or most recently added if which==-1.
virtual int GetState (int which, int extrastate)
virtual int GetItemIndex (int fromid)
 Return index in items of item with fromid, or -1 if not found.
virtual int Flush (int completely=0)
 Remove all items from sliderpopup.
virtual void WrapToExtent ()
 Set the dimensions to the maximum bounds of the entries.
- Public Member Functions inherited from Laxkit::ItemSlider
 ItemSlider (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 *nsendthis)
virtual ~ItemSlider ()
 Empty virtual.
virtual int init ()
 Do nothing init.
virtual int Idle (int tid=0)
 If button is down, then next or previous items are selected rapidly.
virtual int WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d)
virtual int WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
virtual int LBUp (int x, int y, unsigned int state, const LaxMouse *d)
 Select a next or previous item.
virtual int MouseMove (int x, int y, unsigned int state, const LaxMouse *d)
 Dragging the mouse horizontally selects previous or next item.
virtual int GetCurrentItemId ()
 Returns id, not index.
virtual int Select (int id)
 Selects item with id equal to id.
- 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 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 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

int arrowwidth
int pad
int gap
- Public Attributes inherited from Laxkit::ItemSlider
int movewidth
- 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 drawarrow ()
 Draw the little arrow to indicate that there's something to be popped up.
virtual int send ()
 Sends message to owner.
virtual int getid (int i)
 Return the id corresponding to item with index i.
virtual int numitems ()
virtual void makePopup (int mouseid)
 Create the Popup MenuSelector. Called from LBDown().

Protected Attributes

MenuInfoitems
int itemsislocal
- Protected Attributes inherited from Laxkit::ItemSlider
int timerid
int nitems
int curitem
int lbitem
 The index of the current item at the moment the left button is pressed down.
int mx
int my
int lx
int ly
int ox
int oy
int buttondown
int buttondowndevice
- 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

Detailed Description

Basically an extended IconSlider to include a popup MenuSelector.

Todo:
******** needs work! update these docs

The user has the option of poping up the menu by clicking on the little arrow, or clicking, like any other item slider, on the left to decrease one element, or on the right to increase the element.

Uses a MenuInfo class to store the items, which may or may not be local to this window. This enables easy reuse of menu lists. Only the top level of the MenuInfo is used, not submenus.

Todo:
Make optional tab-completing input similar to NumInputSlider, perhaps in a subclass.

Member Function Documentation

int Laxkit::SliderPopup::AddItem ( const char newitem,
int  nid 
)
virtual

Just return AddItem(newitem,NULL,nid).

Use SLIDER_IGNORE_ON_BROWSE in extrastate as a menuitem state, to show in menu, but not prev/next.

Referenced by Laxkit::PrintDialog::addOptions().

int Laxkit::SliderPopup::AddItem ( const char newitem,
LaxImage icon,
int  nid 
)
virtual

Return the number of items. icon's count is not incremented.

Use SLIDER_IGNORE_ON_BROWSE in extrastate as a menuitem state, to show in menu, but not prev/next.

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

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

Adds a bunch of text only items.

Returns number of items added.

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

int Laxkit::SliderPopup::AddSep ( const char name = NULL,
int  where = -1 
)
virtual

Currently adds a grayed separator with name="", id=0, no submenu, (but it is still legal to add a submenu!!)

Returns whatever AddItem returns.

These separators will not show up when just clicking through items.

References Laxkit::MenuInfo::AddSep().

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

Left selects previous str, right selects next. Enter pops up menu.

Reimplemented from Laxkit::anXWindow.

References makePopup(), SelectNext(), SelectPrevious(), and send().

int Laxkit::SliderPopup::Flush ( int  completely = 0)
virtual

Remove all items from sliderpopup.

If completely!=0, then totally remove old items object, and establish a new one.

References Laxkit::MenuInfo::Flush().

const char * Laxkit::SliderPopup::GetCurrentItem ( )
virtual

Returns const pointer to the item name.

Better use it quick, before items change!

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

int Laxkit::SliderPopup::GetState ( int  which,
int  extrastate 
)
virtual

Returns items->menuitems.e[which]->state&extrastate.

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

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

Pop up a MenuSelector with the items in it via popup() when click on arrow.

Todo:
*** work out how transfer focus

Reimplemented from Laxkit::ItemSlider.

References makePopup().

int Laxkit::SliderPopup::SelectNext ( )
virtual

Select the next item.

Returns id of the new item.

This skips over any separators.

Reimplemented from Laxkit::ItemSlider.

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

Referenced by CharInput().

int Laxkit::SliderPopup::SelectPrevious ( )
virtual

Select the previous item.

Returns id of the new item.

This skips over any separators.

Reimplemented from Laxkit::ItemSlider.

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

Referenced by CharInput().

int Laxkit::SliderPopup::send ( )
protectedvirtual

Sends message to owner.

Sends a SimpleMessage with message->info1=id of curitem. Also fill in message->str with the current item's name if win_style&SLIDER_SEND_STRING).

Reimplemented from Laxkit::ItemSlider.

References Laxkit::PtrStack< T >::e, makestr(), Laxkit::MenuInfo::menuitems, Laxkit::anXApp::SendMessage(), Laxkit::anXWindow::win_owner, and Laxkit::anXWindow::win_sendthis.

Referenced by CharInput(), SelectNext(), and SelectPrevious().

int Laxkit::SliderPopup::SetState ( int  which,
int  extrastate,
int  on 
)
virtual

Add extra state flags to an item, or most recently added if which==-1.

Return 0 for success or nonzero for error.

If on==-1, then toggle. If on==0, then clear. If on==1, then set.

Todo:
this is currently a little bit of a kludge to add SLIDER_IGNORE_ON_BROWSE. a more clean way would be to have it in AddItem, but due to the similarity mix of two AddItem() functions, lots of cleanup would have to happen to add an extra int for extrastate there.

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

void Laxkit::SliderPopup::WrapToExtent ( )
virtual

Set the dimensions to the maximum bounds of the entries.

Todo:
*** this only works before mapping because it sets win_w,win_h directly, rather than through Resize().. should probably think if this is good or not.

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


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

Mon Feb 17 2014 11:53:00, Laxkit