00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_GUI_WINDOW_H__
00009 #define __SP_GUI_WINDOW_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_GUI
00015
00016
00017 #include "GUI/spGUIController.hpp"
00018 #include "GUI/spGUIMenuItem.hpp"
00019 #include "GUI/spGUIButtonGadget.hpp"
00020 #include "GUI/spGUICheckboxGadget.hpp"
00021 #include "GUI/spGUIContainerGadget.hpp"
00022 #include "GUI/spGUIListGadget.hpp"
00023 #include "GUI/spGUIProgressbarGadget.hpp"
00024 #include "GUI/spGUIScrollbarGadget.hpp"
00025 #include "GUI/spGUIStringGadget.hpp"
00026 #include "GUI/spGUITrackbarGadget.hpp"
00027 #include "GUI/spGUITreeGadget.hpp"
00028 #include "GUI/spGUITextGadget.hpp"
00029 #include "GUI/spGUIWebGadget.hpp"
00030 #include "GUI/spGUIScrollViewBased.hpp"
00031
00032
00033 namespace sp
00034 {
00035 namespace gui
00036 {
00037
00038
00039 enum EWindowFlags
00040 {
00041 GUIFLAG_CLOSEBUTTON = 0x00000001,
00042 GUIFLAG_MINBUTTON = 0x00000002,
00043 GUIFLAG_MAXBUTTON = 0x00000004,
00044 GUIFLAG_SIZEBUTTON = 0x00000008,
00045 GUIFLAG_VSCROLL = 0x00000010,
00046 GUIFLAG_HSCROLL = 0x00000020,
00047 };
00048
00049
00054 class SP_EXPORT GUIWindow : public GUIController, public GUIScrollViewBased
00055 {
00056
00057 public:
00058
00059 GUIWindow();
00060 ~GUIWindow();
00061
00062
00063
00064 bool update();
00065 void draw();
00066
00067 dim::rect2di getLocalViewArea(const GUIController* Obj = 0) const;
00068 dim::point2di getViewOrigin() const;
00069
00070 void setSize(const dim::size2di &Size);
00071
00073 void close();
00074
00076 void maximize();
00077
00079 void minimize();
00080
00082 void normalize();
00083
00085 void setMenuRoot(GUIMenuItem* MenuRoot);
00086
00087 GUIButtonGadget* addButtonGadget(
00088 const dim::point2di &Position, const dim::size2di &Size, const io::stringc &Text = "", s32 Flags = 0
00089 );
00090 GUICheckboxGadget* addCheckboxGadget(
00091 const dim::point2di &Position, const dim::size2di &Size, const io::stringc &Text = "", s32 Flags = 0
00092 );
00093 GUIContainerGadget* addContainerGadget(
00094 const dim::point2di &Position, const dim::size2di &Size, s32 Flags = 0
00095 );
00096 GUIListGadget* addListGadget(
00097 const dim::point2di &Position, const dim::size2di &Size, s32 Flags = 0
00098 );
00099 GUIProgressbarGadget* addProgressbarGadget(
00100 const dim::point2di &Position, const dim::size2di &Size, s32 Range = 100, s32 Flags = 0
00101 );
00102 GUIScrollbarGadget* addScrollbarGadget(
00103 const dim::point2di &Position, const dim::size2di &Size, s32 Range = 100, s32 Flags = 0
00104 );
00105 GUIStringGadget* addStringGadget(
00106 const dim::point2di &Position, const dim::size2di &Size, const io::stringc &Text = "", s32 Flags = 0
00107 );
00108 GUITextGadget* addTextGadget(
00109 const dim::point2di &Position, const dim::size2di &Size, const io::stringc &Text = "", s32 Flags = 0
00110 );
00111 GUITrackbarGadget* addTrackbarGadget(
00112 const dim::point2di &Position, const dim::size2di &Size, s32 MinRange = 0, s32 MaxRange = 100, s32 Flags = 0
00113 );
00114 GUITreeGadget* addTreeGadget(
00115 const dim::point2di &Position, const dim::size2di &Size, s32 Flags = 0
00116 );
00117 GUIWebGadget* addWebGadget(
00118 const dim::point2di &Position, const dim::size2di &Size, s32 Flags = 0
00119 );
00120
00121
00122
00124 inline GUIMenuItem* getMenuRoot() const
00125 {
00126 return MenuRoot_;
00127 }
00128
00130 inline void setGadgetOrigin(const dim::point2di &Position)
00131 {
00132 GadgetOrigin_ = Position;
00133 }
00134 inline dim::point2di getGadgetOrigin() const
00135 {
00136 return GadgetOrigin_;
00137 }
00138
00139 private:
00140
00141
00142
00143 static const s32 CAPTION_HEIGHT = 25;
00144
00145
00146
00147 enum EFocusUsages
00148 {
00149 USAGE_MOVE,
00150 USAGE_RESIZE,
00151 USAGE_MAXBUTTON,
00152 USAGE_MINBUTTON,
00153 USAGE_CLOSEBUTTON,
00154 };
00155
00156 enum EWindowVisStates
00157 {
00158 VISSTATE_NORMAL,
00159 VISSTATE_MINIMIZED,
00160 VISSTATE_MAXIMIZED,
00161 };
00162
00163
00164
00165 void drawWindowBackground();
00166 void drawWindowFrame();
00167 void drawWindowButtonMin(s32 &PosHorz);
00168 void drawWindowButtonMax(s32 &PosHorz);
00169 void drawWindowButtonFrameNormalize(s32 &PosHorz);
00170 void drawWindowButtonClose(s32 &PosHorz);
00171 bool drawWindowButton(s32 &PosHorz, const video::color &Color);
00172
00173 void checkFlags();
00174
00175 void updateMenu();
00176 void clampWindowLocation();
00177
00178 void addController(
00179 GUIController* NewController, const dim::point2di &Position,
00180 const dim::size2di &Size, const io::stringc &Text, s32 Flags
00181 );
00182
00183
00184
00185 static video::color CaptionColorA[2];
00186 static video::color CaptionColorB[2];
00187
00188 EWindowVisStates VisState_;
00189 dim::point2di VisNormalPos_;
00190 dim::size2di VisNormalSize_;
00191
00192 GUIMenuItem* MenuRoot_;
00193
00194 dim::point2di GadgetOrigin_;
00195
00196 };
00197
00198
00199 }
00200
00201 }
00202
00203
00204 #endif
00205
00206 #endif
00207
00208
00209
00210