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

A window with resizable panes than can be split and joined. More...

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

List of all members.

Public Member Functions

 SplitWindow (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 owner, const char *mes)
 Constructor, merely set space=6.
virtual const charwhattype ()
virtual int init ()
 Adds a single blank pane.
virtual int LBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Initiates a resizing action, split (cntl-click), or join (shift-click).
virtual int LBUp (int x, int y, unsigned int state, const LaxMouse *d)
virtual int RBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 Pops up the join/split/change window.
virtual int RBUp (int x, int y, unsigned int state, const LaxMouse *d)
virtual int MouseMove (int x, int y, unsigned int state, const LaxMouse *d)
 Move the Mouse.
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *d)
virtual int FocusOn (const FocusChangeData *e)
virtual int FocusOff (const FocusChangeData *e)
virtual int Event (const EventData *e, const char *mes)
 Must keep track of where the mouse enters from...
virtual int MoveResize (int nx, int ny, int nw, int nh)
 MoveResize, calls scaleWindows to perform the scaling.
virtual int Resize (int nw, int nh)
 Resize, calls scaleWindows to perform the scaling.
virtual void Refresh ()
 Refresh, draw boxes with an x through them for any NULL areas, and bevel if necessary.
virtual int AddWindowType (const char *wtype, const char *ndesc, unsigned long style, NewWindowFunc winfunc, int settodefault=0)
 Register a new window making function.
virtual void BoxNearPos (int x, int y, PlainWinBox *box, int *l, int *r, int *t, int *b)
 Check for any edge of box within space of x,y.
virtual void PosInBox (int x, int y, PlainWinBox *box, int *xx, int *yy)
 Check if x,y is within a box, -1 is too negative, 1 is too positive, 0 is inside it.
virtual void SetSpace (int spc)
 Set the space between windows.
virtual int Split (int c, int whichside, anXWindow *fillwindow=NULL)
 Split the window corresponding to pane index c (or curbox if c<0), put in fillwindow.
virtual int Join (int c, int whichside, char keepother=0)
 Join pane index c (or curbox if c<0) with the window on whichside (LAX_LEFT, etc).
virtual int Mark (int c)
 Set marked to pane index c, or curbox if c==-1.
virtual int SwapWithMarked ()
 Called on "popupsplitmenu" client message with id==4.
virtual int Curbox (int c)
 Make curbox this pane, which is an index into windows.
virtual int FindBox (int x, int y)
 Return the index of the box that x,y is in, or -1.
virtual int FindBox (anXWindow *newcurbox)
 Find the box containing win. Checks to make sure win is an immediate child of this.
virtual int FindBoxIndex (PlainWinBox *box)
 Return the index in windows corresponding to box, else return < 0.
virtual int Change (anXWindow *towhat, int absorbcount, int which)
 Change the window in pane which (or curbox if which<0) to towhat.
virtual int Add (anXWindow *win, unsigned int whichside=LAX_BOTTOM, int absorbcount=0)
 This adds a whole section rather than simply splitting windows.
virtual int Add (const char *type, unsigned int whichside=LAX_BOTTOM)
 Add a new one based on type: return Add(NewWindow(type),whichside);.
virtual int RemoveCurbox ()
 Try to join curbox to an adjacent box.
virtual int GetAffected (int x, int y, const LaxMouse *m)
 Figure out which windows can possibly be moved with a click and drag from (x,y).
virtual int SetCursor (const char *curs, LaxMouse *d)
 Set cursor based on curs.
virtual void validateX ()
virtual void validateY ()
virtual int Maximize (int which)
 Toggle curbox maximized if which==-1, or maximize (1) or un-maximize(0).
virtual int Mode ()
 Return mode.
- 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 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 int Idle (int tid=0)
 anXWindow::Idle() is an empty placeholeder. Just returns 1.
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 WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d)
 The wheel mouse rolling up. Default is just to return 1.
virtual int WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
 The wheel mouse rolling down. Default is just to return 1.
virtual void contentChanged ()
 Windows may call this when their contents change.
virtual void selectionChanged ()
 Windows may call this when their selections change.
