IMS2  Pre-Alpha
An Orbiter add-on to allow on-runtime construction of spacecraft from predefined modules
GUI_Draw Class Reference

This class contains drawing functions for the GUI. More...

Static Public Member Functions

static SURFHANDLE createElementBackground (GUI_ElementStyle *style, int width, int height)
 Allocates a drawing surface and fills it with a background color. More...
 
static void DrawRectangle (RECT rectangle, Sketchpad *skp, GUI_ElementStyle *style, bool hilight=false)
 Draws a filled rectangle in the passed style. More...
 
static void DrawLine (int x0, int y0, int x1, int y1, Sketchpad *skp, GUI_ElementStyle *style)
 Draws a line. More...
 
static void DrawPolygon (IVECTOR2 *vertexlist, int numvertices, Sketchpad *skp, GUI_ElementStyle *style, bool highlight=false)
 Draws an arbitrary filled polygon. More...
 
static void ColorFill (RECT rectangle, SURFHANDLE srf, GUI_COLOR color)
 Fills a a rectangle with the designated color. More...
 
static DWORD getDwordColor (GUI_COLOR color)
 converts a GUI_COLOR to a DWORD formatted for sketchpad operations More...
 
static DWORD getAlphaCorrectedColor (float alpha, GUI_COLOR &color, GUI_COLOR &bgcolor)
 takes an alpha value, a color and a background color and returns the DWORD value of color when it is blended More...
 

Static Private Member Functions

static IVECTOR2 * createRoundedRectVertexList (RECT rectangle, int corner_radius, int &OUT_numvertices, DWORD corners)
 creates a vertex list to draw a rounded rectangle More...
 
static IVECTOR2 * createRoundedCornerVertexList (IVECTOR2 center, int corner_radius, CORNERS corner, int &OUT_numvertices, IVECTOR2 *previousvertices=NULL)
 creates a list of points on a rounded corner (I.E. a quarter circle). More...
 
static IVECTOR2 * addVertexToVertexList (IVECTOR2 vert, int &IN_OUT_numvertices, IVECTOR2 *vertexlist)
 Appends a vertex to a vertex list. More...
 

Detailed Description

This class contains drawing functions for the GUI.

Note that these drawing functions are relatively slow: they are intended to be used to draw GUI elements once into video memory, while drawing the actual visuals to the panel is done by blitting these pre-drawn textures

also note that this is still very much a mock implementation it just uses the default Sketchpad commands to draw shapes, which is unsatisfactory because the Sketchpad algorithms' suck increases proportional with line width. A future implementation should aim at a complete and well-working drawing implementation on a per-pixel basis using Sketchpad's Pixel()

Member Function Documentation

IVECTOR2 * GUI_Draw::addVertexToVertexList ( IVECTOR2  vert,
int &  IN_OUT_numvertices,
IVECTOR2 *  vertexlist 
)
staticprivate

Appends a vertex to a vertex list.

Parameters
vertThe new vertex to be added to the list
IN_OUT_numverticesreturns number of vertices in the list. Expects length of vertexlist as input
vertexlistThe vertex list vert should be appended to. Will be initialised if NULL.
Note
vertexlist WILL BE DESTROYED during execution of this function!
void GUI_Draw::ColorFill ( RECT  rectangle,
SURFHANDLE  srf,
GUI_COLOR  color 
)
static

Fills a a rectangle with the designated color.

Parameters
rectangleThe rectangle to fill, relative to srf
srfThe drawing surface on which to perform the color fill
colorThe color to fill rectangle with
SURFHANDLE GUI_Draw::createElementBackground ( GUI_ElementStyle style,
int  width,
int  height 
)
static

Allocates a drawing surface and fills it with a background color.

Parameters
styleThe style defining the background color of the element
widthThe width of the surface in pixel
heightthe height of the surface in pixel
Returns
a Handle to the newly created surface
IVECTOR2 * GUI_Draw::createRoundedCornerVertexList ( IVECTOR2  center,
int  corner_radius,
CORNERS  corner,
int &  OUT_numvertices,
IVECTOR2 *  previousvertices = NULL 
)
staticprivate

