Planeshift

pawsscrollmenu.h

Go to the documentation of this file.
00001 /*
00002  * pawsscrollmenu.h - Author: Joe Lyon
00003  *
00004  * Copyright (C) 2013 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 // pawsscrollmenu.h: interface for the pawsScrollMenu class.
00020 //
00022 
00023 #ifndef PAWS_SCROLLMENU_HEADER
00024 #define PAWS_SCROLLMENU_HEADER
00025 
00026 
00027 
00028 #include "globals.h"
00029 
00030 //=============================================================================
00031 // Application Includes
00032 //=============================================================================
00033 #include "pawsscrollmenu.h"
00034 
00035 
00036 //=============================================================================
00037 // Defines
00038 //=============================================================================
00039 #define BUTTON_PADDING          4
00040 #define SHORTCUT_BUTTON_OFFSET  2000
00041 
00042 #define ScrollMenuOptionDISABLED    0
00043 #define ScrollMenuOptionENABLED     1
00044 #define ScrollMenuOptionDYNAMIC     2
00045 #define ScrollMenuOptionHORIZONTAL  3
00046 #define ScrollMenuOptionVERTICAL    4
00047 
00048 #include "paws/pawswidget.h"
00049 #include "gui/pawsdndbutton.h"
00050 
00051 
00052 
00053 
00054 
00057 class pawsScrollMenu : public pawsWidget
00058 {
00059 
00060 public:
00061 
00062 
00063     pawsScrollMenu();
00064     virtual ~pawsScrollMenu();
00065 
00066     bool PostSetup();
00067     void OnResize();
00068     void OnResizeStop();
00069     int  CalcButtonSize(pawsDnDButton* target);
00070     void LayoutButtons();
00071 
00072     virtual bool OnButtonReleased(int mouseButton, int keyModifier, pawsWidget* reporter);
00073     virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* reporter);
00074 
00075     bool LoadArrays(csArray<csString> &name, csArray<csString> &icon, csArray<csString> &toolTip, csArray<csString> &actions, int baseIndex, pawsWidget* widget);
00076     pawsDnDButton* LoadSingle(csString name, csString icon, csString toolTip, csString action, int Index, pawsWidget* widget, bool IsEnabled);
00077 
00078     bool RemoveByName(csString name);
00079     bool Clear();
00080     int  GetSize();
00081     int  GetButtonWidth();
00082 
00083 
00091     int GetWidestWidth();
00092 
00093     int  GetButtonHeight();
00094     int  GetButtonHolderWidth();
00095     int  GetButtonHolderHeight();
00096     int  GetTotalButtonWidth();
00097     int  GetTotalButtonWidth(unsigned int targetButton);
00098     int  GetOrientation();
00099     int  GetEditMode()
00100     {
00101         return EditMode;
00102     }
00103     int GetEditLock()
00104     {
00105         return EditLockMode;
00106     }
00107 
00108     virtual bool Setup(iDocumentNode* node);
00109     bool SelfPopulate(iDocumentNode* node);
00110 
00111     bool ScrollUp();
00112     bool ScrollDown();
00113     bool ScrollToPosition( float pos );
00114     virtual bool OnMouseDown(int button, int modifiers, int x, int y);
00115     virtual bool OnKeyDown(utf32_char keyCode, utf32_char key, int modifiers);
00116 
00117     void SetEditLock(int mode);
00118     bool IsEditable()
00119     {
00120         return EditLockButton->GetState();
00121     }
00122     void SetLeftScroll(int mode);
00123     int GetLeftScroll();
00124     void SetRightScroll(int mode);
00125     int GetRightScroll();
00126     void SetButtonWidth(int width);
00127     void SetButtonHeight(int height);
00128 //    void SetScrollIncrement(int incr);
00129 //    void SetScrollProportion(float prop);
00130     bool SetScrollWidget( pawsScrollBar* sb);
00131     void SetOrientation(int Orientation);
00132     int  AutoResize();
00136     void SetEditMode(int val)
00137     {
00138         EditMode = val;
00139     }
00140 
00141     void SetButtonPaddingWidth( int width )
00142     {
00143         paddingWidth = width;
00144     }
00145     int GetButtonPaddingWidth()
00146     {
00147         return paddingWidth;
00148     }
00149     void SetButtonBackground( const char* image );
00150     csString GetButtonBackground();
00151     void SetButtonFont( const char* Font, int size );
00152     char const * GetButtonFontName();
00153     float GetButtonFontSize();
00154 
00158     char const * GetFontName()
00159     {
00160         return fontName;
00161     }
00162 
00163     void SetTextSpacing( int v );
00164 
00165     void EnableButtonBackground( bool mode );
00166     bool IsButtonBackgroundEnabled();
00167 
00168     void ShowScrollButtons();
00169 
00170     void SetWarnLevel(float, bool);
00171     void SetDangerLevel(float, bool);
00172     void SetFlashLevel(float, bool);
00173 
00174     float GetWarnLevel();
00175     float GetDangerLevel();
00176     float GetFlashLevel();
00177 
00178     void SetWarnMode(int);
00179     void SetDangerMode(int);
00180     void SetFlashMode(int);
00181 
00182 protected:
00183 
00184     int                    buttonWidth,
00185                            buttonHeight,
00186                            scrollIncrement,
00187                            currentButton,
00188                            paddingWidth;
00189 
00190     float                  scrollProportion;
00191     bool                   buttonWidthDynamic;
00192 
00193     pawsWidget*            ButtonHolder;
00194     csArray<pawsWidget*>   Buttons;
00195     int                    buttonLocation;
00196 
00197     pawsButton*            LeftScrollButton;
00198     int                    LeftScrollMode;
00199     bool                   LeftScrollVisible;
00200 
00201     pawsButton*            RightScrollButton;
00202     int                    RightScrollMode;
00203     bool                   RightScrollVisible;
00204 
00205     pawsButton*            EditLockButton;
00206     int                    EditLockMode;               //enabled, disabled, (dynamic==>enabled)
00207     bool                   EditLock;                 //true = editing prevented, false = editing allowed
00208 
00209     pawsWidget*            callbackWidget;
00210 
00211     pawsScrollBar*         scrollBarWidget;
00212 
00213     int                    Orientation;
00214     int                    EditMode;
00215 
00216     float                  warnLevel;
00217     int                    warnMode;
00218     float                  dangerLevel;
00219     bool                   dangerLow;
00220     int                    dangerMode;
00221     float                  flashLevel;
00222     bool                   flashLow;
00223     int                    flashMode;
00224 
00225 };
00226 
00227 //----------------------------------------------------------------------
00228 CREATE_PAWS_FACTORY(pawsScrollMenu);
00229 
00232 #endif