virtual anXWindowGetController ()
 Return the window most relevant for tab control loops.
virtual int SelectNextControl (const LaxDevice *d)
 Transfer focus to nextcontrol.
virtual int SelectPrevControl (const LaxDevice *d)
 Transfer the focus to prevcontrol.
virtual void ControlActivation (int on)
 Do special activation or not when controls are activated by tabbing.
virtual int AddPrevControl (anXWindow *prev)
virtual int AddNextControl (anXWindow *next)
virtual int ConnectControl (anXWindow *towhat, int after=1)
 Connect towhat to this. Used for tab loops.
virtual int CloseControlLoop ()
 Close a tab loop.
virtual void SetOwner (anXWindow *nowner, const char *mes=NULL, unsigned int send_mask=0)
 Set the new owner and control message.
virtual void SetOwner (unsigned long nowner_id, const char *mes=NULL, unsigned int send_mask=0)
virtual void dump_out (FILE *f, int indent, int what, anObject *context)
 Simple dumping function.
virtual LaxFiles::Attributedump_out_atts (LaxFiles::Attribute *att, int what, anObject *context)
virtual void dump_in_atts (LaxFiles::Attribute *att, int flag, anObject *context)
- Public Member Functions inherited from Laxkit::Tagged
virtual int HasTag (const char *tag, int casematters)
 Return whether the tag exists.
virtual int NumberOfTags ()
 Return the number of tags, strangely enough.
virtual const charGetTag (int i)
 Return const pointer to the tag text for tag number i, where i==0 is the first tag.
virtual charGetAllTags ()
 Return a new char[] with a space separated list of all the tags.
virtual int InsertTags (const char *tags, int casematters)
 Insert tags from a string such as 'tag1 tag2 tag3 "tag with spaces" tag4'.
virtual int InsertTag (const char *tag, int casematters)
 Insert tag if it doesn't exist already.
virtual int RemoveTag (const char *tag)
 The tag must be an exact match.
virtual int RemoveTag (int i)
 Remove tag number i. i must be in range [0..NumberOfTags()-1].
virtual void FlushTags ()
- Public Member Functions inherited from LaxFiles::DumpUtility
virtual void dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att)
 Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts.
virtual ~DumpUtility ()
 Empty virtual destructor.
- Public Member Functions inherited from Laxkit::aDrawable
 aDrawable (Drawable d=0)
virtual int DrawableType ()
virtual int ValidDrawable ()

Protected Member Functions

virtual void scaleWindows ()
 Scale all the child windows to fit current win_w/h using proportions of oldw/h.
virtual void drawmovemarks (int on=1)
 Draw vertical and/or horizontal lines when adjusting window boundaries.
virtual void drawsplitmarks ()
 Draw the line showing where a window will be split.
virtual PlainWinBoxfindcurbox (int x, int y, const LaxMouse *mouse)
 Find and set the current box based on whether the mouse is in the pane or not.
virtual void setupsplit (int x, int y)
 Determine whether to split vertically or horizontally and set mode accordingly.
virtual int splitthewindow (anXWindow *fillwindow=NULL, int whichside=0)
 Called usually from LBUp (for which fill=NULL), splits curbox along curx or cury if mode==HORIZ_SPLIT or VERTICAL_SPLIT.
virtual int joinwindow (int x, int y, char keepother)
 Join curbox along the edge closest to (x,y).
virtual void syncaffected ()
 Sync the affected windows after a drag so that the gap is centered on curx/y.
virtual anXWindowNewWindow (const char *wtype, anXWindow *likethis=NULL)
 Create a window by calling the winfuncs entry corresponding to wtype.
virtual MenuInfoGetMenu ()
 Build and return a menu based on what can be done to curbox.
- 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 mousein
PtrStack< PlainWinBoxwindows
PlainWinBoxcurbox
PlainWinBoxmarked
int space
 The pixel length of the gap between windows.
int bevel
int minx
 The minimum x coordinate to allow edges to be dragged.
int curx
 The current x coordinate during an edge drag.
int maxx
 The maximum x coordinate to allow edges to be dragged.
