00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WINDOW_H
00023 #define WINDOW_H
00024
00025 #include "graphics.h"
00026 #include "guichanfwd.h"
00027
00028 #include <guichan/widgetlistener.hpp>
00029
00030 #include <guichan/widgets/window.hpp>
00031
00032 class ContainerPlacer;
00033 class Layout;
00034 class LayoutCell;
00035 class ResizeGrip;
00036 class Skin;
00037 class WindowContainer;
00038
00045 class Window : public gcn::Window, gcn::WidgetListener
00046 {
00047 public:
00059 Window(const std::string &caption = "Window", bool modal = false,
00060 Window *parent = NULL, const std::string &skin = "graphics/gui/gui.xml");
00061
00065 ~Window();
00066
00070 static void setWindowContainer(WindowContainer *windowContainer);
00071
00075 void draw(gcn::Graphics *graphics);
00076
00080 void setContentSize(int width, int height);
00081
00085 void setLocationRelativeTo(gcn::Widget *widget);
00086
00090 void setLocationRelativeTo(ImageRect::ImagePosition position,
00091 int offsetX = 0, int offsetY = 0);
00092
00096 void setResizable(bool resize);
00097
00101 void widgetResized(const gcn::Event &event);
00102
00106 void setCloseButton(bool flag);
00107
00111 bool isResizable() const;
00112
00116 void setMinWidth(int width);
00117
00118 int getMinWidth() const { return mMinWinWidth; }
00119
00123 void setMinHeight(int height);
00124
00125 int getMinHeight() const { return mMinWinHeight; }
00126
00130 void setMaxWidth(int width);
00131
00132 int getMaxWidth() const { return mMaxWinWidth; }
00133
00137 void setMaxHeight(int height);
00138
00139 int getMaxHeight() const { return mMaxWinHeight; }
00140
00144 void setShowTitle(bool flag) { mShowTitle = flag; }
00145
00149 void setStickyButton(bool flag);
00150
00156 void setSticky(bool sticky);
00157
00161 bool isSticky() const { return mSticky; }
00162
00167 void setVisible(bool visible);
00168
00173 void setVisible(bool visible, bool forceSticky);
00174
00178 bool isDefaultVisible() const { return mDefaultVisible; }
00179
00183 void setDefaultVisible(bool save) { mDefaultVisible = save; }
00184
00188 bool willSaveVisible() const { return mSaveVisible; }
00189
00193 void setSaveVisible(bool save) { mSaveVisible = save; }
00194
00200 Window *getParentWindow() const { return mParent; }
00201
00206 void scheduleDelete();
00207
00211 void mousePressed(gcn::MouseEvent &event);
00212
00217 void mouseDragged(gcn::MouseEvent &event);
00218
00223 void mouseMoved(gcn::MouseEvent &event);
00224
00229 void mouseReleased(gcn::MouseEvent &event);
00230
00235 void mouseExited(gcn::MouseEvent &event);
00236
00240 void setWindowName(const std::string &name) { mWindowName = name; }
00241
00245 const std::string &getWindowName() const { return mWindowName; }
00246
00254 void loadWindowState();
00255
00260 void saveWindowState();
00261
00266 void setDefaultSize(int defaultX, int defaultY,
00267 int defaultWidth, int defaultHeight);
00268
00272 void setDefaultSize();
00273
00280 void setDefaultSize(int defaultWidth, int defaultHeight,
00281 ImageRect::ImagePosition position,
00282 int offsetx = 0, int offsetY = 0);
00283
00288 virtual void resetToDefaultSize();
00289
00293 Layout &getLayout();
00294
00303 void reflowLayout(int w = 0, int h = 0);
00304
00308 LayoutCell &place(int x, int y, gcn::Widget *, int w = 1, int h = 1);
00309
00313 ContainerPlacer getPlacer(int x, int y);
00314
00318 void center();
00319
00325 virtual void close();
00326
00330 int getGuiAlpha();
00331
00332 private:
00333 enum ResizeHandles
00334 {
00335 TOP = 0x01,
00336 RIGHT = 0x02,
00337 BOTTOM = 0x04,
00338 LEFT = 0x08
00339 };
00340
00348 int getResizeHandles(gcn::MouseEvent &event);
00349
00350 ResizeGrip *mGrip;
00351 Window *mParent;
00352 Layout *mLayout;
00353 std::string mWindowName;
00354 std::string mDefaultSkinPath;
00355 bool mShowTitle;
00356 bool mModal;
00357 bool mCloseButton;
00358 bool mDefaultVisible;
00359 bool mSaveVisible;
00360 bool mStickyButton;
00361 bool mSticky;
00362 int mMinWinWidth;
00363 int mMinWinHeight;
00364 int mMaxWinWidth;
00365 int mMaxWinHeight;
00366 int mDefaultX;
00367 int mDefaultY;
00368 int mDefaultWidth;
00369 int mDefaultHeight;
00371 static int mouseResize;
00372 static int instances;
00374 Skin* mSkin;
00381 static const int resizeBorderWidth = 10;
00382 };
00383
00384 #endif