Crazy Eddie's GUI System  0.8.7
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 
334 
344 
354 
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 
484 
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 
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  *************************************************************************/
655 
656 
661  virtual void onCloseClicked(WindowEventArgs& e);
662 
665 
668 
669  /*************************************************************************
670  Overridden event handlers
671  *************************************************************************/
672  virtual void onMouseMove(MouseEventArgs& e);
674  virtual void onMouseButtonUp(MouseEventArgs& e);
675  virtual void onCaptureLost(WindowEventArgs& e);
676  virtual void onTextChanged(WindowEventArgs& 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 
EventArgs based class that is used for Activated and Deactivated window events.
Definition: InputEvent.h:330
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:51
Abstract base class for a movable, sizable, window with a title-bar and a frame.
Definition: widgets/FrameWindow.h:49
static const String EventNamespace
Namespace for global events.
Definition: widgets/FrameWindow.h:51
void setNESWSizingCursorImage(const Image *image)
Set the Image to be used for the northeast-southwest sizing mouse cursor.
bool moveTopEdge(float delta, URect &out_area)
move the window's top edge by 'delta'. The rest of the window does not move, thus this changes the si...
void offsetPixelPosition(const Vector2f &offset)
Move the window by the pixel offsets specified in offset.
void setEWSizingCursorImage(const String &name)
Set the image to be used for the east-west sizing mouse cursor.
void setDragMovingEnabled(bool setting)
Set whether this FrameWindow can be moved by dragging the title bar.
bool isFrameEnabled(void) const
Return whether the frame for this window is enabled.
Definition: widgets/FrameWindow.h:139
PushButton * getCloseButton() const
Return a pointer to the close button component widget for this FrameWindow.
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
void setNWSESizingCursorImage(const Image *image)
Set the Image to be used for the northwest-southeast sizing mouse cursor.
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
virtual void initialiseComponents(void)
Initialises the Window based object ready for use.
void setTitleBarEnabled(bool setting)
Enables or disables the title bar for the frame window.
bool d_rolledup
true if window is rolled up.
Definition: widgets/FrameWindow.h:689
bool d_rollupEnabled
true if roll-up of window is allowed.
Definition: widgets/FrameWindow.h:688
static const String EventCloseClicked
Definition: widgets/FrameWindow.h:69
FrameWindow(const String &type, const String &name)
Constructor for FrameWindow objects.
bool isDragMovingEnabled(void) const
Return whether this FrameWindow can be moved by dragging the title bar.
Definition: widgets/FrameWindow.h:309
bool isTitleBarEnabled(void) const
Return whether the title bar for this window is enabled.
static const String EventRollupToggled
Definition: widgets/FrameWindow.h:63
void setNWSESizingCursorImage(const String &name)
Set the image to be used for the northwest-southeast sizing mouse cursor.
void setSizingBorderThickness(float pixels)
Set the size of the sizing border for this window.
Definition: widgets/FrameWindow.h:284
virtual void onTextChanged(WindowEventArgs &e)
Handler called when the window's text is changed.
virtual void onMouseMove(MouseEventArgs &e)
Handler called when the mouse cursor has been moved within this window's area.
virtual ~FrameWindow(void)
Destructor for FramwWindow objects.
void setEWSizingCursorImage(const Image *image)
Set the Image to be used for the east-west sizing mouse cursor.
const Image * d_nsSizingCursor
North/South sizing cursor image.
Definition: widgets/FrameWindow.h:698
const Image * getNESWSizingCursorImage() const
Return a pointer to the currently set Image to be used for the northeast-southwest sizing mouse curso...
bool d_sizingEnabled
true if sizing is enabled for this window.
Definition: widgets/FrameWindow.h:692
virtual void onCloseClicked(WindowEventArgs &e)
Event generated internally whenever the close button is clicked.
virtual void onDeactivated(ActivationEventArgs &e)
Handler called when this window has lost input focus and has been deactivated.
float d_borderSize
thickness of the sizing border around this window
Definition: widgets/FrameWindow.h:694
bool isRolledup(void) const
Return whether the window is currently rolled up (a.k.a shaded).
Definition: widgets/FrameWindow.h:187
bool isRollupEnabled(void) const
Return whether roll up (a.k.a shading) is enabled for this window.
Definition: widgets/FrameWindow.h:169
virtual void onDragSizingEnded(WindowEventArgs &e)
Handler called when drag-sizing of the FrameWindow ends.
bool isCloseButtonEnabled(void) const
Return whether this close button for this window is enabled.
void setNSSizingCursorImage(const Image *image)
Set the Image to be used for the north-south sizing mouse cursor.
bool moveBottomEdge(float delta, URect &out_area)
move the window's bottom edge by 'delta'. The rest of the window does not move, thus this changes the...
const Image * getNSSizingCursorImage() const
Return a pointer to the currently set Image to be used for the north-south sizing mouse cursor.
Vector2f d_dragPoint
point window is being dragged at.
Definition: widgets/FrameWindow.h:695
void setNSSizingCursorImage(const String &name)
Set the image to be used for the north-south sizing mouse cursor.
bool moveRightEdge(float delta, URect &out_area)
move the window's right edge by 'delta'. The rest of the window does not move, thus this changes the ...
bool moveLeftEdge(float delta, URect &out_area)
move the window's left edge by 'delta'. The rest of the window does not move, thus this changes the s...
const Image * d_nwseSizingCursor
North-West/South-East cursor image.
Definition: widgets/FrameWindow.h:700
void setSizingEnabled(bool setting)
Enables or disables sizing for this window.
const Image * getEWSizingCursorImage() const
Return a pointer to the currently set Image to be used for the east-west sizing mouse cursor.
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 void onCaptureLost(WindowEventArgs &e)
Handler called when this window loses capture of mouse inputs.
const Image * d_neswSizingCursor
North-East/South-West cursor image.
Definition: widgets/FrameWindow.h:701
const Image * getNWSESizingCursorImage() const
Return a pointer to the currently set Image to be used for the northwest-southeast sizing mouse curso...
bool isLeftSizingLocation(SizingLocation loc) const
return true if given SizingLocation is on left edge.
Definition: widgets/FrameWindow.h:584
Titlebar * getTitlebar() const
Return a pointer to the Titlebar component widget for this FrameWindow.
void setFrameEnabled(bool setting)
Enables or disables the frame for this window.
void setRollupEnabled(bool setting)
Enables or disables roll-up (shading) for this window.
void setCloseButtonEnabled(bool setting)
Enables or disables the close button for the frame window.
void setRolledup(bool val)
Sets whether the window is currently rolled up (a.k.a shaded).
static const String EventDragSizingStarted
Definition: widgets/FrameWindow.h:75
bool d_frameEnabled
true if window frame should be drawn.
Definition: widgets/FrameWindow.h:685
const Image * d_ewSizingCursor
East/West sizing cursor image.
Definition: widgets/FrameWindow.h:699
bool d_dragMovable
true if the window will move when dragged by the title bar.
Definition: widgets/FrameWindow.h:703
static const String TitlebarName
Widget name for the titlebar component.
Definition: widgets/FrameWindow.h:89
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
bool closeClickHandler(const EventArgs &e)
Method to respond to close button click events and fire our close event.
static const String EventDragSizingEnded
Definition: widgets/FrameWindow.h:81
bool isHit(const Vector2f &position, const bool) const
check if the given pixel position would hit this window.
Definition: widgets/FrameWindow.h:470
bool isTopSizingLocation(SizingLocation loc) const
return true if given SizingLocation is on top edge.
Definition: widgets/FrameWindow.h:610
static const float DefaultSizingBorderSize
Default size for the sizing border (in pixels)
Definition: widgets/FrameWindow.h:84
bool isBottomSizingLocation(SizingLocation loc) const
return true if given SizingLocation is on bottom edge.
Definition: widgets/FrameWindow.h:623
void setCursorForPoint(const Vector2f &pt) const
Set the appropriate mouse cursor for the given window-relative pixel point.
void toggleRollup(void)
Toggles the state of the window between rolled-up (shaded) and normal sizes. This requires roll-up to...
static const String CloseButtonName
Widget name for the close button component.
Definition: widgets/FrameWindow.h:90
void setNESWSizingCursorImage(const String &name)
Set the image to be used for the northeast-southwest sizing mouse cursor.
virtual void onActivated(ActivationEventArgs &e)
Handler called when this window has become the active window.
virtual void onDragSizingStarted(WindowEventArgs &e)
Handler called when drag-sizing of the FrameWindow starts.
SizingLocation getSizingBorderAtPoint(const Vector2f &pt) const
check local pixel co-ordinate point 'pt' and return one of the SizingLocation enumerated values depen...
virtual void onMouseButtonUp(MouseEventArgs &e)
Handler called when a mouse button has been released within this window's area.
static const String WidgetTypeName
Window factory name.
Definition: widgets/FrameWindow.h:52
SizingLocation
Enumeration that defines the set of possible locations for the mouse on a frame windows sizing border...
Definition: widgets/FrameWindow.h:97
@ SizingTopRight
Position will size from the top-right.
Definition: widgets/FrameWindow.h:100
@ SizingBottomRight
Position will size from the bottom right.
Definition: widgets/FrameWindow.h:102
@ SizingBottomLeft
Position will size from the bottom left.
Definition: widgets/FrameWindow.h:101
@ SizingTop
Position will size from the top.
Definition: widgets/FrameWindow.h:103
@ SizingBottom
Position will size from the bottom.
Definition: widgets/FrameWindow.h:105
@ SizingNone
Position is not a sizing location.
Definition: widgets/FrameWindow.h:98
@ SizingTopLeft
Position will size from the top-left.
Definition: widgets/FrameWindow.h:99
@ SizingLeft
Position will size from the left.
Definition: widgets/FrameWindow.h:104
virtual void onRollupToggled(WindowEventArgs &e)
Event generated internally whenever the roll-up / shade state of the window changes.
float getSizingBorderThickness(void) const
Return the thickness of the sizing border.
Definition: widgets/FrameWindow.h:197
Interface for Image.
Definition: Image.h:161
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition: InputEvent.h:281
Base class to provide logic for push button type widgets.
Definition: PushButton.h:48
String class used within the GUI system.
Definition: String.h:64
Class representing the title bar for Frame Windows.
Definition: widgets/Titlebar.h:51
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:252
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
virtual bool isHit(const Vector2f &position, const bool allow_disabled=false) const
check if the given pixel position would hit this window.
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1