int miny
 The minimum y coordinate to allow edges to be dragged.
int cury
 The current y coordinate during an edge drag.
int maxy
 The maximum y coordinate to allow edges to be dragged.
int sminx
 The minimum x coordinate of ***.
int smaxx
 The maximum x coordinate of ***.
int sminy
 The minimum y coordinate of ***.
int smaxy
 The maximum y coordinate of ***.
int mx
int my
int mode
 What's happening: move, join, split.
anXWindowlastactivewindow
NumStack< intlaffected
 Windows whose left edge is affected by a mouse move stored here.
NumStack< intraffected
 Windows whose right edge is affected by a mouse move stored here.
NumStack< inttaffected
 Windows whose top edge is affected by a mouse move stored here.
NumStack< intbaffected
 Windows whose bottom edge is affected by a mouse move stored here.
PtrStack< WinFuncNodewinfuncs
int defaultwinfunc
- 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

Additional Inherited Members

- 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

Detailed Description

A window with resizable panes than can be split and joined.

This frame is similar to the windows found in the program Blender, and the Ion window manager. It is so cool, Laxkit just had to have its own.

Uses PlainWinBox to store the windows. The w,h of those boxes are the windows' w and h plus their borders.

SPLIT_BEVEL draws a bevel around the panes in the space between them. SPLIT_DRAG_MAPPED will resize the panes as the edges are dragged, rather than just show lines moving.

#define SPLIT_WITH_SAME (1<<16) ***todo
#define SPLIT_WITH_DEFAULT (1<<17) ***todo
#define SPLIT_WITH_BLANK (1<<18) ***todo
#define SPLIT_BEVEL (1<<19)
#define SPLIT_DRAG_MAPPED (1<<20)
#define SPLIT_STACKED_PANES (1<<21) ***todo
#define SPLIT_TABBED_PANES (1<<22) ***todo
#define SPLIT_NO_MAXIMIZE (1<<23) ***todo do and not do!
Todo:

*** Resizing should be redone, it is not reversible owning to integer rounding errors. perhaps have PlainWinBox have float x,y,w,h to shadow the windows actual values? or just finish imping validateX() and validateY()

*** maximize/minimize with alt-numpad-/ or some such

*** implement optional stack of windows for each pane. each is accessible how(??? tabbed window? through menu), then have option to spread out the stack into separate boxes?


Member Function Documentation

int Laxkit::SplitWindow::Add ( anXWindow win,
unsigned int  whichside = LAX_BOTTOM,
int  absorbcount = 0 
)
virtual

This adds a whole section rather than simply splitting windows.

whichside is LAX_LEFT, LAX_RIGHT, LAX_TOP, or LAX_BOTTOM. If whichside is not any of those, then the window is added to the bottom. It is ok to add a NULL window.

If there is only one box in the whole window, and it is an empty box (no window in it) then the new window is put in it. Whole window is divided in half, and the existing windows are squished down. The new window is inserted into the new space.

If win->window==0 then the window is addwindow'd if this->window!=0.

Returns 0 if window is added. Nonzero otherwise.

Todo:

*** TODO: If lots of adding goes on before creating the window, or just after creating when the dimensions are meaningless, should have some mechanism to keep the stacking order when the windows are scaled properly!! have a flag that gets turned off in init?

*** when head->window==0 and win is parented elsewhere, does this work correctly?

References Laxkit::anObject::dec_count(), Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::n, Laxkit::PlainWinBox::NewWindow(), Laxkit::PtrStack< T >::push(), Laxkit::anXApp::reparent(), scaleWindows(), space, and Laxkit::PlainWinBox::sync().

Referenced by Add().

int Laxkit::SplitWindow::AddWindowType ( const char wtype,
const char ndesc,
unsigned long  style,
NewWindowFunc  winfunc,
int  settodefault = 0 
)
virtual

Register a new window making function.

These functions can be used in split and change functions to fill the new windows with specific types of windows.

The style gets passed as the window style when calling winfunc. wtype should be the whattype() of the window. ndesc can be a more free form name.

