1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#include <ClanLib/gl.h>
#include <ClanLib/gui.h>
#include "stylemanager_opengl.h"
#include "button_opengl.h"
#include "checkbox_opengl.h"
#include "frame_opengl.h"
#include "inputbox_opengl.h"
#include "window_opengl.h"
#include "listbox_opengl.h"
#include "scrollbar_opengl.h"
// Construction:
CL_StyleManager_OpenGL::CL_StyleManager_OpenGL(CL_ResourceManager *resources)
: CL_StyleManager_Default(resources)
{
}
CL_StyleManager_OpenGL::~CL_StyleManager_OpenGL()
{
}
// Attributes:
// Operations:
void CL_StyleManager_OpenGL::fill_rect(
int x1, int y1, int x2, int y2,
float r, float g, float b,
float a0, float a1, float a2, float a3)
{
CL_OpenGL::begin_2d();
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glColor4f(r,g,b,a0);
glVertex2i(x1, y1);
glColor4f(r,g,b,a1);
glVertex2i(x2, y1);
glColor4f(r,g,b,a2);
glVertex2i(x2, y2);
glColor4f(r,g,b,a3);
glVertex2i(x1, y2);
glEnd();
glEnable(GL_TEXTURE_2D);
CL_OpenGL::end_2d();
}
void CL_StyleManager_OpenGL::fill_rect(
int x1, int y1, int x2, int y2,
float r0, float g0, float b0,
float r1, float g1, float b1,
float r2, float g2, float b2,
float r3, float g3, float b3,
float a)
{
CL_OpenGL::begin_2d();
glDisable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glColor4f(r0,g0,b0,a);
glVertex2i(x1, y1);
glColor4f(r1,g1,b1,a);
glVertex2i(x2, y1);
glColor4f(r2,g2,b2,a);
glVertex2i(x2, y2);
glColor4f(r3,g3,b3,a);
glVertex2i(x1, y2);
glEnd();
glEnable(GL_TEXTURE_2D);
CL_OpenGL::end_2d();
}
// Overridables:
void CL_StyleManager_OpenGL::connect_styles(
const std::string &type,
CL_Component *owner)
{
if (type == "button")
{
CL_Button *button = (CL_Button *) owner;
button->attach_style(new CL_Button_OpenGL(button, this));
}
else if (type == "window")
{
CL_Window *window = (CL_Window *) owner;
window->attach_style(new CL_Window_OpenGL(window, this));
}
else if (type == "frame")
{
CL_Frame *frame = (CL_Frame *) owner;
frame->attach_style(new CL_Frame_OpenGL(frame, this));
}
else if (type == "inputbox")
{
CL_InputBox *inputbox = (CL_InputBox *) owner;
inputbox->attach_style(new CL_InputBox_OpenGL(inputbox, this));
}
else if (type == "listbox")
{
CL_ListBox *listbox = (CL_ListBox *) owner;
listbox->attach_style(new CL_ListBox_OpenGL(listbox, this));
}
else if (type == "scrollbar")
{
CL_ScrollBar *scrollbar = (CL_ScrollBar *) owner;
scrollbar->attach_style(new CL_ScrollBar_OpenGL(scrollbar, this));
}
else if (type == "checkbox")
{
CL_CheckBox *checkbox = (CL_CheckBox *) owner;
checkbox->attach_style(new CL_CheckBox_OpenGL(checkbox, this));
}
else
{
CL_StyleManager_Default::connect_styles(type, owner);
}
}
|