MyGUI 3.0.1

MyGUI_Button.h

Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009 
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014 
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #ifndef __MYGUI_BUTTON_H__
00024 #define __MYGUI_BUTTON_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_StaticText.h"
00028 
00029 namespace MyGUI
00030 {
00031 
00032     class MYGUI_EXPORT Button :
00033         public StaticText
00034     {
00035         MYGUI_RTTI_DERIVED( Button )
00036 
00037     public:
00038         Button();
00039 
00041         void setButtonPressed(bool _value) { setStateCheck(_value); }
00043         bool getButtonPressed() { return getStateCheck(); }
00044 
00046         void setStateCheck(bool _value);
00047 
00049         bool getStateCheck() { return mIsStateCheck; }
00050 
00052         void setImageIndex(size_t _value);
00054         size_t getImageIndex();
00055 
00060         void setModeImage(bool _value);
00062         bool getModeImage() { return mModeImage; }
00063 
00065         StaticImage* getStaticImage() { return mImage; }
00066 
00068         virtual void setProperty(const std::string& _key, const std::string& _value);
00069 
00070     /*internal:*/
00071         virtual void _initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name);
00072 
00073         void _setMouseFocus(bool _focus);
00074 
00075     protected:
00076         virtual ~Button();
00077 
00078         virtual void baseChangeWidgetSkin(ResourceSkin* _info);
00079 
00080         virtual void onMouseLostFocus(Widget* _new);
00081         virtual void onMouseSetFocus(Widget* _old);
00082         virtual void onMouseButtonPressed(int _left, int _top, MouseButton _id);
00083         virtual void onMouseButtonReleased(int _left, int _top, MouseButton _id);
00084 
00085         virtual void baseUpdateEnable();
00086 
00087         bool _setState(const std::string& _value);
00088         void setImageResource(const std::string& _name);
00089 
00090     private:
00091         void updateButtonState();
00092 
00093         void shutdownWidgetSkin();
00094         void initialiseWidgetSkin(ResourceSkin* _info);
00095 
00096     private:
00097         // нажата ли кнопка
00098         bool mIsMousePressed;
00099         // в фокусе ли кнопка
00100         bool mIsMouseFocus;
00101         // статус кнопки нажата или нет
00102         bool mIsStateCheck;
00103 
00104         StaticImage* mImage;
00105         bool mModeImage;
00106 
00107     };
00108 
00109 } // namespace MyGUI
00110 
00111 #endif // __MYGUI_BUTTON_H__
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines