Crazy Eddies GUI System 0.7.5
|
00001 /*********************************************************************** 00002 filename: CEGUIFrameWindow.h 00003 created: 13/4/2004 00004 author: Paul D Turner 00005 00006 purpose: Interface to base class for FrameWindow 00007 *************************************************************************/ 00008 /*************************************************************************** 00009 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team 00010 * 00011 * Permission is hereby granted, free of charge, to any person obtaining 00012 * a copy of this software and associated documentation files (the 00013 * "Software"), to deal in the Software without restriction, including 00014 * without limitation the rights to use, copy, modify, merge, publish, 00015 * distribute, sublicense, and/or sell copies of the Software, and to 00016 * permit persons to whom the Software is furnished to do so, subject to 00017 * the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be 00020 * included in all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00023 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00024 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00025 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00026 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00027 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 * OTHER DEALINGS IN THE SOFTWARE. 00029 ***************************************************************************/ 00030 #ifndef _CEGUIFrameWindow_h_ 00031 #define _CEGUIFrameWindow_h_ 00032 00033 #include "../CEGUIBase.h" 00034 #include "../CEGUIWindow.h" 00035 #include "CEGUIFrameWindowProperties.h" 00036 00037 00038 #if defined(_MSC_VER) 00039 # pragma warning(push) 00040 # pragma warning(disable : 4251) 00041 #endif 00042 00043 00044 // Start of CEGUI namespace section 00045 namespace CEGUI 00046 { 00051 class CEGUIEXPORT FrameWindow : public Window 00052 { 00053 public: 00054 static const String EventNamespace; 00055 static const String WidgetTypeName; 00056 00057 /************************************************************************* 00058 Constants 00059 *************************************************************************/ 00060 // additional event names for this window 00066 static const String EventRollupToggled; 00072 static const String EventCloseClicked; 00078 static const String EventDragSizingStarted; 00084 static const String EventDragSizingEnded; 00085 00086 // other bits 00087 static const float DefaultSizingBorderSize; 00088 00089 /************************************************************************* 00090 Child Widget name suffix constants 00091 *************************************************************************/ 00092 static const String TitlebarNameSuffix; 00093 static const String CloseButtonNameSuffix; 00094 00095 00100 enum SizingLocation { 00101 SizingNone, 00102 SizingTopLeft, 00103 SizingTopRight, 00104 SizingBottomLeft, 00105 SizingBottomRight, 00106 SizingTop, 00107 SizingLeft, 00108 SizingBottom, 00109 SizingRight 00110 }; 00111 00122 virtual void initialiseComponents(void); 00123 00124 00132 bool isSizingEnabled(void) const {return d_sizingEnabled && isFrameEnabled();} 00133 00134 00142 bool isFrameEnabled(void) const {return d_frameEnabled;} 00143 00144 00152 bool isTitleBarEnabled(void) const; 00153 00154 00162 bool isCloseButtonEnabled(void) const; 00163 00164 00172 bool isRollupEnabled(void) const {return d_rollupEnabled;} 00173 00174 00182 bool isRolledup(void) const {return d_rolledup;} 00183 00184 00192 float getSizingBorderThickness(void) const {return d_borderSize;} 00193 00194 00205 void setSizingEnabled(bool setting); 00206 00207 00218 void setFrameEnabled(bool setting); 00219 00220 00231 void setTitleBarEnabled(bool setting); 00232 00233 00244 void setCloseButtonEnabled(bool setting); 00245 00246 00257 void setRollupEnabled(bool setting); 00258 00259 00267 void toggleRollup(void); 00268 00269 00280 void setSizingBorderThickness(float pixels) {d_borderSize = pixels;} 00281 00282 00295 void offsetPixelPosition(const Vector2& offset); 00296 00297 00305 bool isDragMovingEnabled(void) const {return d_dragMovable;} 00306 00307 00318 void setDragMovingEnabled(bool setting); 00319 00320 00329 const Image* getNSSizingCursorImage() const; 00330 00339 const Image* getEWSizingCursorImage() const; 00340 00349 const Image* getNWSESizingCursorImage() const; 00350 00359 const Image* getNESWSizingCursorImage() const; 00360 00371 void setNSSizingCursorImage(const Image* image); 00372 00383 void setEWSizingCursorImage(const Image* image); 00384 00395 void setNWSESizingCursorImage(const Image* image); 00396 00407 void setNESWSizingCursorImage(const Image* image); 00408 00424 void setNSSizingCursorImage(const String& imageset, const String& image); 00425 00441 void setEWSizingCursorImage(const String& imageset, const String& image); 00442 00458 void setNWSESizingCursorImage(const String& imageset, const String& image); 00459 00475 void setNESWSizingCursorImage(const String& imageset, const String& image); 00476 00477 // overridden from Window class 00478 bool isHit(const Point& position, const bool /*allow_disabled*/) const 00479 { return Window::isHit(position) && !d_rolledup; } 00480 00491 Titlebar* getTitlebar() const; 00492 00504 PushButton* getCloseButton() const; 00505 00506 /************************************************************************* 00507 Construction / Destruction 00508 *************************************************************************/ 00513 FrameWindow(const String& type, const String& name); 00514 00519 virtual ~FrameWindow(void); 00520 00521 00522 protected: 00523 /************************************************************************* 00524 Implementation Functions 00525 *************************************************************************/ 00533 bool moveLeftEdge(float delta, URect& out_area); 00534 00535 00543 bool moveRightEdge(float delta, URect& out_area); 00544 00545 00553 bool moveTopEdge(float delta, URect& out_area); 00554 00555 00563 bool moveBottomEdge(float delta, URect& out_area); 00564 00565 00579 SizingLocation getSizingBorderAtPoint(const Point& pt) const; 00580 00581 00592 bool isLeftSizingLocation(SizingLocation loc) const {return ((loc == SizingLeft) || (loc == SizingTopLeft) || (loc == SizingBottomLeft));} 00593 00594 00605 bool isRightSizingLocation(SizingLocation loc) const {return ((loc == SizingRight) || (loc == SizingTopRight) || (loc == SizingBottomRight));} 00606 00607 00618 bool isTopSizingLocation(SizingLocation loc) const {return ((loc == SizingTop) || (loc == SizingTopLeft) || (loc == SizingTopRight));} 00619 00620 00631 bool isBottomSizingLocation(SizingLocation loc) const {return ((loc == SizingBottom) || (loc == SizingBottomLeft) || (loc == SizingBottomRight));} 00632 00633 00638 bool closeClickHandler(const EventArgs& e); 00639 00640 00645 void setCursorForPoint(const Point& pt) const; 00646 00647 00652 virtual Rect getSizingRect(void) const {return Rect(0, 0, d_pixelSize.d_width, d_pixelSize.d_height);} 00653 00654 00665 virtual bool testClassName_impl(const String& class_name) const 00666 { 00667 if (class_name=="FrameWindow") return true; 00668 return Window::testClassName_impl(class_name); 00669 } 00670 00671 00672 /************************************************************************* 00673 New events for Frame Windows 00674 *************************************************************************/ 00680 virtual void onRollupToggled(WindowEventArgs& e); 00681 00682 00687 virtual void onCloseClicked(WindowEventArgs& e); 00688 00690 virtual void onDragSizingStarted(WindowEventArgs& e); 00691 00693 virtual void onDragSizingEnded(WindowEventArgs& e); 00694 00695 /************************************************************************* 00696 Overridden event handlers 00697 *************************************************************************/ 00698 virtual void onMouseMove(MouseEventArgs& e); 00699 virtual void onMouseButtonDown(MouseEventArgs& e); 00700 virtual void onMouseButtonUp(MouseEventArgs& e); 00701 virtual void onCaptureLost(WindowEventArgs& e); 00702 virtual void onTextChanged(WindowEventArgs& e); 00703 virtual void onActivated(ActivationEventArgs& e); 00704 virtual void onDeactivated(ActivationEventArgs& e); 00705 00706 00707 /************************************************************************* 00708 Implementation Data 00709 *************************************************************************/ 00710 // frame data 00711 bool d_frameEnabled; 00712 00713 // window roll-up data 00714 bool d_rollupEnabled; 00715 bool d_rolledup; 00716 00717 // drag-sizing data 00718 bool d_sizingEnabled; 00719 bool d_beingSized; 00720 float d_borderSize; 00721 Point d_dragPoint; 00722 00723 // images for cursor when on sizing border 00724 const Image* d_nsSizingCursor; 00725 const Image* d_ewSizingCursor; 00726 const Image* d_nwseSizingCursor; 00727 const Image* d_neswSizingCursor; 00728 00729 bool d_dragMovable; 00730 00731 00732 private: 00733 /************************************************************************* 00734 Static Properties for this class 00735 *************************************************************************/ 00736 static FrameWindowProperties::SizingEnabled d_sizingEnabledProperty; 00737 static FrameWindowProperties::FrameEnabled d_frameEnabledProperty; 00738 static FrameWindowProperties::TitlebarEnabled d_titlebarEnabledProperty; 00739 static FrameWindowProperties::CloseButtonEnabled d_closeButtonEnabledProperty; 00740 static FrameWindowProperties::RollUpState d_rollUpStateProperty; 00741 static FrameWindowProperties::RollUpEnabled d_rollUpEnabledProperty; 00742 static FrameWindowProperties::DragMovingEnabled d_dragMovingEnabledProperty; 00743 static FrameWindowProperties::SizingBorderThickness d_sizingBorderThicknessProperty; 00744 static FrameWindowProperties::NSSizingCursorImage d_nsSizingCursorProperty; 00745 static FrameWindowProperties::EWSizingCursorImage d_ewSizingCursorProperty; 00746 static FrameWindowProperties::NWSESizingCursorImage d_nwseSizingCursorProperty; 00747 static FrameWindowProperties::NESWSizingCursorImage d_neswSizingCursorProperty; 00748 00749 00750 /************************************************************************* 00751 Private methods 00752 *************************************************************************/ 00753 void addFrameWindowProperties(void); 00754 }; 00755 00756 } // End of CEGUI namespace section 00757 00758 #if defined(_MSC_VER) 00759 # pragma warning(pop) 00760 #endif 00761 00762 #endif // end of guard _CEGUIFrameWindow_h_