00001 //================================================================================================== 00002 // Copyright (C) 2010 Brian Tietz sdbtietz at yahoo dot com 00003 // 00004 // This program is free software; you can redistribute it and/or modify it under the terms of the 00005 // GNU General Public License as published by the Free Software Foundation, version 2.0 of the 00006 // License. 00007 // 00008 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 00009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00010 // General Public License for more details. 00011 // 00012 // You should have received a copy of the GNU General Public License along with this program; if 00013 // not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00014 // 02110-1301, USA. 00015 // 00016 // For commercial software, the copyright holder (Brian Tietz, email sdbtietz at yahoo dot com) 00017 // reserves the right and is willing to waive the proprietary source code disclosure aspects of that 00018 // license as applied to the UT library in exchange for either substantial contributions to the 00019 // development of the UT library or other forms of compensation. Any such waiver must be 00020 // established in writing between the copyright holder and the commercial entity obtaining such a 00021 // waiver. 00022 //================================================================================================== 00023 00024 00025 #ifndef _UT_BUTTON_H_ 00026 #define _UT_BUTTON_H_ 00027 00030 00031 00032 //================================================================================================== 00033 //=== Project headers 00034 //================================================================================================== 00035 #include "UTView.h" 00036 #include "UTString.h" 00037 #include "UTMessageDestination.h" 00038 #include "UTMessage.h" 00039 00040 00041 //================================================================================================== 00042 //=== Forward name declarations 00043 //================================================================================================== 00044 class ButtonPlatformInfo_t; 00045 00046 00047 //================================================================================================== 00048 class UTGUI_EXPORT Button_t 00049 //================================================================================================== 00055 : public View_t 00056 { 00057 //---------------------------------------------------------------------------------------------- 00058 public: 00059 //---------------------------------------------------------------------------------------------- 00060 Button_t(const String_t& label); 00068 00069 virtual ~Button_t(); 00071 00072 virtual void SetMinMaxSize( float min_width, 00073 float max_width, 00074 float min_height, 00075 float max_height ); 00094 00095 inline const String_t& Label() const; 00097 00098 void SetLabel(const String_t& label); 00101 00102 void SetAction( takes Message_t* message_to_send, 00103 const AbstractMessageDestination_t& destination ); 00106 00107 void Disable(); 00111 00112 inline bool IsEnabled() const; 00115 00116 inline const Message_t* ActionMessage() const; 00119 00120 virtual void MouseChanged( const Point_t& point, 00121 bool mouse_inside_view, 00122 bool left_mouse_button_down, 00123 bool left_mouse_button_double_clicked, 00124 bool right_mouse_button_down_if_present ); 00150 00151 //---------------------------------------------------------------------------------------------- 00152 protected: 00153 //---------------------------------------------------------------------------------------------- 00154 virtual void LBoundsChanged( const Rect_t& old_lbounds, 00155 const Rect_t& new_lbounds ); 00159 00160 virtual void Paint(const Region_t& clip_to); 00172 00173 //---------------------------------------------------------------------------------------------- 00174 private: 00175 //---------------------------------------------------------------------------------------------- 00176 String_t m_label; 00177 Message_t* m_action_message; 00178 AbstractMessageDestination_t m_action_destination; 00179 bool m_dialog_button_trigger_on_enter; 00180 00181 friend class ButtonPlatformInfo_t; 00182 }; 00183 00184 00185 00186 00187 //================================================================================================== 00188 //================================================================================================== 00189 //=== 00190 //=== Inline function implementations 00191 //=== 00192 //================================================================================================== 00193 //================================================================================================== 00194 inline const String_t& 00195 Button_t::Label() const 00196 { 00197 return m_label; 00198 } 00199 00200 00201 #endif // _UT_BUTTON_H_