creates a list of points on a rounded corner (I.E. a quarter circle).

Note
Corners will ALWAYS be drawn counter-clockwise, so choose the starting point accordingly
Parameters
centerThe position of the center of the corner radius
corner_radiusthe radius of the corner in pixel
cornerThe designation for the corner
OUT_numverticesContains the number of vertices in the returned array after the function finishes.
Note
If previousvertices != NULL, OUT_numvertices is expected to already contain the number of vertices in previousvertices when passed
Parameters
previousverticesA list of vertices these vertices should be appended to. If not NULL, the function will return previousvertices with the new vertices appended, with OUT_numvertices containing the total amount of vertices
Note
previousvertices WILL BE DESTROYED during execution of this function!!
IVECTOR2 * GUI_Draw::createRoundedRectVertexList ( RECT  rectangle,
int  corner_radius,
int &  OUT_numvertices,
DWORD  corners 
)
staticprivate

creates a vertex list to draw a rounded rectangle

Parameters
rectangleThe position and dimensions of the rectangle
corner_radiusIn pixel
OUT_numverticescontains the number of vertices in the list after the operation finishes
cornersBitmask describing which corners to round
void GUI_Draw::DrawLine ( int  x0,
int  y0,
int  x1,
int  y1,
Sketchpad *  skp,
GUI_ElementStyle style 
)
static

Draws a line.

Parameters
x0The x-coordinate (surface relative) of the starting point
y0The y-coordinate (surface relative) of the starting point
x1The x-coordinate (surface relative) of the end point
y1The y-coordinate (surface relative) of the end point
skpThe sketchpad to draw the line with
styleThe style determining linewidth and color
void GUI_Draw::DrawPolygon ( IVECTOR2 *  vertexlist,
int  numvertices,
Sketchpad *  skp,
GUI_ElementStyle style,
bool  highlight = false 
)
static

Draws an arbitrary filled polygon.

Parameters
vertexlistPointer to an array of vertices. The caller is responsible for freeing the list after use!
numverticesThe number of vertices in vertexlist
skpThe sketchpad to draw with
styleThe style determining border color and width as well as fill color. Border radius is ignored.
highlightIf true, the styles hilightcolor will be used as fill color, otherwise the styles fill color
void GUI_Draw::DrawRectangle ( RECT  rectangle,
Sketchpad *  skp,
GUI_ElementStyle style,
bool  hilight = false 
)
static

Draws a filled rectangle in the passed style.

Allows corner radiuses. If you don't want a border, set border-width of the style to 0.

Parameters
rectanglePosition and Dimensions of the rectangle
stylePointer to the style the background should be drawn in
skpPointer to the sketchpad doing the drawing
styleThe style defining the visuals of the rectangle
hilightIf true, the rectangle will be filled with the styles hilight color, otherwise with its fillcolor
DWORD GUI_Draw::getAlphaCorrectedColor ( float  alpha,
GUI_COLOR color,
GUI_COLOR bgcolor 
)
static

takes an alpha value, a color and a background color and returns the DWORD value of color when it is blended

Parameters
alphaThe alpha value for which to calculate (transparency if you will)
colorthe overlying color
bgcolorThe background color
Returns
the color that results from the alpha-blending of color and bgcolor
Note
functional, but currently unused. Was intended for line effects, but because sketchpad gets really bad at thicker lines that experiment was abandoned until somebody writes better line drawing algorithms.
DWORD GUI_Draw::getDwordColor ( GUI_COLOR  color)
static

converts a GUI_COLOR to a DWORD formatted for sketchpad operations

Returns
A DWORD with formatting 0xBBGGRR
Parameters
colorThe color to convert
Note
The DWORD returned by oapiGetColor has the formatting 0xRRGGBB and cannot be used for sketchpad operations. On the other hand, the formatting returned by this function will not work for oapiColorFill().

The documentation for this class was generated from the following files: