MyGUI  3.2.0
MyGUI_Button.h
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 #ifndef __MYGUI_BUTTON_H__
00023 #define __MYGUI_BUTTON_H__
00024 
00025 #include "MyGUI_Prerequest.h"
00026 #include "MyGUI_TextBox.h"
00027 
00028 namespace MyGUI
00029 {
00030 
00031     class MYGUI_EXPORT Button :
00032         public TextBox,
00033         public MemberObsolete<Button>
00034     {
00035         MYGUI_RTTI_DERIVED( Button )
00036 
00037     public:
00038         Button();
00039 
00041         void setStateSelected(bool _value);
00043         bool getStateSelected() const;
00044 
00049         void setModeImage(bool _value);
00051         bool getModeImage() const;
00052 
00053         void setImageResource(const std::string& _name);
00054 
00055         void setImageGroup(const std::string& _name);
00056 
00057         void setImageName(const std::string& _name);
00058 
00059     /*internal:*/
00060         void _setMouseFocus(bool _focus);
00061 
00062         ImageBox* _getImageBox();
00063 
00064     protected:
00065         virtual void initialiseOverride();
00066         virtual void shutdownOverride();
00067 
00068         virtual void onMouseLostFocus(Widget* _new);
00069         virtual void onMouseSetFocus(Widget* _old);
00070         virtual void onMouseButtonPressed(int _left, int _top, MouseButton _id);
00071         virtual void onMouseButtonReleased(int _left, int _top, MouseButton _id);
00072 
00073         virtual void baseUpdateEnable();
00074 
00075         bool _setState(const std::string& _value);
00076 
00077         virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
00078 
00079     private:
00080         void updateButtonState();
00081 
00082     private:
00083         // нажата ли кнопка
00084         bool mIsMousePressed;
00085         // в фокусе ли кнопка
00086         bool mIsMouseFocus;
00087         // статус кнопки нажата или нет
00088         bool mStateSelected;
00089 
00090         ImageBox* mImage;
00091         bool mModeImage;
00092     };
00093 
00094 } // namespace MyGUI
00095 
00096 #endif // __MYGUI_BUTTON_H__