Laxkit
0.0.7.1
|
A vertical or horizontal scroll bar, with optional zooming handles, and togglable arrow positions. More...
Public Member Functions | |
Scroller (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int nx, int ny, int nw, int nh, int brder, anXWindow *prev, unsigned long nowner, const char *mes, PanController *npan, long nmins=0, long nmaxs=0, long nps=0, long nes=0, long ncp=-1, long ncpe=-1) | |
Constructor. Creates a new panner if npan==NULL. | |
virtual | ~Scroller () |
Empty default destructor. | |
virtual int | Event (const EventData *e, const char *mes) |
virtual void | Refresh () |
Essentially clears the window, then drawtrack(), then drawtrackbox(). | |
virtual int | Idle (int id=0) |
virtual int | MoveResize (int nx, int ny, int nw, int nh) |
Calls anXWindow::MoveResize, then redoarrows. | |
virtual int | Resize (int nw, int nh) |
Calls anXWindow::Resize, then redoarrows. | |
virtual int | RBDown (int mx, int my, unsigned int state, int count, const LaxMouse *d) |
Right clicking on the arrows causes pageup/down at the next idle or on RBUp. | |
virtual int | RBUp (int mx, int my, unsigned int state, const LaxMouse *d) |
Right clicking on the arrows causes pageup/down. | |
virtual int | LBDown (int mx, int my, unsigned int state, int count, const LaxMouse *d) |
LBDown. | |
virtual int | LBUp (int mx, int my, unsigned int state, const LaxMouse *d) |
virtual int | WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d) |
Wheel up. Move 1 element, shift or control moves 1 page, shift+control moves 5 pages. | |
virtual int | WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d) |
Wheel down. Move 1 element, shift moves 1 page, shift+control moves 5 pages. | |
virtual int | MouseMove (int mx, int my, unsigned int state, const LaxMouse *d) |
Mouse Move. | |
virtual int | CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *d) |
Control-, and control-. toggle the arrow style. | |
virtual void | drawarrows () |
Draw the arrows in their proper place based on a1off, a2off, and ah. | |
virtual void | drawtrack () |
Draw the track, including arrows. Default is draw a line, then call drawarrows. | |
virtual void | drawtrackbox () |
Draw the track box including the zoom handles if required. | |
virtual long | SetPageSize (long nps) |
Sets pagesize (meaning curposend-curpos+1), returns actual new pagesize. | |
virtual long | GetPageSize () |
Return end-start. | |
virtual long | GetCurPos (long *poss=NULL, long *pose=NULL) |
Just returns panner->GetCurPos(poss,pose);. | |
virtual long | GetCurPosEnd () |
Returns the panner->end. | |
virtual long | SetCurPos (long newcurpos) |
Sets current position, keeping the old page size. Returns actual new curpos. | |
virtual long | SetCurPos (long start, long end) |
Sets current position and end position, assigning new page size. | |
virtual long | SetSize (long nmins, long nmaxs, long ncurpos, long ncurposend, long nps, long nes) |
Set lots of attributes. | |
virtual long | SetSize (long nmins, long nmaxs, long nps=0) |
Calling this one assumes you want definite pagesize, not pagesize=curposend-curpos. | |
virtual int | getpos (int mx, int my) |
Return which of the various elements the mouse is in. | |
virtual int | send () |
virtual void | send (long change, int pagesizechange=0) |
Send a control message. If change==0, then nothing is sent. | |
virtual long | PageDown (int numpages=1) |
Shift the bar numpages up. | |
virtual long | PageUp (int numpages=1) |
Shift the bar numpages down. | |
virtual long | OneDown () |
Move the track up one unit. | |
virtual long | OneUp () |
Move the track down one element unit. | |
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::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 | init () |
Empty placeholeder. Just returns 0. | |
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 int | FocusOn (const FocusChangeData *e) |
Increment win_active, and highlights the window's border, if the event refers to this window. | |
virtual int | FocusOff (const FocusChangeData *e) |
Decrements win_active, and de-highlights the window's border if win_active==0, if event is a real focus off. | |
virtual void | contentChanged () |
Windows may call this when their contents change. | |
virtual void | selectionChanged () |
Windows may call this when their selections change. | |
virtual 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. | |
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 | bordercolor |
unsigned long | wholecolor |
unsigned long | trackcolor |
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 | redoarrows () |
Sets ah,zh,toff based on a presumed changed in win_w/win_h. | |
Protected Member Functions inherited from Laxkit::anXWindow | |
virtual int | deletekid (anXWindow *w) |
Purges child anXWindows from window's child stack. | |
virtual void | SwapBuffers () |
Swap buffers. This should be called from Refresh() if VIEWPORT_BACK_BUFFER is set in win_style. | |
virtual void | SetupBackBuffer () |
Initialize the backbuffer. |
Protected Attributes | |
ButtonDownInfo | buttondown |
int | zh |
The height of an individual zoom handle. | |
int | ah |
The height of an individual arrow. | |
int | minboxlen |
int | toff |
The offset from the left (or top) to the track. | |
int | a1off |
The offset from the left (or top) to the first arrow. | |
int | a2off |
The offset from the left (or top) to the second arrow. | |
int | omx |
int | omy |
int | tid |
int | idlemx |
int | idlemy |
Protected Attributes inherited from Laxkit::anXWindow | |
char * | win_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< char > | list_of_tags |
A vertical or horizontal scroll bar, with optional zooming handles, and togglable arrow positions.
*** all this assumes max>min, should allow min>max?? flip(pos) { return max-(pos-min); }
*** watch out for ALLOW_SMALL
This uses a PanController to keep track of the space being scrolled through. This is particularly convenient when the scroller is part of a pair, and they have zoom handles, as the PanController helps to synchronize them.
Control-left-click or typing any of '.' ',' '<' or '>' toggles the arrow style, which can be one arrow at each end (SC_ASPLIT), both arrows on top or left (SC_ATOP), or both arrows at the bottom or right (SC_ABOTTOM). Or one can have no arrows at all (SC_NOARROWS).
When there is a change in the scroll bar handle position, a SimpleMessage is filled thus:
mevent->info1 = amount of change, basically curpos-oldcurpos; mevent->info2 = start position; mevent->info3 = end position; mevent->info4 = pagesizechange; <– 1 if zoom handle was changed
Style Defines:
|— a | ^ |— b | | c (c-a)= toff, where track box begins | | | z c | z d (d-c)+1= zh, the height of a zoom handle | + e | + | m ]<– minboxlen is the minimum size of the trackbox (not including zoom handles) | m ] | + | + | z f (g-f)+1= zh | z g (g-c+1)= the track box height | | | | | | |— h (h-c)= th, the height or length of the track | v |— i
bw,bh is the width,height of track box, xscroll or yscroll
Laxkit::Scroller::Scroller | ( | anXWindow * | parnt, |
const char * | nname, | ||
const char * | ntitle, | ||
unsigned long | nwstyle, | ||
int | nx, | ||
int | ny, | ||
int | nw, | ||
int | nh, | ||
int | brder, | ||
anXWindow * | prev, | ||
unsigned long | nowner, | ||
const char * | mes, | ||
PanController * | npan, | ||
long | nmins = 0 , |
||
long | nmaxs = 0 , |
||
long | nps = 0 , |
||
long | nes = 0 , |
||
long | ncp = -1 , |
||
long | ncpe = -1 |
||
) |
Constructor. Creates a new panner if npan==NULL.
If npan is not NULL, then all the parameters after npan are ignored, so it's a good thing the constructor is overloaded.
nmins | Minimum value |
nmaxs | Maximum value |
nps | Page size |
nes | Element size |
ncp | Curpos |
ncpe | Curpos end. Use -1 if you do not need an actual range for the curpos. |
References Laxkit::anXWindow::installColors(), redoarrows(), Laxkit::PanController::SetStuff(), and zh.
|
virtual |
Control-, and control-. toggle the arrow style.
Reimplemented from Laxkit::anXWindow.
References redoarrows().
|
virtual |
Default is to read in text, and whatever anXWindow reads.
Reimplemented from Laxkit::anXWindow.
References Laxkit::PtrStack< T >::e, LaxFiles::LongAttribute(), Laxkit::PtrStack< T >::n, Laxkit::PanController::SetStuff(), and Laxkit::anXWindow::setWinStyle().
|
virtual |
Append to att if att!=NULL, else return a new Attribute whose name is whattype().
Default is to add attributes for "text", and whatever anXWindow adds.
Reimplemented from Laxkit::anXWindow.
References Laxkit::PanController::elementsize, GetCurPos(), Laxkit::PanController::maxsel, Laxkit::PanController::minsel, Laxkit::PanController::pagesize, and LaxFiles::Attribute::push().
Return which of the various elements the mouse is in.
purpose here is to find where the mouse was when pressed 1 left/up arrow 2 right/down arrow 3 on tracker 4 pgleft/up 5 pgright/down 6 left/up zoom handle 7 right/down zoom handle
References a1off, a2off, ah, Laxkit::PanController::GetMagToBox(), Laxkit::PanController::GetMagToWhole(), toff, and zh.
Reimplemented from Laxkit::anXWindow.
References Laxkit::ButtonDownInfo::any(), Laxkit::ButtonDownInfo::getextrainfo(), OneDown(), OneUp(), PageDown(), PageUp(), Laxkit::anXApp::removetimer(), and Laxkit::ButtonDownInfo::whichdown().
Mouse Move.
This might not work as expected when selbox larger than wholebox... fancy zoom allows scaling even though dragging causes cross over sel==whole boundary.
Reimplemented from Laxkit::anXWindow.
References ah, Laxkit::ButtonDownInfo::any(), Laxkit::PanController::end, GetCurPos(), Laxkit::ButtonDownInfo::getinfo(), Laxkit::ButtonDownInfo::isdown(), Laxkit::PanController::max, Laxkit::PanController::min, Laxkit::ButtonDownInfo::move(), Laxkit::PanController::Shift(), Laxkit::PanController::ShiftEnd(), Laxkit::PanController::ShiftStart(), Laxkit::PanController::start, and zh.
|
virtual |
Move the track up one unit.
Returns 1 if movement occurs.
References Laxkit::PanController::OneUp().
Referenced by Idle(), and WheelDown().
|
virtual |
Move the track down one element unit.
Returns amount of change.
References Laxkit::PanController::OneDown().
|
virtual |
Shift the bar numpages up.
This does not send an event. It is assumed that the application calls this, and already knows that it is calling and so does not need to be notified of changes.
Returns amount of change.
References Laxkit::PanController::PageUp().
Referenced by Idle(), RBUp(), and WheelDown().
|
virtual |
Shift the bar numpages down.
This does not send an event. It is assumed that the application calls this, and already knows that it is calling and so does not need to be notified of changes.
Returns amount of change.
References Laxkit::PanController::PageDown().
Right clicking on the arrows causes pageup/down.
Control-Right click changes the arrow styles.
Reimplemented from Laxkit::anXWindow.
References Laxkit::ButtonDownInfo::any(), Laxkit::ButtonDownInfo::getinfo(), getpos(), Laxkit::ButtonDownInfo::isdown(), PageDown(), PageUp(), Laxkit::anXApp::removetimer(), and Laxkit::ButtonDownInfo::up().
|
protectedvirtual |
Sets ah,zh,toff based on a presumed changed in win_w/win_h.
zoom height is 2/3 of the window height (for x scrollers, for instance)
References a1off, a2off, ah, toff, and zh.
Referenced by CharInput(), MoveResize(), Resize(), and Scroller().
|
virtual |
Send a control message. If change==0, then nothing is sent.
Fills a SimpleMessage thus:
info1 = amount of change, basically curpos-oldcurpos; info2 = start position; info3 = end position; info4 = pagesizechange;
pagesizechange should be nonzero if there has been some zooming action.
References Laxkit::PanController::GetCurPos(), Laxkit::anXApp::SendMessage(), Laxkit::anXWindow::win_owner, Laxkit::anXWindow::win_sendthis, and Laxkit::anXWindow::WindowTitle().
|
virtual |
Sets current position, keeping the old page size. Returns actual new curpos.
Returns difference between old and new pos.
References Laxkit::PanController::SetCurPos().
Referenced by Laxkit::MultiLineEdit::makeinwindow(), and Laxkit::MultiLineEdit::ShiftScreen().
|
virtual |
Sets current position and end position, assigning new page size.
Returns difference between new curpos and old curpos.
References Laxkit::PanController::SetCurPos().
|
virtual |
Set lots of attributes.
nps and nes are interpreted however the panner interprets them. That is, whether they are percent of the selbox or absolute space units.
Returns whatever panner->SetStuff returns, currently just 1 if stuff was set else 0.
nmins | New minimum number |
nmaxs | New maximum number |
ncurpos | New current position |
ncurposend | New current end position |
nps | New page size (could be percent, depends on panner settings) |
nes | New element size (could be percent, depends on panner settings) |
References Laxkit::PanController::SetStuff().
Referenced by Laxkit::MultiLineEdit::Getmostwide().
|
virtual |
Calling this one assumes you want definite pagesize, not pagesize=curposend-curpos.
Returns curpos.
nmins | New minimum size |
nmaxs | New maximym size |
nps | New size for curposend-curpos+1. |
References Laxkit::PanController::SetSize().