00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #if !defined(_XRB_TOOLBARBUTTON_HPP_)
00012 #define _XRB_TOOLBARBUTTON_HPP_
00013
00014 #include "xrb.hpp"
00015
00016 #include "xrb_radiobutton.hpp"
00017
00018 namespace Xrb
00019 {
00020
00021 template <typename T, T sentinel>
00022 class ToolbarButton : public RadioButton<T, sentinel>
00023 {
00024 public:
00025
00026 ToolbarButton (
00027 Resource<GLTexture> const &picture,
00028 T id,
00029 RadioButtonGroup<T, sentinel> *group,
00030 ContainerWidget *parent,
00031 std::string const &name = "ToolbarButton");
00032 virtual ~ToolbarButton () { }
00033
00034 protected:
00035
00036 virtual void HandleMouseoverOn ();
00037 virtual void HandleMouseoverOff ();
00038
00039 virtual void UpdateRenderBackground ();
00040 virtual void UpdateRenderPicture ();
00041
00042
00043 virtual void HandleChangedWidgetSkinWidgetBackground (
00044 WidgetSkin::WidgetBackgroundType widget_background_type);
00045 };
00046
00047
00048
00049
00050
00051 template <typename T, T sentinel>
00052 ToolbarButton<T, sentinel>::ToolbarButton (
00053 Resource<GLTexture> const &picture,
00054 T const id,
00055 RadioButtonGroup<T, sentinel> *const group,
00056 ContainerWidget *const parent,
00057 std::string const &name)
00058 :
00059 RadioButton<T, sentinel>(picture, id, group, parent, name)
00060 {
00061 ASSERT1(this->Picture().IsValid());
00062 ToolbarButton<T, sentinel>::UpdateRenderBackground();
00063 ToolbarButton<T, sentinel>::UpdateRenderPicture();
00064 }
00065
00066 template <typename T, T sentinel>
00067 void ToolbarButton<T, sentinel>::HandleMouseoverOn ()
00068 {
00069 ASSERT1(this->IsMouseover());
00070 Button::HandleMouseoverOn();
00071 UpdateRenderBackground();
00072 }
00073
00074 template <typename T, T sentinel>
00075 void ToolbarButton<T, sentinel>::HandleMouseoverOff ()
00076 {
00077 ASSERT1(!this->IsMouseover());
00078 Button::HandleMouseoverOff();
00079 UpdateRenderBackground();
00080 }
00081
00082 template <typename T, T sentinel>
00083 void ToolbarButton<T, sentinel>::UpdateRenderBackground ()
00084 {
00085
00086 if (!this->IsEnabled())
00087 SetRenderBackground(
00088 this->WidgetSkinWidgetBackground(
00089 WidgetSkin::TOOLBAR_BUTTON_BACKGROUND));
00090 else if (this->IsPressed())
00091 SetRenderBackground(
00092 this->WidgetSkinWidgetBackground(
00093 WidgetSkin::TOOLBAR_BUTTON_PRESSED_BACKGROUND));
00094 else if (this->IsMouseover() && this->AcceptsMouseover())
00095 SetRenderBackground(
00096 this->WidgetSkinWidgetBackground(
00097 WidgetSkin::TOOLBAR_BUTTON_MOUSEOVER_BACKGROUND));
00098 else if (this->IsChecked())
00099 SetRenderBackground(
00100 this->WidgetSkinWidgetBackground(
00101 WidgetSkin::TOOLBAR_BUTTON_CHECKED_BACKGROUND));
00102 else
00103 SetRenderBackground(
00104 this->WidgetSkinWidgetBackground(
00105 WidgetSkin::TOOLBAR_BUTTON_BACKGROUND));
00106 }
00107
00108 template <typename T, T sentinel>
00109 void ToolbarButton<T, sentinel>::UpdateRenderPicture ()
00110 {
00111 SetRenderPicture(this->Picture());
00112 }
00113
00114 template <typename T, T sentinel>
00115 void ToolbarButton<T, sentinel>::HandleChangedWidgetSkinWidgetBackground (
00116 WidgetSkin::WidgetBackgroundType const widget_background_type)
00117 {
00118
00119 UpdateRenderBackground();
00120 }
00121
00122 }
00123
00124 #endif // !defined(_XRB_TOOLBARBUTTON_HPP_)