Crazy Eddie's GUI System  0.8.5
widgets/FrameWindow.h
1 /***********************************************************************
2  created: 13/4/2004
3  author: Paul D Turner
4 
5  purpose: Interface to base class for FrameWindow
6 *************************************************************************/
7 /***************************************************************************
8  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining
11  * a copy of this software and associated documentation files (the
12  * "Software"), to deal in the Software without restriction, including
13  * without limitation the rights to use, copy, modify, merge, publish,
14  * distribute, sublicense, and/or sell copies of the Software, and to
15  * permit persons to whom the Software is furnished to do so, subject to
16  * the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be
19  * included in all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  ***************************************************************************/
29 #ifndef _CEGUIFrameWindow_h_
30 #define _CEGUIFrameWindow_h_
31 
32 #include "../Base.h"
33 #include "../Window.h"
34 
35 #if defined(_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 
41 // Start of CEGUI namespace section
42 namespace CEGUI
43 {
48 class CEGUIEXPORT FrameWindow : public Window
49 {
50 public:
51  static const String EventNamespace;
52  static const String WidgetTypeName;
53 
54  /*************************************************************************
55  Constants
56  *************************************************************************/
57  // additional event names for this window
63  static const String EventRollupToggled;
69  static const String EventCloseClicked;
82 
83  // other bits
84  static const float DefaultSizingBorderSize;
85 
86  /*************************************************************************
87  Child Widget name constants
88  *************************************************************************/
89  static const String TitlebarName;
90  static const String CloseButtonName;
91 
92 
106  SizingRight
107  };
108 
119  virtual void initialiseComponents(void);
120 
121 
129  bool isSizingEnabled(void) const {return d_sizingEnabled && isFrameEnabled();}
130 
131 
139  bool isFrameEnabled(void) const {return d_frameEnabled;}
140 
141 
149  bool isTitleBarEnabled(void) const;
150 
151 
159  bool isCloseButtonEnabled(void) const;
160 
161 
169  bool isRollupEnabled(void) const {return d_rollupEnabled;}
170 
178  void setRolledup(bool val);
179 
187  bool isRolledup(void) const {return d_rolledup;}
188 
189 
197  float getSizingBorderThickness(void) const {return d_borderSize;}
198 
199 
210  void setSizingEnabled(bool setting);
211 
212 
223  void setFrameEnabled(bool setting);
224 
225 
236  void setTitleBarEnabled(bool setting);
237 
238 
249  void setCloseButtonEnabled(bool setting);
250 
251 
262  void setRollupEnabled(bool setting);
263 
264 
272  void toggleRollup(void);
273 
284  void setSizingBorderThickness(float pixels) {d_borderSize = pixels;}
285 
286 
299  void offsetPixelPosition(const Vector2f& offset);
300 
301 
309  bool isDragMovingEnabled(void) const {return d_dragMovable;}
310 
311 
322  void setDragMovingEnabled(bool setting);
323 
324 
333  const Image* getNSSizingCursorImage() const;
334 
343  const Image* getEWSizingCursorImage() const;
344 
353  const Image* getNWSESizingCursorImage() const;
354 
363  const Image* getNESWSizingCursorImage() const;
364 
375  void setNSSizingCursorImage(const Image* image);
376 
387  void setEWSizingCursorImage(const Image* image);
388 
399  void setNWSESizingCursorImage(const Image* image);
400 
411  void setNESWSizingCursorImage(const Image* image);
412 
425  void setNSSizingCursorImage(const String& name);
426 
439  void setEWSizingCursorImage(const String& name);
440 
453  void setNWSESizingCursorImage(const String& name);
454 
467  void setNESWSizingCursorImage(const String& name);
468 
469  // overridden from Window class
470  bool isHit(const Vector2f& position, const bool /*allow_disabled*/) const
471  { return Window::isHit(position) && !d_rolledup; }
472 
483  Titlebar* getTitlebar() const;
484 
496  PushButton* getCloseButton() const;
497 
498  /*************************************************************************
499  Construction / Destruction
500  *************************************************************************/
505  FrameWindow(const String& type, const String& name);
506 
511  virtual ~FrameWindow(void);
512 
513 
514 protected:
515  /*************************************************************************
516  Implementation Functions
517  *************************************************************************/
525  bool moveLeftEdge(float delta, URect& out_area);
526 
527 
535  bool moveRightEdge(float delta, URect& out_area);
536 
537 
545  bool moveTopEdge(float delta, URect& out_area);
546 
547 
555  bool moveBottomEdge(float delta, URect& out_area);
556 
557 
571  SizingLocation getSizingBorderAtPoint(const Vector2f& pt) const;
572 
573 
584  bool isLeftSizingLocation(SizingLocation loc) const {return ((loc == SizingLeft) || (loc == SizingTopLeft) || (loc == SizingBottomLeft));}
585 
586 
597  bool isRightSizingLocation(SizingLocation loc) const {return ((loc == SizingRight) || (loc == SizingTopRight) || (loc == SizingBottomRight));}
598 
599 
610  bool isTopSizingLocation(SizingLocation loc) const {return ((loc == SizingTop) || (loc == SizingTopLeft) || (loc == SizingTopRight));}
611 
612 
623  bool isBottomSizingLocation(SizingLocation loc) const {return ((loc == SizingBottom) || (loc == SizingBottomLeft) || (loc == SizingBottomRight));}
624 
625 
630  bool closeClickHandler(const EventArgs& e);
631 
632 
637  void setCursorForPoint(const Vector2f& pt) const;
638 
639 
644  virtual Rectf getSizingRect(void) const {return Rectf(0, 0, d_pixelSize.d_width, d_pixelSize.d_height);}
645 
646  /*************************************************************************
647  New events for Frame Windows
648  *************************************************************************/
654  virtual void onRollupToggled(WindowEventArgs& e);
655 
656 
661  virtual void onCloseClicked(WindowEventArgs& e);
662 
664  virtual void onDragSizingStarted(WindowEventArgs& e);
665 
667  virtual void onDragSizingEnded(WindowEventArgs& e);
668 
669  /*************************************************************************
670  Overridden event handlers
671  *************************************************************************/
672  virtual void onMouseMove(MouseEventArgs& e);
673  virtual void onMouseButtonDown(MouseEventArgs& e);
674  virtual void onMouseButtonUp(MouseEventArgs& e);
675  virtual void onCaptureLost(WindowEventArgs& e);
676  virtual void onTextChanged(WindowEventArgs& e);
677  virtual void onActivated(ActivationEventArgs& e);
678  virtual void onDeactivated(ActivationEventArgs& e);
679 
680 
681  /*************************************************************************
682  Implementation Data
683  *************************************************************************/
684  // frame data
686 
687  // window roll-up data
689  bool d_rolledup;
690 
691  // drag-sizing data
694  float d_borderSize;
696 
697  // images for cursor when on sizing border
702 
704 
705 
706 private:
707  /*************************************************************************
708  Private methods
709  *************************************************************************/
710  void addFrameWindowProperties(void);
711 };
712 
713 } // End of CEGUI namespace section
714 
715 #if defined(_MSC_VER)
716 # pragma warning(pop)
717 #endif
718 
719 #endif // end of guard _CEGUIFrameWindow_h_
720 
bool d_rolledup
true if window is rolled up.
Definition: widgets/FrameWindow.h:689
virtual bool isHit(const Vector2f &position, const bool allow_disabled=false) const
check if the given pixel position would hit this window.
Position will size from the left.
Definition: widgets/FrameWindow.h:104
bool d_rollupEnabled
true if roll-up of window is allowed.
Definition: widgets/FrameWindow.h:688
static const String WidgetTypeName
Window factory name.
Definition: widgets/FrameWindow.h:52
bool d_sizingEnabled
true if sizing is enabled for this window.
Definition: widgets/FrameWindow.h:692
Position will size from the bottom left.
Definition: widgets/FrameWindow.h:101
Interface for Image.
Definition: Image.h:158
Position will size from the top-right.
Definition: widgets/FrameWindow.h:100
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
static const float DefaultSizingBorderSize
Default size for the sizing border (in pixels)
Definition: widgets/FrameWindow.h:84
static const String EventNamespace
Namespace for global events.
Definition: widgets/FrameWindow.h:51
const Image * d_nwseSizingCursor
North-West/South-East cursor image.
Definition: widgets/FrameWindow.h:700
bool isRolledup(void) const
Return whether the window is currently rolled up (a.k.a shaded).
Definition: widgets/FrameWindow.h:187
Vector2f d_dragPoint
point window is being dragged at.
Definition: widgets/FrameWindow.h:695
static const String EventDragSizingStarted
Definition: widgets/FrameWindow.h:75
SizingLocation
Enumeration that defines the set of possible locations for the mouse on a frame windows sizing border...
Definition: widgets/FrameWindow.h:97
void setSizingBorderThickness(float pixels)
Set the size of the sizing border for this window.
Definition: widgets/FrameWindow.h:284
bool d_beingSized
true if window is being sized.
Definition: widgets/FrameWindow.h:693
bool isRightSizingLocation(SizingLocation loc) const
return true if given SizingLocation is on right edge.
Definition: widgets/FrameWindow.h:597
virtual Rectf getSizingRect(void) const
Return a Rect that describes, in window relative pixel co-ordinates, the outer edge of the sizing are...
Definition: widgets/FrameWindow.h:644
static const String TitlebarName
Widget name for the titlebar component.
Definition: widgets/FrameWindow.h:89
bool isHit(const Vector2f &position, const bool) const
check if the given pixel position would hit this window.
Definition: widgets/FrameWindow.h:470
bool isDragMovingEnabled(void) const
Return whether this FrameWindow can be moved by dragging the title bar.
Definition: widgets/FrameWindow.h:309
Position will size from the bottom right.
Definition: widgets/FrameWindow.h:102
static const String CloseButtonName
Widget name for the close button component.
Definition: widgets/FrameWindow.h:90
Position will size from the top.
Definition: widgets/FrameWindow.h:103
Class representing the title bar for Frame Windows.
Definition: widgets/Titlebar.h:50
Position is not a sizing location.
Definition: widgets/FrameWindow.h:98
float d_borderSize
thickness of the sizing border around this window
Definition: widgets/FrameWindow.h:694
Base class to provide logic for push button type widgets.
Definition: PushButton.h:47
bool d_dragMovable
true if the window will move when dragged by the title bar.
Definition: widgets/FrameWindow.h:703
static const String EventCloseClicked
Definition: widgets/FrameWindow.h:69
float getSizingBorderThickness(void) const
Return the thickness of the sizing border.
Definition: widgets/FrameWindow.h:197
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
Abstract base class for a movable, sizable, window with a title-bar and a frame.
Definition: widgets/FrameWindow.h:48
bool isSizingEnabled(void) const
Return whether this window is sizable. Note that this requires that the window have an enabled frame ...
Definition: widgets/FrameWindow.h:129
bool d_frameEnabled
true if window frame should be drawn.
Definition: widgets/FrameWindow.h:685
Position will size from the top-left.
Definition: widgets/FrameWindow.h:99
const Image * d_ewSizingCursor
East/West sizing cursor image.
Definition: widgets/FrameWindow.h:699
bool isFrameEnabled(void) const
Return whether the frame for this window is enabled.
Definition: widgets/FrameWindow.h:139
static const String EventDragSizingEnded
Definition: widgets/FrameWindow.h:81
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:251
EventArgs based class that is used for objects passed to input event handlers concerning mouse input...
Definition: InputEvent.h:280
bool isBottomSizingLocation(SizingLocation loc) const
return true if given SizingLocation is on bottom edge.
Definition: widgets/FrameWindow.h:623
static const String EventRollupToggled
Definition: widgets/FrameWindow.h:63
bool isLeftSizingLocation(SizingLocation loc) const
return true if given SizingLocation is on left edge.
Definition: widgets/FrameWindow.h:584
Position will size from the bottom.
Definition: widgets/FrameWindow.h:105
bool isTopSizingLocation(SizingLocation loc) const
return true if given SizingLocation is on top edge.
Definition: widgets/FrameWindow.h:610
bool isRollupEnabled(void) const
Return whether roll up (a.k.a shading) is enabled for this window.
Definition: widgets/FrameWindow.h:169
const Image * d_nsSizingCursor
North/South sizing cursor image.
Definition: widgets/FrameWindow.h:698
const Image * d_neswSizingCursor
North-East/South-West cursor image.
Definition: widgets/FrameWindow.h:701
EventArgs based class that is used for Activated and Deactivated window events.
Definition: InputEvent.h:329
String class used within the GUI system.
Definition: String.h:62