Returns 0 on success, nonzero on failure.

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

void Laxkit::SplitWindow::BoxNearPos ( int  x,
int  y,
PlainWinBox box,
int l,
int r,
int t,
int b 
)
virtual

Check for any edge of box within space of x,y.

Assumes that l,r,t,b are all already allocated pointers to int, and this function fills them with -1,0, or 1, depending on whether the corresponding box edge is less than, near, or greater than a box centered on x,y with width 2*space.

References space.

int Laxkit::SplitWindow::Change ( anXWindow towhat,
int  absorbcount,
int  which 
)
virtual

Change the window in pane which (or curbox if which<0) to towhat.

The old window gets app->destroywindow'd.

If absorbcount!=0, then take possession of one count of towhat. Otherwise, the calling code will have to dec_count whatever count it had.

If there is an error, the count is NOT absorbed.

Return 0 if window taken, else nonzero error.

References Laxkit::anObject::dec_count(), Laxkit::anXApp::destroywindow(), Laxkit::PtrStack< T >::e, mode, Laxkit::anXWindow::MoveResize(), Laxkit::PtrStack< T >::n, Laxkit::PlainWinBox::NewWindow(), Laxkit::anXApp::reparent(), space, and Laxkit::PlainWinBox::sync().

Referenced by Event().

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

'/' on the keypad will maximize or de-maximize the current pane.

Reimplemented from Laxkit::anXWindow.

References Curbox(), drawsplitmarks(), FindBox(), Maximize(), mode, Laxkit::mouseposition(), and Laxkit::anXWindow::WindowTitle().

int Laxkit::SplitWindow::Curbox ( int  c)
virtual

Make curbox this pane, which is an index into windows.

You cannot force curbox to be NULL. Checks to make sure c is valid index of windows. Return c if curbox changed or was already curbox. If there was no curbox, and c<0 then return -1. Else return -2.

This function is called whenever curbox is changed. This is particularly useful for derived classes that want to keep track of the last focused text box or view box or whatever.

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

Referenced by CharInput(), Event(), findcurbox(), Join(), and Split().

void Laxkit::SplitWindow::drawmovemarks ( int  on = 1)
protectedvirtual

Draw vertical and/or horizontal lines when adjusting window boundaries.

Draws a horizontal line from (minx,cury) to (maxx,cury) and a vertical line from (curx,miny) to (curx,maxy).

This is slightly different then the temporary lines that are drawn when a window is being split.

References baffected, curx, cury, Laxkit::draw_line(), Laxkit::drawing_function(), laffected, Laxkit::LAXOP_Source, Laxkit::NumStack< T >::n, raffected, Laxkit::rgbcolor(), smaxx, smaxy, sminx, sminy, and taffected.

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

void Laxkit::SplitWindow::drawsplitmarks ( )
protectedvirtual

Draw the line showing where a window will be split.

This draws a line by xor'ing with the screen, thus drawing the lines on, then off are done with the same operation.

References curx, cury, Laxkit::draw_line(), Laxkit::drawing_function(), Laxkit::LAXOP_Source, Laxkit::LAXOP_Xor, and mode.

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

int Laxkit::SplitWindow::Event ( const EventData e,
const char mes 
)
virtual

Must keep track of where the mouse enters from...

The joining, splitting, and resizing of windows depends on the edge that the mouse enters the spacing through. So EnterNotify, and focus events need special treatment....***

Also Catches 'popupsplitmenu'. See GetMenu().

For 1 (split), 2 (join), 3 (mark), 4 (swap with marked), 5 toggle temporary pane maximized it is assumed that mx and my are relevant coordinates.

100 means change to a blank pane. >=101 means change to window type n-101.

Reimplemented from Laxkit::anXWindow.

References Laxkit::ButtonDownInfo::any(), Change(), Curbox(), Laxkit::PtrStack< T >::e, FindBox(), Laxkit::anXApp::findwindow_by_id(), GetAffected(), joinwindow(), Mark(), Maximize(), mode, Laxkit::PtrStack< T >::n, setupsplit(), splitthewindow(), and SwapWithMarked().

