#include "clientlib.h"#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>Defines | |
| #define | DBG(fmt, args...) printf( "%s: " fmt, __FUNCTION__ , ## args); fflush(stdout) |
| #define | PGDM_INPUT_RAW 8 |
Functions | |
| void | pgUpdate (void) |
| Update the screen. | |
| int | pgEnterContext (void) |
| Enter a new context. | |
| int | pgGetContext (void) |
| Get the current context ID. | |
| void | pgLeaveContext (void) |
| Leave a context. | |
| void | pgSetContext (int id) |
| Set the context ID used when creating new handles. | |
| void | pgDeleteHandleContext (int id) |
| Delete all handles in one context. | |
| pghandle | pgDataString (struct pgmemdata obj) |
| Load memory into a string handle. | |
| pghandle | pgLoadTheme (struct pgmemdata obj) |
| Load a compiled theme. | |
| pghandle | pgLoadWidgetTemplate (struct pgmemdata obj) |
| Load a compiled Widget Template. | |
| u32 | pgThemeLookup (s16 object, s16 property) |
| Retrieve a theme property. | |
| pgmemdata | pgFromMemory (void *data, u32 length) |
| Refer to data loaded into memory. | |
| pgmemdata | pgFromTempMemory (void *data, u32 length) |
| Refer to data loaded into memory, free when done. | |
| pgmemdata | pgFromFile (const char *file) |
| Refer to data in a file. | |
| pgmemdata | pgFromStream (FILE *f, u32 length) |
| Refer to data in an opened stream. | |
| void | pgSetPayload (pghandle object, u32 payload) |
| Set an object's payload. | |
| void | pgRegisterOwner (int resource) |
| Register exclusive access to a resouce. | |
| void | pgUnregisterOwner (int resource) |
| Unregister exclusive access to a resouce. | |
| void | pgSetVideoMode (u16 xres, u16 yres, u16 bpp, u16 flagmode, u32 flags) |
| Change video mode at runtime. | |
| u32 | pgGetPayload (pghandle object) |
| Get an object's payload. | |
| pghandle | pgGetServerRes (u32 res) |
| Get a server resource. | |
| void | pgSetInactivity (u32 time) |
| Set the inactivity timer. | |
| u32 | pgGetInactivity (void) |
| Get the inactivity timer. | |
| pghandle | pgNewCursor (void) |
| Create a cursor that can be used for input filters. | |
| void | pgSubUpdate (pghandle widget) |
| Update a subsection of the screen. | |
| void | pgFocus (pghandle widget) |
| Give a widget the keyboard focus. | |
| void | pgDelete (pghandle object) |
| Delete any object that has a handle. | |
| pghandle | pgRegisterApp (s16 type, const char *name,...) |
| Register a new application. | |
| void | pgSetWidget (pghandle widget,...) |
| Set widget properties. | |
| pghandle | pgCreateWidget (s16 type) |
| Create a new widget without a parent. | |
| pghandle | pgNewInFilter (pghandle insert_after, u32 accept_trigs, u32 absorb_trigs) |
| Create a new client-side input filter. | |
| void | pgAttachWidget (pghandle parent, s16 rship, pghandle widget) |
| Attach a widget to a new parent. | |
| void | pgInFilterSend (union pg_client_trigger *trig) |
| Send an event back from a client-side input filter. | |
| pghandle | pgNewWidget (s16 type, s16 rship, pghandle parent) |
| Create a new widget, derived from a parent widget. | |
| pghandle | pgNewPopupAt (int x, int y, int width, int height) |
| Create a popup box at the specified position. | |
| pghandle | pgNewFont (const char *name, s16 size, u32 style) |
| Create a new font object. | |
| pghandle | pgNewPopup (int width, int height) |
| Create a popup box, centered on the screen. | |
| pghandle | pgNewBitmap (struct pgmemdata obj) |
| Create a new bitmap object from existing data. | |
| pghandle | pgCreateBitmap (s16 width, s16 height) |
| Create a new bitmap object. | |
| pghandle | pgNewString (const char *str) |
| Create a new string object. | |
| pghandle | pgFindWidget (const char *str) |
| Search for a widget by its PG_WP_NAME property. | |
| int | pgFindThemeObject (const char *str) |
| Find a theme object's ID given its name. | |
| pghandle | pgNewArray (const s32 *dat, u16 size) |
| Create a new array object. | |
| pghandle | pgEvalRequest (s16 reqtype, void *data, u32 datasize) |
| Evaluate a PicoGUI request packet. | |
| s32 | pgGetWidget (pghandle widget, s16 property) |
| Get a widget property. | |
| pghandle | pgTraverseWidget (pghandle widget, int direction, int count) |
| Finds a widget in relation to another widget. | |
| void | pgSizeText (int *w, int *h, pghandle font, pghandle text) |
| Measure a string of text. | |
| void | pgSizeBitmap (int *w, int *h, pghandle bitmap) |
| Return the size of a bitmap object. | |
| char * | pgGetString (pghandle string) |
| Get the contents of a string handle. | |
| pgshmbitmap * | pgMakeSHMBitmap (pghandle bitmap) |
| Map a bitmap into a shared memory segment. | |
| int | pgGetFontStyle (s16 index, char *name, u16 *size, u16 *fontrep, u32 *flags) |
| Get information about a font style. | |
| pgmodeinfo * | pgGetVideoMode (void) |
| Get information about the current video mode. | |
| void | pgDriverMessage (u32 message, u32 param) |
| Send a message to the drivers. | |
| void | pgReplaceText (pghandle widget, const char *str) |
| Change a widget's text. | |
| void | pgReplaceTextFmt (pghandle widget, const char *fmt,...) |
| Change a widget's text, with formatting. | |
| void | pgWriteData (pghandle widget, struct pgmemdata data) |
| Write data to a widget. | |
| void | pgWriteCmd (pghandle widget, s32 command, s16 numparams,...) |
| Write a command to a widget. | |
| void | pgRender (pghandle bitmap, s16 groptype,...) |
| Render a gropnode to a bitmap. | |
| pghandle | pgLoadDriver (const char *name) |
| Load an input driver by name and return a handle. | |
| pghandle | pgDup (pghandle object) |
| Duplicate an object that has a handle. | |
| void | pgChangeContext (pghandle object, s16 delta) |
| Change the handle context of an object. | |
| int | pgCheckEvent (void) |
| Check the number of pending events. | |
| void | pgEventPoll (void) |
| Get and dispatch new events if there are any. | |
| void | pgAppMessage (pghandle dest, struct pgmemdata data) |
| Send a message to a widget owned by any application. | |
| void * | pgSyncAppMessage (pghandle dest, struct pgmemdata data) |
| Send a message to a widget owned by any application, and wait for an answer. | |
|
|
|
|
|
|
|
||||||||||||
|
Send a message to a widget owned by any application.
data parameter is sent as the data in a PG_WE_APPMSG event on behalf of the dest widget. |
|
||||||||||||||||
|
Attach a widget to a new parent.
|
|
||||||||||||
|
Change the handle context of an object.
pgEnterContext(); pgDialogBox("My Dialog"); ... Allocate lots of memory ... pgChangeContext(important_data,-1); pgLeaveContext(); return important_data;
|
|
|
Check the number of pending events.
You can use this function if, for some reason, you need to poll PicoGUI events instead of waiting for them. In the middle of a long operation, for example, you may wish to periodically check if the user clicks a cancel button. If this function indicates that there are events waiting, pgGetEvent will return immediately with the oldest queued event.
|
|
||||||||||||
|
Create a new bitmap object.
|
|
|
Create a new widget without a parent.
|
|
|
Load memory into a string handle.
|
|
|
Delete any object that has a handle.
object. |
|
|
Delete all handles in one context. This lets you use contexts as individuals with an ID rather than as a stack. pgLeaveContext() deletes the current context (stored per-connection) and decrements that current context. This function deletes the specified context without touching the current context number. This way new contexts can be requested and discarded indefinitely (or at least until the IDs wrap around, in which case the server will skip context nubmers that are in use)
|
|
||||||||||||
|
Send a message to the drivers.
|
|
|
Duplicate an object that has a handle.
|
|
|
Enter a new context. PicoGUI uses a context system, similar to a variable's scope in C. Whenever the program leaves a context, all objects created while in that context are deleted. No memory is used by creating a context, and they can be nested a very large number of times.
pghandle x,y,z; pgEnterContext(); x = pgNewString("X"); pgEnterContext(); y = pgNewString("Y"); pgLeaveContext(); // y is deleted z = pgNewString("Z"); pgLeaveContext(); // x and z are deleted
|
|
||||||||||||||||
|
Evaluate a PicoGUI request packet.
The format of the data accepted by the request packet depends on the type of packet. |
|
|
Get and dispatch new events if there are any. This function is a non-blocking version of pgEventLoop(). It calls pgCheckEvent(), and if there are any new events it uses pgGetEvent() and pgDispatchEvent() to retrieve and process any pending events. This is good to call during an animation or other lengthy operation to check for the user clicking the close button, canceling the operation, etc.
|
|
|
Find a theme object's ID given its name.
custom are assigned an ID automatically at load time. These objects can be found with this function as long as each is assigned a unique name property.
|
|
|
Search for a widget by its PG_WP_NAME property.
|
|
|
Give a widget the keyboard focus.
|
|
|
Refer to data in a file.
|
|
||||||||||||
|
Refer to data loaded into memory.
|
|
||||||||||||
|
Refer to data in an opened stream.
length bytes past it. The stream's position is advanced by length bytes.
|
|
||||||||||||
|
Refer to data loaded into memory, free when done.
data will be freed with the free() function.
|
|
|
Get the current context ID.
|
|
||||||||||||||||||||||||
|
Get information about a font style.
char name[40]; u16 size; u16 fontrep; u32 flags; s16 i; i = 0; while (pgGetFontStyle(i++, name, &size, &fontrep, &flags)) { printf("Font #%d: %s\n" " size: %d\n" " fontrep: 0x%04X\n" " flags: 0x%08X\n\n", i,name,size,fontrep,flags); }
|
|
|
Get the inactivity timer.
|
|
|
Get an object's payload.
|
|
|
Get a server resource.
|
|
|
Get the contents of a string handle.
|
|
|
Get information about the current video mode.
struct pgmodeinfo mi; mi = *pgGetVideoMode();
|
|
||||||||||||
|
Get a widget property.
|
|
|
Send an event back from a client-side input filter.
|
|
|
Leave a context. When leaving a context, all objects created within it are deleted, and the context ID is decremented. This default behavior simulates a stack of contexts. See pgEnterContext for an example.
|
|
|
Load an input driver by name and return a handle.
|
|
|
Load a compiled theme.
themec utility. The theme can be unloaded by calling pgDelete with the returned theme handle.
|
|
|
Load a compiled Widget Template.
|
|
|
Map a bitmap into a shared memory segment.
|
|
||||||||||||
|
Create a new array object.
|
|
|
Create a new bitmap object from existing data.
|
|
|
Create a cursor that can be used for input filters.
|
|
||||||||||||||||
|
Create a new font object.
fDefault = pgNewFont(NULL,0,PG_FSTYLE_DEFAULT); // Find the font marked as default fBold = pgNewFont(NULL,0,PG_FSTYLE_DEFAULT | PG_FSTYLE_BOLD); // Bold version of the default font fBig = pgNewFont(NULL,40,PG_FSTYLE_ITALIC); // A large italic font fFlush = pgNewFont("Helvetica",0,PG_FSTYLE_FLUSH); // Helvetica at the default size, with no space at the edges
|
|
||||||||||||||||
|
Create a new client-side input filter.
|
|
||||||||||||
|
Create a popup box, centered on the screen.
width and/or height can be PGDEFAULT (zero) to determine the size automatically. This is preferred because the app should assume as little as possible about physical screen coordinates.NOTE: This function is now just a shortcut for creating a popup widget and setting its PG_WP_ABSOLUTEX, PG_WP_ABSOLUTEY, PG_WP_WIDTH, and PG_WP_HEIGHT properties
|
|
||||||||||||||||||||
|
Create a popup box at the specified position.
width and/or height can be PGDEFAULT (zero) to determine the size automatically. This is preferred because the app should assume as little as possible about physical screen coordinates.
NOTE: This function is now just a shortcut for creating a popup widget and setting its PG_WP_ABSOLUTEX, PG_WP_ABSOLUTEY, PG_WP_WIDTH, and PG_WP_HEIGHT properties
|
|
|
Create a new string object.
|
|
||||||||||||||||
|
Create a new widget, derived from a parent widget.
rship indicates where in the widget stacking order, relative to the parent, the new widget will be:
|
|
||||||||||||||||
|
Register a new application. < Send PG_NWE_PNTR_RAW from the specified widget |
|
|
Register exclusive access to a resouce.
|
|
||||||||||||||||
|
Render a gropnode to a bitmap.
|
|
||||||||||||
|
Change a widget's text.
It is the preferred way of setting or changing the text of a button, label, or other widget that takes a PG_WP_TEXT property.
|
|
||||||||||||||||
|
Change a widget's text, with formatting. This function is equivalent to pgReplaceText, with support for printf-style formatting
|
|
|
Set the context ID used when creating new handles.
|
|
|
Set the inactivity timer.
|
|
||||||||||||
|
Set an object's payload.
|
|
||||||||||||||||||||||||
|
Change video mode at runtime.
xres, yres, and bpp can be zero to keep the current values.
|
|
||||||||||||
|
Set widget properties.
widget, pgSetWidget accepts a list of property-value pairs terminated by a zero. For example:
pgSetWidget(wLabel, PG_WP_TEXT,pgNewString("Hello"), PG_WP_FONT,pgNewFont("Helvetica",12,0), 0);
|
|
||||||||||||||||
|
Return the size of a bitmap object.
|
|
||||||||||||||||||||
|
Measure a string of text.
*w and *h, returns the size in pixels of the given text in the given font. Font may be PGDEFAULT to use the default font.Note that if you use pgNewText to create a string object just for this function call, you should delete it afterwards to prevent a memory leak: pghandle sText; int w,h; sText = pgNewString("Hello, World!"); pgSizeText(&w,&h,PGDEFAULT,sText); pgDelete(sText); Alternatively, defining a context with pgEnterContext and pgLeaveContext will clean up the string object automatically: pgEnterContext(); pgSizeText(&w,&h,PGDEFAULT,pgNewString("Hello, World!"); pgLeaveContext();
|
|
|
Update a subsection of the screen. The given widget and all other widgets contained within it are redrawn if necessary. The request buffer is flushed and the section is redrawn independantly and immediately. This function is recommended for animation. Areas of the screen other than the specified widget and its children are never updated, and SubUpdates can occur in toolbars even while a popup dialog is onscreen.
|
|
||||||||||||
|
Send a message to a widget owned by any application, and wait for an answer.
data parameter is sent as the data in a PG_WE_APPMSG event on behalf of the dest widget.
This call acts very similarly to
NOTE: The data is assumed to be a structure whose very first field is of type |
|
||||||||||||
|
Retrieve a theme property.
|
|
||||||||||||||||
|
Finds a widget in relation to another widget.
direction at this time:
|
|
|
Unregister exclusive access to a resouce.
|
|
|
Update the screen. Redraw portions of the screen if necessary. This forces all unsent packets to be flushed to the server, and instructs the server to draw changed areas of the screen. If your application is pgEventLoop (or pgGetEvent) based, this is handled automatically. The server always updates the screen before waiting for user interaction. For doing animation, consider using pgSubUpdate instead.
|
|
||||||||||||||||||||
|
Write a command to a widget.
|
|
||||||||||||
|
Write data to a widget.
|
1.3-rc3