//| //| Dockable window widget for the Fast Light Tool Kit (FLTK). //| //| Copyright 1998-1999 by Vivality llc, Venice, CA, U.S.A. //| and Matthias Melcher. //| //| This library is free software; you can redistribute it and/or //| modify it under the terms of the GNU Library General Public //| License as published by the Free Software Foundation; either //| version 2 of the License, or (at your option) any later version. //| //| This library is distributed in the hope that it will be useful, //| but WITHOUT ANY WARRANTY; without even the implied warranty of //| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //| Library General Public License for more details. //| //| You should have received a copy of the GNU Library General Public //| License along with this library; if not, write to the Free Software //| Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 //| USA. //| //| Please report all bugs and problems to "matthias@mediaone.net". //| // There are two widget classes in this module. // Fl_Dock is derived from Fl_New_Tile and adds some functionality. // - The user can move all widgets around within the Fl_Dock. // - The user can drag widgets out of the Fl_Dock. They will appear as // seperate windows on the desktop (Fl_Dockable) // - The user can drag those windows back into the Fl_Dock. // Fl_Dock tries to make smart decissions about placing. // Fl_Dockable is derived from Fl_Group. The Fl_Dock takes care of generating // Fl_Dockable widgets // 08/25/1999: // - improved docking and undocking behaviour, still lots to do // - created a way to have "free spots" that are generated and removed as required (canReplace) // - created prefered resizable widgets that fill free space if possible (canMerge) // planned: docking into an FL_Tab // planned: callback to let application know we docked/undocked etc. /* sample usage void main() { Fl_Window *w = new Fl_Window(50, 50, 300, 300, "Fl_Dock test"); Fl_Dock *t = new Fl_Dock(20, 20, 260, 260); Fl_Box *w1 = new Fl_Box(FL_DOWN_BOX, 20, 20, 140, 130, ""); w1->color(FL_RED); Fl_Box *w2 = new Fl_Box(FL_DOWN_BOX, 20+140, 20, 120, 130, ""); w2->color(FL_GREEN); Fl_Box *w3 = new Fl_Box(FL_DOWN_BOX, 20, 20+130, 130, 130, ""); w3->color(FL_BLUE); Fl_Box *w4 = new Fl_Box(FL_DOWN_BOX, 20+130, 20+130, 130, 130, ""); w4->color(FL_YELLOW); t->end(); w->end(); w->resizable(t); Fl_Window *x = new Fl_Window(400, 50, 120, 60, "Fl_Dockable"); Fl_Dockable *x1 = new Fl_Dockable(0, 0, 120, 60); x1->docks_to(t); Fl_Box *w5 = new Fl_Box(FL_DOWN_BOX, 0, 0, 120, 60, ""); w5->color(FL_MAGENTA); x1->end(); x->end(); w->show(); x->show(); Fl::run(); } */ #include #include "Fl_New_Tile.H" #include class Fl_Dock : public Fl_New_Tile { public: Fl_Dock(int x, int y, int w, int h, char *t=0L); virtual ~Fl_Dock(); char takeOut(Fl_Widget*); void putIn(Fl_Widget*, int, int); void canMerge(Fl_Widget*, int cando); int canMerge(Fl_Widget*); char mergeRemove(Fl_Widget*); void canReplace(Fl_Widget*, int cando); int canReplace(Fl_Widget*); char addReplace(Fl_Widget*, Fl_Widget*); Fl_Widget *findReplace(); protected: int handle(int); void putIn(Fl_Widget*, Fl_Widget*, char); Fl_Widget *dockWhere(int, int, char&); void reparent(Fl_Widget*, int, int); Fl_Widget **mergeList; int nMergeList, NMergeList; Fl_Widget **replaceList; int nReplaceList, NReplaceList; }; class Fl_Dockable : public Fl_Group { public: Fl_Dockable(int x, int y, int w, int h, char *t=0L) : Fl_Group(x, y, w, h, t) { dock_ = 0L; } void docks_to(Fl_Dock *d) { dock_ = d; } protected: int handle(int); Fl_Dock *dock_; };