Functions | |
| void | pgEventLoop (void) |
| Event processing and dispatching loop. | |
| void | pgExitEventLoop (void) |
| Exit the current event loop. | |
| pgEvent * | pgGetEvent (void) |
| Wait for a single event. | |
| int | pgCheckEvent (void) |
| Check the number of pending events. | |
| void | pgDispatchEvent (struct pgEvent *evt) |
| Dispatch an event to registered handlers. | |
| void | pgEventPoll (void) |
| Get and dispatch new events if there are any. | |
| int | pgEnterContext (void) |
| Enter a new context. | |
| void | pgLeaveContext (void) |
| Leave a context. | |
| void | pgDeleteHandleContext (int id) |
| Delete all handles in one context. | |
| void | pgSetContext (int id) |
| Set the context ID used when creating new handles. | |
| int | pgGetContext (void) |
| Get the current context ID. | |
|
|
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.
|
|
|
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)
|
|
|
Dispatch an event to registered handlers.
|
|
|
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
|
|
|
Event processing and dispatching loop. pgEventLoop waits for events from the PicoGUI server and dispatches them according to bindings set up with pgBind. The handler set with pgSetIdle is also called if applicable. pgEventLoop can be called more than once throughout the life of the program, but it is not re-entrant. If the app recieves an event while it is not waiting in an EventLoop, the server will queue them until the client is ready.
|
|
|
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.
|
|
|
Exit the current event loop. If the client is currently inside an event loop, this function sets a flag to exit it at the next possible opportunity
|
|
|
Get the current context ID.
|
|
|
Wait for a single event.
You can also use this in combination with pgCheckEvent to passively check for new events while performing some other operation, such as animation. Important! Note that the returned pointer is only valid until the next PicoGUI call! It's usually a good idea to use something like this:
struct pgEvent evt; evt = *pgGetEvent(); If the relevant values from the pgEvent structure will be copied elsewhere before the next PicoGUI call, that is alright too. Thus, the following code is perfectly fine:
i = pgGetPayload( pgGetEvent()->from );
|
|
|
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.
|
|
|
Set the context ID used when creating new handles.
|
1.3-rc3