Laxkit
0.0.7.1
|
A convenience for scroller types of things. More...
Public Member Functions | |
PanController () | |
Default constructor, sets minsel to 1, maxsel to 1000000, and style to PANC_ELEMENT_IS_PERCENT|PANC_PAGE_IS_PERCENT. | |
PanController (const PanController &pan) | |
Copy constructor. Does not copy tellstack. | |
PanController & | operator= (PanController &pan) |
Assignment operator does NOT copy the tellstack. Leaves tellstack as is. | |
PanController (long xmin, long xmax, long xstart, long xend, long ymin, long ymax, long ystart, long yend, int w, int h, unsigned long panstyle=PANC_ELEMENT_IS_PERCENT|PANC_PAGE_IS_PERCENT) | |
Constructor. | |
virtual | ~PanController () |
Destructor, turns off the panner in any PanUser in tellstack. | |
virtual long | SetPageSize (int which, long nps) |
Set so that end-start+1==nps. Returns new actual end-start+1;. | |
virtual long | GetPageSize (int which) |
Return end[which]-start[which]+1;. | |
virtual double | GetMagToBox (int which, int boxwidth, long *wholestartret, long *wholeendret) |
Get the horizontal (which==1) or vertical(=2) magnification of the box to the screen (screen=Getmag*real) | |
virtual double | GetMagToWhole (int which, int trackwidth, long *boxstartret, long *boxendret) |
Get the horizontal (which==1) or vertical(=2) magnification of the whole space to the screen (screen=Getmag*real) | |
virtual void | SetSelBounds (int which, long small, long big) |
Set the minimum selection size and maximum selection size. | |
virtual void | SetPixelAspect (double npixaspect=1.0) |
Set the level of difference between x and y zoom. | |
virtual double | findpixelaspect () |
Compute the new pixelaspect based on other info..... | |
virtual void | SetBoxAspect (int w, int h) |
Set the preferred dimensions of a target window. | |
virtual int | SetWholebox (long xmin, long xmax, long ymin, long ymax) |
Set both the dimensions of the workspace, preserving proportionally the selbox. | |
virtual int | SetStuff (int which, long nmin, long nmax, long nps, long nes, long posstart, long posend) |
Set the metrics of the space of one of the dimensions: 1==x, 2==y. | |
virtual int | SetSize (int which, long nmin, long nmax, long nps) |
Set the min/max, and adjust start,end based on nps. | |
virtual long | GetCurPos (int which, long *curpos=NULL, long *curposend=NULL) |
Return the start of x (which==1) or y (which==2) dimension. | |
virtual long | SetCurPos (int which, long pos) |
Set the start. Shortcut for calling Shift(pos-start). | |
virtual long | SetCurPos (int which, long poss, long pose) |
Set the start and the end. | |
virtual int | validateSelbox (int which=3) |
Make sure the selbox is completely in wholebox or vice versa, as necessary. | |
virtual int | adjustSelbox (int which=2, char validatetoo=1) |
Reconfigure the selbox based on boxaspect and pixelaspect. | |
virtual int | Center (int which=3) |
Make the whole and sel centers coincide. 1=x, 2=y, 0=neither, other=both. | |
virtual long | Shift (int which, long d, long wholelen=0, long boxlen=0) |
Shift the selbox x or y (if which==1 or 2) sel box by d units coords where whole maps to max-min+1. | |
virtual int | ShiftEnd (int which, long d, int center=0, long wholelen=0, long boxlen=0) |
Shift the screen sel box end by de units. wholelen maps to whole space (max-min+1). | |
virtual int | ShiftStart (int which, long ds, int center=0, long wholelen=0, long boxlen=0) |
Shift the screen sel box start by de units. wholelen maps to whole space (max-min+1). | |
virtual long | OneUp (int which) |
Move selbox one element size in the negative direction. | |
virtual long | OneDown (int which) |
Move selbox one element size in the positive direction. | |
virtual long | PageUp (int which, int numpages=1) |
Move selbox one page size in the negative direction. | |
virtual long | PageDown (int which, int numpages=1) |
Move selbox one page size in the positive direction. | |
virtual void | sendMessages () |
Send messages to all who want to know what's what with the pan. | |
virtual void | tell (anXWindow *win) |
Push win onto the stack of windows to notify of changes. | |
virtual void | tellPop (anXWindow *win=NULL) |
Pop win from the tellstack. If win==NULL, then flush the tellstack. | |
virtual void | dontTell (anXWindow *win) |
Exhempt win from getting messages sent to it, until dontTell(NULL) or dontTell(someotherwindow) is called. | |
Public Member Functions inherited from Laxkit::anObject | |
anObject () | |
Set object_id=getUniqueNumber(). | |
virtual | ~anObject () |
Empty virtual destructor. | |
virtual const char * | whattype () |
Returns the type of anObject. | |
virtual anObject * | duplicate (anObject *ref=NULL) |
virtual int | inc_count () |
Increment the data's count by 1. Returns count. | |
virtual int | dec_count () |
Decrement the count of the data, deleting if count is less than or equal to 0. | |
virtual int | the_count () |
Public Attributes | |
anXWindow * | donttell |
unsigned int | pan_style |
Style of the controller. | |
int | sendstatus |
long | minsel [2] |
The minimum allowable selection which == end-start+1. | |
long | maxsel [2] |
The maximum allowable selection which == end-start+1. | |
long | min [2] |
The minimum coordinate of the space (min[0],min[1]). | |
long | max [2] |
The maximum coordinate of the space (max[0],max[1]). | |
long | start [2] |
The minimum coordinate of the selection box (start[0],start[1]). | |
long | end [2] |
The maximum coordinate of the selection box (end[0],end[1]). | |
long | pagesize [2] |
The pagesize used when calling PageUp/Down. | |
long | elementsize [2] |
The element used when calling OneUp/Down. | |
int | boxaspect [2] |
Basically the aspect of the window corresponding to the selection box. | |
double | pixelaspect |
The relative scaling between x and y: (pixel width/pixel height). | |
Public Attributes inherited from Laxkit::anObject | |
int | suppress_debug |
DeleteRefCountedFunc | deleteMe |
Called when the count is decremented to 0. | |
unsigned long | object_id |
char * | object_idstr |
Protected Attributes | |
PtrStack< anXWindow > | tellstack |
Stack of windows to notify when settings change. | |
Protected Attributes inherited from Laxkit::anObject | |
int | _count |
The reference count of the object. |
A convenience for scroller types of things.
This class keeps track of one rectangle (herein referred to as the selbox) sliding around in (or around) another rectangle (hereafter referred to as the wholebox). Also can handle zooming. It is used, for instance, by Scroller, particularly when the Scroller is one of a pair, and they both have zoom handles.
This class is a little comparable to the Adjustment widget of Gtkmm, except that it is 2 dimensional, and handles zooming.
The rectangle that is the bounds of workspace runs x: [min[0],max[0]] and y: [min[1],max[1]]. The amount supposedly viewable is [start,end] within that range. Internally, the positions and bounds are stored as type long.
Get/set pagesize, clean up the Get/Set to be more like fltk (overloaded functions?)
*** must work out when messages are actually sent, by which functions.. don't want to unnecessarily duplicate messages.
*** please note that panuser/pancontroller setup is hell with threads..
pan_style holds:
Laxkit::PanController::PanController | ( | long | xmin, |
long | xmax, | ||
long | xstart, | ||
long | xend, | ||
long | ymin, | ||
long | ymax, | ||
long | ystart, | ||
long | yend, | ||
int | w, | ||
int | h, | ||
unsigned long | panstyle = PANC_ELEMENT_IS_PERCENT|PANC_PAGE_IS_PERCENT |
||
) |
Constructor.
|
virtual |
Destructor, turns off the panner in any PanUser in tellstack.
This is done by calling UseThisPanner(NULL) on anything that can be cast to PanUser. This prevents any PanUser classes from calling a panner that has just been destroyed. This of course assumes that the panner is destroyed before those windows!! Otherwise the pointers in the tellstack may not point to valid values.
IMPORTANT: For this destructing mechanism to work, in your class definition of the PanUser-derived class, you MUST declare the PanUser BEFORE the window part, otherwise the PanUser will not pop itself from this tellstack during its destructor.
The tellstack is not flushed here. It flushes in the natural automatic way.
Reconfigure the selbox based on boxaspect and pixelaspect.
If which is nonzero, then try to keep which's metrics. That is to say, the selbox in which dimension stays the same, and others is adjusted to match it. Default is to keep y. It is assumed that the start/end for which are already valid.
Internally, this is called by SetBoxAspect and SetPixelAspect.
Make the whole and sel centers coincide. 1=x, 2=y, 0=neither, other=both.
The changes are made to start and end, not to min and max.
Returns which had to be changed.
|
virtual |
Exhempt win from getting messages sent to it, until dontTell(NULL) or dontTell(someotherwindow) is called.
There can only be one exhemption at a time.
Referenced by Laxkit::Displayer::syncPanner(), and Laxkit::Displayer::WrapWindow().
|
virtual |
Compute the new pixelaspect based on other info.....
boxaspect = pixelaspect * (selboxwidth/selboxheight)
If max[0]-min[0]==0 then return 1.0, else the new pixelaspect.
|
virtual |
Return the start of x (which==1) or y (which==2) dimension.
If curpos or curposend are not NULL, then the start and end are put there.
Referenced by Laxkit::MenuSelector::findItem(), Laxkit::MenuSelector::findRect(), Laxkit::Scroller::GetCurPos(), Laxkit::Scroller::GetCurPosEnd(), Laxkit::TreeSelector::movescreen(), Laxkit::Scroller::send(), and Laxkit::Displayer::syncFromPanner().
|
virtual |
Get the horizontal (which==1) or vertical(=2) magnification of the box to the screen (screen=Getmag*real)
Use this when you have a screen size boxwidth that must correspond to the selection box. If wholestart/endret are not NULL, then return what would be the whole space start and end if viewed in screen coordinates. The origin is taken to be the start of the transformed box (screen coords).
If boxwidth<=0, then use end-start+1 as boxwidth.
Note that end-start+1 must != 0 or else your program will crash!
Referenced by Laxkit::Scroller::drawtrackbox(), and Laxkit::Scroller::getpos().
|
virtual |
Get the horizontal (which==1) or vertical(=2) magnification of the whole space to the screen (screen=Getmag*real)
Use this when you have a screen size trackwidth that must correspond to the whole space. If boxstart/endret are not NULL, then return what would be the selection box start and end if viewed in screen coordinates. Coordinates are scaled so that the whole space maps to the range [0,trackwidth].
If trackwidth<=0, then use max-min+1 as trackwidth.
This is akin to getting the placement of a track box in a scroller window.
Referenced by Laxkit::PanWindow::centerOnMouse(), Laxkit::Scroller::drawtrackbox(), Laxkit::Scroller::getpos(), and Laxkit::PanWindow::Refresh().
|
virtual |
Move selbox one element size in the positive direction.
Returns the amount of change (new start-old start).
Referenced by Laxkit::Scroller::OneUp().
|
virtual |
Move selbox one element size in the negative direction.
Returns the amount of change (new start-old start).
Referenced by Laxkit::Scroller::OneDown().
Move selbox one page size in the positive direction.
Returns the amount of change (new start-old start).
Referenced by Laxkit::Scroller::PageUp().
Move selbox one page size in the negative direction.
Returns the amount of change (new start-old start).
Referenced by Laxkit::Scroller::PageDown().
|
virtual |
Send messages to all who want to know what's what with the pan.
If sendstatus!=1, then no messages are sent.
The message is filled thus:
info1=start[0]; info2=end[0]; info3=start[1]; info4=end[1];
Set the preferred dimensions of a target window.
Any zooming done tries to preserve the aspect w/h. These values basically would correspond to a window's width and height. This is separate from pixelaspect so as to preserve the zooming ratio between x and y while adjusting the actual shape of the selbox.
Basically, the selbox width/height is equal to boxaspect/pixelaspect.
Referenced by Laxkit::ScrolledWindow::init(), Laxkit::ScrolledWindow::syncWindows(), and Laxkit::Displayer::WrapWindow().
|
virtual |
Set the start. Shortcut for calling Shift(pos-start).
Returns the new pos minus the old pos.
Referenced by Laxkit::TreeSelector::arrangeItems(), Laxkit::MenuSelector::arrangeItems(), Laxkit::Scroller::SetCurPos(), Laxkit::DoublePanner::syncPanner(), and Laxkit::Displayer::syncPanner().
|
virtual |
Set the start and the end.
currently just sets start/end, calls validateSelbox
Returns the new pos minus the old pos.
|
virtual |
Set the level of difference between x and y zoom.
Nothing is changed if npixaspect is <=0.
Suppose you want pixels to be twice as wide as tall, then pixelaspect=2. Basically, the selbox width/height is equal to boxaspect/pixelaspect.
boxaspect = pixelaspect * (selboxwidth/selboxheight)
|
virtual |
Set the minimum selection size and maximum selection size.
Referenced by Laxkit::DoublePanner::DoublePanner(), and Laxkit::Displayer::syncPanner().
Set the min/max, and adjust start,end based on nps.
nps is used to set things so that end-start+1==nps. The pagesize[] is not modified, same goes for nes. start is changed only if necessary to accomodate nps.
Does not try to synchronize the other dimension.
Returns which on success.
Referenced by Laxkit::Scroller::SetSize().
|
virtual |
Set the metrics of the space of one of the dimensions: 1==x, 2==y.
If PANC_PAGESIZE_IS_PERCENT, then nps is a percent, not absolute coordinates. and same goes for nes.
If posstart<nmin, then make posstart=nmin. Same for posend. If posend>nmax then make posend=nmax, same for posstart. if nps or nes are <=0, then do not change them.
This also sets boxaspect to be end-start+1.
Return 1 if stuff was set, else 0.
Referenced by Laxkit::Scroller::dump_in_atts(), Laxkit::Scroller::Scroller(), and Laxkit::Scroller::SetSize().
|
virtual |
Set both the dimensions of the workspace, preserving proportionally the selbox.
Returns the value of validateSelbox, which should indicate whether some other values had to be changed.
Referenced by Laxkit::TreeSelector::arrangeItems(), Laxkit::MenuSelector::arrangeItems(), Laxkit::DoublePanner::syncPanner(), and Laxkit::Displayer::syncPanner().
|
virtual |
Shift the selbox x or y (if which==1 or 2) sel box by d units coords where whole maps to max-min+1.
If wholelen==0, then d is in space units.
If the wholebox is larger than the selbox, then the selbox can move freely around within the wholebox. If the wholebox is smaller than the selbox, then the wholebox can move freely around within the selbox, as long as PANC_ALLOW_SMALL is set. Then, if PANC_CENTER_SMALL is set, then the whole box is always centered within the selbox. Thus one box can fully contain the other box. Partial containment is not allowed. *** must check for this in the other functions!!
Returns the amount of change (newpos-oldpos).
Referenced by Laxkit::TreeSelector::makeinwindow(), Laxkit::MenuSelector::makeinwindow(), Laxkit::Scroller::MouseMove(), Laxkit::MenuSelector::movescreen(), and Laxkit::TreeSelector::movescreen().
|
virtual |
Shift the screen sel box end by de units. wholelen maps to whole space (max-min+1).
This basically zooms. Say which=1, de is nonzero. Then x is scaled up (or down) proportionally. The y start and end are changed so that after the expansion (or contraction) of the y selection box, its center doesn't move (if possible). If PANC_SYNC_XY is not set, then y start and end are not affected by changes in x, and vice versa.
This action is equivalent to dragging a zoom handle in a Scroller. If center is nonzero, then move the start point the same amount the end point is moved.
Return 1 if x info changes, 2 if y changes, 3 if both change.
Referenced by Laxkit::Scroller::MouseMove().
|
virtual |
Shift the screen sel box start by de units. wholelen maps to whole space (max-min+1).
This basically zooms. Say which=1, de is nonzero. Then x is scaled up (or down) proportionally. The y start and end are changed so that after the expansion (or contraction) of the y selection box, its center doesn't move (if possible). If PANC_SYNC_XY is not set, then y start and end are not affected by changes in x, and vice versa.
This action is equivalent to dragging a zoom handle in a Scroller. If center is nonzero, then move the start point the same amount the end point is moved.
Return 1 if x info changes, 2 if y changes, 3 if both change.
Referenced by Laxkit::Scroller::MouseMove().
|
virtual |
Pop win from the tellstack. If win==NULL, then flush the tellstack.
If the window is already on the stack, it is not pushed again.
References Laxkit::anXWindow::WindowTitle().
Referenced by LaxInterfaces::ViewportWindow::UseTheseScrollers(), Laxkit::ScrolledWindow::UseThisWindow(), and Laxkit::PanUser::~PanUser().
Make sure the selbox is completely in wholebox or vice versa, as necessary.
Returns 1 if x needed to be adjusted, 2 if y, 3 if both. Note that if PANC_ALLOW_SMALL is not set, then the selbox has to be contained by the wholebox, and the selbox is scaled to as necessary. Otherwise, then either selbox is in whole or whole is in selbox is ok. If both PANC_ALLOW_SMALL and PANC_CENTER_SMALL are set, then whenever the selbox is larger than the wholebox, then the wholebox is centered in the selbox.
This assumes the selbox is already ok according to boxaspect and pixelaspect.
Internally, this function is called by SetCurPos, SetWholebox, and adjustSelbox, and indirectly (through adjustSelbox) from SetPixelAspect and SetBoxAspect.
Should return which dim had to be adjusted. *** must check that..
int Laxkit::PanController::boxaspect[2] |
Basically the aspect of the window corresponding to the selection box.
This is stored so that zooming by dragging control handles in one dimension causes the proper changes in the other dimension.
Referenced by Laxkit::DoublePanner::DoublePanner(), operator=(), and PanController().
long Laxkit::PanController::elementsize[2] |
The element used when calling OneUp/Down.
If PANC_ELEMENT_IS_PERCENT is set in pan_style, then elementsize is that percent (100=100%) of the selbox size. Otherwise, elementsize is that absolute number of whole space units.
Referenced by Laxkit::Scroller::dump_out_atts(), operator=(), and PanController().
long Laxkit::PanController::pagesize[2] |
The pagesize used when calling PageUp/Down.
If PANC_PAGE_IS_PERCENT is set in pan_style, then pagesize is that percent (100=100%) of the selbox size. Otherwise, pagesize is that absolute number of whole space units.
Referenced by Laxkit::Scroller::dump_out_atts(), operator=(), and PanController().
double Laxkit::PanController::pixelaspect |
The relative scaling between x and y: (pixel width/pixel height).
boxaspect = pixelaspect * (selboxwidth/selboxheight)
Referenced by Laxkit::DoublePanner::DoublePanner(), operator=(), and PanController().
Stack of windows to notify when settings change.
If the windows in tellstack can be cast to PanUser, then proper deleting procedures will occur. That is, when either a window or a panner is deleted, the relevant members in the other are reset.