00001 #include "gui/gui.h"
00002 #include "gui/image.h"
00003 using namespace VGUI;
00004
00005
00006 Image::Image( Widget* w )
00007 {
00008 filename = "";
00009 center = w->GetCenter();
00010 name = w->GetName();
00011 text = w->GetText();
00012 type = w->GetType();
00013 tip = w->GetTip();
00014 rel_width = w->GetRelWidth();
00015 rel_height = w->GetRelHeight();
00016 enabled = w->GetEnabled();
00017 selected = w->GetSelected();
00018 is_default = w->GetDefault();
00019 is_cancel = w->GetCancel();
00020 has_icon = w->GetHasIcon();
00021 width_auto = w->GetWidthAuto();
00022 height_auto = w->GetHeightAuto();
00023 font_size = w->GetFontSize();
00024 color_r = w->GetColorR();
00025 color_g = w->GetColorG();
00026 color_b = w->GetColorB();
00027 }
00028
00029 Image::~Image()
00030 {
00031 }
00032
00033 void Image::Load()
00034 {
00035 int img_width, img_height;
00036 img_tex.Load( filename.c_str(), false, img_width, img_height );
00037 if( width_auto )
00038 {
00039 rel_width = (float)img_width / 1280.0f;
00040 }
00041
00042 if( height_auto )
00043 {
00044 rel_height = (float)img_height / 1024.0f;
00045 }
00046 }
00047
00048 void Image::Draw()
00049 {
00050 Draw( 1.0 );
00051 }
00052
00053 void Image::Draw( float opacity )
00054 {
00055 float center_x = center.GetXPercent();
00056 float center_y = center.GetYPercent();
00057 float rel_width_half = rel_width / 2.0f;
00058 float rel_height_half = rel_height / 2.0f;
00059 utility.Draw2D( center_x - rel_width_half, center_y - rel_height_half, center_x + rel_width_half, center_y + rel_height_half, &img_tex, 0.0, 0, opacity );
00060 }