The Pedigree Project
0.1
|
#include <Widget.h>
Public Member Functions | |
uint64_t | getHandle () const |
bool | construct (const char *endpoint, const char *title, widgetCallback_t cb, PedigreeGraphics::Rect &dimensions) |
bool | setTitle (const std::string &newTitle) |
virtual bool | render (PedigreeGraphics::Rect &rt, PedigreeGraphics::Rect &dirty)=0 |
bool | redraw (PedigreeGraphics::Rect &rt) |
bool | visibility (bool vis) |
void | destroy () |
void * | getRawFramebuffer () |
int | getSocket () const |
Static Public Member Functions | |
static void | checkForEvents (bool bAsync=false) |
Private Member Functions | |
widgetCallback_t | getCallback () const |
Static Private Member Functions | |
static void | checkForMessage (size_t which, bool bResponse=false) |
static void | handleMessage (const char *pMessageBuffer) |
static bool | handlePendingMessages () |
Private Attributes | |
bool | m_bConstructed |
PedigreeGraphics::Framebuffer * | m_pFramebuffer |
uint64_t | m_Handle |
widgetCallback_t | m_EventCallback |
int | m_Socket |
PedigreeIpc::SharedIpcMessage * | m_SharedFramebuffer |
Static Private Attributes | |
static std::map< uint64_t, Widget * > | s_KnownWidgets |
static std::queue< char * > | s_PendingMessages |
static size_t | s_NumWidgets |
Base class for all GUI widgets in the system. Defines the interface for all widgets to use.
|
static |
Handles emptying the pending event queue and dispatch to callbacks for an application automatically.
Definition at line 339 of file Widget.cc.
References getSocket(), handleMessage(), and handlePendingMessages().
Referenced by construct(), getSocket(), Tui::initialise(), TestWidget::render(), PedigreeTerminalEmulator::render(), Gears::render(), and Tui::run().
|
staticprivate |
Waits for a message of the given type, queuing other messages along the way.
Definition at line 391 of file Widget.cc.
References getSocket(), LibUiProtocol::WindowManagerMessage::isResponse, and LibUiProtocol::WindowManagerMessage::messageCode.
Referenced by construct(), destroy(), getSocket(), and redraw().
bool Widget::construct | ( | const char * | endpoint, |
const char * | title, | ||
widgetCallback_t | cb, | ||
PedigreeGraphics::Rect & | dimensions | ||
) |
Constructs the internal state of the widget. This involves talking to the window manager via IPC to obtain a framebuffer for rendering, as well as notifying the window manager that this widget now exists. No other calls are valid until this call has returned successfully.
endpoint | Unique IPC endpoint name to listen on for this widget |
cb | Event handler callback. |
dimensions | Dimensions of the widget to be created. |
Definition at line 90 of file Widget.cc.
References checkForEvents(), checkForMessage(), LibUiProtocol::CreateMessage::endpoint, LibUiProtocol::WindowManagerMessage::isResponse, LibUiProtocol::WindowManagerMessage::messageCode, LibUiProtocol::WindowManagerMessage::messageSize, LibUiProtocol::CreateMessage::minWidth, LibUiProtocol::CreateMessage::rigid, LibUiProtocol::CreateMessage::title, and LibUiProtocol::WindowManagerMessage::widgetHandle.
Referenced by getHandle(), TestWidget::render(), PedigreeTerminalEmulator::render(), and Gears::render().
void Widget::destroy | ( | ) |
Destroys the widget and all internal state.
Definition at line 301 of file Widget.cc.
References checkForMessage(), LibUiProtocol::WindowManagerMessage::isResponse, LibUiProtocol::WindowManagerMessage::messageCode, LibUiProtocol::WindowManagerMessage::messageSize, and LibUiProtocol::WindowManagerMessage::widgetHandle.
Referenced by getHandle(), and Gears::render().
|
inlineprivate |
Get the Widget's callback.
Definition at line 179 of file Widget.h.
References m_EventCallback.
Referenced by handleMessage().
|
inline |
Obtains a handle for this widget. The handle is only usable by the window manager, and is determined by the following formula during widget construction in construct():
Definition at line 79 of file Widget.h.
References construct(), destroy(), m_Handle, redraw(), render(), setTitle(), and visibility().
Referenced by TestWidget::render().
|
inline |
Gets the raw framebuffer for the window. This will be in ARGB32 format.
Definition at line 142 of file Widget.h.
References m_SharedFramebuffer.
Referenced by PedigreeTerminalEmulator::render(), and Gears::render().
|
inline |
Gets a raw socket that can be used for select() or poll().
An application can take all widgets it is aware of and select() on them; when they are readable, a call to Widget::checkForEvents will clear the queued events that arrived.
Definition at line 154 of file Widget.h.
References checkForEvents(), checkForMessage(), handleMessage(), handlePendingMessages(), and m_Socket.
Referenced by checkForEvents(), checkForMessage(), and Tui::run().
|
staticprivate |
Handle the given message.
Definition at line 476 of file Widget.cc.
References getCallback(), m_SharedFramebuffer, LibUiProtocol::WindowManagerMessage::messageCode, LibUiProtocol::RepositionMessage::rt, LibUiProtocol::RepositionMessage::shmem_handle, LibUiProtocol::RepositionMessage::shmem_size, and LibUiProtocol::WindowManagerMessage::widgetHandle.
Referenced by checkForEvents(), getSocket(), and handlePendingMessages().
|
staticprivate |
Clear out pending messages.
Definition at line 562 of file Widget.cc.
References handleMessage().
Referenced by checkForEvents(), and getSocket().
bool Widget::redraw | ( | PedigreeGraphics::Rect & | rt | ) |
Called to begin a redraw of the widget by the window manager.
rt | Rect defining the redraw area. |
Definition at line 225 of file Widget.cc.
References checkForMessage(), LibUiProtocol::WindowManagerMessage::isResponse, LibUiProtocol::WindowManagerMessage::messageCode, LibUiProtocol::WindowManagerMessage::messageSize, and LibUiProtocol::WindowManagerMessage::widgetHandle.
Referenced by getHandle(), Tui::redraw(), TestWidget::render(), and Gears::render().
|
pure virtual |
Called to actually render the widget. Would normally be called by the RepaintNeeded handler by application code.
rt | Area that needs to be rendered. |
dirty | Object containing a dirty rectangle for redrawing. |
Implemented in Gears, PedigreeTerminalEmulator, and TestWidget.
Referenced by getHandle(), and TestWidget::render().
bool Widget::setTitle | ( | const std::string & | newTitle | ) |
Sets the title of the widget.
title | New title for the widget. |
Definition at line 189 of file Widget.cc.
References LibUiProtocol::WindowManagerMessage::isResponse, LibUiProtocol::WindowManagerMessage::messageCode, LibUiProtocol::WindowManagerMessage::messageSize, and LibUiProtocol::WindowManagerMessage::widgetHandle.
Referenced by getHandle().
bool Widget::visibility | ( | bool | vis | ) |
Sets the visibility of the widget.
vis | True if the widget is to be made visible, False otherwise. |
Definition at line 269 of file Widget.cc.
References LibUiProtocol::WindowManagerMessage::isResponse, LibUiProtocol::WindowManagerMessage::messageCode, LibUiProtocol::WindowManagerMessage::messageSize, and LibUiProtocol::WindowManagerMessage::widgetHandle.
Referenced by getHandle(), and TestWidget::render().
|
private |
|
private |
|
private |
|
private |
Framebuffer for all rendering.
|
private |
IPC shared message that handles our framebuffer.
Definition at line 205 of file Widget.h.
Referenced by getRawFramebuffer(), and handleMessage().
|
private |
IPC socket for window manager communication (supercedes IPC enpdoint).
Definition at line 198 of file Widget.h.
Referenced by getSocket().
|
staticprivate |
|
staticprivate |
|
staticprivate |