00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _FL_MDI_WINDOW_H_
00023 #define _FL_MDI_WINDOW_H_
00024
00025 #include "Fl_Workspace.h"
00026 #include "Fl_Util.h"
00027 #include "Fl_Group.h"
00028 #include "Fl_Window.h"
00029 #include "Fl_Box.h"
00030 #include "Fl_Button.h"
00031 #include "Fl.h"
00032
00033 #include <string.h>
00034
00035 #define NO_RESIZE -1
00036 #define TOP 0
00037 #define BOTTOM 1
00038 #define RIGHT 2
00039 #define LEFT 3
00040 #define RIGHTTOP 4
00041 #define RIGHTBOTTOM 5
00042 #define LEFTTOP 6
00043 #define LEFTBOTTOM 7
00044
00045 class Fl_MDI_Window;
00046
00048 class FL_API Fl_MDI_Titlebar : public Fl_Group {
00049 friend class Fl_MDI_Window;
00050 public:
00051 static Fl_Named_Style* default_style;
00052
00053 Fl_MDI_Titlebar(int x,int y,int w,int h,const char *l=0);
00054
00055 virtual void draw();
00056 virtual int handle(int event);
00057 virtual void layout();
00058
00059 static int ex;
00060 static int ey;
00061 static int old_rx;
00062 static int old_ry;
00063
00064 Fl_Button *close_button() { return &_close; }
00065 Fl_Button *min_button() { return &_min; }
00066 Fl_Button *max_button() { return &_max; }
00067
00068 protected:
00069 Fl_Button _close, _max, _min;
00070 Fl_MDI_Window *_owner;
00071 };
00072
00074 class Fl_MDI_Window : public Fl_Window {
00075 friend class Fl_MDI_Viewport;
00076 friend class Fl_Workspace;
00077 friend class Fl_MDI_Titlebar;
00078 public:
00079 enum {
00080 NORMAL = 0,
00081 MAXIMIZED,
00082 MINIMIZED
00083 };
00084
00085 static Fl_Named_Style* default_style;
00086
00087 Fl_MDI_Window(int x, int y, int w, int h, const char *label);
00088 virtual ~Fl_MDI_Window();
00089
00090 bool active() { return _active; }
00091 void active(bool a) { _active = a; }
00092
00093
00094 Fl_Group *view(Fl_Group *v);
00095 Fl_Group *view() { return prv; }
00096
00097 void resizable(Fl_Widget *w) { prv->resizable(w); }
00098 void resizable(Fl_Widget &w) { prv->resizable(w); }
00099 Fl_Widget *resizable() { return prv->resizable(); }
00100
00101
00102 void caption(const char *cap);
00103 void caption(const Fl_String &cap);
00104 const Fl_String &caption() const { return label(); }
00105
00106
00107 Fl_MDI_Titlebar* titlebar() { return &_titlebar; }
00108
00109 bool toplevel() { return _toplevel; }
00110
00111 void detach();
00112 void attach() { attach(_owner); }
00113 void attach(Fl_MDI_Viewport *ws);
00114
00115 void owner(Fl_MDI_Viewport *ws) { _owner = ws; }
00116 Fl_MDI_Viewport *owner() { return _owner; }
00117
00118 void setTop() { if(!_toplevel && _owner) _owner->top(this); else show(); }
00119 bool isTop() { return _toplevel==true ? 0 : (_owner->top()==this); }
00120
00121 void state(int s);
00122 int state() { return state_; }
00123
00124 void maximize(bool val) { state(val?MAXIMIZED:NORMAL); }
00125 bool maximized() { return (state_==MAXIMIZED); }
00126 void minimize(bool val) { state(val?MINIMIZED:NORMAL); }
00127 bool minimized() { return (state_==MINIMIZED); }
00128
00129 static void animate_opaque(bool o) { anim_opaque_ = o; }
00130 static bool animate_opaque() { return anim_opaque_; }
00131 static void animate(bool val) { animate_ = val; }
00132 static bool animate() { return animate_; }
00133
00134 void boundary_check(bool val) { _boundaries = val; }
00135 bool boundary_check() { return _boundaries; }
00136
00137 int minw() { return _minw; }
00138 int minh() { return _minh; }
00139 void minw(int w) { _minw = w+box()->dw(); }
00140 void minh(int h) { _minh = h+box()->dw()+titlebar()->h(); }
00141
00142 virtual int handle(int ev);
00143 virtual void handle_resize(int where);
00144 virtual void draw();
00145 virtual void layout();
00146
00147 static void default_callback(Fl_MDI_Window*, void* v);
00148
00149 private:
00150 void check_move_boundary(int &x, int &y);
00151 void check_size_boundary(int &w, int &h);
00152
00153 void animate(int fx, int fy, int fw, int fh,
00154 int tx, int ty, int tw, int th);
00155
00156 void _resize(int x, int y, int w, int h);
00157 void _position(int x, int y);
00158
00159 Fl_MDI_Viewport *_owner;
00160 Fl_Group *prv;
00161 Fl_MDI_Titlebar _titlebar;
00162
00163 bool _toplevel;
00164 bool _active;
00165
00166 int _ox, _oy, _oh, _ow;
00167
00168 bool _boundaries;
00169 int state_;
00170
00171 int _resize_where;
00172
00173 int tx,ty,tw,th;
00174 int px,py,pw,ph;
00175
00176 Fl_Rect bot;
00177 Fl_Rect top;
00178 Fl_Rect left;
00179 Fl_Rect right;
00180
00181 Fl_Rect ltcorn;
00182 Fl_Rect rtcorn;
00183 Fl_Rect lbcorn;
00184 Fl_Rect rbcorn;
00185
00186 static bool anim_opaque_;
00187 static bool animate_;
00188
00189 short _minw, _minh;
00190 short _maxw, _maxh;
00191
00192 void add_menu_buttons();
00193 void delete_menu_buttons();
00194 };
00195
00196 #endif