source: OGRE/trunk/ogrenew/Dependencies/include/CEGUI/elements/CEGUIFrameWindow.h @ 657

Revision 657, 18.1 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

Line 
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    Crazy Eddie's GUI System (http://www.cegui.org.uk)
10    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
11
12    This library is free software; you can redistribute it and/or
13    modify it under the terms of the GNU Lesser General Public
14    License as published by the Free Software Foundation; either
15    version 2.1 of the License, or (at your option) any later version.
16
17    This library is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20    Lesser General Public License for more details.
21
22    You should have received a copy of the GNU Lesser General Public
23    License along with this library; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25*************************************************************************/
26#ifndef _CEGUIFrameWindow_h_
27#define _CEGUIFrameWindow_h_
28
29#include "CEGUIBase.h"
30#include "CEGUIWindow.h"
31#include "elements/CEGUIFrameWindowProperties.h"
32
33
34#if defined(_MSC_VER)
35#       pragma warning(push)
36#       pragma warning(disable : 4251)
37#endif
38
39
40// Start of CEGUI namespace section
41namespace CEGUI
42{
43/*!
44\brief
45        Abstract base class for a movable, sizable, window with a title-bar and a frame.
46*/
47class CEGUIEXPORT FrameWindow : public Window
48{
49public:
50        static const String EventNamespace;                             //!< Namespace for global events
51
52
53        /*************************************************************************
54                Constants       
55        *************************************************************************/
56        // additional event names for this window
57        static const String EventRollupToggled;         //!< Fired when the rollup (shade) state of the window changes
58        static const String EventCloseClicked;          //!< Fired when the close button for the window is clicked.
59
60        // other bits
61        static const float      DefaultSizingBorderSize;        //!< Default size for the sizing border (in pixels)
62
63
64        /*!
65        \brief
66                Enumeration that defines the set of possible locations for the mouse on a frame windows sizing border.
67        */
68        enum SizingLocation {
69                SizingNone,                     //!< Position is not a sizing location.
70                SizingTopLeft,          //!< Position will size from the top-left.
71                SizingTopRight,         //!< Position will size from the top-right.
72                SizingBottomLeft,       //!< Position will size from the bottom left.
73                SizingBottomRight,      //!< Position will size from the bottom right.
74                SizingTop,                      //!< Position will size from the top.
75                SizingLeft,                     //!< Position will size from the left.
76                SizingBottom,           //!< Position will size from the bottom.
77                SizingRight         //!< Position will size from the right.
78        };
79
80        /*!
81        \brief
82                Initialises the Window based object ready for use.
83
84        \note
85                This must be called for every window created.  Normally this is handled automatically by the WindowFactory for each Window type.
86
87        \return
88                Nothing
89        */
90        virtual void    initialise(void);
91       
92       
93        /*!
94        \brief
95                Return whether this window is sizable.  Note that this requires that the window have an enabled frame and that sizing itself is enabled
96
97        \return
98                true if the window can be sized, false if the window can not be sized
99        */
100        bool    isSizingEnabled(void) const                                     {return d_sizingEnabled && isFrameEnabled();}
101
102
103        /*!
104        \brief
105                Return whether the frame for this window is enabled.
106
107        \return
108                true if the frame for this window is enabled, false if the frame for this window is disabled.
109        */
110        bool    isFrameEnabled(void) const                                      {return d_frameEnabled;}
111
112
113        /*!
114        \brief
115                Return whether the title bar for this window is enabled.
116
117        \return
118                true if the window has a title bar and it is enabled, false if the window has no title bar or if the title bar is disabled.
119        */     
120        bool    isTitleBarEnabled(void) const                           {return (d_titlebar != NULL) && !((Window*)d_titlebar)->isDisabled();}
121
122
123        /*!
124        \brief
125                Return whether this close button for this window is enabled.
126
127        \return
128                true if the window has a close button and it is enabled, false if the window either has no close button or if the close button is disabled.
129        */
130        bool    isCloseButtonEnabled(void) const                        {return (d_closeButton != NULL) && !((Window*)d_closeButton)->isDisabled();}
131
132
133        /*!
134        \brief
135                Return whether roll up (a.k.a shading) is enabled for this window.
136
137        \return
138                true if roll up is enabled, false if roll up is disabled.
139        */
140        bool    isRollupEnabled(void) const                                     {return d_rollupEnabled;}
141
142
143        /*!
144        \brief
145                Return whether the window is currently rolled up (a.k.a shaded).
146
147        \return
148                true if the window is rolled up, false if the window is not rolled up.
149        */
150        bool    isRolledup(void) const                                          {return d_rolledup;}
151
152
153        /*!
154        \brief
155                Return the thickness of the sizing border.
156
157        \return
158                float value describing the thickness of the sizing border in screen pixels.
159        */
160        float   getSizingBorderThickness(void) const            {return d_borderSize;}
161
162
163        /*!
164        \brief
165                Enables or disables sizing for this window.
166
167        \param setting
168                set to true to enable sizing (also requires frame to be enabled), or false to disable sizing.
169
170        \return
171                nothing
172        */
173        void    setSizingEnabled(bool setting);
174
175
176        /*!
177        \brief
178                Enables or disables the frame for this window.
179
180        \param setting
181                set to true to enable the frame for this window, or false to disable the frame for this window.
182
183        \return
184                Nothing.
185        */
186        void    setFrameEnabled(bool setting);
187
188
189        /*!
190        \brief
191                Enables or disables the title bar for the frame window.
192
193        \param setting
194                set to true to enable the title bar (if one is attached), or false to disable the title bar.
195
196        \return
197                Nothing.
198        */
199        void    setTitleBarEnabled(bool setting);
200
201
202        /*!
203        \brief
204                Enables or disables the close button for the frame window.
205
206        \param setting
207                Set to true to enable the close button (if one is attached), or false to disable the close button.
208
209        \return
210                Nothing.
211        */
212        void    setCloseButtonEnabled(bool setting);
213
214
215        /*!
216        \brief
217                Enables or disables roll-up (shading) for this window.
218
219        \param setting
220                Set to true to enable roll-up for the frame window, or false to disable roll-up.
221
222        \return
223                Nothing.
224        */
225        void    setRollupEnabled(bool setting);
226
227
228        /*!
229        \brief
230                Toggles the state of the window between rolled-up (shaded) and normal sizes.  This requires roll-up to be enabled.
231
232        \return
233                Nothing
234        */
235        void    toggleRollup(void);
236
237
238        /*!
239        \brief
240                Set the size of the sizing border for this window.
241
242        \param pixels
243                float value specifying the thickness for the sizing border in screen pixels.
244
245        \return
246                Nothing.
247        */
248        void    setSizingBorderThickness(float pixels)          {d_borderSize = pixels;}
249
250
251        /*!
252        \brief
253                Set the font to use for the title bar text
254
255        \param name
256                String object holding the name of the font to use.
257
258        \return
259                Nothing.
260        */
261        void    setTitlebarFont(const String& name);
262
263
264        /*!
265        \brief
266                Set the font to use for the title bar text
267
268        \param font
269                Pointer to the font to use.
270
271        \return
272                Nothing.
273        */
274        void    setTitlebarFont(Font* font);
275
276
277        /*!
278        \brief
279                Move the window by the pixel offsets specified in \a offset.
280
281                This is intended for internal system use - it is the method by which the title bar moves the frame window.
282
283        \param offset
284                Vector2 object containing the offsets to apply (offsets are in screen pixels).
285
286        \return
287                Nothing.
288        */
289        void    offsetPixelPosition(const Vector2& offset);
290
291
292        /*!
293        \brief
294                Return whether this FrameWindow can be moved by dragging the title bar.
295
296        \return
297                true if the Window will move when the user drags the title bar, false if the window will not move.
298        */
299        bool    isDragMovingEnabled(void) const         {return d_dragMovable;}
300
301
302        /*!
303        \brief
304                Set whether this FrameWindow can be moved by dragging the title bar.
305
306        \param setting
307                true if the Window should move when the user drags the title bar, false if the window should not move.
308
309        \return
310                Nothing.
311        */
312        void    setDragMovingEnabled(bool setting);
313
314
315        /*!
316        \brief
317                Return the font being used for the title bar text
318
319        \return
320                Pointer to the Font being used for the TitleBar on this FrameWindow.
321        */
322        const Font*     getTitlebarFont(void) const;
323
324
325        /*!
326        \brief
327                Return the current colour used for rendering the caption text
328
329        \return
330                colour value that specifies the colour used when rendering the title bar caption text.
331        */
332        colour  getCaptionColour(void) const;
333
334
335        /*!
336        \brief
337                Sets the colour to be used for rendering the caption text.
338
339        \param col
340                colour value that specifies the colour to be used when rendering the title bar caption text.
341
342        \return
343                Nothing.
344        */
345        void    setCaptionColour(colour col);
346
347
348        /*************************************************************************
349                Construction / Destruction
350        *************************************************************************/
351        /*!
352        \brief
353                Constructor for FrameWindow objects.
354        */
355        FrameWindow(const String& name, const String& type);
356
357        /*!
358        \brief
359                Destructor for FramwWindow objects.
360        */
361        virtual ~FrameWindow(void);
362
363
364protected:
365        /*************************************************************************
366                Implementation Functions
367        *************************************************************************/
368        /*!
369        \brief
370                Create a control based upon the Titlebar base class to be used as the title bar for this window.
371
372        \return
373                Pointer to an object who's class derives from Titlebar
374        */
375        virtual Titlebar*       createTitlebar(void) const              = 0;
376
377
378        /*!
379        \brief
380                Create a control based upon the PushButton base class, to be used at the close button for the window.
381
382        \return
383                Pointer to an object who's class derives from PushButton.
384        */
385        virtual PushButton*     createCloseButton(void) const   = 0;
386
387
388        /*!
389        \brief
390                Setup size and position for the title bar and close button widgets attached to this window
391
392        \return
393                Nothing.
394        */
395        virtual void    layoutComponentWidgets()                = 0;
396
397
398        /*!
399        \brief
400                move the window's left edge by 'delta'.  The rest of the window does not move, thus this changes the size of the Window.
401
402        \param delta
403                float value that specifies the amount to move the window edge, and in which direction.  Positive values make window smaller.
404        */
405        void    moveLeftEdge(float delta);
406
407
408        /*!
409        \brief
410                move the window's right edge by 'delta'.  The rest of the window does not move, thus this changes the size of the Window.
411
412        \param delta
413                float value that specifies the amount to move the window edge, and in which direction.  Positive values make window larger.
414        */
415        void    moveRightEdge(float delta);
416
417
418        /*!
419        \brief
420                move the window's top edge by 'delta'.  The rest of the window does not move, thus this changes the size of the Window.
421
422        \param delta
423                float value that specifies the amount to move the window edge, and in which direction.  Positive values make window smaller.
424        */
425        void    moveTopEdge(float delta);
426
427
428        /*!
429        \brief
430                move the window's bottom edge by 'delta'.  The rest of the window does not move, thus this changes the size of the Window.
431
432        \param delta
433                float value that specifies the amount to move the window edge, and in which direction.  Positive values make window larger.
434        */
435        void    moveBottomEdge(float delta);
436
437
438        /*!
439        \brief
440                check local pixel co-ordinate point 'pt' and return one of the
441                SizingLocation enumerated values depending where the point falls on
442                the sizing border.
443
444        \param pt
445                Point object describing, in pixels, the window relative offset to check.
446
447        \return
448                One of the SizingLocation enumerated values that describe which part of
449                the sizing border that \a pt corresponded to, if any.
450        */
451        SizingLocation  getSizingBorderAtPoint(const Point& pt) const;
452
453 
454        /*!
455        \brief
456                return true if given SizingLocation is on left edge.
457
458        \param loc
459                SizingLocation value to be checked.
460
461        \return
462                true if \a loc is on the left edge.  false if \a loc is not on the left edge.
463        */
464        bool    isLeftSizingLocation(SizingLocation loc) const                  {return ((loc == SizingLeft) || (loc == SizingTopLeft) || (loc == SizingBottomLeft));}
465
466
467        /*!
468        \brief
469                return true if given SizingLocation is on right edge.
470
471        \param loc
472                SizingLocation value to be checked.
473
474        \return
475                true if \a loc is on the right edge.  false if \a loc is not on the right edge.
476        */
477        bool    isRightSizingLocation(SizingLocation loc) const                 {return ((loc == SizingRight) || (loc == SizingTopRight) || (loc == SizingBottomRight));}
478
479
480        /*!
481        \brief
482                return true if given SizingLocation is on top edge.
483
484        \param loc
485                SizingLocation value to be checked.
486
487        \return
488                true if \a loc is on the top edge.  false if \a loc is not on the top edge.
489        */
490        bool    isTopSizingLocation(SizingLocation loc) const                   {return ((loc == SizingTop) || (loc == SizingTopLeft) || (loc == SizingTopRight));}
491
492
493        /*!
494        \brief
495                return true if given SizingLocation is on bottom edge.
496
497        \param loc
498                SizingLocation value to be checked.
499
500        \return
501                true if \a loc is on the bottom edge.  false if \a loc is not on the bottom edge.
502        */
503        bool    isBottomSizingLocation(SizingLocation loc) const                {return ((loc == SizingBottom) || (loc == SizingBottomLeft) || (loc == SizingBottomRight));}
504
505
506        /*!
507        \brief
508                Add frame window specific events
509        */
510        void    addFrameWindowEvents(void);
511
512
513        /*!
514        \brief
515                Method to respond to close button click events and fire our close event
516        */
517        bool    closeClickHandler(const EventArgs& e);
518
519
520        /*!
521        \brief
522                Set the appropriate mouse cursor for the given window-relative pixel point.
523        */
524        void    setCursorForPoint(const Point& pt) const;
525
526
527        /*!
528        \brief
529                Return a Rect that describes, in window relative pixel co-ordinates, the outer edge of the sizing area for this window.
530        */
531        virtual Rect    getSizingRect(void) const               {return Rect(0, 0, d_abs_area.getWidth(), d_abs_area.getHeight());}
532
533
534        /*!
535        \brief
536                Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
537
538        \param class_name
539                The class name that is to be checked.
540
541        \return
542                true if this window was inherited from \a class_name. false if not.
543        */
544        virtual bool    testClassName_impl(const String& class_name) const
545        {
546                if (class_name==(const utf8*)"FrameWindow")     return true;
547                return Window::testClassName_impl(class_name);
548        }
549
550
551        /*************************************************************************
552                New events for Frame Windows
553        *************************************************************************/
554        /*!
555        \brief
556                Event generated internally whenever the roll-up / shade state of the window
557                changes.
558        */
559        virtual void    onRollupToggled(WindowEventArgs& e);
560
561
562        /*!
563        \brief
564                Event generated internally whenever the close button is clicked.
565        */
566        virtual void    onCloseClicked(WindowEventArgs& e);
567
568
569        /*************************************************************************
570                Overridden event handlers
571        *************************************************************************/
572        virtual void    onMouseMove(MouseEventArgs& e);
573        virtual void    onMouseButtonDown(MouseEventArgs& e);
574        virtual void    onMouseButtonUp(MouseEventArgs& e);
575        virtual void    onCaptureLost(WindowEventArgs& e);
576        virtual void    onSized(WindowEventArgs& e);
577        virtual void    onParentSized(WindowEventArgs& e);
578
579
580        /*************************************************************************
581                Implementation Data
582        *************************************************************************/
583        // frame data
584        bool    d_frameEnabled;         //!< true if window frame should be drawn.
585
586        // window roll-up data
587        bool    d_rollupEnabled;        //!< true if roll-up of window is allowed.
588        bool    d_rolledup;                     //!< true if window is rolled up.
589        Size    d_abs_openSize;         //!< stores original size of window when rolled-up.
590        Size    d_rel_openSize;         //!< stores original size of window when rolled-up.
591
592        // drag-sizing data
593        bool    d_sizingEnabled;        //!< true if sizing is enabled for this window.
594        bool    d_beingSized;           //!< true if window is being sized.
595        float   d_borderSize;           //!< thickness of the sizing border around this window
596        Point   d_dragPoint;            //!< point window is being dragged at.
597
598        // composite controls
599        Titlebar*       d_titlebar;                             //!< points to the title bar widget.
600        PushButton*     d_closeButton;                  //!< points to close button widget.
601
602        // images for cursor when on sizing border
603        const Image*    d_nsSizingCursor;               //!< North/South sizing cursor image.
604        const Image*    d_ewSizingCursor;               //!< East/West sizing cursor image.
605        const Image*    d_nwseSizingCursor;             //!< North-West/South-East cursor image.
606        const Image*    d_neswSizingCursor;             //!< North-East/South-West cursor image.
607
608        bool    d_dragMovable;          //!< true if the window will move when dragged by the title bar.
609
610
611private:
612        /*************************************************************************
613                Static Properties for this class
614        *************************************************************************/
615        static FrameWindowProperties::SizingEnabled             d_sizingEnabledProperty;
616        static FrameWindowProperties::FrameEnabled              d_frameEnabledProperty;
617        static FrameWindowProperties::TitlebarEnabled   d_titlebarEnabledProperty;
618        static FrameWindowProperties::CloseButtonEnabled d_closeButtonEnabledProperty;
619        static FrameWindowProperties::RollUpState               d_rollUpStateProperty;
620        static FrameWindowProperties::RollUpEnabled             d_rollUpEnabledProperty;
621        static FrameWindowProperties::DragMovingEnabled d_dragMovingEnabledProperty;
622        static FrameWindowProperties::SizingBorderThickness d_sizingBorderThicknessProperty;
623        static FrameWindowProperties::TitlebarFont              d_titlebarFontProperty;
624        static FrameWindowProperties::CaptionColour             d_captionColourProperty;
625
626
627        /*************************************************************************
628                Private methods
629        *************************************************************************/
630        void    addFrameWindowProperties(void);
631};
632
633} // End of  CEGUI namespace section
634
635#if defined(_MSC_VER)
636#       pragma warning(pop)
637#endif
638
639#endif  // end of guard _CEGUIFrameWindow_h_
Note: See TracBrowser for help on using the repository browser.