From 39ed87570bdb2f86969d4be821c94b722dc71179 Mon Sep 17 00:00:00 2001 From: Joe Ludwig Date: Wed, 26 Jun 2013 15:22:04 -0700 Subject: First version of the SOurce SDK 2013 --- mp/src/vgui2/vgui_controls/Image.cpp | 282 +++++++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 mp/src/vgui2/vgui_controls/Image.cpp (limited to 'mp/src/vgui2/vgui_controls/Image.cpp') diff --git a/mp/src/vgui2/vgui_controls/Image.cpp b/mp/src/vgui2/vgui_controls/Image.cpp new file mode 100644 index 00000000..b7ab8564 --- /dev/null +++ b/mp/src/vgui2/vgui_controls/Image.cpp @@ -0,0 +1,282 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include +#include +#include + +#include +#include + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: Conctructor. Start with default position and default color. +//----------------------------------------------------------------------------- +Image::Image() +{ + SetPos(0,0); + SetSize(0,0); + SetColor(Color(255,255,255,255)); +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +Image::~Image() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Set the position of the image, you need to reset this every time you +// call Paint() +//----------------------------------------------------------------------------- +void Image::SetPos(int x,int y) +{ + _pos[0]=x; + _pos[1]=y; +} + +//----------------------------------------------------------------------------- +// Purpose: Get the position of the image +//----------------------------------------------------------------------------- +void Image::GetPos(int& x,int& y) +{ + x=_pos[0]; + y=_pos[1]; +} + +//----------------------------------------------------------------------------- +// Purpose: Get the size of the image +//----------------------------------------------------------------------------- +void Image::GetSize(int &wide, int &tall) +{ + wide = _size[0]; + tall = _size[1]; +} + +//----------------------------------------------------------------------------- +// Purpose: Gets the size of the image contents (by default the set size) +//----------------------------------------------------------------------------- +void Image::GetContentSize(int &wide, int &tall) +{ + GetSize(wide, tall); +} + +//----------------------------------------------------------------------------- +// Purpose: Set the size of the image +//----------------------------------------------------------------------------- +void Image::SetSize(int wide, int tall) +{ + _size[0]=wide; + _size[1]=tall; +} + +//----------------------------------------------------------------------------- +// Purpose: Set the draw color using a Color struct. +//----------------------------------------------------------------------------- +void Image::DrawSetColor(Color col) +{ + surface()->DrawSetColor(col[0], col[1], col[2], col[3]); +} + +//----------------------------------------------------------------------------- +// Purpose: Set the draw color using RGBA ints +//----------------------------------------------------------------------------- +void Image::DrawSetColor(int r,int g,int b,int a) +{ + surface()->DrawSetColor(r,g,b,a); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw a filled rectangle +//----------------------------------------------------------------------------- +void Image::DrawFilledRect(int x0,int y0,int x1,int y1) +{ + x0+=_pos[0]; + y0+=_pos[1]; + x1+=_pos[0]; + y1+=_pos[1]; + surface()->DrawFilledRect(x0,y0,x1,y1); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw an outlined rectangle +//----------------------------------------------------------------------------- +void Image::DrawOutlinedRect(int x0,int y0,int x1,int y1) +{ + x0+=_pos[0]; + y0+=_pos[1]; + x1+=_pos[0]; + y1+=_pos[1]; + surface()->DrawOutlinedRect(x0,y0,x1,y1); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw a line between two points +//----------------------------------------------------------------------------- +void Image::DrawLine(int x0,int y0,int x1,int y1) +{ + x0+=_pos[0]; + y0+=_pos[1]; + x1+=_pos[0]; + y1+=_pos[1]; + surface()->DrawLine(x0,y0,x1,y1); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw a line between a list of 'numPoints' points +//----------------------------------------------------------------------------- +void Image::DrawPolyLine(int *px, int *py, int numPoints) +{ + // update the positions to be relative to this panel + for(int i=0;iDrawPolyLine(px, py, numPoints); +} + +//----------------------------------------------------------------------------- +// Purpose: Set the font +//----------------------------------------------------------------------------- +void Image::DrawSetTextFont(HFont font) +{ + surface()->DrawSetTextFont(font); +} + +//----------------------------------------------------------------------------- +// Purpose: Set the text color using a color struct +//----------------------------------------------------------------------------- +void Image::DrawSetTextColor(Color sc) +{ + surface()->DrawSetTextColor(sc[0], sc[1], sc[2], sc[3]); +} + +//----------------------------------------------------------------------------- +// Purpose: Set the text color useing RGBA ints +//----------------------------------------------------------------------------- +void Image::DrawSetTextColor(int r,int g,int b,int a) +{ + surface()->DrawSetTextColor(r,g,b,a); +} + +//----------------------------------------------------------------------------- +// Purpose: Set the text position +//----------------------------------------------------------------------------- +void Image::DrawSetTextPos(int x,int y) +{ + x+=_pos[0]; + y+=_pos[1]; + surface()->DrawSetTextPos(x,y); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw a text string +//----------------------------------------------------------------------------- +void Image::DrawPrintText(const wchar_t *str,int strlen) +{ + surface()->DrawPrintText(str, strlen); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw a text string at the given coords. +//----------------------------------------------------------------------------- +void Image::DrawPrintText(int x, int y, const wchar_t *str, int strlen) +{ + x += _pos[0]; + y += _pos[1]; + + surface()->DrawSetTextPos(x, y); + surface()->DrawPrintText(str, strlen); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw a character +//----------------------------------------------------------------------------- +void Image::DrawPrintChar(wchar_t ch) +{ + surface()->DrawUnicodeChar(ch); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw a character at the given coords +//----------------------------------------------------------------------------- +void Image::DrawPrintChar(int x, int y, wchar_t ch) +{ + x+=_pos[0]; + y+=_pos[1]; + + surface()->DrawSetTextPos(x, y); + surface()->DrawUnicodeChar(ch); +} + +//----------------------------------------------------------------------------- +// Purpose: Set a texture +//----------------------------------------------------------------------------- +void Image::DrawSetTexture(int id) +{ + surface()->DrawSetTexture(id); +} + +//----------------------------------------------------------------------------- +// Purpose: Draw a rectangle filled with the current texture +//----------------------------------------------------------------------------- +void Image::DrawTexturedRect(int x0,int y0,int x1,int y1) +{ + surface()->DrawTexturedRect(x0,y0,x1,y1); +} + +//----------------------------------------------------------------------------- +// Purpose: Paint the contents of the image on screen. +// You must call this explicitly each frame. +//----------------------------------------------------------------------------- +void Image::Paint() +{ +} + +//----------------------------------------------------------------------------- +// Purpose: Set the current color using a color struct +//----------------------------------------------------------------------------- +void Image::SetColor(Color color) +{ + _color=color; + DrawSetTextColor(color); // now update the device context underneath us :) +} + +//----------------------------------------------------------------------------- +// Purpose: Get the current color as a color struct +//----------------------------------------------------------------------------- +Color Image::GetColor() +{ + return _color; +} + +bool Image::Evict() +{ + return false; +} + +int Image::GetNumFrames() +{ + return 0; +} + +void Image::SetFrame( int nFrame ) +{ +} + +HTexture Image::GetID() +{ + return 0; +} + -- cgit v1.2.3