AppGeneric is a simple application structure. In other words, it is the base structure for applications. It implements such functions as: receiving the graphics context for application needs, cleaning the screen, processing messages and canceling MSG_SHUTUP events. This object cannot be instantiated! It can be obtained using init_module().
Cancels the MSG_SHUTUP message.
Cancels a task switch operation previously launched by another application in the task manager, and deletes any MSG_SHUTUP messages from the message queue. Requires the AppGeneric object pointer.
#include <cybiko.h> ... struct module_t main_module; ... init_module( &main_module ); struct Message* ptr_message; ... ptr_message = AppGeneric_get_message( main_module.m_process, 0, 1, MSG_USER ); if( ptr_message->msgid == MSG_SHUTUP ) { // We do not need to exit. // Cancels shutup and deletes all MSG_SHUTUP messages. AppGeneric_cancel_shutup( main_module.m_process ); ... } ...
Clears the screen with a white color.
#include <cybiko.h> ... struct DisplayGraphics* ptr_gfx; ... // Clears the screen. AppGeneric_clear_screen(); ... // Draws a filled rectangle. ptr_gfx = AppGeneric_init_display(); DisplayGraphics_set_color( ptr_gfx , CLR_BLACK ); DisplayGraphics_fill_rect( ptr_gfx , 5, 5, 30, 30 ); DisplayGraphics_show( ptr_gfx ); ...
Cancels the MGS_SHUTUP message statically.
Used to cancel a task switch operation previously launched by another application in the task manager. Doesn't require the AppGeneric object pointer, but doesn't delete any MSG_SHUTUP messages.
#include <cybiko.h> ... struct module_t main_module; ... init_module( &main_module ); struct Message* ptr_message; ... ptr_message = AppGeneric_get_message( main_module.m_process, 0, 1, MSG_USER ); if( ptr_message->msgid == MSG_SHUTUP ) { // We do not need to exit. // Cancels shutup. AppGeneric_ext_cancel_shutup(); ... } ...
Retrieves DisplayGraphics object to access the Cybiko computer's display.
#include <cybiko.h> ... struct Bitmap bmp; ... // Creates a bitmap from the file "root.ico". Bitmap_ctor_Ex1( &bmp, "root.ico" ); ... // Draws bitmap. DisplayGraphics_draw_bitmap( AppGeneric_get_display(), &bmp, 30, 40, BM_NORMAL ); DisplayGraphics_show( AppGeneric_get_display() ); ... Bitmap_dtor( &bmp, LEAVE_MEMORY ); ...
Returns the message for the specified interval.
The calling thread waits until the first message appears in the queue. Be careful, not to overload the queue. Delete the message when you are finished with it.
#include <cybiko.h> ... struct module_t main_module; struct Message* ptr_message; ... init_module( &main_module ); ... ptr_message = AppGeneric_get_message( main_module.m_process, 0, 1, MSG_USER ); if( ptr_message->msgid == MSG_KEYDOWN ) { if( Message_get_key_param( ptr_message )->scancode == KEY_ESC ) { // Processes 'Esc' key. } } ... Message_delete( ptr_message ); ...
Retrieves the name of the application.
#include <cybiko.h> ... struct module_t main_module; ... init_module( &main_module ); ... TRACE( "Hello from the %s application", AppGeneric_get_name( main_module.m_process ) ); ...
Tests whether the process has the device's focus.
#include <cybiko.h> ... struct module_t main_module; ... init_module( &main_module ); ... AppGeneric_request_focus( main_module.m_process ); ... if( AppGeneric_has_focus( main_module.m_process ) ) { // Draws something. ... } ...
Obtains the graphics context.
#include <cybiko.h> ... struct DisplayGraphics* ptr_gfx; ... // Clears the screen. AppGeneric_clear_screen(); ... // Draws a filled rectangle. ptr_gfx = AppGeneric_init_display(); DisplayGraphics_set_color( ptr_gfx , CLR_BLACK ); DisplayGraphics_fill_rect( ptr_gfx , 5, 5, 30, 30 ); DisplayGraphics_show( ptr_gfx ); ...
Pauses execution of the application.
#include <cybiko.h> ... struct module_t main_module; ... init_module( &main_module ); ... play_tone( 30 ); AppGeneric_pause( main_module.m_process, 200 ); play_tone( -1 ); ...
Peeks or gets a message from the queue.
If 'remove' is TRUE, the message will be removed. This function does not wait for a message to be available; it returns 0 immediately if there are no messages in the specified range. Don't use it unless you really need to.
#include <cybiko.h> ... struct module_t main_module; struct Message* ptr_message; ... init_module( &main_module ); ... // Removes all keyboard messages from the queue. while( ptr_message = AppGeneric_peek_message( main_module.m_process, TRUE, MSG_KEYDOWN, MSG_KEYDOWN ) ) { Message_delete( ptr_message ); } ...
Provides generic message processing.
Should be called on every message that the user doesn't process.
#include <cybiko.h> ... struct module_t main_module; struct Message* ptr_message; ... init_module( &main_module ); ... // Sets the resource "0.help" as the help file main_module.m_process->HelpContext = 0; ptr_message = AppGeneric_get_message( main_module.m_process, 0, 1, MSG_USER ); // The help screen appears if the user presses the '?' button AppGeneric_proc( main_module.m_process, ptr_message ); ...
Puts a Message in the application's Queue.
#include <cybiko.h> #define MSG_MAKE_TASK MSG_USER + 1 ... struct module_t main_module; struct Message* ptr_message; ... init_module( &main_module ); ... ptr_message = AppGeneric_get_message( main_module.m_process, 0, 1, MSG_MAKE_TASK ); if( ptr_message->msgid == MSG_MAKE_TASK ) { ... // Performs some periodical calculation. ... sleep( 250 ); AppGeneric_put_message( main_module.m_process, ptr_message ); } else { Message_delete( ptr_message ); } ...
Requests that the application receive the focus.
The application with the focus has actual access to the screen and receives the keyboard and pointing device events. When the system gets this call, it passes the focus to the process that requested it and sends it the message MSG_GOTFOCUS. After that, the system sends the message MSG_LOSTFOCUS to the process that had the focus before this call.
#include <cybiko.h> ... struct module_t main_module; ... init_module( &main_module ); ... AppGeneric_request_focus( main_module.m_process ); ... if( AppGeneric_has_focus( main_module.m_process ) ) { // Draws something. ... } ...