guiPaneCtrl.h

Engine/source/gui/containers/guiPaneCtrl.h

More...

Classes:

class

Collapsable pane control.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _GUIPANECTRL_H_
 25#define _GUIPANECTRL_H_
 26
 27#ifndef _GUICONTROL_H_
 28   #include "gui/core/guiControl.h"
 29#endif
 30#ifndef _GFXDEVICE_H_
 31   #include "gfx/gfxDevice.h"
 32#endif
 33#ifndef _CONSOLE_H_
 34   #include "console/console.h"
 35#endif
 36#ifndef _CONSOLETYPES_H_
 37   #include "console/consoleTypes.h"
 38#endif
 39
 40
 41/// Collapsable pane control.
 42///
 43/// This class wraps a single child control and displays a header with caption
 44/// above it. If you click the header it will collapse or expand. The control
 45/// resizes itself based on its collapsed/expanded size.
 46///
 47/// In the GUI editor, if you just want the header you can make collapsable
 48/// false. The caption field lets you set the caption. It expects a bitmap
 49/// (from the GuiControlProfile) that contains two images - the first is
 50/// displayed when the control is expanded and the second is displayed when
 51/// it is collapsed. The header is sized based off of the first image.
 52class GuiPaneControl : public GuiControl
 53{
 54   public:
 55   
 56      typedef GuiControl Parent;
 57
 58   protected:
 59
 60      /// If true, the pane can be collapsed and extended by clicking its header.
 61      bool mCollapsable;
 62      
 63      /// Whether the pane is currently collapsed.
 64      bool mCollapsed;
 65      
 66      /// Whether to display the bitmapped pane bar behind the header text, too.
 67      bool mBarBehindText;
 68      
 69      ///
 70      Point2I mOriginalExtents;
 71      
 72      /// Text to display as the pane caption.
 73      String mCaption;
 74      
 75      /// String table text ID to use as caption string.
 76      StringTableEntry mCaptionID;
 77      
 78      ///
 79      Point2I mThumbSize;
 80
 81      ///
 82      bool mMouseOver;
 83      
 84      ///
 85      bool mDepressed;
 86
 87   public:
 88   
 89      GuiPaneControl();
 90
 91      /// Return whether the pane is currently collapsed.
 92      bool getCollapsed() { return mCollapsed; };
 93      
 94      /// Collapse or expand the pane.
 95      void setCollapsed(bool isCollapsed);
 96
 97      virtual void setCaptionID(S32 id);
 98      virtual void setCaptionID(const char *id);
 99      
100      // GuiControl.
101      virtual bool onWake();
102
103      virtual void onMouseDown(const GuiEvent &event);
104      virtual void onMouseUp(const GuiEvent &event);
105      virtual void onMouseMove(const GuiEvent &event);
106      virtual void onMouseLeave(const GuiEvent &event);
107      virtual void onMouseEnter(const GuiEvent &event);
108
109      virtual bool resize(const Point2I &newPosition, const Point2I &newExtent);
110      virtual void onRender(Point2I offset, const RectI &updateRect);
111
112      static void initPersistFields();
113      
114      DECLARE_CONOBJECT(GuiPaneControl);
115      DECLARE_CATEGORY( "Gui Containers" );
116      DECLARE_DESCRIPTION( "A container that wraps a single child control displaying a header\n"
117         "with a caption above it.  If enabled, the pane can be collapsed and expanded\n"
118         "by clicking the header." );
119};
120
121#endif
122