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

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

added ogre dependencies and patched ogre sources

Line 
1/************************************************************************
2        filename:       CEGUIScrollablePane.h
3        created:        1/3/2005
4        author:         Paul D Turner
5*************************************************************************/
6/*************************************************************************
7    Crazy Eddie's GUI System (http://www.cegui.org.uk)
8    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
9
10    This library is free software; you can redistribute it and/or
11    modify it under the terms of the GNU Lesser General Public
12    License as published by the Free Software Foundation; either
13    version 2.1 of the License, or (at your option) any later version.
14
15    This library is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    Lesser General Public License for more details.
19
20    You should have received a copy of the GNU Lesser General Public
21    License along with this library; if not, write to the Free Software
22    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23*************************************************************************/
24#ifndef _CEGUIScrollablePane_h_
25#define _CEGUIScrollablePane_h_
26
27#include "CEGUIBase.h"
28#include "CEGUIWindow.h"
29#include "elements/CEGUIScrollablePaneProperties.h"
30
31// Start of CEGUI namespace section
32namespace CEGUI
33{
34    /*!
35    \brief
36        Base class for the ScrollablePane widget.
37
38        The ScrollablePane widget allows child windows to be attached which cover an area
39        larger than the ScrollablePane itself and these child windows can be scrolled into
40        view using the scrollbars of the scrollable pane.
41    */
42    class CEGUIEXPORT ScrollablePane : public Window
43    {
44    public:
45        /*************************************************************************
46            Constants
47        *************************************************************************/
48        static const String EventNamespace;                 //!< Namespace for global events
49        static const String EventContentPaneChanged;        //!< Event fired when an area on the content pane has been updated.
50        static const String EventVertScrollbarModeChanged;      //!< Event triggered when the vertical scroll bar 'force' setting changes.
51        static const String EventHorzScrollbarModeChanged;      //!< Event triggered when the horizontal scroll bar 'force' setting changes.
52        static const String EventAutoSizeSettingChanged;    //!< Event fired when the auto size setting changes.
53        static const String EventContentPaneScrolled;       //!< Event fired when the pane gets scrolled.
54
55        /*************************************************************************
56            Construction / Destruction
57        *************************************************************************/
58        /*!
59        \brief
60            Constructor for the ScrollablePane base class.
61        */
62        ScrollablePane(const String& type, const String& name);
63
64        /*!
65        \brief
66            Destructor for the ScrollablePane base class.
67        */
68        ~ScrollablePane(void);
69
70        /*************************************************************************
71                Public interface
72        *************************************************************************/
73        /*!
74        \brief
75            Returns a pointer to the window holding the pane contents.
76
77            The purpose of this is so that attached windows may be inspected,
78            client code may not modify the returned window in any way.
79
80        \return
81            Pointer to the ScrolledContainer that is acting as the container for the
82            scrollable pane content.  The returned window is const, client code should
83            not modify the ScrolledContainer settings directly.
84        */
85        const ScrolledContainer* getContentPane(void) const;
86
87        /*!
88        \brief
89            Return whether the vertical scroll bar is always shown.
90
91        \return
92            - true if the scroll bar will always be shown even if it is not required.
93            - false if the scroll bar will only be shown when it is required.
94        */
95        bool    isVertScrollbarAlwaysShown(void) const;
96        /*!
97        \brief
98            Set whether the vertical scroll bar should always be shown.
99
100        \param setting
101            - true if the vertical scroll bar should be shown even when it is not required.
102            - false if the vertical scroll bar should only be shown when it is required.
103
104        \return
105            Nothing.
106        */
107        void    setShowVertScrollbar(bool setting);
108
109        /*!
110        \brief
111            Return whether the horizontal scroll bar is always shown.
112
113        \return
114            - true if the scroll bar will always be shown even if it is not required.
115            - false if the scroll bar will only be shown when it is required.
116        */
117        bool    isHorzScrollbarAlwaysShown(void) const;
118
119        /*!
120        \brief
121            Set whether the horizontal scroll bar should always be shown.
122
123        \param setting
124            - true if the horizontal scroll bar should be shown even when it is not required.
125            - false if the horizontal scroll bar should only be shown when it is required.
126
127        \return
128            Nothing.
129        */
130        void    setShowHorzScrollbar(bool setting);
131
132        /*!
133        \brief
134            Return whether the content pane is auto sized.
135
136        \return
137            - true to indicate the content pane will automatically resize itself.
138            - false to indicate the content pane will not automatically resize itself.
139        */
140        bool isContentPaneAutoSized(void) const;
141
142        /*!
143        \brief
144            Set whether the content pane should be auto-sized.
145
146        \param setting
147            - true to indicate the content pane should automatically resize itself.
148            - false to indicate the content pane should not automatically resize itself.
149
150        \return
151            Nothing.
152        */
153        void setContentPaneAutoSized(bool setting);
154
155        /*!
156        \brief
157            Return the current content pane area for the ScrollablePane.
158
159        \return
160            Rect object that details the current pixel extents of the content
161            pane attached to this ScrollablePane.
162        */
163        const Rect& getContentPaneArea(void) const;
164
165        /*!
166        \brief
167            Set the current content pane area for the ScrollablePane.
168
169        \note
170            If the ScrollablePane is configured to auto-size the content pane
171            this call will have no effect.
172
173        \param area
174            Rect object that details the pixel extents to use for the content
175            pane attached to this ScrollablePane.
176
177        \return
178            Nothing.
179        */
180        void setContentPaneArea(const Rect& area);
181
182        /*!
183        \brief
184            Returns the horizontal scrollbar step size as a fraction of one
185            complete view page.
186
187        \return
188            float value specifying the step size where 1.0f would be the width of
189            the viewing area.
190        */
191        float getHorizontalStepSize(void) const;
192
193        /*!
194        \brief
195            Sets the horizontal scrollbar step size as a fraction of one
196            complete view page.
197
198        \param step
199            float value specifying the step size, where 1.0f would be the width of
200            the viewing area.
201
202        \return
203            Nothing.
204        */
205        void setHorizontalStepSize(float step);
206
207        /*!
208        \brief
209            Returns the horizontal scrollbar overlap size as a fraction of one
210            complete view page.
211
212        \return
213            float value specifying the overlap size where 1.0f would be the width of
214            the viewing area.
215        */
216        float getHorizontalOverlapSize(void) const;
217
218        /*!
219        \brief
220            Sets the horizontal scrollbar overlap size as a fraction of one
221            complete view page.
222
223        \param overlap
224            float value specifying the overlap size, where 1.0f would be the width of
225            the viewing area.
226
227        \return
228            Nothing.
229        */
230        void setHorizontalOverlapSize(float overlap);
231
232        /*!
233        \brief
234            Returns the horizontal scroll position as a fraction of the
235            complete scrollable width.
236
237        \return
238            float value specifying the scroll position.
239        */
240        float getHorizontalScrollPosition(void) const;
241
242        /*!
243        \brief
244            Sets the horizontal scroll position as a fraction of the
245            complete scrollable width.
246
247        \param position
248            float value specifying the new scroll position.
249
250        \return
251            Nothing.
252        */
253        void setHorizontalScrollPosition(float position);
254
255        /*!
256        \brief
257            Returns the vertical scrollbar step size as a fraction of one
258            complete view page.
259
260        \return
261            float value specifying the step size where 1.0f would be the height of
262            the viewing area.
263        */
264        float getVerticalStepSize(void) const;
265
266        /*!
267        \brief
268            Sets the vertical scrollbar step size as a fraction of one
269            complete view page.
270
271        \param step
272            float value specifying the step size, where 1.0f would be the height of
273            the viewing area.
274
275        \return
276            Nothing.
277        */
278        void setVerticalStepSize(float step);
279
280        /*!
281        \brief
282            Returns the vertical scrollbar overlap size as a fraction of one
283            complete view page.
284
285        \return
286            float value specifying the overlap size where 1.0f would be the height of
287            the viewing area.
288        */
289        float getVerticalOverlapSize(void) const;
290
291        /*!
292        \brief
293            Sets the vertical scrollbar overlap size as a fraction of one
294            complete view page.
295
296        \param overlap
297            float value specifying the overlap size, where 1.0f would be the height of
298            the viewing area.
299
300        \return
301            Nothing.
302        */
303        void setVerticalOverlapSize(float overlap);
304
305        /*!
306        \brief
307            Returns the vertical scroll position as a fraction of the
308            complete scrollable height.
309
310        \return
311            float value specifying the scroll position.
312        */
313        float getVerticalScrollPosition(void) const;
314
315        /*!
316        \brief
317            Sets the vertical scroll position as a fraction of the
318            complete scrollable height.
319
320        \param position
321            float value specifying the new scroll position.
322
323        \return
324            Nothing.
325        */
326        void setVerticalScrollPosition(float position);
327
328        /*************************************************************************
329            Overridden from Window
330        *************************************************************************/
331        void initialise(void);
332
333    protected:
334        /*************************************************************************
335                Abstract interface
336        *************************************************************************/
337        /*!
338        \brief
339            Create a Scrollbar based widget to be used as the horizontal scrollbar.
340
341        \param name
342            String object holding the name that must be used when creating the widget.
343
344        \return
345            Scrollbar based object.
346        */
347        virtual Scrollbar* createHorizontalScrollbar(const String& name) const = 0;
348
349        /*!
350        \brief
351            Create a Scrollbar based widget to be used as the vertical scrollbar.
352
353        \param name
354            String object holding the name that must be used when creating the widget.
355
356        \return
357            Scrollbar based object.
358        */
359        virtual Scrollbar* createVerticalScrollbar(const String& name) const = 0;
360
361        /*!
362        \brief
363            Perform look and feel specific layout of the component widgets.
364        */
365        virtual void layoutComponentWidgets(void) = 0;
366
367        /*!
368        \brief
369            Return a Rect that described the pane's viewable area, relative
370            to this Window, in pixels.
371
372        \return
373            Rect object describing the ScrollablePane's viewable area.
374        */
375        virtual Rect getViewableArea(void) const = 0;
376
377        /*************************************************************************
378                Implementation Methods
379        *************************************************************************/
380        /*!
381        \brief
382            Add ScrollablePane specific events
383        */
384        void addScrollablePaneEvents(void);
385
386        /*!
387            \brief
388                    display required integrated scroll bars according to current size of
389            the ScrollablePane view area and the size of the attached ScrolledContainer.
390            */
391            void configureScrollbars(void);
392
393        /*!
394        \brief
395            Return whether the vertical scrollbar is needed.
396
397        \return
398            - true if the scrollbar is either needed or forced via setting.
399            - false if the scrollbar should not be shown.
400        */
401        bool isVertScrollbarNeeded(void) const;
402
403        /*!
404        \brief
405            Return whether the horizontal scrollbar is needed.
406
407        \return
408            - true if the scrollbar is either needed or forced via setting.
409            - false if the scrollbar should not be shown.
410        */
411        bool isHorzScrollbarNeeded(void) const;
412
413        /*!
414        \brief
415            Update the content container position according to the current
416            state of the widget (like scrollbar positions, etc).
417        */
418        void updateContainerPosition(void);
419
420
421                /*!
422                \brief
423                        Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
424
425                \param class_name
426                        The class name that is to be checked.
427
428                \return
429                        true if this window was inherited from \a class_name. false if not.
430                */
431                virtual bool    testClassName_impl(const String& class_name) const
432                {
433                        if (class_name==(const utf8*)"ScrollablePane")  return true;
434                        return Window::testClassName_impl(class_name);
435                }
436
437
438        /*************************************************************************
439                Event triggers
440        *************************************************************************/
441        /*!
442        \brief
443            Event trigger method called when some pane content has changed size
444            or location.
445
446        \param e
447            WindowEventArgs object.
448
449        \return
450            Nothing.
451        */
452        virtual void onContentPaneChanged(WindowEventArgs& e);
453
454        /*!
455        \brief
456            Event trigger method called when the setting that controls whether the
457            vertical scrollbar is always shown or not, is changed.
458
459        \param e
460            WindowEventArgs object.
461
462        \return
463            Nothing.
464        */
465        virtual void onVertScrollbarModeChanged(WindowEventArgs& e);
466
467        /*!
468        \brief
469            Event trigger method called when the setting that controls whether the
470            horizontal scrollbar is always shown or not, is changed.
471
472        \param e
473            WindowEventArgs object.
474
475        \return
476            Nothing.
477        */
478        virtual void onHorzScrollbarModeChanged(WindowEventArgs& e);
479
480        /*!
481        \brief
482            Notification method called whenever the setting that controls whether
483            the content pane is automatically sized is changed.
484
485        \param e
486            WindowEventArgs object.
487
488        \return
489            Nothing.
490        */
491        virtual void onAutoSizeSettingChanged(WindowEventArgs& e);
492
493        /*!
494        \brief
495            Notification method called whenever the content pane is scrolled via
496            changes in the scrollbar positions.
497
498        \param e
499            WindowEventArgs object.
500
501        \return
502            Nothing.
503        */
504        virtual void onContentPaneScrolled(WindowEventArgs& e);
505
506        /*************************************************************************
507                Event handler methods
508        *************************************************************************/
509        /*!
510        \brief
511            Handler method which gets subscribed to the scrollbar position change
512            events.
513        */
514        bool handleScrollChange(const EventArgs&  e);
515
516        /*!
517        \brief
518            Handler method which gets subscribed to the ScrolledContainer content
519            change events.
520        */
521        bool handleContentAreaChange(const EventArgs& e);
522
523        /*!
524        \brief
525            Handler method which gets subscribed to the ScrolledContainer auto-size
526            setting changes.
527        */
528        bool handleAutoSizePaneChanged(const EventArgs& e);
529
530        /*************************************************************************
531                Overridden from Window
532        *************************************************************************/
533        void addChild_impl(Window* wnd);
534        void removeChild_impl(Window* wnd);
535        void onSized(WindowEventArgs& e);
536        void onMouseWheel(MouseEventArgs& e);
537
538        /*************************************************************************
539                Data fields
540        *************************************************************************/
541        bool    d_forceVertScroll;              //!< true if vertical scrollbar should always be displayed
542        bool    d_forceHorzScroll;              //!< true if horizontal scrollbar should always be displayed
543        Rect    d_contentRect;          //!< holds content area so we can track changes.
544        float   d_vertStep;             //!< vertical scroll step fraction.
545        float   d_vertOverlap;          //!< vertical scroll overlap fraction.
546        float   d_horzStep;             //!< horizontal scroll step fraction.
547        float   d_horzOverlap;          //!< horizontal scroll overlap fraction.
548
549        // component widgets
550        Scrollbar*  d_vertScrollbar;        //!< Scrollbar widget used for vertical scrolling.
551        Scrollbar*  d_horzScrollbar;        //!< Scrollbar widget used for horizontal scrolling.
552        ScrolledContainer*  d_container;    //!< ScrolledContainer widget holding the attached widgets.
553
554    private:
555            /*************************************************************************
556                    Static Properties for this class
557            *************************************************************************/
558        static ScrollablePaneProperties::ForceHorzScrollbar     d_horzScrollbarProperty;
559        static ScrollablePaneProperties::ForceVertScrollbar     d_vertScrollbarProperty;
560            static ScrollablePaneProperties::ContentPaneAutoSized       d_autoSizedProperty;
561            static ScrollablePaneProperties::ContentArea            d_contentAreaProperty;
562        static ScrollablePaneProperties::HorzStepSize           d_horzStepProperty;
563        static ScrollablePaneProperties::HorzOverlapSize        d_horzOverlapProperty;
564        static ScrollablePaneProperties::HorzScrollPosition     d_horzScrollPositionProperty;
565        static ScrollablePaneProperties::VertStepSize           d_vertStepProperty;
566        static ScrollablePaneProperties::VertOverlapSize        d_vertOverlapProperty;
567        static ScrollablePaneProperties::VertScrollPosition     d_vertScrollPositionProperty;
568
569            /*************************************************************************
570                    Private methods
571            *************************************************************************/
572            void addScrollablePaneProperties(void);
573    };
574
575} // End of  CEGUI namespace section
576
577
578#endif  // end of guard _CEGUIScrollablePane_h_
Note: See TracBrowser for help on using the repository browser.