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
|
/*
* Modification History
*
* 2001-September-15 Jason Rohrer
* Created.
*/
#ifndef GUI_PANEL_GL_INCLUDED
#define GUI_PANEL_GL_INCLUDED
#include "GUIComponentGL.h"
#include "GUIContainerGL.h"
#include "minorGems/util/SimpleVector.h"
#include "minorGems/graphics/Color.h"
#include <GL/gl.h>
/**
* A container with a background color that is drawn
* behind the components.
*
* @author Jason Rohrer
*/
class GUIPanelGL : public GUIContainerGL {
public:
/**
* Constructs a panel.
*
* @param inAnchorX the x position of the upper left corner
* of this component.
* @param inAnchorY the y position of the upper left corner
* of this component.
* @param inWidth the width of this component.
* @param inHeight the height of this component.
* @param inColor the background color for this panel.
* Will be destroyed when this class is destroyed.
*/
GUIPanelGL(
double inAnchorX, double inAnchorY, double inWidth,
double inHeight, Color *inColor );
~GUIPanelGL();
// override fireRedraw() in GUIComponentGL
virtual void fireRedraw();
protected:
Color *mColor;
};
inline GUIPanelGL::GUIPanelGL(
double inAnchorX, double inAnchorY, double inWidth,
double inHeight, Color *inColor )
: GUIContainerGL( inAnchorX, inAnchorY, inWidth, inHeight ),
mColor( inColor ) {
}
inline GUIPanelGL::~GUIPanelGL() {
delete mColor;
}
inline void GUIPanelGL::fireRedraw() {
// draw our background color as a rectangle
glColor3f( mColor->r, mColor->g, mColor->b );
glBegin( GL_QUADS ); {
glVertex2d( mAnchorX, mAnchorY );
glVertex2d( mAnchorX + mWidth, mAnchorY );
glVertex2d( mAnchorX + mWidth, mAnchorY + mHeight );
glVertex2d( mAnchorX, mAnchorY + mHeight );
}
glEnd();
// call the supercalss redraw
GUIContainerGL::fireRedraw();
}
#endif
|