00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "picture_text_cbox.h"
00023 #include "../include/app.h"
00024 #include "../graphic/font.h"
00025 #include "../graphic/sprite.h"
00026 #include "../tool/resource_manager.h"
00027
00028 PictureTextCBox::PictureTextCBox(const std::string &label, const std::string &resource_id,
00029 const Rectanglei &rect, bool value):
00030 CheckBox(label, rect, value)
00031 {
00032 Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false);
00033 m_image = resource_manager.LoadImage(res, resource_id);
00034 resource_manager.UnLoadXMLProfile( res);
00035
00036 SetPosition( rect.GetPosition() );
00037 SetSize( rect.GetSize() );
00038
00039 SetSizeY( m_image.GetHeight() + (*Font::GetInstance(Font::FONT_NORMAL, Font::BOLD)).GetHeight() );
00040 m_value = value;
00041
00042 txt_label = new Text(label, dark_gray_color, Font::GetInstance(Font::FONT_NORMAL, Font::BOLD), false);
00043 txt_label->SetMaxWidth (GetSizeX());
00044 }
00045
00046 void PictureTextCBox::Draw(const Point2i &mousePosition, Surface& surf) const
00047 {
00048 if (!hidden)
00049 {
00050
00051 uint tmp_x = GetPositionX() + (GetSizeX() - m_image.GetWidth() - 20)/2 ;
00052 uint tmp_y = GetPositionY() + (GetSizeY() - m_image.GetHeight() - txt_label->GetHeight() - 5) /2;
00053
00054 AppWormux::GetInstance()->video.window.Blit(m_image, Point2i(tmp_x, tmp_y));
00055
00056 txt_label->DrawCenterTop( GetPositionX() + GetSizeX()/2,
00057 GetPositionY() + GetSizeY() - txt_label->GetHeight() );
00058
00059 if (m_value)
00060 m_checked_image->SetCurrentFrame(0);
00061 else
00062 m_checked_image->SetCurrentFrame(1);
00063
00064 m_checked_image->Blit(surf,
00065 GetPositionX() + GetSizeX() - 16,
00066 GetPositionY() + (GetSizeY()-16)/2 );
00067 }
00068 }
00069
00070 void PictureTextCBox::SetSizePosition(const Rectanglei &rect)
00071 {
00072 StdSetSizePosition(rect);
00073 txt_label->SetMaxWidth (GetSizeX());
00074 }