Crazy Eddies GUI System  0.7.1
CEGUIFrameWindow.h
1 /***********************************************************************
2  filename: CEGUIFrameWindow.h
3  created: 13/4/2004
4  author: Paul D Turner
5 
6  purpose: Interface to base class for FrameWindow
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIFrameWindow_h_
31 #define _CEGUIFrameWindow_h_
32 
33 #include "../CEGUIBase.h"
34 #include "../CEGUIWindow.h"
35 #include "CEGUIFrameWindowProperties.h"
36 
37 
38 #if defined(_MSC_VER)
39 # pragma warning(push)
40 # pragma warning(disable : 4251)
41 #endif
42 
43 
44 // Start of CEGUI namespace section
45 namespace CEGUI
46 {
51 class CEGUIEXPORT FrameWindow : public Window
52 {
53 public:
54  static const String EventNamespace;
55  static const String WidgetTypeName;
56 
57  /*************************************************************************
58  Constants
59  *************************************************************************/
60  // additional event names for this window
61  static const String EventRollupToggled;
62  static const String EventCloseClicked;
63 
67 
68  // other bits
69  static const float DefaultSizingBorderSize;
70 
71  /*************************************************************************
72  Child Widget name suffix constants
73  *************************************************************************/
74  static const String TitlebarNameSuffix;
76 
77 
91  SizingRight
92  };
93 
104  virtual void initialiseComponents(void);
105 
106 
114  bool isSizingEnabled(void) const {return d_sizingEnabled && isFrameEnabled();}
115 
116 
124  bool isFrameEnabled(void) const {return d_frameEnabled;}
125 
126 
134  bool isTitleBarEnabled(void) const;
135 
136 
144  bool isCloseButtonEnabled(void) const;
145 
146 
154  bool isRollupEnabled(void) const {return d_rollupEnabled;}
155 
156 
164  bool isRolledup(void) const {return d_rolledup;}
165 
166 
174  float getSizingBorderThickness(void) const {return d_borderSize;}
175 
176 
187  void setSizingEnabled(bool setting);
188 
189 
200  void setFrameEnabled(bool setting);
201 
202 
213  void setTitleBarEnabled(bool setting);
214 
215 
226  void setCloseButtonEnabled(bool setting);
227 
228 
239  void setRollupEnabled(bool setting);
240 
241 
249  void toggleRollup(void);
250 
251 
262  void setSizingBorderThickness(float pixels) {d_borderSize = pixels;}
263 
264 
277  void offsetPixelPosition(const Vector2& offset);
278 
279 
287  bool isDragMovingEnabled(void) const {return d_dragMovable;}
288 
289 
300  void setDragMovingEnabled(bool setting);
301 
302 
311  const Image* getNSSizingCursorImage() const;
312 
321  const Image* getEWSizingCursorImage() const;
322 
331  const Image* getNWSESizingCursorImage() const;
332 
341  const Image* getNESWSizingCursorImage() const;
342 
353  void setNSSizingCursorImage(const Image* image);
354 
365  void setEWSizingCursorImage(const Image* image);
366 
377  void setNWSESizingCursorImage(const Image* image);
378 
389  void setNESWSizingCursorImage(const Image* image);
390 
406  void setNSSizingCursorImage(const String& imageset, const String& image);
407 
423  void setEWSizingCursorImage(const String& imageset, const String& image);
424 
440  void setNWSESizingCursorImage(const String& imageset, const String& image);
441 
457  void setNESWSizingCursorImage(const String& imageset, const String& image);
458 
459  // overridden from Window class
460  bool isHit(const Point& position, const bool /*allow_disabled*/) const
461  { return Window::isHit(position) && !d_rolledup; }
462 
473  Titlebar* getTitlebar() const;
474 
486  PushButton* getCloseButton() const;
487 
488  /*************************************************************************
489  Construction / Destruction
490  *************************************************************************/
495  FrameWindow(const String& name, const String& type);
496 
501  virtual ~FrameWindow(void);
502 
503 
504 protected:
505  /*************************************************************************
506  Implementation Functions
507  *************************************************************************/
515  bool moveLeftEdge(float delta, URect& out_area);
516 
517 
525  bool moveRightEdge(float delta, URect& out_area);
526 
527 
535  bool moveTopEdge(float delta, URect& out_area);
536 
537 
545  bool moveBottomEdge(float delta, URect& out_area);
546 
547 
561  SizingLocation getSizingBorderAtPoint(const Point& pt) const;
562 
563 
574  bool isLeftSizingLocation(SizingLocation loc) const {return ((loc == SizingLeft) || (loc == SizingTopLeft) || (loc == SizingBottomLeft));}
575 
576 
587  bool isRightSizingLocation(SizingLocation loc) const {return ((loc == SizingRight) || (loc == SizingTopRight) || (loc == SizingBottomRight));}
588 
589 
600  bool isTopSizingLocation(SizingLocation loc) const {return ((loc == SizingTop) || (loc == SizingTopLeft) || (loc == SizingTopRight));}
601 
602 
613  bool isBottomSizingLocation(SizingLocation loc) const {return ((loc == SizingBottom) || (loc == SizingBottomLeft) || (loc == SizingBottomRight));}
614 
615 
620  bool closeClickHandler(const EventArgs& e);
621 
622 
627  void setCursorForPoint(const Point& pt) const;
628 
629 
634  virtual Rect getSizingRect(void) const {return Rect(0, 0, d_pixelSize.d_width, d_pixelSize.d_height);}
635 
636 
647  virtual bool testClassName_impl(const String& class_name) const
648  {
649  if (class_name=="FrameWindow") return true;
650  return Window::testClassName_impl(class_name);
651  }
652 
653 
654  /*************************************************************************
655  New events for Frame Windows
656  *************************************************************************/
662  virtual void onRollupToggled(WindowEventArgs& e);
663 
664 
669  virtual void onCloseClicked(WindowEventArgs& e);
670 
672  virtual void onDragSizingStarted(WindowEventArgs& e);
673 
675  virtual void onDragSizingEnded(WindowEventArgs& e);
676 
677  /*************************************************************************
678  Overridden event handlers
679  *************************************************************************/
680  virtual void onMouseMove(MouseEventArgs& e);
681  virtual void onMouseButtonDown(MouseEventArgs& e);
682  virtual void onMouseButtonUp(MouseEventArgs& e);
683  virtual void onCaptureLost(WindowEventArgs& e);
684  virtual void onTextChanged(WindowEventArgs& e);
685  virtual void onActivated(ActivationEventArgs& e);
686  virtual void onDeactivated(ActivationEventArgs& e);
687 
688 
689  /*************************************************************************
690  Implementation Data
691  *************************************************************************/
692  // frame data
694 
695  // window roll-up data
697  bool d_rolledup;
698 
699  // drag-sizing data
702  float d_borderSize;
704 
705  // images for cursor when on sizing border
710 
712 
713 
714 private:
715  /*************************************************************************
716  Static Properties for this class
717  *************************************************************************/
718  static FrameWindowProperties::SizingEnabled d_sizingEnabledProperty;
719  static FrameWindowProperties::FrameEnabled d_frameEnabledProperty;
720  static FrameWindowProperties::TitlebarEnabled d_titlebarEnabledProperty;
721  static FrameWindowProperties::CloseButtonEnabled d_closeButtonEnabledProperty;
722  static FrameWindowProperties::RollUpState d_rollUpStateProperty;
723  static FrameWindowProperties::RollUpEnabled d_rollUpEnabledProperty;
724  static FrameWindowProperties::DragMovingEnabled d_dragMovingEnabledProperty;
725  static FrameWindowProperties::SizingBorderThickness d_sizingBorderThicknessProperty;
726  static FrameWindowProperties::NSSizingCursorImage d_nsSizingCursorProperty;
727  static FrameWindowProperties::EWSizingCursorImage d_ewSizingCursorProperty;
728  static FrameWindowProperties::NWSESizingCursorImage d_nwseSizingCursorProperty;
729  static FrameWindowProperties::NESWSizingCursorImage d_neswSizingCursorProperty;
730 
731 
732  /*************************************************************************
733  Private methods
734  *************************************************************************/
735  void addFrameWindowProperties(void);
736 };
737 
738 } // End of CEGUI namespace section
739 
740 #if defined(_MSC_VER)
741 # pragma warning(pop)
742 #endif
743 
744 #endif // end of guard _CEGUIFrameWindow_h_