Laxkit
0.0.7.1
|
General list and menu controller. Base class for PopupMenu. More...
Public Member Functions | |
MenuSelector (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, char nmenuislocal=0) | |
Constructor. | |
virtual | ~MenuSelector () |
Destructor, just does if (menu && menuislocal) delete menu. | |
virtual int | init () |
Set some values that are derived from other values (pagesize, hightlight, shadow, ...). | |
virtual void | Refresh () |
Draw the window. | |
virtual int | Event (const EventData *e, const char *mes) |
Intercept LAX_onMapped in case MENUSEL_GRAB_ON_MAP is set. | |
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 | WrapToMouse (int mouseid, anXWindow *onedgeofthis=NULL) |
Resize the window to the extent of the items, and reposition near the mouse. | |
virtual int | WrapToPosition (int screen_x, int screen_y, int screen, anXWindow *onedgeofthis=NULL) |
Orient the window's size and position to be near the given screen coordinates. | |
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 item which be near screen coordinate x,y. | |
virtual int | Curitem () |
Return curitem, which is the last item whose state was toggled. | |
virtual const MenuItem * | Item (int c) |
virtual int | Select (int which) |
Programs call this to select index which. | |
virtual int | NumSelected () |
Return how many items are currently selected. | |
virtual int * | WhichSelected (unsigned int state) |
Return a new'd int array of which items are in the given state, if there are any, else NULL. | |
virtual void | SetLineHeight (int ntotalheight, int newleading, char forcearrange=1) |
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) |
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, int nid, int nst) |
Add item with text i to the top index of menuitems. | |
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. | |
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 PanController * | createNewPanner (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 char * | whattype () |
virtual const char * | WindowTitle (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 char * | tooltip (int mouseid=0) |
By default, return win_tooltip. | |
virtual const char * | tooltip (const char *newtooltip) |
Replace the current tooltip, return the current tooltip (after replacing). | |
virtual anXWindow * | findChildWindowByTitle (const char *title) |
Find the first immediate child window that has win_title==title. | |
virtual anXWindow * | findChildWindowByName (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 Displayer * | MakeCurrent () |
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 ShortcutHandler * | GetShortcuts () |
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 anXWindow * | GetController () |
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::Attribute * | dump_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 char * | GetTag (int i) |
Return const pointer to the tag text for tag number i, where i==0 is the first tag. | |
virtual char * | GetAllTags () |
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 | |
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 |
int | leading |
The height of lines are leading+(text height). | |
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 |
PanPopup * | panpopup |
anXWindow * | thewindow |
Scroller * | xscroller |
Scroller * | yscroller |
Public Attributes inherited from Laxkit::PanUser | |
PanController * | panner |
Public Attributes inherited from Laxkit::anXWindow | |
WindowColors * | win_colors |
anXApp * | app |
char * | win_name |
An arbitrary string to be used as an id. | |
char * | win_title |
The title of the window. | |
anXWindow * | win_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 |
char * | win_sendthis |
The type of message that gets sent to owner. | |
anXWindow * | nextcontrol |
anXWindow * | prevcontrol |
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 *x, double *y) |
Base MenuSelector currently just does text, so points w and h to 0. | |
virtual void | drawStatusGraphic (int x, int y, int state) |
Draw the status graphic at window coordinates x,y,width=sgw,height=textheight+leading, with state. | |
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 | 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 | drawcheck (int on, int x, int y) |
Draw a check mark in rectangle x,y,width=checkw, height=textheight+leading. | |
virtual void | drawsubindicator (MenuItem *mitem, int x, int y) |
Draws a submenu indicator in rectangle x,y,width=subw, height=textheight+leading. | |
virtual void | drawitemname (MenuItem *mitem, IntRectangle *rect) |
Draw the item icon and name in rect. | |
virtual void | drawtitle () |
Draw the menu title if present. Default is print it out at top of window (not inrect). | |
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 | findmaxwidth (int s, int e, int *h_ret) |
Find the maximum width of (text+ pad+ graphic+ statusgraphicw+ checkwidth+ subw) of items in range [s,e]. | |
virtual int | findItem (int x, int y) |
Find the would be item at window coordinates (x,y). | |
virtual int | findRect (int c, IntRectangle *itemspot) |
Find screen rectangle item c goes in. | |
virtual void | editInPlace () |
Set up the edit in place mode. ****TODO!! | |
virtual int | numItems () |
Default is to return the number of items in menu->menuitems stack. | |
virtual MenuItem * | item (int i, char skipcache=0) |
Return the item corresponding to screen index i. | |
virtual void | arrangeItems (int forwrapping=0) |
Setup columns based on inrect, then sync up the panner. | |
virtual void | setcuritem (int i) |
Sets curitem and curmenuitem. Internal function. | |
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. |
Protected Attributes | |
ButtonDownInfo | buttondown |
int | mousedragged |
Flag for whether the mouse has been dragged since a button was down. | |
NumStack< int > | columns |
Each element of the stack holds the width of that column. | |
MenuInfo * | menu |
Stores the actual menu items. | |
char | menuislocal |
Whether menu is local to this MenuSelector. | |
int | mx |
int | my |
int | sgw |
The width of the status graphic element of a menu item. (only one width, not per item) | |
int | checkw |
The width of the check mark graphic of a menu item. (only one width, not per item) | |
int | subw |
The width of the sub menu indicator graphic of a menu item. (only one width, not per item) | |
int | firstinw |
The equivalent index of the first line in the window. | |
int | textheight |
The height of lines are leading+(text height). | |
int | lineheight |
int | pagesize |
The number of lines that can be comfortably fit in inrect. | |
int | columnsize |
The maximum number of actual elements in any the columns. | |
MenuItem * | curmenuitem |
The MenuItem corresponding to curitem. | |
int | curitem |
The last selected or deselected item. | |
int | ccuritem |
The item which one has cursored to. | |
int | timerid |
General list and menu controller. Base class for PopupMenu.
For speed, all lines have the same height. This is really a little bit of a cop-out for not wanting to program for lines that have differing heights.
Please note that the ridiculously large number of style flags are passed in through a dedicated long long in the constructor, rather than the normal or'ing with the anXWindow::win_style flags. These menu flags are stored in menustyle.
This class handles only one level of a menu. Multiple levels are handled in the more specialized derived classes TreeSelector (***todo!) and PopupMenu. All items can be selected. They are indicated by being highlighted (or having a status graphic checked). 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.
Items can be displayed in 1 long vertical list. Alternately, the items fill columns the size of the window, and columns extend off to the left and right. A third (*** not implemented) style has how ever many columns fit across the width of the window, and the contents extend off the top and bottom. Items fill downward in the first column, then fill the second column, etc.
MenuItems that have LAX_ISTOGGLE are allowed to be checked on and off. This is different then being selected/highlighted. Items can also be hidden (***not implemented), but still be stored in the stack.
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.
There are three standard color schemes to choose from. First, there are the standard button colors for text and background (MENUSEL_BUTTONCOLORS). Second are the standard text edit colors (MENUSEL_TEXTCOLORS). And last and default are the standard menu panel colors.
//... remember that the buck stops with (1<<63)
TODO: label in 2 parts: "Blah\t+t" –> 'Blah +t' (2 part labels, also underline character for hot keys??), rearrange, edit in place TODO *** RemoveItem *** put in a newstate(int newstate,int drawnow)/toggle(item,-1) *** when mouseover up arrow or autoscroll up, moving down should not shiftscreen *** scrollbar (x/y) versus up/down arrows and right click dragging?? *** Menu | Blah ^x | <– parse item in two parts, "Blah\t^x" -> "Blah" —> "^x"?? | Yack +^y | | Pshaww ^p | Shift: + // Control: ^ // Alt: * // Mod4: ~
*** non-constant item height, easier facility for graphic+text?? *** menu groups, so you can push groups of things onto a single menu, without the need of poping up a submenu!! Quite useful for many of the potential menus in laidout ==== this is basically a tree, without all the tree lines... *** neat from fltk: Add("File") Add("File/Save") Add("File/Save As")....
Laxkit::MenuSelector::MenuSelector | ( | 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 * | atom = 0 , |
||
unsigned long long | nmstyle = 0 , |
||
MenuInfo * | usethismenu = NULL , |
||
char | nmenuislocal = 0 |
||
) |
Constructor.
If you pass in a MenuInfo, you can also pass in whether the MenuSelector should be resposible for deleting it (menuislocal==1) or not. If usethismenu is NULL, then a new MenuInfo is created and menuislocal is set to 1. If usethismenu is not NULL, then the value of nmenuislocal is used. The default is 1: for the MenuSelector to take possession of the MenuInfo. This allows programs to create a menuinfo themselves, and then not worry about deleting it, because the selector will delete it.
Sets up colors, and pushes 0 onto the columns stack.
nstyle | Holds the usual anXWindow style flags |
nmstyle | Holds the menu style defines |
usethismenu | Pass in a MenuInfo class, if not NULL is assumed to not be local |
nmenuislocal | Whether the passed in menu is local. Default is 1 |
References ccuritem, columns, columnsize, curitem, curmenuitem, firstinw, Laxkit::anXWindow::installColors(), leading, menu, menuislocal, mousedragged, pagesize, Laxkit::NumStack< T >::push(), and textheight.
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(), item(), menu, and numItems().
Referenced by AddItems().
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.
Reimplemented in Laxkit::PopupMenu.
References ccuritem, curitem, curmenuitem, drawitem(), item(), numItems(), Laxkit::MenuItem::state, and Laxkit::anXWindow::WindowTitle().
Referenced by CharInput(), LBUp(), MouseMove(), and Select().
|
protectedvirtual |
Remove the pads from inrect.
This is called last thing from ScrolledWindow::syncWindows(). Also sets pagesize=(inrect.height+leading)/(textheight+leading)
This and arrangeItems are the only places that pagesize gets set.
Reimplemented from Laxkit::ScrolledWindow.
References Laxkit::ScrolledWindow::inrect, leading, pagesize, and textheight.
Referenced by WrapToPosition().
|
protectedvirtual |
Setup columns based on inrect, then sync up the panner.
Default is for single column. FIT_TO_HEIGHT causes multiple columns that continue off horizontally. Assumes inrect has been found and arranges items to fit in that. Sets columnsize to something appropriate.
This sets pagesize if necessary.
Syncs the panner such that the wholebox of the panner is the newly found wholerect, and the selbox is inrect. However, any shifting changes the panner's selbox, but this does not trigger any change in inrect.
If forwrapping!=0 then do not try to expand wholerect to fill up inrect, and do not update the panner. This is when you are arranging items first, and then wrapping the window to the extent of the items.
References columns, columnsize, Laxkit::NumStack< T >::e, findmaxwidth(), Laxkit::NumStack< T >::flush(), Laxkit::ScrolledWindow::inrect, leading, Laxkit::NumStack< T >::n, numItems(), pagesize, Laxkit::NumStack< T >::push(), Laxkit::PanController::SetCurPos(), Laxkit::PanController::SetWholebox(), and textheight.
Referenced by init(), SetLineHeight(), Sync(), syncWindows(), and WrapToPosition().
|
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. ^'m' (***imp me!) move selected items to ccuritem '/' (***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.
Reimplemented in Laxkit::PopupMenu.
References addselect(), ccuritem, columns, columnsize, Laxkit::anXApp::destroywindow(), drawitem(), item(), leading, makeinwindow(), movescreen(), Laxkit::NumStack< T >::n, numItems(), pagesize, Laxkit::ScrolledWindow::send(), Laxkit::MenuItem::state, and textheight.
|
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.
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().
|
protectedvirtual |
Draw the item in the provided area..
All the things that go on an item line:
[status graphic=whether highlighted][check toggle][graphic icon][text][submenu indicator] First XClearArea, then put it in..
Finally, the actual item text and icon fill the remaining space.
Normally, drawitem would use drawStatusGraphic,****is this right and getitemextent to determine these things.
References checkw, drawcheck(), drawitemname(), drawsep(), drawStatusGraphic(), drawsubindicator(), Laxkit::fill_rectangle(), sgw, Laxkit::MenuItem::state, and subw.
Referenced by addselect(), CharInput(), drawitem(), FocusOff(), FocusOn(), MouseMove(), and Refresh().
|
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 drawitem(), findRect(), Laxkit::ScrolledWindow::inrect, item(), and numItems().
Draw the status graphic at window coordinates x,y,width=sgw,height=textheight+leading, with state.
This is not an item's icon. It is the menu style in which the items are not highlighted, but act like several checkboxes. The boxes are marked instead of the whole item being hightlighted.
Of this scheme, MENUSEL_CHECKBOXES causes the graphic to be a circle with the mark inside the circle. Otherwise, the mark is drawn without a surrounding circle.
References highlight, sgw, shadow, and textheight.
Referenced by drawitem().
Draws a submenu indicator in rectangle x,y,width=subw, height=textheight+leading.
References Laxkit::draw_lines(), drawarrow(), Laxkit::fill_polygon(), leading, Laxkit::MenuItem::state, subw, and textheight.
Referenced by drawitem().
|
protectedvirtual |
Intercept LAX_onMapped in case MENUSEL_GRAB_ON_MAP is set.
Grabs the pointer if that style is set. In either case, it then properly calls anXWindow::Event().
Reimplemented from Laxkit::ScrolledWindow.
References Laxkit::anXApp::destroywindow(), and Laxkit::anXApp::setfocus().
Find the would be item at window coordinates (x,y).
The value returned is not necessarily an actual element index. It could be -1, or >=menuitems.n.
References columns, columnsize, Laxkit::NumStack< T >::e, Laxkit::PanController::GetCurPos(), Laxkit::ScrolledWindow::inrect, leading, Laxkit::NumStack< T >::n, and textheight.
Referenced by LBUp(), and MouseMove().
Find the maximum width of (text+ pad+ graphic+ statusgraphicw+ checkwidth+ 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 checkw, Laxkit::getextent(), getgraphicextent(), item(), numItems(), padg, sgw, and subw.
Referenced by arrangeItems().
|
protectedvirtual |
Find screen rectangle item c goes in.
Return 0 for rectangle found, otherwise 1 for unable to find (for instance when called before necessary initialization done).
References columns, columnsize, Laxkit::NumStack< T >::e, Laxkit::PanController::GetCurPos(), Laxkit::ScrolledWindow::inrect, leading, and textheight.
Referenced by Laxkit::PopupMenu::addselect(), drawitem(), makeinwindow(), and movescreen().
|
virtual |
Focus off draws the char over item.
Also, if MENUSEL_FOCUS_OFF_DESTROYS, then an off focus destroys this window.
Reimplemented from Laxkit::anXWindow.
References ccuritem, Laxkit::anXApp::destroywindow(), drawitem(), Laxkit::anXWindow::win_active, and Laxkit::anXWindow::WindowTitle().
|
protectedvirtual |
Base MenuSelector currently just does text, so points w and h to 0.
Returns the width.
mitem | the item |
w | Put the x extent here |
h | Put the y extent here |
References Laxkit::LaxImage::h(), and Laxkit::LaxImage::w().
Referenced by findmaxwidth(), and getitemextent().
|
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.
mitem | the index, MUST already be in bounds |
w | Put the x extent here |
h | Put the y extent here |
gx | Where the graphic would start, relative to whole item |
tx | Where the text would start, relative to whole item |
References Laxkit::getextent(), getgraphicextent(), and padg.
Referenced by drawitemname().
Autoscroll if necessary****TODO.
Reimplemented from Laxkit::anXWindow.
Reimplemented in Laxkit::PopupMenu.
|
virtual |
Set some values that are derived from other values (pagesize, hightlight, shadow, ...).
Sets leading to have a little bit extra if MENUSEL_CHECKBOXES and not otherwise specified. Also sets the shadow and hightlight colors, and determines the pagesize.
Reimplemented from Laxkit::ScrolledWindow.
References arrangeItems(), Laxkit::coloravg(), highlight, leading, padg, Laxkit::rgbcolor(), SetLineHeight(), sgw, shadow, textheight, and Laxkit::anXWindow::WindowTitle().
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.
References Laxkit::PtrStack< T >::e, menu, Laxkit::MenuInfo::menuitems, and Laxkit::PtrStack< T >::n.
Referenced by AddItem(), addselect(), CharInput(), drawitem(), drawitemname(), findmaxwidth(), NumSelected(), Select(), send(), setcuritem(), and WhichSelected().
|
virtual |
Left button down.
If MENUSEL_OUT_CLICK_DESTROYS is set, then app->destroywindow(this) when clicking down outside the window.
Reimplemented from Laxkit::anXWindow.
References curitem, curmenuitem, Laxkit::anXApp::destroywindow(), Laxkit::ButtonDownInfo::down(), mousedragged, and Laxkit::ScrolledWindow::send().
Left button up.
If clicked on an arrow, then shift screen. If on item, then addselect(that item). Send the control message if MENUSEL_SEND_ON_UP is set. Destroy this window if MENUSEL_CLICK_UP_DESTROYS is set.
Reimplemented from Laxkit::anXWindow.
References addselect(), Laxkit::anXApp::destroywindow(), editInPlace(), findItem(), Laxkit::ButtonDownInfo::isdown(), mousedragged, numItems(), Laxkit::ScrolledWindow::send(), and Laxkit::ButtonDownInfo::up().
|
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().
|
virtual |
Left might select depending on style. Right button drags. +R fast drags.
Reimplemented from Laxkit::anXWindow.
Reimplemented in Laxkit::PopupMenu.
References addselect(), Laxkit::ButtonDownInfo::any(), ccuritem, drawitem(), findItem(), Laxkit::ButtonDownInfo::isdown(), mousedragged, movescreen(), and numItems().
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, columns, columnsize, Laxkit::NumStack< T >::e, findRect(), Laxkit::ScrolledWindow::inrect, leading, Laxkit::NumStack< T >::n, numItems(), Laxkit::PanController::Shift(), and textheight.
Referenced by CharInput(), MouseMove(), WheelDown(), and WheelUp().
|
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 menu, Laxkit::MenuInfo::menuitems, and Laxkit::PtrStack< T >::n.
Referenced by AddItem(), addselect(), arrangeItems(), CharInput(), drawitem(), findmaxwidth(), LBUp(), MouseMove(), movescreen(), NumSelected(), Refresh(), Select(), send(), Sort(), and WhichSelected().
|
virtual |
Right button and drag drags the screen around (with potential autoscrolling)
Reimplemented from Laxkit::anXWindow.
Reimplemented in Laxkit::PopupMenu.
References Laxkit::ButtonDownInfo::down().
|
virtual |
Draw the window.
Draws the items by calling drawitem(). Then draws the up arrow and down arrow if they are needed. Draws the title along top of window
// *** will need a smart refreshing to XCopyArea instead of redrawing the whole thing
// *** need itemrect????
Goes like: drawtitle() drawitem(int) for each item then with that item and rect on screen where it goes, call: drawitem(MenuItem *mitem,IntRectangle *itemspot) which might call as appropriate: drawsep(const char *name,IntRectangle *rect) <– separator drawStatusGraphic(int x,int y,int state) <– in lieu of highlighting drawcheck(int on, int x,int y) <– togglable check mark drawsubindicator(MenuItem *mitem,int x,int y) <– whether there's a submenu drawitemname(MenuItem *mitem,IntRectangle *rect) <– item name and/or icon
Reimplemented from Laxkit::anXWindow.
References Laxkit::clear_window(), drawitem(), drawtitle(), numItems(), and Laxkit::anXWindow::win_on.
Programs call this to select index which.
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.
Referenced by Laxkit::FileDialog::getDirectory(), Laxkit::SliderPopup::makePopup(), Laxkit::MenuButton::makePopup(), and Laxkit::PopupMenu::PopupMenu().
Send message to owner.
If !(menustyle&MENUSEL_SEND_STRINGS) Sends SimpleMessage with:
Otherwise, sends a list of the selected strings in a StrsEventData, with info=curitem.
*** 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::MenuItem::info, item(), newstr(), numItems(), Laxkit::anXApp::SendMessage(), Laxkit::MenuItem::state, Laxkit::anXWindow::win_owner, Laxkit::anXWindow::win_sendthis, and Laxkit::anXWindow::WindowTitle().
|
protectedvirtual |
Sets curitem and curmenuitem. Internal function.
*** doesn't seem to be used anywhere.. get rid of it?
References curitem, curmenuitem, and item().
Make item which be near screen coordinate x,y.
Returns ???***.
Referenced by WrapToPosition().
|
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(), checkw, leading, padg, sgw, subw, syncWindows(), and textheight.
Referenced by init(), and WrapToPosition().
|
virtual |
Sort the items alphabetically by the name.
t is passed on to MenuInfo::sortstyle. t==0 means do the default sorting.
References menu, numItems(), and Laxkit::MenuInfo::sort().
|
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().
|
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.
|
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.
Return a new'd int array of which items are in the given state, if there are any, else NULL.
Same state means MenuItem::state&LAX_MSTATE_MASK == state.
The first element is the number of selected items. The calling code is responsible for deleting the array.
References Laxkit::NumStack< T >::e, Laxkit::NumStack< T >::extractArray(), item(), Laxkit::NumStack< T >::n, numItems(), and Laxkit::NumStack< T >::push().
Referenced by Laxkit::FileDialog::send().
|
virtual |
Orient the window's size and position to be near the given screen coordinates.
This function tries to place the window near screen coordinates of the mouse.
If onedgeofthis is None, it prefers to put the window to the left of the mouse. If it does not fit then it tries to put the window to the right of x,y. Also, the currently selected item is made to be at the same height of y.
If onedgeofthis is not NULL, then it also tries to place itself on a nearby right edge of onedgeofthis.
Currently, it assumes that this window is a top level window, such as a popup menu, and that it is not a tree, that is it does not consider submenus.
This also calls anXWindow::MoveResize().
References adjustinrect(), arrangeItems(), columns, columnsize, curitem, Laxkit::NumStack< T >::e, Laxkit::PtrStack< T >::e, findoutrect(), Laxkit::LaxImage::h(), Laxkit::ScrolledWindow::inrect, leading, menu, Laxkit::MenuInfo::menuitems, MoveResize(), Laxkit::NumStack< T >::n, Laxkit::PtrStack< T >::n, Laxkit::ScrolledWindow::outrect, Laxkit::anXApp::ScreenInfo(), SetFirst(), SetLineHeight(), and textheight.
Referenced by Laxkit::PopupMenu::PopupMenu(), and WrapToMouse().
Each element of the stack holds the width of that column.
So of course, columns.n is the number of columns. The height of a full column is just pagesize*(textheight+leading).
Referenced by arrangeItems(), CharInput(), findItem(), findRect(), MenuSelector(), movescreen(), and WrapToPosition().
|
protected |
The maximum number of actual elements in any the columns.
When the style is wrapping to the height, columnsize should be equal to pagesize.
Referenced by arrangeItems(), CharInput(), findItem(), findRect(), MenuSelector(), movescreen(), and WrapToPosition().
|
protected |
The equivalent index of the first line in the window.
This could be a negative value, and so should not be interpreted as an index into the menuitems stack. It is useful for instance when popping up menus and you want the current selection to be near the mouse, no matter where the actual bounds of the window are.
Referenced by MenuSelector().
int Laxkit::MenuSelector::leading |
The height of lines are leading+(text height).
Any highlighting does not include the leading pixels.
Referenced by adjustinrect(), arrangeItems(), CharInput(), drawcheck(), drawitemname(), drawsubindicator(), drawtitle(), findItem(), findRect(), init(), MenuSelector(), movescreen(), SetLineHeight(), WheelDown(), WheelUp(), and WrapToPosition().
|
protected |
Stores the actual menu items.
The MenuInfo may be owned by MenuSelector or not, based on whether menuislocal is nonzero or not. If it is non-zero, then the destructor calls 'delete menu'.
Referenced by AddItem(), Laxkit::PopupMenu::addselect(), drawtitle(), findoutrect(), item(), MenuSelector(), numItems(), Laxkit::PopupMenu::PopupMenu(), Sort(), WrapToPosition(), and ~MenuSelector().
|
protected |
Flag for whether the mouse has been dragged since a button was down.
If it is a simple move, then mousedragged==1. If the menuselector is REARRANGEABLE, and items are in the process of being moved, then mousedragged==2.
Referenced by LBDown(), LBUp(), MenuSelector(), and MouseMove().
|
protected |
The number of lines that can be comfortably fit in inrect.
That is, pagesize=(inrect.height+leading)/(textheight+leading)
Referenced by adjustinrect(), arrangeItems(), CharInput(), MenuSelector(), WheelDown(), and WheelUp().
|
protected |
The height of lines are leading+(text height).
Any highlighting only includes the textheight pixels.
Referenced by adjustinrect(), arrangeItems(), CharInput(), drawcheck(), drawitemname(), drawStatusGraphic(), drawsubindicator(), drawtitle(), findItem(), findoutrect(), findRect(), init(), MenuSelector(), movescreen(), SetLineHeight(), WheelDown(), WheelUp(), and WrapToPosition().