csGraphics2D Class Reference
[Common Plugin Classes]
This is the base class for 2D canvases. More...
#include <csplugincommon/canvas/graph2d.h>
Public Types | |
enum | HWMouseMode { hwmcOff, hwmcOn, hwmcRGBAOnly } |
Hardware mouse cursor setting. More... | |
Public Member Functions | |
virtual void | AllowResize (bool) |
Enable/disable canvas resize (Over-ride in sub classes). | |
virtual bool | BeginDraw () |
This routine should be called before any draw operations. | |
virtual void | ChangeDepth (int d) |
Change the depth of the canvas. | |
virtual void | Clear (int color) |
Clear backbuffer. | |
virtual void | ClearAll (int color) |
Clear all video pages. | |
virtual bool | ClipLine (float &x1, float &y1, float &x2, float &y2, int xmin, int ymin, int xmax, int ymax) |
Clip a line against given rectangle Function returns true if line is not visible. | |
virtual void | Close () |
(*) Close graphics system | |
csGraphics2D (iBase *) | |
Create csGraphics2D object. | |
virtual int | FindRGB (int r, int g, int b, int a=255) |
Find an RGB (0..255) color. | |
virtual void | FinishDraw () |
This routine should be called when you finished drawing. | |
virtual void | GetClipRect (int &xmin, int &ymin, int &xmax, int &ymax) |
Query clipping rectangle. | |
int | GetColorDepth () |
Return color depth of the framebuffer. | |
virtual iFontServer * | GetFontServer () |
Gets the font server. | |
void | GetFramebufferDimensions (int &width, int &height) |
Get the dimensions of the framebuffer. | |
virtual bool | GetFullScreen () |
Returns 'true' if the program is being run full-screen. | |
virtual float | GetGamma () const |
Get gamma value. | |
virtual int | GetHeight () |
Return the height of the framebuffer. | |
const char * | GetHWGLVersion () |
Get a string containing the OpenGL version. | |
const char * | GetHWRenderer () |
Get a string containing the hardware renderer. | |
const char * | GetHWVendor () |
Get a string containing the vendor info. | |
virtual const char * | GetName () const |
Get the name of this canvas. | |
virtual iNativeWindow * | GetNativeWindow () |
Return the Native Window interface for this canvas (if it has one). | |
virtual void | GetRGB (int color, int &r, int &g, int &b, int &a) |
Retrieve the R,G,B,A tuple for a given color number. | |
virtual void | GetRGB (int color, int &r, int &g, int &b) |
Retrieve the R,G,B tuple for a given color number. | |
void | GetViewport (int &left, int &top, int &width, int &height) |
Get the currently set viewport. | |
virtual int | GetWidth () |
Return the width of the framebuffer. | |
virtual bool | HandleEvent (iEvent &) |
Event handler for plugin. | |
virtual bool | Initialize (iObjectRegistry *) |
Initialize the plugin. | |
virtual bool | Open () |
(*) Open graphics system (set videomode, open window etc) | |
virtual bool | PerformExtension (char const *command,...) |
Perform a system specific extension. | |
virtual bool | PerformExtensionV (char const *command, va_list) |
Perform a system specific extension. | |
virtual void | Print (csRect const *=0) |
(*) Flip video pages (or dump backbuffer into framebuffer). | |
virtual bool | Resize (int w, int h) |
Resize the canvas. | |
virtual void | SetClipRect (int xmin, int ymin, int xmax, int ymax) |
Set clipping rectangle. | |
virtual void | SetFullScreen (bool b) |
Change the fullscreen state of the canvas. | |
virtual bool | SetGamma (float) |
Set gamma value (if supported by canvas). | |
virtual bool | SetMouseCursor (iImage *image, const csRGBcolor *keycolor=0, int hotspot_x=0, int hotspot_y=0, csRGBcolor fg=csRGBcolor(255, 255, 255), csRGBcolor bg=csRGBcolor(0, 0, 0)) |
Set mouse cursor using an image. | |
virtual bool | SetMouseCursor (csMouseCursorID iShape) |
Set mouse cursor to one of predefined shape classes (see csmcXXX enum above). | |
virtual bool | SetMousePosition (int x, int y) |
Set mouse cursor position; return success status. | |
void | SetViewport (int left, int top, int width, int height) |
Set the viewport (the rectangle of the framebuffer to draw to). | |
virtual | ~csGraphics2D () |
Destroy csGraphics2D object. | |
virtual void | Write (iFont *font, int x, int y, int fg, int bg, const wchar_t *text, uint flags=0) |
Write a text string into the back buffer. | |
virtual void | Write (iFont *font, int x, int y, int fg, int bg, const char *text, uint flags=0) |
Write a text string into the back buffer. | |
Public Attributes | |
bool | AllowResizing |
Whether to allow resizing. | |
int | ClipX1 |
The clipping rectangle. | |
csConfigAccess | config |
The configuration file. | |
int | DisplayNumber |
Display number. | |
int | fbWidth |
The width, height and depth of visual. | |
csFontCache * | fontCache |
The font cache. | |
csWeakRef< iFontServer > | FontServer |
The font server. | |
int | FrameBufferLocked |
The counter that is incremented inside BeginDraw and decremented in FinishDraw(). | |
bool | FullScreen |
True if visual is full-screen. | |
bool | is_open |
Open/Close state. | |
iObjectRegistry * | object_reg |
The object registry. | |
csWeakRef< iPluginManager > | plugin_mgr |
The plugin manager. | |
csString | win_title |
Pointer to a title. | |
Protected Member Functions | |
virtual bool | AddWindowFrameDimensions (int &width, int &height) |
Helper function for FitSizeToWorkingArea(): compute window dimensions with the window frame included. | |
virtual bool | GetWorkspaceDimensions (int &width, int &height) |
Helper function for FitSizeToWorkingArea(): obtain workspace dimensions. | |
iNativeWindowManager implementation | |
virtual void | Alert (int type, const wchar_t *title, const wchar_t *okMsg, const wchar_t *msg,...) |
Show an alert. | |
virtual void | Alert (int type, const char *title, const char *okMsg, const char *msg,...) |
Show an alert. | |
virtual void | AlertV (int type, const wchar_t *title, const wchar_t *okMsg, const wchar_t *msg, va_list args) |
Show an alert. | |
virtual void | AlertV (int type, const char *title, const char *okMsg, const char *msg, va_list args) |
Show an alert. | |
iDebugHelper implementation | |
virtual csTicks | Benchmark (int) |
Perform a benchmark. | |
virtual bool | DebugCommand (const char *cmd) |
Perform a debug command as defined by the module itself. | |
virtual void | Dump (iGraphics3D *) |
Do a graphical dump of the current state of this object. | |
virtual csPtr< iString > | Dump () |
Do a text dump of the current state of this object. | |
virtual int | GetSupportedTests () const |
Return a bit field indicating what types of functions this specific unit test implementation supports. | |
virtual csPtr< iString > | StateTest () |
Perform a state test. | |
virtual csPtr< iString > | UnitTest () |
iNativeWindow implementation | |
virtual bool | FitSizeToWorkingArea (int &desiredWidth, int &desiredHeight) |
Sets the icon of this window with the provided one. | |
virtual bool | GetWindowDecoration (WindowDecoration decoration) |
Sets the icon of this window with the provided one. | |
virtual bool | GetWindowTransparent () |
Sets the icon of this window with the provided one. | |
virtual bool | IsWindowTransparencyAvailable () |
Sets the icon of this window with the provided one. | |
virtual void | SetIcon (iImage *image) |
Sets the icon of this window with the provided one. | |
virtual void | SetTitle (const wchar_t *title) |
Sets the icon of this window with the provided one. | |
virtual void | SetTitle (const char *title) |
Sets the icon of this window with the provided one. | |
virtual bool | SetWindowDecoration (WindowDecoration decoration, bool flag) |
Sets the icon of this window with the provided one. | |
virtual bool | SetWindowTransparent (bool transparent) |
Sets the icon of this window with the provided one. | |
iPluginConfig implementation | |
virtual bool | GetOption (int id, csVariant *value) |
Get the value of the option of index idx. | |
virtual bool | GetOptionDescription (int idx, csOptionDescription *) |
Get the description of the option of index idx. | |
virtual bool | SetOption (int id, csVariant *value) |
Set the value of the option of index idx. | |
Protected Attributes | |
bool | fitToWorkingArea |
Reduce window size to fit into workspace, if necessary. | |
int | refreshRate |
Screen refresh rate. | |
bool | vsync |
Activate Vsync. |
Detailed Description
This is the base class for 2D canvases.
Plugins should derive their own class from this one and implement required (marked with an asterisk (*)) functions. Functions not marked with an asterisk are optional, but possibly slow since they are too general.
Definition at line 62 of file graph2d.h.
Member Enumeration Documentation
Constructor & Destructor Documentation
csGraphics2D::csGraphics2D | ( | iBase * | ) |
Create csGraphics2D object.
virtual csGraphics2D::~csGraphics2D | ( | ) | [virtual] |
Destroy csGraphics2D object.
Member Function Documentation
virtual bool csGraphics2D::AddWindowFrameDimensions | ( | int & | width, | |
int & | height | |||
) | [protected, virtual] |
Helper function for FitSizeToWorkingArea(): compute window dimensions with the window frame included.
virtual void csGraphics2D::Alert | ( | int | type, | |
const wchar_t * | title, | |||
const wchar_t * | okMsg, | |||
const wchar_t * | msg, | |||
... | ||||
) | [protected, virtual] |
virtual void csGraphics2D::Alert | ( | int | type, | |
const char * | title, | |||
const char * | okMsg, | |||
const char * | msg, | |||
... | ||||
) | [protected, virtual] |
Show an alert.
Type is one of CS_ALERT_???.
- Remarks:
- All strings are expected to be UTF-8 encoded.
Implements iNativeWindowManager.
virtual void csGraphics2D::AlertV | ( | int | type, | |
const wchar_t * | title, | |||
const wchar_t * | okMsg, | |||
const wchar_t * | msg, | |||
va_list | arg | |||
) | [protected, virtual] |
virtual void csGraphics2D::AlertV | ( | int | type, | |
const char * | title, | |||
const char * | okMsg, | |||
const char * | msg, | |||
va_list | arg | |||
) | [protected, virtual] |
virtual void csGraphics2D::AllowResize | ( | bool | ) | [inline, virtual] |
Enable/disable canvas resize (Over-ride in sub classes).
Implements iGraphics2D.
virtual bool csGraphics2D::BeginDraw | ( | ) | [virtual] |
This routine should be called before any draw operations.
It should return true if graphics context is ready.
Implements iGraphics2D.
Reimplemented in csGraphics2DGLCommon.
virtual csTicks csGraphics2D::Benchmark | ( | int | num_iterations | ) | [inline, protected, virtual] |
Perform a benchmark.
This function will return a number indicating how long the benchmark lasted in milliseconds.
Implements iDebugHelper.
virtual void csGraphics2D::ChangeDepth | ( | int | d | ) | [virtual] |
Change the depth of the canvas.
virtual void csGraphics2D::Clear | ( | int | color | ) | [virtual] |
virtual void csGraphics2D::ClearAll | ( | int | color | ) | [virtual] |
Clear all video pages.
Implements iGraphics2D.
virtual bool csGraphics2D::ClipLine | ( | float & | x1, | |
float & | y1, | |||
float & | x2, | |||
float & | y2, | |||
int | xmin, | |||
int | ymin, | |||
int | xmax, | |||
int | ymax | |||
) | [virtual] |
Clip a line against given rectangle Function returns true if line is not visible.
Implements iGraphics2D.
virtual void csGraphics2D::Close | ( | ) | [virtual] |
virtual bool csGraphics2D::DebugCommand | ( | const char * | cmd | ) | [protected, virtual] |
Perform a debug command as defined by the module itself.
Returns 'false' if the command was not recognized.
Implements iDebugHelper.
Reimplemented in csGraphics2DGLCommon.
virtual void csGraphics2D::Dump | ( | iGraphics3D * | g3d | ) | [inline, protected, virtual] |
Do a graphical dump of the current state of this object.
Implements iDebugHelper.
Do a text dump of the current state of this object.
Returns 0 if not supported or else a string which you should DecRef() after use.
Implements iDebugHelper.
virtual int csGraphics2D::FindRGB | ( | int | r, | |
int | g, | |||
int | b, | |||
int | a = 255 | |||
) | [inline, virtual] |
Find an RGB (0..255) color.
The actual color bytes are returned.
Use returned value for color arguments in iGraphics2D.
Implements iGraphics2D.
virtual void csGraphics2D::FinishDraw | ( | ) | [virtual] |
This routine should be called when you finished drawing.
Implements iGraphics2D.
Reimplemented in csGraphics2DGLCommon.
virtual bool csGraphics2D::FitSizeToWorkingArea | ( | int & | desiredWidth, | |
int & | desiredHeight | |||
) | [protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
virtual void csGraphics2D::GetClipRect | ( | int & | xmin, | |
int & | ymin, | |||
int & | xmax, | |||
int & | ymax | |||
) | [virtual] |
Query clipping rectangle.
Implements iGraphics2D.
int csGraphics2D::GetColorDepth | ( | ) | [inline, virtual] |
Return color depth of the framebuffer.
Implements iGraphics2D.
virtual iFontServer* csGraphics2D::GetFontServer | ( | ) | [inline, virtual] |
void csGraphics2D::GetFramebufferDimensions | ( | int & | width, | |
int & | height | |||
) | [inline, virtual] |
Get the dimensions of the framebuffer.
Implements iGraphics2D.
virtual bool csGraphics2D::GetFullScreen | ( | ) | [inline, virtual] |
Returns 'true' if the program is being run full-screen.
Implements iGraphics2D.
virtual float csGraphics2D::GetGamma | ( | ) | const [inline, virtual] |
virtual int csGraphics2D::GetHeight | ( | ) | [inline, virtual] |
Return the height of the framebuffer.
Implements iGraphics2D.
const char* csGraphics2D::GetHWGLVersion | ( | ) | [inline, virtual] |
Get a string containing the OpenGL version.
Implements iGraphics2D.
Reimplemented in csGraphics2DGLCommon.
const char* csGraphics2D::GetHWRenderer | ( | ) | [inline, virtual] |
Get a string containing the hardware renderer.
Implements iGraphics2D.
Reimplemented in csGraphics2DGLCommon.
const char* csGraphics2D::GetHWVendor | ( | ) | [inline, virtual] |
Get a string containing the vendor info.
Implements iGraphics2D.
Reimplemented in csGraphics2DGLCommon.
virtual const char* csGraphics2D::GetName | ( | ) | const [virtual] |
Get the name of this canvas.
Implements iGraphics2D.
virtual iNativeWindow* csGraphics2D::GetNativeWindow | ( | ) | [virtual] |
Return the Native Window interface for this canvas (if it has one).
Implements iGraphics2D.
virtual bool csGraphics2D::GetOption | ( | int | index, | |
csVariant * | value | |||
) | [protected, virtual] |
Get the value of the option of index idx.
Return false if this option does not exist, true otherwise.
- Parameters:
-
index The index of the option value A variant where to store the value of the option
Implements iPluginConfig.
virtual bool csGraphics2D::GetOptionDescription | ( | int | index, | |
csOptionDescription * | option | |||
) | [protected, virtual] |
Get the description of the option of index idx.
Return false if this option does not exist, true otherwise.
- Parameters:
-
index The index of the option option The returned description of the option
Implements iPluginConfig.
virtual void csGraphics2D::GetRGB | ( | int | color, | |
int & | r, | |||
int & | g, | |||
int & | b, | |||
int & | a | |||
) | [inline, virtual] |
Retrieve the R,G,B,A tuple for a given color number.
Implements iGraphics2D.
virtual void csGraphics2D::GetRGB | ( | int | color, | |
int & | r, | |||
int & | g, | |||
int & | b | |||
) | [inline, virtual] |
Retrieve the R,G,B tuple for a given color number.
Implements iGraphics2D.
virtual int csGraphics2D::GetSupportedTests | ( | ) | const [inline, protected, virtual] |
Return a bit field indicating what types of functions this specific unit test implementation supports.
This will return a combination of the CS_DBGHELP_... flags:
Implements iDebugHelper.
void csGraphics2D::GetViewport | ( | int & | left, | |
int & | top, | |||
int & | width, | |||
int & | height | |||
) | [inline, virtual] |
virtual int csGraphics2D::GetWidth | ( | ) | [inline, virtual] |
Return the width of the framebuffer.
Implements iGraphics2D.
virtual bool csGraphics2D::GetWindowDecoration | ( | WindowDecoration | decoration | ) | [protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
virtual bool csGraphics2D::GetWindowTransparent | ( | ) | [inline, protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
virtual bool csGraphics2D::GetWorkspaceDimensions | ( | int & | width, | |
int & | height | |||
) | [protected, virtual] |
Helper function for FitSizeToWorkingArea(): obtain workspace dimensions.
virtual bool csGraphics2D::HandleEvent | ( | iEvent & | ) | [virtual] |
Event handler for plugin.
Implements iEventHandler.
virtual bool csGraphics2D::Initialize | ( | iObjectRegistry * | ) | [virtual] |
virtual bool csGraphics2D::IsWindowTransparencyAvailable | ( | ) | [inline, protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
virtual bool csGraphics2D::Open | ( | ) | [virtual] |
(*) Open graphics system (set videomode, open window etc)
Implements iGraphics2D.
Reimplemented in csGraphics2DGLCommon.
virtual bool csGraphics2D::PerformExtension | ( | char const * | command, | |
... | ||||
) | [virtual] |
Perform a system specific extension.
Return false if extension not supported.
Implements iGraphics2D.
virtual bool csGraphics2D::PerformExtensionV | ( | char const * | command, | |
va_list | ||||
) | [virtual] |
Perform a system specific extension.
Return false if extension not supported.
Implements iGraphics2D.
Reimplemented in csGraphics2DGLCommon.
virtual void csGraphics2D::Print | ( | csRect const * | = 0 |
) | [inline, virtual] |
(*) Flip video pages (or dump backbuffer into framebuffer).
Implements iGraphics2D.
virtual bool csGraphics2D::Resize | ( | int | w, | |
int | h | |||
) | [virtual] |
virtual void csGraphics2D::SetClipRect | ( | int | xmin, | |
int | ymin, | |||
int | xmax, | |||
int | ymax | |||
) | [virtual] |
virtual void csGraphics2D::SetFullScreen | ( | bool | b | ) | [virtual] |
Change the fullscreen state of the canvas.
Implements iGraphics2D.
virtual bool csGraphics2D::SetGamma | ( | float | gamma | ) | [inline, virtual] |
Set gamma value (if supported by canvas).
By default this is 1. Smaller values are darker. If the canvas doesn't support gamma then this function will return false.
Implements iGraphics2D.
virtual void csGraphics2D::SetIcon | ( | iImage * | image | ) | [protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
virtual bool csGraphics2D::SetMouseCursor | ( | iImage * | image, | |
const csRGBcolor * | keycolor = 0 , |
|||
int | hotspot_x = 0 , |
|||
int | hotspot_y = 0 , |
|||
csRGBcolor | fg = csRGBcolor(255, 255, 255) , |
|||
csRGBcolor | bg = csRGBcolor(0, 0, 0) | |||
) | [virtual] |
Set mouse cursor using an image.
If the operation is unsupported, return 'false' otherwise return 'true'. On some platforms there is only monochrome pointers available. In this all black colors in the image will become the value of 'bg' and all non-black colors will become 'fg'
Implements iGraphics2D.
virtual bool csGraphics2D::SetMouseCursor | ( | csMouseCursorID | iShape | ) | [virtual] |
Set mouse cursor to one of predefined shape classes (see csmcXXX enum above).
If a specific mouse cursor shape is not supported, return 'false'; otherwise return 'true'. If system supports it and iBitmap != 0, shape should be set to the bitmap passed as second argument; otherwise cursor should be set to its nearest system equivalent depending on iShape argument.
Implements iGraphics2D.
virtual bool csGraphics2D::SetMousePosition | ( | int | x, | |
int | y | |||
) | [virtual] |
Set mouse cursor position; return success status.
Implements iGraphics2D.
virtual bool csGraphics2D::SetOption | ( | int | index, | |
csVariant * | value | |||
) | [protected, virtual] |
Set the value of the option of index idx.
Return false if this option does not exist, true otherwise.
- Parameters:
-
index The index of the option value The new value to be set for the option
Implements iPluginConfig.
virtual void csGraphics2D::SetTitle | ( | const wchar_t * | title | ) | [inline, protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
virtual void csGraphics2D::SetTitle | ( | const char * | title | ) | [protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
void csGraphics2D::SetViewport | ( | int | left, | |
int | top, | |||
int | width, | |||
int | height | |||
) | [virtual] |
Set the viewport (the rectangle of the framebuffer to draw to).
- Parameters:
-
left Left of the viewport. X=0 will map to this. top Right of the viewport. Y=0 will map to this. width Width of the viewport. height Height of the viewport.
Implements iGraphics2D.
Reimplemented in csGraphics2DGLCommon.
virtual bool csGraphics2D::SetWindowDecoration | ( | WindowDecoration | decoration, | |
bool | flag | |||
) | [inline, protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
virtual bool csGraphics2D::SetWindowTransparent | ( | bool | transparent | ) | [inline, protected, virtual] |
Sets the icon of this window with the provided one.
- Note:
- Virtual SetIcon function so it can be overridden by subclasses of csGraphics2D.
- Parameters:
-
image the iImage to set as the icon of this window.
Implements iNativeWindow.
Perform a state test.
This function will test if the current state of the object is ok. It will return 0 if it is ok. Otherwise an iString is returned containing some information about the errors. DecRef() this returned string after using it.
Implements iDebugHelper.
virtual void csGraphics2D::Write | ( | iFont * | font, | |
int | x, | |||
int | y, | |||
int | fg, | |||
int | bg, | |||
const wchar_t * | text, | |||
uint | flags = 0 | |||
) | [virtual] |
Write a text string into the back buffer.
Implements iGraphics2D.
virtual void csGraphics2D::Write | ( | iFont * | font, | |
int | x, | |||
int | y, | |||
int | fg, | |||
int | bg, | |||
const char * | text, | |||
uint | flags = 0 | |||
) | [virtual] |
Write a text string into the back buffer.
Implements iGraphics2D.
Member Data Documentation
bool csGraphics2D::fitToWorkingArea [protected] |
The counter that is incremented inside BeginDraw and decremented in FinishDraw().
int csGraphics2D::refreshRate [protected] |
bool csGraphics2D::vsync [protected] |
The documentation for this class was generated from the following file:
- csplugincommon/canvas/graph2d.h
Generated for Crystal Space 2.0 by doxygen 1.6.1