cButton Struct Reference

Inheritance diagram for cButton

Inheritance graph

Collaboration diagram for cButton:

Collaboration graph


Public Methods

struct cButton* cButton_ctor (struct cButton *ptr_cbutton, char *text, int modal_result)
void cButton_dtor (struct cButton *ptr_cbutton, int memory_flag)
int cButton_GetModalResult (struct cButton *ptr_cbutton)
bool cButton_proc (struct cButton *ptr_cbutton, struct Message *ptr_message)
void cButton_Enable (struct cButton *ptr_cbutton)
void cButton_Disable (struct cButton *ptr_cbutton)
void cButton_Show (struct cButton *ptr_cbutton)
void cButton_Hide (struct cButton *ptr_cbutton)
void cButton_Disconnect (struct cButton *ptr_cbutton)
bool cButton_Select (struct cButton *ptr_cbutton)
void cButton_update (struct cButton *ptr_cbutton)
struct cClipcButton_GetParent (struct cButton *ptr_cbutton)


Detailed Description

A basic button. You can add a button to any user form, as well as to the Cybiko screen.

Every button must have its own modal result, which can be defined in the third parameter of the cButton_ctor function. Variants of modal results are contained in the tmResults enumeration. Every button can have a message-processing function.

You must call the cButton_ctor function before use and the cButton_dtor function after use.

See also:
Controls


Member Function Documentation

void cButton_Disable ( struct cButton * ptr_cbutton )
 

Disables the cButton object so that it cannot be selected..

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     struct cClip* parent;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     // It's the same as using the cButton_Disable( &button ) function.
     // Now the user can't use this object.
     cButton_Disable( &button )
     ...
     // It's the same as using the cButton_Enable( &button ) function.
     // Now the user can use this object again.
     cButton_Enable( &button )
     ...
     cButton_dtor( &button, LEAVE_MEMORY );
See also:
cButton_Enable.

void cButton_Disconnect ( struct cButton * ptr_cbutton )
 

Disconnects the cButton object from its parent object.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     // Removes the object from the Cybiko screen.
     cButton_Disconnect( &button);
     ...
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     // Afterwards this function disconnects the cText object automatically
     cButton_dtor( &button, LEAVE_MEMORY );

void cButton_Enable ( struct cButton * ptr_cbutton )
 

Enables the cButton object so that it may be selected.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     struct cClip* parent;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     // It's the same as using the cButton_Disable( &button ) function.
     // Now the user can't use this object.
     cButton_Disable( &button )
     ...
     // It's the same as using the cButton_Enable( &button ) function.
     // Now the user can use this object again.
     cButton_Enable( &button )
     ...
     cButton_dtor( &button, LEAVE_MEMORY );
See also:
cButton_Disable.

int cButton_GetModalResult ( struct cButton * ptr_cbutton )
 

Returns the button modal result, which was set in the cButton constructor.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
Returns:
The button modal result
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     if ( cButton_GetModalResult( &button ) == mrOk )
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

struct cClip * cButton_GetParent ( struct cButton * ptr_cbutton )
 

Returns a pointer to the parent object.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
Returns:
A pointer to the parent object
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     struct cClip* parent;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     // It's the same as using the cButton_GetParent( &button ) function.
     // Checks for the right parent relation.
     parent = cObject_GetParent( &button );
     if ( parent == main_module.m_process )
     {
     }
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

void cButton_Hide ( struct cButton * ptr_cbutton )
 

Hides a cButton object.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object.
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     // It's the same as using the cButton_Hide( &button ) function.
     cObject_Hide( &button );
     ...
     // It's the same as using the cButton_Show( &button ) function.
     cObject_Show( &button );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );
See also:
cButton_Show.

bool cButton_Select ( struct cButton * ptr_cbutton )
 

Selects a cButton object.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
Returns:
TRUE if the object was selected
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     // It's the same as using the cButton_Select( &button ) function.
     // Selects the button.
     cButton_Select( &button );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

void cButton_Show ( struct cButton * ptr_cbutton )
 

Shows cButton object.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object.
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     // It's the same as using the cButton_Hide( &button ) function.
     cObject_Hide( &button );
     ...
     // It's the same as using the cButton_Show( &button ) function.
     cObject_Show( &button );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );
See also:
cButton_Hide.

struct cButton * cButton_ctor ( struct cButton * ptr_cbutton,
char * text,
int modal_result )
 

Initializes a cButton object.

Parameters:
ptr_cbutton   A pointer to a cButton object
text   The button's text
modal_result   Will be set in cForm when the button is pressed
Returns:
A pointer to the initialized cButton object
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

void cButton_dtor ( struct cButton * ptr_cbutton,
int memory_flag )
 

Deletes a cButton object.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
memory_flag   Can be FREE_MEMORY or LEAVE_MEMORY. If the memory was allocated for the object by malloc(), use FREE_MEMORY to free it. Use LEAVE_MEMORY if the object was static or allocated in stack
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     cButton_dtor( &button, LEAVE_MEMORY );
See also:
FREE_MEMORY, LEAVE_MEMORY.

bool cButton_proc ( struct cButton * ptr_cbutton,
struct Message * ptr_message )
 

The Message-processing function.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
ptr_message   A pointer to the processed message
Returns:
TRUE if the message was processed
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     struct Message* ptr_message;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER );
     if ( ptr_message->msgid == MSG_KEYDOWN )
     {
       //  If user presses 'Enter' button will be pushed.
       cButton_proc( &button, ptr_message);
     }
     ...
     cButton_dtor( &button, LEAVE_MEMORY );

void cButton_update ( struct cButton * ptr_cbutton )
 

Updates a cButton object.

Parameters:
ptr_cbutton   A pointer to the initialized cButton object
Returns:
None
   #include <cywin.h>
     ...
     struct cButton button;
     struct module_t main_module;
     ...
     init_module( &main_module );
     ...
     cButton_ctor( &button, "Button text", mrOk );
     // Puts the 'button' object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
     ...
     cWinApp_clear_screen();
     // It's the same as using the cButton_update( &button ) function.
     // Redraws the button.
     cButton_update( &button )
     ...
     cButton_dtor( &button, LEAVE_MEMORY );