guiArrayCtrl.h
Engine/source/gui/core/guiArrayCtrl.h
Classes:
class
Renders a grid of cells.
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 _GUIARRAYCTRL_H_ 25#define _GUIARRAYCTRL_H_ 26 27#ifndef _GUITYPES_H_ 28#include "gui/core/guiTypes.h" 29#endif 30#ifndef _GUITEXTCTRL_H_ 31#include "gui/controls/guiTextCtrl.h" 32#endif 33 34/// Renders a grid of cells. 35class GuiArrayCtrl : public GuiControl 36{ 37 typedef GuiControl Parent; 38 39protected: 40 41 Point2I mHeaderDim; 42 Point2I mSize; 43 Point2I mCellSize; 44 Point2I mSelectedCell; 45 Point2I mMouseOverCell; 46 47 Resource<GFont> mFont; 48 49 virtual bool cellSelected(Point2I cell); 50 virtual void onCellSelected(Point2I cell); 51 virtual void onCellHighlighted(Point2I cell); 52 53 bool _findHitCell( const Point2I& pos, Point2I& cellOut ); 54 55 /// @name Callbacks 56 /// @{ 57 58 DECLARE_CALLBACK( void, onCellHighlighted, ( const Point2I& cell ) ); 59 DECLARE_CALLBACK( void, onCellSelected, ( const Point2I& cell ) ); 60 61 /// @} 62 63public: 64 65 GuiArrayCtrl(); 66 DECLARE_CONOBJECT(GuiArrayCtrl); 67 68 bool onWake(); 69 void onSleep(); 70 71 /// @name Array attribute methods 72 /// @{ 73 Point2I getSize() { return mSize; } 74 virtual void setSize(Point2I size); 75 void setHeaderDim(const Point2I &dim) { mHeaderDim = dim; } 76 void getScrollDimensions(S32 &cell_size, S32 &num_cells); 77 /// @} 78 79 /// @name Selected cell methods 80 /// @{ 81 void setSelectedCell(Point2I cell); 82 void deselectCells() { mSelectedCell.set(-1,-1); } 83 Point2I getSelectedCell(); 84 void scrollSelectionVisible(); 85 void scrollCellVisible(Point2I cell); 86 /// @} 87 88 /// @name Rendering methods 89 /// @{ 90 virtual void onRenderColumnHeaders(Point2I offset, Point2I parentOffset, Point2I headerDim); 91 virtual void onRenderRowHeader(Point2I offset, Point2I parentOffset, Point2I headerDim, Point2I cell); 92 virtual void onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver); 93 void onRender(Point2I offset, const RectI &updateRect); 94 /// @} 95 96 /// @name Mouse input methods 97 /// @{ 98 void onMouseDown( const GuiEvent &event ); 99 void onMouseUp( const GuiEvent &event ); 100 void onMouseMove( const GuiEvent &event ); 101 void onMouseDragged( const GuiEvent &event ); 102 void onMouseEnter( const GuiEvent &event ); 103 void onMouseLeave( const GuiEvent &event ); 104 bool onKeyDown( const GuiEvent &event ); 105 void onRightMouseDown( const GuiEvent &event ); 106 /// @} 107}; 108 109#endif //_GUI_ARRAY_CTRL_H 110