source: GTP/trunk/Lib/Geom/OgreStuff/include/CEGUI/elements/CEGUIListHeaderSegment.h @ 1809

Revision 1809, 13.4 KB checked in by gumbau, 18 years ago (diff)
Line 
1/************************************************************************
2        filename:       CEGUIListHeaderSegment.h
3        created:        15/6/2004
4        author:         Paul D Turner
5       
6        purpose:        Interface to list header segment class.
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 _CEGUIListHeaderSegment_h_
27#define _CEGUIListHeaderSegment_h_
28
29#include "CEGUIBase.h"
30#include "CEGUIWindow.h"
31#include "elements/CEGUIListHeaderSegmentProperties.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        Base class for list header segment window
46*/
47class CEGUIEXPORT ListHeaderSegment : public Window
48{
49public:
50        static const String EventNamespace;                             //!< Namespace for global events
51
52
53        /*************************************************************************
54                Constants
55        *************************************************************************/
56        // Event names
57        static const String EventSegmentClicked;                                //!< Event fired when the segment is clicked.
58        static const String EventSplitterDoubleClicked;         //!< Event fired when the sizer/splitter is double-clicked.
59        static const String EventSizingSettingChanged;          //!< Event fired when the sizing setting changes.
60        static const String EventSortDirectionChanged;          //!< Event fired when the sort direction value changes.
61        static const String EventMovableSettingChanged;         //!< Event fired when the movable setting changes.
62        static const String EventSegmentDragStart;                      //!< Event fired when the segment has started to be dragged.
63        static const String EventSegmentDragStop;                               //!< Event fired when segment dragging has stopped (via mouse release).
64        static const String EventSegmentDragPositionChanged;    //!< Event fired when the segment drag position has changed.
65        static const String EventSegmentSized;                          //!< Event fired when the segment is sized.
66        static const String EventClickableSettingChanged;               //!< Event fired when the clickable state of the segment changes.
67
68        // Defaults
69        static const float      DefaultSizingArea;              //!< Default size of the sizing area.
70        static const float      SegmentMoveThreshold;   //!< Amount the mouse must be dragged before drag-moving is initiated.
71
72
73        /*************************************************************************
74                Enumerated types
75        *************************************************************************/
76        /*!
77        \brief
78                Enumeration of possible values for sorting direction used with ListHeaderSegment classes
79        */
80        enum SortDirection
81        {
82                None,           //!< Items under this segment should not be sorted.
83                Ascending,      //!< Items under this segment should be sorted in ascending order.
84                Descending      //!< Items under this segment should be sorted in descending order.
85        };
86
87
88        /*************************************************************************
89                Accessor Methods
90        *************************************************************************/
91        /*!
92        \brief
93                Return whether this segment can be sized.
94
95        \return
96                true if the segment can be horizontally sized, false if the segment can not be horizontally sized.
97        */
98        bool    isSizingEnabled(void) const                     {return d_sizingEnabled;}
99
100
101        /*!
102        \brief
103                Return the current sort direction set for this segment.
104
105                Note that this has no impact on the way the segment functions (aside from the possibility
106                of varied rendering).  This is intended as a 'helper setting' to classes that make use of
107                the ListHeaderSegment objects.
108
109        \return
110                One of the SortDirection enumerated values indicating the current sort direction set for this
111                segment.
112        */
113        SortDirection   getSortDirection(void) const    {return d_sortDir;}
114
115
116        /*!
117        \brief
118                Return whether drag moving is enabled for this segment.
119
120        \return
121                true if the segment can be drag moved, false if the segment can not be drag moved.
122        */
123        bool    isDragMovingEnabled(void) const         {return d_movingEnabled;}
124
125
126        /*!
127        \brief
128                Return the current drag move position offset (in pixels relative to the top-left corner of the segment).
129
130        \return
131                Point object describing the drag move offset position.
132        */
133        const Point&    getDragMoveOffset(void) const   {return d_dragPosition;}
134
135
136        /*!
137        \brief
138                Return whether the segment is clickable.
139
140        \return
141                true if the segment can be clicked, false of the segment can not be clicked (so no highlighting or events will happen).
142        */
143        bool    isClickable(void) const         {return d_allowClicks;}
144
145
146        /*************************************************************************
147                Manipulator Methods
148        *************************************************************************/
149        /*!
150        \brief
151                Set whether this segment can be sized.
152
153        \param setting
154                true if the segment may be horizontally sized, false if the segment may not be horizontally sized.
155
156        \return
157                Nothing.
158        */
159        void    setSizingEnabled(bool setting);
160
161
162        /*!
163        \brief
164                Set the current sort direction set for this segment.
165
166                Note that this has no impact on the way the segment functions (aside from the possibility
167                of varied rendering).  This is intended as a 'helper setting' to classes that make use of
168                the ListHeaderSegment objects.
169
170        \param sort_dir
171                One of the SortDirection enumerated values indicating the current sort direction set for this
172                segment.
173
174        \return
175                Nothing
176        */
177        void    setSortDirection(SortDirection sort_dir);
178
179
180        /*!
181        \brief
182                Set whether drag moving is allowed for this segment.
183
184        \param setting
185                true if the segment may be drag moved, false if the segment may not be drag moved.
186
187        \return
188                Nothing.
189        */
190        void    setDragMovingEnabled(bool setting);
191
192
193        /*!
194        \brief
195                Set whether the segment is clickable.
196
197        \param setting
198                true if the segment may be clicked, false of the segment may not be clicked (so no highlighting or events will happen).
199
200        \return
201                Nothing.
202        */
203        void setClickable(bool setting);
204
205
206        /*************************************************************************
207                Construction & Destruction
208        *************************************************************************/
209        /*!
210        \brief
211                Constructor for list header segment base class
212        */
213        ListHeaderSegment(const String& type, const String& name);
214
215
216        /*!
217        \brief
218                Destructor for list header segment base class.
219        */
220        virtual ~ListHeaderSegment(void);
221
222
223protected:
224        /*************************************************************************
225                Implementation Methods
226        *************************************************************************/
227        /*!
228        \brief
229                Add list header segment specific events
230        */
231        void    addHeaderSegmentEvents(void);
232
233
234        /*!
235        \brief
236                Update state for drag sizing.
237
238        \param local_mouse
239                Mouse position as a pixel offset from the top-left corner of this window.
240
241        \return
242                Nothing.
243        */
244        void    doDragSizing(const Point& local_mouse);
245
246
247        /*!
248        \brief
249                Update state for drag moving.
250
251        \param local_mouse
252                Mouse position as a pixel offset from the top-left corner of this window.
253
254        \return
255                Nothing.
256        */
257        void    doDragMoving(const Point& local_mouse);
258
259
260        /*!
261        \brief
262                Initialise the required states to put the widget into drag-moving mode.
263        */
264        void    initDragMoving(void);
265
266
267        /*!
268        \brief
269                Initialise the required states when we are hovering over the sizing area.
270        */
271        void    initSizingHoverState(void);
272
273
274        /*!
275        \brief
276                Initialise the required states when we are hovering over the main segment area.
277        */
278        void    initSegmentHoverState(void);
279
280
281        /*!
282        \brief
283                Return whether the required minimum movement threshold before initiating drag-moving
284                has been exceeded.
285
286        \param local_mouse
287                Mouse position as a pixel offset from the top-left corner of this window.
288
289        \return
290                true if the threshold has been exceeded and drag-moving should be initiated, or false
291                if the threshold has not been exceeded.
292        */             
293        bool    isDragMoveThresholdExceeded(const Point& local_mouse);
294
295
296        /*!
297        \brief
298                Return whether this window was inherited from the given class name at some point in the inheritance heirarchy.
299
300        \param class_name
301                The class name that is to be checked.
302
303        \return
304                true if this window was inherited from \a class_name. false if not.
305        */
306        virtual bool    testClassName_impl(const String& class_name) const
307        {
308                if (class_name==(const utf8*)"ListHeaderSegment")       return true;
309                return Window::testClassName_impl(class_name);
310        }
311
312
313        /*************************************************************************
314                New Event Handlers
315        *************************************************************************/
316        /*!
317        \brief
318                Handler called when segment is clicked.
319        */
320        virtual void    onSegmentClicked(WindowEventArgs& e);
321
322
323        /*!
324        \brief
325                Handler called when the sizer/splitter is double-clicked.
326        */
327        virtual void    onSplitterDoubleClicked(WindowEventArgs& e);
328
329
330        /*!
331        \brief
332                Handler called when sizing setting changes.
333        */
334        virtual void    onSizingSettingChanged(WindowEventArgs& e);
335
336
337        /*!
338        \brief
339                Handler called when the sort direction value changes.
340        */
341        virtual void    onSortDirectionChanged(WindowEventArgs& e);
342
343
344        /*!
345        \brief
346                Handler called when the drag-movable setting is changed.
347        */
348        virtual void    onMovableSettingChanged(WindowEventArgs& e);
349
350
351        /*!
352        \brief
353                Handler called when the user starts dragging the segment.
354        */
355        virtual void    onSegmentDragStart(WindowEventArgs& e);
356
357
358        /*!
359        \brief
360                Handler called when the user stops dragging the segment (releases mouse button)
361        */
362        virtual void    onSegmentDragStop(WindowEventArgs& e);
363
364
365        /*!
366        \brief
367                Handler called when the drag position changes.
368        */
369        virtual void    onSegmentDragPositionChanged(WindowEventArgs& e);
370
371
372        /*!
373        \brief
374                Handler called when the segment is sized.
375        */
376        virtual void    onSegmentSized(WindowEventArgs& e);
377
378
379        /*!
380        \brief
381                Handler called when the clickable setting for the segment changes
382        */
383        virtual void    onClickableSettingChanged(WindowEventArgs& e);
384
385
386        /*************************************************************************
387                Overridden Event Handlers
388        *************************************************************************/
389        virtual void    onMouseMove(MouseEventArgs& e);
390        virtual void    onMouseButtonDown(MouseEventArgs& e);
391        virtual void    onMouseButtonUp(MouseEventArgs& e);
392        virtual void    onMouseDoubleClicked(MouseEventArgs& e);
393        virtual void    onMouseLeaves(MouseEventArgs& e);
394        virtual void    onCaptureLost(WindowEventArgs& e);
395
396
397        /*************************************************************************
398                Implementation Data
399        *************************************************************************/
400        const Image*    d_sizingMouseCursor;    //!< Image to use for mouse when sizing (typically set by derived class).
401        const Image*    d_movingMouseCursor;    //!< Image to use for mouse when moving (typically set by derived class).
402
403        float   d_splitterSize;         //!< pixel width of the sizing area.
404        bool    d_splitterHover;        //!< True if the mouse is over the splitter
405
406        bool    d_dragSizing;           //!< true when we are being sized.
407        Point   d_dragPoint;            //!< point we are being dragged at when sizing or moving.
408
409        SortDirection   d_sortDir;      //!< Direction for sorting (used for deciding what icon to display).
410
411        bool    d_segmentHover;         //!< true when the mouse is within the segment area (and not in sizing area).
412        bool    d_segmentPushed;        //!< true when the left mouse button has been pressed within the confines of the segment.
413        bool    d_sizingEnabled;        //!< true when sizing is enabled for this segment.
414        bool    d_movingEnabled;        //!< True when drag-moving is enabled for this segment;
415        bool    d_dragMoving;           //!< true when segment is being drag moved.
416        Point   d_dragPosition;         //!< position of dragged segment.
417        bool    d_allowClicks;          //!< true if the segment can be clicked.
418
419
420private:
421        /*************************************************************************
422                Static Properties for this class
423        *************************************************************************/
424        static ListHeaderSegmentProperties::Clickable           d_clickableProperty;
425        static ListHeaderSegmentProperties::Dragable            d_dragableProperty;
426        static ListHeaderSegmentProperties::Sizable                     d_sizableProperty;
427        static ListHeaderSegmentProperties::SortDirection       d_sortDirectionProperty;
428
429
430        /*************************************************************************
431                Private methods
432        *************************************************************************/
433        void    addHeaderSegmentProperties(void);
434};
435
436} // End of  CEGUI namespace section
437
438#if defined(_MSC_VER)
439#       pragma warning(pop)
440#endif
441
442#endif  // end of guard _CEGUIListHeaderSegment_h_
Note: See TracBrowser for help on using the repository browser.