Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_GUI_CONTROLLER_H__
00009 #define __SP_GUI_CONTROLLER_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013
00014 #ifdef SP_COMPILE_WITH_GUI
00015
00016
00017 #include "RenderSystem/spRenderSystem.hpp"
00018 #include "GUI/spGUIBaseObject.hpp"
00019
00020
00021 namespace sp
00022 {
00023 namespace gui
00024 {
00025
00026
00027 class GUIScrollbarGadget;
00028
00029 enum EGUIControllerTypes
00030 {
00031 CONTROLLER_WINDOW,
00032 CONTROLLER_GADGET,
00033 };
00034
00035 enum EControllerFlags
00036 {
00037 GUIFLAG_TEXTLEFT = 0x01000000,
00038 GUIFLAG_TEXTRIGHT = 0x02000000,
00039 GUIFLAG_TEXTCENTER = 0x04000000,
00040 GUIFLAG_BORDERLESS = 0x08000000,
00041 GUIFLAG_NOSCROLL = 0x10000000,
00042 GUIFLAG_HOLDSELECTION = 0x20000000,
00043 };
00044
00045
00046 class SP_EXPORT GUIController : public GUIBaseObject
00047 {
00048
00049 public:
00050
00051 virtual ~GUIController();
00052
00053
00054
00055 virtual bool update() = 0;
00056 virtual void draw() = 0;
00057 virtual void updateAlways();
00058
00060 virtual void setRect(const dim::rect2di &Rect);
00061
00063 virtual void setPosition(const dim::point2di &Position);
00064
00066 virtual void setSize(const dim::size2di &Size);
00067
00073 virtual dim::point2di getPosition(bool isGlobal) const;
00074
00076 virtual dim::rect2di getRect(bool isGlobal) const;
00077
00079 virtual dim::rect2di getLocalViewArea(const GUIController* Obj = 0) const;
00080
00082 virtual dim::rect2di getViewArea(const GUIController* Obj = 0) const;
00083
00085 virtual dim::point2di getViewOrigin() const;
00086
00088 virtual dim::point2di getScrollPosition(bool isGlobal) const;
00089
00095 virtual void setParent(GUIController* Parent);
00096
00098 virtual void focus();
00099
00101 virtual bool hasFocus() const;
00102
00104 virtual void foreground();
00105
00112 virtual void setFlags(s32 Flags);
00113
00114
00115
00117 inline EGUIControllerTypes getType() const
00118 {
00119 return Type_;
00120 }
00121
00123 inline GUIController* getParent() const
00124 {
00125 return Parent_;
00126 }
00127
00129 inline dim::rect2di getRect() const
00130 {
00131 return Rect_;
00132 }
00133
00135 inline dim::point2di getPosition() const
00136 {
00137 return dim::point2di(RootRect_.Left, RootRect_.Top);
00138 }
00139
00141 inline dim::size2di getSize() const
00142 {
00143 return dim::size2di(RootRect_.Right - RootRect_.Left, RootRect_.Bottom - RootRect_.Top);
00144 }
00145
00147 inline void setScrollPosition(const dim::point2di &Position)
00148 {
00149 ScrollPos_ = Position;
00150 }
00151
00153 inline dim::point2di getScrollPosition() const
00154 {
00155 return ScrollPos_;
00156 }
00157
00159 inline void translate(const dim::point2di &Direction)
00160 {
00161 setPosition(getPosition() + Direction);
00162 }
00163
00165 inline void transform(const dim::size2di &Size)
00166 {
00167 setSize(getSize() + Size);
00168 }
00169
00171 inline void scroll(const dim::point2di &Direction)
00172 {
00173 setScrollPosition(getScrollPosition() + Direction);
00174 }
00175
00177 inline void setMinSize(const dim::size2di &Size)
00178 {
00179 MinSize_ = Size;
00180 }
00181 inline dim::size2di getMinSize() const
00182 {
00183 return MinSize_;
00184 }
00185
00187 inline void setMaxSize(const dim::size2di &Size)
00188 {
00189 MaxSize_ = Size;
00190 }
00191 inline dim::size2di getMaxSize() const
00192 {
00193 return MaxSize_;
00194 }
00195
00197 inline void setOrder(s32 Order)
00198 {
00199 Order_ = Order;
00200 }
00201 inline s32 getOrder() const
00202 {
00203 return Order_;
00204 }
00205
00207 inline void setVisible(bool isVisible)
00208 {
00209 isVisible_ = isVisible;
00210 }
00211 inline bool getVisible() const
00212 {
00213 return isVisible_;
00214 }
00215
00217 inline bool hasForeground() const
00218 {
00219 return isForeground_;
00220 }
00221
00223 inline s32 getFlags() const
00224 {
00225 return Flags_;
00226 }
00227
00228 protected:
00229
00230 friend class GUIManager;
00231
00232
00233
00234 static const s32 SCROLLBAR_SIZE = 15;
00235
00236
00237
00238 GUIController(const EGUIControllerTypes Type);
00239
00240 void updateChildren();
00241 void drawChildren();
00242
00243 void updateClipping();
00244 bool setupClipping();
00245 bool checkClipping() const;
00246 void updateRect();
00247 bool checkDefaultUpdate();
00248
00249 virtual void addChild(GUIController* Child);
00250 virtual void removeChild(GUIController* Child);
00251
00252 void useFocus(s32 Usage = 0);
00253 bool usage(s32 Usage) const;
00254 bool usage() const;
00255 bool foreignUsage() const;
00256
00257 dim::rect2di getParentViewArea() const;
00258
00259 void updateScrollBars(GUIScrollbarGadget* HorzScroll, GUIScrollbarGadget* VertScroll);
00260
00261 virtual void checkFlags();
00262
00263
00264
00265 EGUIControllerTypes Type_;
00266
00267 GUIController* Parent_;
00268 std::list<GUIController*> Children_;
00269
00270 s32 Order_;
00271 dim::rect2di RootRect_, Rect_, VisRect_;
00272 dim::size2di MinSize_, MaxSize_;
00273 dim::point2di ScrollPos_;
00274
00275 bool isVisible_;
00276 bool isValidated_;
00277 bool isForeground_;
00278
00279 s32 Flags_;
00280
00281 s32 FocusUsage_;
00282 bool Usable_;
00283
00284 };
00285
00286
00287 }
00288
00289 }
00290
00291
00292 #endif
00293
00294 #endif
00295
00296
00297
00298