Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: 13/4/2004 00003 author: Paul D Turner 00004 00005 purpose: Interface to base class for FrameWindow 00006 *************************************************************************/ 00007 /*************************************************************************** 00008 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining 00011 * a copy of this software and associated documentation files (the 00012 * "Software"), to deal in the Software without restriction, including 00013 * without limitation the rights to use, copy, modify, merge, publish, 00014 * distribute, sublicense, and/or sell copies of the Software, and to 00015 * permit persons to whom the Software is furnished to do so, subject to 00016 * the following conditions: 00017 * 00018 * The above copyright notice and this permission notice shall be 00019 * included in all copies or substantial portions of the Software. 00020 * 00021 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00023 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00024 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00025 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00026 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00027 * OTHER DEALINGS IN THE SOFTWARE. 00028 ***************************************************************************/ 00029 #ifndef _CEGUIFrameWindow_h_ 00030 #define _CEGUIFrameWindow_h_ 00031 00032 #include "../Base.h" 00033 #include "../Window.h" 00034 00035 #if defined(_MSC_VER) 00036 # pragma warning(push) 00037 # pragma warning(disable : 4251) 00038 #endif 00039 00040 00041 // Start of CEGUI namespace section 00042 namespace CEGUI 00043 { 00048 class CEGUIEXPORT FrameWindow : public Window 00049 { 00050 public: 00051 static const String EventNamespace; 00052 static const String WidgetTypeName; 00053 00054 /************************************************************************* 00055 Constants 00056 *************************************************************************/ 00057 // additional event names for this window 00063 static const String EventRollupToggled; 00069 static const String EventCloseClicked; 00075 static const String EventDragSizingStarted; 00081 static const String EventDragSizingEnded; 00082 00083 // other bits 00084 static const float DefaultSizingBorderSize; 00085 00086 /************************************************************************* 00087 Child Widget name constants 00088 *************************************************************************/ 00089 static const String TitlebarName; 00090 static const String CloseButtonName; 00091 00092 00097 enum SizingLocation { 00098 SizingNone, 00099 SizingTopLeft, 00100 SizingTopRight, 00101 SizingBottomLeft, 00102 SizingBottomRight, 00103 SizingTop, 00104 SizingLeft, 00105 SizingBottom, 00106 SizingRight 00107 }; 00108 00119 virtual void initialiseComponents(void); 00120 00121 00129 bool isSizingEnabled(void) const {return d_sizingEnabled && isFrameEnabled();} 00130 00131 00139 bool isFrameEnabled(void) const {return d_frameEnabled;} 00140 00141 00149 bool isTitleBarEnabled(void) const; 00150 00151 00159 bool isCloseButtonEnabled(void) const; 00160 00161 00169 bool isRollupEnabled(void) const {return d_rollupEnabled;} 00170 00178 void setRolledup(bool val); 00179 00187 bool isRolledup(void) const {return d_rolledup;} 00188 00189 00197 float getSizingBorderThickness(void) const {return d_borderSize;} 00198 00199 00210 void setSizingEnabled(bool setting); 00211 00212 00223 void setFrameEnabled(bool setting); 00224 00225 00236 void setTitleBarEnabled(bool setting); 00237 00238 00249 void setCloseButtonEnabled(bool setting); 00250 00251 00262 void setRollupEnabled(bool setting); 00263 00264 00272 void toggleRollup(void); 00273 00284 void setSizingBorderThickness(float pixels) {d_borderSize = pixels;} 00285 00286 00299 void offsetPixelPosition(const Vector2f& offset); 00300 00301 00309 bool isDragMovingEnabled(void) const {return d_dragMovable;} 00310 00311 00322 void setDragMovingEnabled(bool setting); 00323 00324 00333 const Image* getNSSizingCursorImage() const; 00334 00343 const Image* getEWSizingCursorImage() const; 00344 00353 const Image* getNWSESizingCursorImage() const; 00354 00363 const Image* getNESWSizingCursorImage() const; 00364 00375 void setNSSizingCursorImage(const Image* image); 00376 00387 void setEWSizingCursorImage(const Image* image); 00388 00399 void setNWSESizingCursorImage(const Image* image); 00400 00411 void setNESWSizingCursorImage(const Image* image); 00412 00425 void setNSSizingCursorImage(const String& name); 00426 00439 void setEWSizingCursorImage(const String& name); 00440 00453 void setNWSESizingCursorImage(const String& name); 00454 00467 void setNESWSizingCursorImage(const String& name); 00468 00469 // overridden from Window class 00470 bool isHit(const Vector2f& position, const bool /*allow_disabled*/) const 00471 { return Window::isHit(position) && !d_rolledup; } 00472 00483 Titlebar* getTitlebar() const; 00484 00496 PushButton* getCloseButton() const; 00497 00498 /************************************************************************* 00499 Construction / Destruction 00500 *************************************************************************/ 00505 FrameWindow(const String& type, const String& name); 00506 00511 virtual ~FrameWindow(void); 00512 00513 00514 protected: 00515 /************************************************************************* 00516 Implementation Functions 00517 *************************************************************************/ 00525 bool moveLeftEdge(float delta, URect& out_area); 00526 00527 00535 bool moveRightEdge(float delta, URect& out_area); 00536 00537 00545 bool moveTopEdge(float delta, URect& out_area); 00546 00547 00555 bool moveBottomEdge(float delta, URect& out_area); 00556 00557 00571 SizingLocation getSizingBorderAtPoint(const Vector2f& pt) const; 00572 00573 00584 bool isLeftSizingLocation(SizingLocation loc) const {return ((loc == SizingLeft) || (loc == SizingTopLeft) || (loc == SizingBottomLeft));} 00585 00586 00597 bool isRightSizingLocation(SizingLocation loc) const {return ((loc == SizingRight) || (loc == SizingTopRight) || (loc == SizingBottomRight));} 00598 00599 00610 bool isTopSizingLocation(SizingLocation loc) const {return ((loc == SizingTop) || (loc == SizingTopLeft) || (loc == SizingTopRight));} 00611 00612 00623 bool isBottomSizingLocation(SizingLocation loc) const {return ((loc == SizingBottom) || (loc == SizingBottomLeft) || (loc == SizingBottomRight));} 00624 00625 00630 bool closeClickHandler(const EventArgs& e); 00631 00632 00637 void setCursorForPoint(const Vector2f& pt) const; 00638 00639 00644 virtual Rectf getSizingRect(void) const {return Rectf(0, 0, d_pixelSize.d_width, d_pixelSize.d_height);} 00645 00646 /************************************************************************* 00647 New events for Frame Windows 00648 *************************************************************************/ 00654 virtual void onRollupToggled(WindowEventArgs& e); 00655 00656 00661 virtual void onCloseClicked(WindowEventArgs& e); 00662 00664 virtual void onDragSizingStarted(WindowEventArgs& e); 00665 00667 virtual void onDragSizingEnded(WindowEventArgs& e); 00668 00669 /************************************************************************* 00670 Overridden event handlers 00671 *************************************************************************/ 00672 virtual void onMouseMove(MouseEventArgs& e); 00673 virtual void onMouseButtonDown(MouseEventArgs& e); 00674 virtual void onMouseButtonUp(MouseEventArgs& e); 00675 virtual void onCaptureLost(WindowEventArgs& e); 00676 virtual void onTextChanged(WindowEventArgs& e); 00677 virtual void onActivated(ActivationEventArgs& e); 00678 virtual void onDeactivated(ActivationEventArgs& e); 00679 00680 00681 /************************************************************************* 00682 Implementation Data 00683 *************************************************************************/ 00684 // frame data 00685 bool d_frameEnabled; 00686 00687 // window roll-up data 00688 bool d_rollupEnabled; 00689 bool d_rolledup; 00690 00691 // drag-sizing data 00692 bool d_sizingEnabled; 00693 bool d_beingSized; 00694 float d_borderSize; 00695 Vector2f d_dragPoint; 00696 00697 // images for cursor when on sizing border 00698 const Image* d_nsSizingCursor; 00699 const Image* d_ewSizingCursor; 00700 const Image* d_nwseSizingCursor; 00701 const Image* d_neswSizingCursor; 00702 00703 bool d_dragMovable; 00704 00705 00706 private: 00707 /************************************************************************* 00708 Private methods 00709 *************************************************************************/ 00710 void addFrameWindowProperties(void); 00711 }; 00712 00713 } // End of CEGUI namespace section 00714 00715 #if defined(_MSC_VER) 00716 # pragma warning(pop) 00717 #endif 00718 00719 #endif // end of guard _CEGUIFrameWindow_h_ 00720