#include <xbuttonimage.h>
Inheritance diagram for Ars::XButtonImage:


Public Member Functions | |
| XButtonImage (void) | |
| ~XButtonImage (void) | |
| Standard destructor. | |
| virtual void | Init (icstring &aStr) |
| virtual const bool | SetupWindow (const Message &msg) |
| Initialize the XButtonImage. | |
| void | ChangeImage (const std::string &aFilename) |
| void | ChangeImage (const std::string &aSection, const std::string &aId, std::string aFilename="") |
| void | SetImage (SDL_Surface *aImage) |
| virtual void | Draw (void) |
| Draws the checkbox. | |
Protected Attributes | |
| int | id |
| std::string | sct |
| std::string | key |
| std::string | fname |
|
|
Constructs a new XButtonImage
Definition at line 6 of file xbuttonimage.cpp.
00007 : id( -1 ) 00008 { 00009 } |
|
|
Standard destructor.
Definition at line 11 of file xbuttonimage.cpp.
00012 {
00013 }
|
|
||||||||||||||||
|
Definition at line 52 of file xbuttonimage.cpp. References Ars::Window::clientRect, and id.
00053 {
00054 id = Graf::LoadImg( aSection , aId , aFilename );
00055 Graf::ButtonImg( id , static_cast<XRect &>( *this ) );
00056 clientRect = *this;
00057 }
|
|
|
Definition at line 45 of file xbuttonimage.cpp. References Ars::Window::clientRect, and id. Referenced by Ars::XScrollBar::SetupWindow().
00046 {
00047 id = Graf::LoadImg( aFilename );
00048 Graf::ButtonImg( id , static_cast<XRect &>( *this ) );
00049 clientRect = *this;
00050 }
|
|
|
Draws the checkbox.
Reimplemented from Ars::XLabel. Definition at line 66 of file xbuttonimage.cpp. References Ars::XRect::Center(), Ars::Window::DrawBG(), Ars::HPaint::GetFontSize(), Ars::HPaint::GetGDI(), Ars::Painter::GetStates(), Ars::HPaint::GetTextSize(), Ars::Thing::GetWindowRect(), Ars::Window::GetWindowText(), Ars::XRect::Grow(), HALIGN_MASK, id, Ars::Thing::ResetState(), S_ALIGN_BOTTOM, S_ALIGN_LEFT, S_ALIGN_RIGHT, S_ALIGN_TOP, S_DISABLED, S_FOCUS, S_HIGHLIGHT, S_SELECTED, Ars::Thing::SetState(), VALIGN_MASK, Ars::XPoint::x, and Ars::XPoint::y.
00067 {
00068 if( id == -1 )
00069 XButton::Draw();
00070 else
00071 {
00072 XRect dst( GetWindowRect() );
00073 SDL_Surface *sfc = Graf::ButtonImg( id , dst ) , *bkgnd = 0;
00074
00075 if( GetStates() & S_DISABLED )
00076 bkgnd = Graf::ButtonImg( Graf::Dark , dst );
00077 else if( (GetStates() & (S_SELECTED|S_HIGHLIGHT|S_FOCUS)) != 0 )
00078 bkgnd = Graf::ButtonImg( Graf::Light , dst );
00079
00080 if( bkgnd )
00081 SDL_BlitSurface( bkgnd , NULL , GetGDI() , &dst );
00082
00083 if( (GetStates() & S_SELECTED) != 0 )
00084 SDL_SetAlpha( sfc , SDL_SRCALPHA , 100 );
00085 else if( GetStates() & S_DISABLED )
00086 SDL_SetAlpha( sfc , SDL_SRCALPHA , 100 );
00087 else if( (GetStates() & (S_HIGHLIGHT|S_FOCUS)) != 0 )
00088 SDL_SetAlpha( sfc , SDL_SRCALPHA , 160 );
00089 else
00090 SDL_SetAlpha( sfc , SDL_SRCALPHA , 192 );
00091
00092 SDL_BlitSurface( sfc , 0 , GetGDI() , &dst );
00093
00094 if( !GetWindowText().empty() )
00095 {
00096 XPoint box = GetTextSize( GetWindowText() );
00097 XRect bak = GetWindowRect();
00098 XRect &wnd = *this;
00099 XPoint center = bak.Center();
00100 const unsigned long stateBak = GetStates();
00101 if( GetStates() & S_ALIGN_TOP )
00102 {
00103 wnd = wnd - XPoint( 0, box.y + GetFontSize() );
00104 wnd.x = center.x - box.x / 2;
00105 }
00106 else if( GetStates() & S_ALIGN_BOTTOM )
00107 {
00108 wnd = wnd + XPoint( 0, wnd.h + GetFontSize() );
00109 wnd.x = center.x - box.x / 2;
00110 }
00111 else if( GetStates() & S_ALIGN_RIGHT )
00112 {
00113 wnd = wnd + XPoint( wnd.w + GetFontSize() , 0 );
00114 wnd.y = center.y - box.y / 2;
00115 }
00116 else if( GetStates() & S_ALIGN_LEFT )
00117 {
00118 wnd = wnd - XPoint( box.x + GetFontSize() , 0 );
00119 wnd.y = center.y - box.y / 2;
00120 }
00121 wnd.w = box.x;
00122 wnd.h = box.y;
00123 ResetState( VALIGN_MASK|HALIGN_MASK );
00124 Grow( GetFontSize() / 2 );
00125 DrawBG();
00126 XButton::Draw();
00127 SetState( stateBak );
00128 SDL_UpdateRect( GetGDI() , x , y , w + 1 , h + 1 );
00129 static_cast<XRect &>( *this ) = bak;
00130 }
00131 }
00132 }
|
|
|
Initialize the thing object via a string the CAR identifiers used are: cfg: "section" "key" "fname" NB if fname starts with @ the string is the key of associated with afilename in the global Cfg file Reimplemented from Ars::Window. Definition at line 15 of file xbuttonimage.cpp. References fname, icstring, key, and sct. Referenced by Ars::XScrollBar::Init(), and Ars::XDropDown::Init().
|
|
|
Definition at line 59 of file xbuttonimage.cpp. References Ars::Window::clientRect, and id.
00060 {
00061 id = Graf::AddImage( aImage );
00062 Graf::ButtonImg( id , static_cast<XRect &>( *this ) );
00063 clientRect = *this;
00064 }
|
|
|
Initialize the XButtonImage.
Reimplemented from Ars::XButton. Definition at line 26 of file xbuttonimage.cpp. References Ars::Window::clientRect, fname, id, key, and sct. Referenced by Ars::XScrollBar::SetupWindow(), and Ars::XDropDown::SetupWindow().
00027 {
00028 XButton::SetupWindow( msg );
00029
00030 if( !sct.empty() || !key.empty() || !fname.empty() )
00031 {
00032 if( id == -1 )
00033 if( key.empty() )
00034 id = Graf::LoadImg( fname.empty() ? sct : fname );
00035 else
00036 id = Graf::LoadImg( sct , key , fname );
00037
00038 Graf::ButtonImg( id , static_cast<XRect &>( *this ) );
00039 clientRect = *this;
00040 }
00041
00042 return true;
00043 }
|
|
|
Definition at line 10 of file xbuttonimage.h. Referenced by Init(), and SetupWindow(). |
|
|
Definition at line 9 of file xbuttonimage.h. Referenced by ChangeImage(), Draw(), SetImage(), and SetupWindow(). |
|
|
Definition at line 10 of file xbuttonimage.h. Referenced by Init(), and SetupWindow(). |
|
|
Definition at line 10 of file xbuttonimage.h. Referenced by Init(), and SetupWindow(). |
1.3.3