int Laxkit::SplitWindow::FindBox ( int  x,
int  y 
)
virtual

Return the index of the box that x,y is in, or -1.

This must be in the seen box. That is, excluding the gap.

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

Referenced by CharInput(), Event(), and findcurbox().

int Laxkit::SplitWindow::FindBox ( anXWindow win)
virtual

Find the box containing win. Checks to make sure win is an immediate child of this.

Return the index in windows (so >=0 if it is there) of the box containing win. Else return -1.

Does not change curbox.

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

PlainWinBox * Laxkit::SplitWindow::findcurbox ( int  x,
int  y,
const LaxMouse mouse 
)
protectedvirtual

Find and set the current box based on whether the mouse is in the pane or not.

If x,y are found to be within the bounds of a box, then that becomes the current box. Otherwise, if curbox exists already then it is not changed. If cubox was NULL, then the last focused window is the current box, that is to say the immediate child of the SplitWindow that last held the focus (or any of the child's descendents).

This is called by setupsplit() if !curbox, and LBDown() (always).

References Curbox(), Laxkit::PtrStack< T >::e, FindBox(), Laxkit::anXApp::findwindow_by_id(), Laxkit::PtrStack< T >::n, and space.

Referenced by Maximize(), MouseMove(), and setupsplit().

int Laxkit::SplitWindow::GetAffected ( int  x,
int  y,
const LaxMouse m 
)
virtual

Figure out which windows can possibly be moved with a click and drag from (x,y).

This modifies the [lrtb]affected stacks to reflect what would need to be changed if one were to start dragging right there. Also sets the segment min/max[xy], and figures out what the mouse should look like. and sets it. All the windows that touch the min/max segments get adjusted when the mouse moves.

Todo:
*** this should probably be redone to not be very dependent on space. that would allow recovering from resizing to really small windows easier..

References baffected, curx, cury, Laxkit::NumStack< T >::e, Laxkit::PtrStack< T >::e, Laxkit::NumStack< T >::flush(), laffected, maxx, maxy, minx, miny, Laxkit::NumStack< T >::n, Laxkit::PtrStack< T >::n, Laxkit::NumStack< T >::push(), raffected, SetCursor(), smaxx, smaxy, sminx, sminy, space, and taffected.

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

MenuInfo * Laxkit::SplitWindow::GetMenu ( )
protectedvirtual

Build and return a menu based on what can be done to curbox.

Makes menu with 'Split', 'Join', and all the desc members of objects in winfuncs in a submenu for 'Change'.

The message sent has data.l[0]==curitem, and data.l[1]==id:

  Split –> 1
  Join  –> 2
  Change to:
    winfunc number i (starting from 0)–> 101+i
    (Blank) –> 100
  Mark  –> 3
  Swap with Marked  –> 4
  Maximize (Or Reduce) –> 5
 
Todo:
*** swap with....

References Laxkit::MenuInfo::AddItem(), Laxkit::PtrStack< T >::e, Laxkit::MenuInfo::EndSubMenu(), mode, Laxkit::PtrStack< T >::n, and Laxkit::MenuInfo::SubMenu().

Referenced by RBDown().

int Laxkit::SplitWindow::Join ( int  c,
int  whichside,
char  keepother = 0 
)
virtual

Join pane index c (or curbox if c<0) with the window on whichside (LAX_LEFT, etc).

If c<0, then join curbox. Default is to preserve pane c.

Returns the pane index of the remaining window, or -1 if illegal join.

Todo:
*** test this

References Curbox(), Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::findindex(), joinwindow(), and Laxkit::PtrStack< T >::n.

Referenced by RemoveCurbox().

int Laxkit::SplitWindow::joinwindow ( int  x,
int  y,
char  keepother 
)
protectedvirtual

Join curbox along the edge closest to (x,y).

If keepother, then the window of curbox removed rather than the other one.

Return 0 on success. Return 1 if if curbox==NULL. Return 2 if (x,y) is not near an edge of curbox. Return 3 if illegal join.

Todo:
*** when windows are joined, what happens to the vanquished one? store it in limbo?

References Laxkit::anXApp::destroywindow(), Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::findindex(), Laxkit::PtrStack< T >::n, Laxkit::PlainWinBox::NewWindow(), Laxkit::PtrStack< T >::remove(), space, and Laxkit::PlainWinBox::sync().

Referenced by Event(), Join(), LBDown(), and RemoveCurbox().

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

Initiates a resizing action, split (cntl-click), or join (shift-click).

Todo:
Straight clicking starts a move on the whole continuous segment. would be neat if double clicking moved only the primary windows.

Reimplemented from Laxkit::anXWindow.

References baffected, curx, cury, Laxkit::ButtonDownInfo::down(), drawmovemarks(), drawsplitmarks(), Laxkit::NumStack< T >::e, Laxkit::PtrStack< T >::e, GetAffected(), Laxkit::ButtonDownInfo::isdown(), joinwindow(), laffected, mode, Laxkit::NumStack< T >::n, raffected, setupsplit(), taffected, and Laxkit::anXApp::unmapwindow().

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

Split if mode==VERTICAL_SPLIT || mode==HORIZ_SPLIT.

Reimplemented from Laxkit::anXWindow.

References drawmovemarks(), drawsplitmarks(), Laxkit::ButtonDownInfo::isdown(), mode, splitthewindow(), syncaffected(), and Laxkit::ButtonDownInfo::up().

int Laxkit::SplitWindow::Maximize ( int  which)
virtual

Toggle curbox maximized if which==-1, or maximize (1) or un-maximize(0).

Return 1 for is now maximized, or 0 for not, or -1 if you cannot change the maximization state for current mode, or -2 for curbox cannot be found.

To maximize, mode must previously have been 0.

If there is only one window, you cannot put the window in maximized mode.

References Laxkit::PtrStack< T >::e, findcurbox(), mode, Laxkit::anXWindow::MoveResize(), Laxkit::PtrStack< T >::n, space, Laxkit::PlainWinBox::sync(), and Laxkit::anXApp::unmapwindow().

Referenced by CharInput(), and Event().

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

Move the Mouse.

If nothing pressed, then GetAffected(). If left pressed, then move affected. If right pressed then pop up the split/join menu *** but mouse grab should have been transferred to the popup menu.

Reimplemented from Laxkit::anXWindow.

References Laxkit::ButtonDownInfo::any(), baffected, curx, cury, drawmovemarks(), drawsplitmarks(), findcurbox(), GetAffected(), Laxkit::ButtonDownInfo::isdown(), laffected, maxx, maxy, minx, miny, mode, Laxkit::ButtonDownInfo::move(), Laxkit::NumStack< T >::n, raffected, space, syncaffected(), and taffected.

anXWindow * Laxkit::SplitWindow::NewWindow ( const char wtype,
anXWindow likethis = NULL 
)
protectedvirtual

Create a window by calling the winfuncs entry corresponding to wtype.

Returns NULL if no such type exists.

If wtype is NULL, then use these: SPLIT_WITH_SAME assumes that winfunc names are the whattype() of the window, and fills the new space with a window of that type (wtype is that whattype, this function is called from splitthewindow()). SPLIT_WITH_DEFAULT returns a window of type defaultwinfunc. SPLIT_WITH_BLANK returns NULL.

Todo:
**** implement the SPLIT_*!!!!

If likethis!=NULL, then NewWindow should try to make the new window as much like it as possible. In this default SplitWindow, likethis is ignored.

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

Referenced by Add(), and splitthewindow().

void Laxkit::SplitWindow::PosInBox ( int  x,
int  y,
PlainWinBox box,
int xx,
int yy 
)
virtual

Check if x,y is within a box, -1 is too negative, 1 is too positive, 0 is inside it.

It is ok for xx or yy to be NULL.

References space.

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

Pops up the join/split/change window.

Todo:
*** should only pop a menu if in a blank pane or in gutter.. this is because uncaught mouse events are propagated in anXWindow...

Reimplemented from Laxkit::anXWindow.

References Laxkit::ButtonDownInfo::any(), GetMenu(), mode, and Laxkit::anXApp::rundialog().

int Laxkit::SplitWindow::RemoveCurbox ( )
virtual

Try to join curbox to an adjacent box.

If curbox->win, then app->destroywindow(curbox->win).

If curbox cannot be connected to another box, then 0 is returned. Else 1 is returned. Attempts to connect the curbox to the box near (mx,my).

Todo:
if the pane span is such that several windows might be expanded to cover it, then do that, rather than demand that 1 window can join to it.. The super fancy version would somehow figure out how to fill the void if no join is available (like a tatami mat)

References Laxkit::anXApp::destroywindow(), Laxkit::PtrStack< T >::findindex(), Join(), joinwindow(), Laxkit::PtrStack< T >::n, and Laxkit::PlainWinBox::NewWindow().

void Laxkit::SplitWindow::scaleWindows ( )
protectedvirtual

Scale all the child windows to fit current win_w/h using proportions of oldw/h.

This computes the old bounds of all the panes, then scales them to fit in this window, inset by space/2. If there are any boxes that end up with width or height less then space, then validateX() or validateY() are called. Those functions expand the windows back out. *** not necessary for double panes?

This function must be called after the window is resized, because it uses win_w and win_h as the new width and height.

References Laxkit::PtrStack< T >::e, mode, Laxkit::anXWindow::MoveResize(), Laxkit::PtrStack< T >::n, space, Laxkit::PlainWinBox::sync(), validateX(), and validateY().

Referenced by Add(), MoveResize(), and Resize().

int Laxkit::SplitWindow::SetCursor ( const char curs,
LaxMouse d 
)
virtual

Set cursor based on curs.

This is called from GetAffected(). Default is to use the typical up/down, left/right, or 4-way cursor. Subclasses might want to get super fancy and take into account the multitude of possibilities for cursors. They can also consult the [lrtb]affected stacks for more info. Those stacks must accurately be reflected by curs.

Return 1 for cursor changed, or 0.

   .  . .    .

   . .  . .  .

   .#### ####. 

   . .  .    .
   curs has info about the cursor: If there are no primaries, then the cursor is off the
   window, or is inside a box, or otherwise not near an edge, and curs="", else assuming 
   that there is no more than space
   between windows, curs will be some permutation of these:
    The well formed ones:
     "lr"       - vert gap,  cursor points left/right
    "tb"       | horiz gap, curs up/down
    "lrrtb"    < up/down/left
    "llrtb"    > up/down/right
    "lrbtt"    v l/r/down
    "lrbbt"    ^ l/r/up
    "llrrbbtt" + u/d/l/r
      These are on edges where there is only one side of a crack:
    "l"     on far left, use cursor up/down
    "lltb"  use l/u/d/r
    "lb"    low left corner, use u/d/l/r
    "lrbb"
    "b"
    "br"
    "r"
    "rrtb"
    "tr"
    "t"
    "lrtt"  top center, use l/r/t/b
    "lt"    up-left corner, use l/r/t/b
 

References baffected, laffected, Laxkit::NumStack< T >::n, raffected, and taffected.

Referenced by GetAffected().

void Laxkit::SplitWindow::SetSpace ( int  spc)
virtual

Set the space between windows.

! Add a window to the left of the last focused window, by splitting the last focused in half ! If nextto is not NULL, then add next to that rather than last focused.

Space values less than 2 and greater than 30 are rejected. The new space is the first even number less than or equal to spc.

Todo:
this needs checking so that skinny windows do not get negative width/height

References Resize(), and space.

void Laxkit::SplitWindow::setupsplit ( int  x,
int  y 
)
protectedvirtual

Determine whether to split vertically or horizontally and set mode accordingly.

Based on x,y, finds the edge of curbox nearest that point, and sets mode to HORIZ_SPLIT (to cut horizontally, making 2 boxes vertically) or VERTICAL_SPLIT (to cut vertically, making 2 boxes horizontally) accordingly.

Also sets curx,cury so that they are within the bounds of curbox.

References curx, cury, findcurbox(), mode, and space.

Referenced by Event(), LBDown(), and Split().

int Laxkit::SplitWindow::Split ( int  c,
int  whichside,
anXWindow fillwindow = NULL 
)
virtual

Split the window corresponding to pane index c (or curbox if c<0), put in fillwindow.

If whichside is LAX_RIGHT or LAX_LEFT then split horizontally, else vertically for LAX_TOP or LAX_BOTTOM. Otherwise the default is LAX_BOTTOM. The box is split, and fillwindow is put to the top, bottom, left, or right of the box, according to whichside. If fillwindow==NULL, then a default window is put there.

Returns the index in windows of the new part of the split, or a negative number for error. This can be -2 for mode isn't normal (might be maximized or in process for some other mode), or -1 for some other low level mix up.

Todo:
*** test this

References Curbox(), curx, cury, Laxkit::PtrStack< T >::e, Laxkit::PtrStack< T >::findindex(), mode, Laxkit::PtrStack< T >::n, setupsplit(), and splitthewindow().

int Laxkit::SplitWindow::splitthewindow ( anXWindow fillwindow = NULL,
int  whichside = 0 
)
protectedvirtual

Called usually from LBUp (for which fill=NULL), splits curbox along curx or cury if mode==HORIZ_SPLIT or VERTICAL_SPLIT.

This does the actual splitting of a pane. setupsplit() should have been called before this, which sets mode. mode is not changed within this function. whichside is mainly a hint for which side to put fillwindow. So if you pass LAX_LEFT for a vertical split, it will not make it actually a horizontal split.

fillwindow is reparented here. Note that the value in mode is not actually changed in this function.

Returns 0 if the window was actually split, nonzero error otherwise. Remember that the new window is on the top of the windows stack.

Current possible errors are:
1: There is no current box to split!
2: The split bar is too near the window's edge, so no split is possible.

References curx, cury, Laxkit::PtrStack< T >::e, mode, Laxkit::PtrStack< T >::n, NewWindow(), Laxkit::PtrStack< T >::push(), Laxkit::anXApp::reparent(), space, and Laxkit::PlainWinBox::sync().

Referenced by Event(), LBUp(), and Split().

int Laxkit::SplitWindow::SwapWithMarked ( )
virtual

Called on "popupsplitmenu" client message with id==4.

This does the work of swapping with a marked window. The built in swapping uses SplitWindow::marked, and only swaps within this window. Subclasses might redefine this to use any top level SplitWindow.

This function is called straight away from receiving the client message. Any checking that a swap should proceed should be done within this function.

References Laxkit::anObject::dec_count(), Laxkit::anObject::inc_count(), Laxkit::PlainWinBox::NewWindow(), space, and Laxkit::PlainWinBox::sync().

Referenced by Event().

void Laxkit::SplitWindow::syncaffected ( )
protectedvirtual

Sync the affected windows after a drag so that the gap is centered on curx/y.

This is called to aid updating of window dragging from MouseMove() if SPLIT_DRAG_MAPPED. and otherwise from LBUp() only.

References baffected, curx, cury, Laxkit::PtrStack< T >::e, laffected, Laxkit::NumStack< T >::n, raffected, space, Laxkit::PlainWinBox::sync(), and taffected.

Referenced by LBUp(), and MouseMove().

void Laxkit::SplitWindow::validateX ( )
virtual
Todo:
***

Referenced by scaleWindows().

void Laxkit::SplitWindow::validateY ( )
virtual
Todo:
***

Referenced by scaleWindows().


Member Data Documentation

int Laxkit::SplitWindow::mode
protected

What's happening: move, join, split.

 0=nothing special, 
 1=moving,
 2=vertical split,
 3=horizontal split,
 4=curbox temporarily maximized
 

Referenced by Change(), CharInput(), Curbox(), drawsplitmarks(), Event(), GetMenu(), LBDown(), LBUp(), Maximize(), Mode(), MouseMove(), RBDown(), Refresh(), scaleWindows(), setupsplit(), Split(), splitthewindow(), and SplitWindow().


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

Mon Feb 17 2014 11:53:00, Laxkit