Commit a15570aa authored by Gerhard Stein's avatar Gerhard Stein

Added some missig repo files

parent cecab34c
......@@ -8,3 +8,14 @@ Makefile
.settings
.svn
*.dmg
CMakeCache.txt
CPackConfig.cmake
CPackSourceConfig.cmake
Debug/*
*~
build/*
cmake_install.cmake
install_manifest.txt
*.dll
*.dll
readme.txt
This diff is collapsed.
File added
1 ICON "CGLogo.ico"
/*
* CGUISwitch.cpp
*
* Created on: 04.03.2012
* Author: gerstrong
*/
#include "CGUISwitch.h"
CGUISwitch::CGUISwitch( const std::string& text,
const Style style ) :
CGUIComboSelection( text, filledStrList( 2, "off", "on" ), style )
{}
/*
* CGUISwitch.h
*
* Created on: 04.03.2012
* Author: gerstrong
*/
#include "CGUIComboSelection.h"
#include "Utils.h"
#ifndef CGUISWITCH_H_
#define CGUISWITCH_H_
class CGUISwitch : public CGUIComboSelection {
public:
CGUISwitch( const std::string& text,
const Style style );
void enable( const bool sel )
{ CGUIComboSelection::setSelection( sel ? "on" : "off" ); }
bool isEnabled()
{ return CGUIComboSelection::getSelection() == "on"; }
};
#endif /* CGUISWITCH_H_ */
/*
* extensions.cpp
*
* Created on: 31.01.2012
* Author: gerstrong
*
* Extensions for SDL
*/
#include "extensions.h"
Uint32 getPixel(SDL_Surface *surface, int x, int y)
{
int bpp = surface->format->BytesPerPixel;
/* Here p is the address to the pixel we want to retrieve */
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
switch(bpp)
{
case 1:
return *p;
break;
case 2:
return *(Uint16 *)p;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
return p[0] << 16 | p[1] << 8 | p[2];
else
return p[0] | p[1] << 8 | p[2] << 16;
break;
case 4:
return *(Uint32 *)p;
break;
default:
return 0; /* shouldn't happen, but avoids warnings */
}
}
inline Colormask getColourMask32bit()
{
Colormask mask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
mask.r = 0xFF000000;
mask.g = 0x00FF0000;
mask.b = 0x0000FF00;
mask.a = 0x000000FF;
#else
mask.r = 0x000000FF;
mask.g = 0x0000FF00;
mask.b = 0x00FF0000;
mask.a = 0xFF000000;
#endif
return mask;
}
SDL_Surface *CG_CreateRGBSurface( const SDL_Rect rect )
{
Colormask mask = getColourMask32bit();
return SDL_CreateRGBSurface( SDL_SWSURFACE, // TODO: Must be changed in future for better hardware support
rect.w,
rect.h,
32, // TODO: Must be changed in future for better 16 bpp support
mask.r,
mask.g,
mask.b,
mask.a );
}
/*
* extensions.h
*
* Created on: 31.01.2012
* Author: gerstrong
* Extensions for SDL
*/
#ifndef SDL_EXTENSIONS_H_
#define SDL_EXTENSIONS_H_
#include <SDL.h>
struct Colormask
{
Uint32 r,g,b,a;
};
Uint32 getPixel(SDL_Surface *surface, int x, int y);
inline Colormask getColourMask32bit();
SDL_Surface *CG_CreateRGBSurface( const SDL_Rect rect );
#endif /* SDL_EXTENSIONS_H_ */
/*
* Geometry.cpp
*
* Created on: 25.01.2012
* Author: gerstrong
*/
#include "Geometry.h"
void drawRect( SDL_Surface *sfc,
SDL_Rect *rect,
const int thickness,
const Uint32 &ContourColor )
{
SDL_Rect TempRect;
// Get the proper Rect for drawing
if(rect)
{
TempRect = *rect;
}
else
{
TempRect.x = 0;
TempRect.y = 0;
TempRect.w = sfc->w;
TempRect.h = sfc->h;
}
SDL_Rect tempr;
// Upper side contour
tempr.x = TempRect.x;
tempr.y = TempRect.y;
tempr.w = TempRect.w;
tempr.h = thickness;
SDL_FillRect(sfc, &tempr, ContourColor );
// Left side contour
tempr.y = TempRect.y + thickness;
tempr.w = thickness;
tempr.h = TempRect.h - (2 * thickness);
SDL_FillRect(sfc, &tempr, ContourColor);
// Right side contour
tempr.x = TempRect.x + TempRect.w - thickness;
SDL_FillRect(sfc, &tempr, ContourColor);
// Lower side contour
tempr.x = TempRect.x;
tempr.y = TempRect.y + TempRect.h - thickness;
tempr.w = TempRect.w;
tempr.h = thickness;
SDL_FillRect(sfc, &tempr, ContourColor);
}
void drawRect( SDL_Surface *sfc,
SDL_Rect *rect,
const int thickness,
const Uint32 &ContourColor,
const Uint32 &FillColor )
{
drawRect( sfc, rect, thickness, ContourColor );
SDL_Rect TempRect;
// Get the proper Rect for drawing
if(rect)
{
TempRect = *rect;
}
else
{
TempRect.x = 0;
TempRect.y = 0;
TempRect.w = sfc->w;
TempRect.h = sfc->h;
}
TempRect.x += thickness;
TempRect.y += thickness;
TempRect.w -= (2*thickness);
TempRect.h -= (2*thickness);
SDL_FillRect(sfc, &TempRect, FillColor);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment