A Screen represents the framebuffer that is the final destination of the GUI. More...
#include <gui_tk.h>
Public Member Functions | |
virtual | ~Screen () |
Destructor. | |
template<typename STR > | |
void | setClipboard (const STR s) |
Set clipboard content. | |
virtual void | setClipboard (const String &s) |
Set clipboard content. | |
virtual const String & | getClipboard () |
Get clipboard content. | |
virtual void | resize (int w, int h) |
Do nothing. | |
virtual void | move (int x, int y) |
Do nothing. | |
virtual bool | hasFocus () const |
Screen has always focus. | |
Ticks | update (void *surface, Ticks ticks=1) |
Update the given surface with this screen's content, fully honouring the alpha channel. | |
virtual void | paint (Drawable &d) const |
Default: clear screen. | |
Protected Member Functions | |
virtual void | rgbToSurface (RGB color, void **pixel)=0 |
Store a single RGB triple (8 bit each) as a native pixel value and advance pointer. | |
virtual RGB | surfaceToRGB (void *pixel)=0 |
Map a single framebuffer pixel to an RGB value. | |
Screen (Size width, Size height) | |
Create a new screen with the given characteristics. | |
Screen (Drawable *d) | |
Create a new screen from the given GUI::Drawable. | |
Protected Attributes | |
Drawable *const | buffer |
Screen buffer. | |
bool | buffer_i_alloc |
String | clipboard |
Clipboard. | |
MouseButton | button = (MouseButton)0 |
Currently pressed mouse button. |
A Screen represents the framebuffer that is the final destination of the GUI.
It's main purpose is to manage the current contents of the surface and to combine it with all GUI elements. You can't resize and move the screen. Requests to do so will be ignored.
This is an abstract base class. You need to use a subclass which implements rgbToSurface and surfaceToRGB.
To make things work, Screen needs events. Call the mouse and key event functions (see Window) whenever such an event occurs. Call update(void *surface, int ticks) regularly, if possible about every 40msec (25 fps). If nothing has changed, screen updates are quite fast.
unsigned int GUI::Screen::update | ( | void * | surface, |
Ticks | ticks = 1 |
||
) |
Update the given surface with this screen's content, fully honouring the alpha channel.
ticks
can be set to a different value depending on how much time has passed. Timing doesn't need to be perfect, but try to call this at least every 40 msec. Each tick amounts to about 10 msec. Returns the number of ticks until the next event is scheduled, or 0 if none.
Definition at line 1609 of file gui_tk.cpp.
References buffer, GUI::Drawable::buffer, GUI::Color::GreenMask, GUI::Window::height, GUI::Color::MagentaMask, GUI::Timer::next(), GUI::Window::paintAll(), rgbToSurface(), surfaceToRGB(), GUI::Window::width, GUI::Window::x, and GUI::Window::y.