cItem Struct Reference

Inheritance diagram for cItem

Inheritance graph

Collaboration diagram for cItem:

Collaboration graph


Public Methods

struct cItem* cItem_ctor (struct cItem *ptr_citem, int width, char *title_name, bool submenu, char *right_text, struct Bitmap *ptr_bitmap)
void cItem_dtor (struct cItem *ptr_citem, int memory_flag)
char* cItem_GetTitle (struct cItem *ptr_citem)
bool cItem_proc (struct cItem *ptr_citem, struct Message *ptr_message)
void cItem_Disconnect (struct cItem *ptr_citem)
bool cItem_Select (struct cItem *ptr_citem)
void cItem_update (struct cItem *ptr_citem)
struct cClipcItem_GetParent (struct cItem *ptr_citem)
void cItem_Hide (struct cItem *ptr_citem)
void cItem_Show (struct cItem *ptr_citem)
void cItem_Disable (struct cItem *ptr_citem)
void cItem_Enable (struct cItem *ptr_citem)


Detailed Description

This structure implements methods for working with simple units of the list, such as a text string. It might have an icon on the left and/or an additional text on the right.

You must call the cItem_ctor function before use and the cItem_dtor function after use.

See also:
Controls


Member Function Documentation

void cItem_Disable ( struct cItem * ptr_citem )
 

Disables a cItem object so that it cannot be selected.

Parameters:
ptr_citem   A pointer to a cItem object
Returns:
None
See also:
cItem_Enable.

void cItem_Disconnect ( struct cItem * ptr_citem )
 

Disconnects a cItem from its parent object.

Parameters:
ptr_citem   A pointer to a cItem object
Returns:
None

void cItem_Enable ( struct cItem * ptr_citem )
 

Enables a cItem object so that it may be selected.

Parameters:
ptr_citem   A pointer to a cItem object
Returns:
None
See also:
cItem_Disable.

struct cClip * cItem_GetParent ( struct cItem * ptr_citem )
 

Returns a pointer to the parent object.

Parameters:
ptr_citem   A pointer to a cItem object
Returns:
A pointer to the parent object

char * cItem_GetTitle ( struct cItem * ptr_citem )
 

Returns the item's title.

Parameters:
ptr_citem   A pointer to the initialized cItem object
Returns:
The item's title
   #include <cywin.h>
     ...
   {
     int index;
     struct cList menu;
     struct module_t main_module;
     struct cItem* ptr_menu_item[3];
     static const char* sz_menu_text[3] = {
                                           "Start",
                                           "High Score",
                                           "Exit"
                                          };
     ...
     init_module( &main_module );
     ...
     cList_ctor( &menu, 100 );
     for( index = 0; index < 3; index++ )
     {
       ptr_menu_item[index] = (struct cItem* )malloc ( sizeof ( struct cItem ) );
       cItem_ctor( ptr_menu_item + index, 100, sz_menu_text[index], FALSE, NULL, NULL );
       cList_AddItem( &menu, ptr_menu_item + index );
     }
     // Puts the cList object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &menu, 10, 40 );
     ...
     for( index = 0; index < 3; index++ )
     {
        TRACE( "%s - item #%d ", cItem_GetTitle( ptr_menu_item + index), index );
     }
     ...
     // Menu items will be destroyed automatically.
     cList_dtor( &menu, LEAVE_MEMORY );
   }

void cItem_Hide ( struct cItem * ptr_citem )
 

Hides a cItem object.

Parameters:
ptr_citem   A pointer to a cItem object
Returns:
None
See also:
cItem_Show.

bool cItem_Select ( struct cItem * ptr_citem )
 

Selects a cItem object.

Parameters:
ptr_citem   A pointer to a cItem object
Returns:
TRUE if the object was selected

void cItem_Show ( struct cItem * ptr_citem )
 

Shows a cItem object.

Parameters:
ptr_citem   A pointer to a cItem object.
Returns:
None
See also:
cItem_Hide.

struct cItem * cItem_ctor ( struct cItem * ptr_citem,
int width,
char * title_name,
bool submenu,
char * right_text,
struct Bitmap * ptr_bitmap )
 

Constructor.
Initialize the cItem object.

Parameters:
ptr_citem   A pointer to the cItem struct
width   Item's width (in pixels)
title_name   Item's title
submenu   Determines whether there is a submenu
right_text   Creates an additional text area on the right
ptr_bitmap   Creates pointer to the icon bitmap
Returns:
A pointer to the initialized cItem object
   #include <cywin.h>
     ...
   {
     struct cList menu;
     struct BitmapSequence menu_icons;
     struct module_t main_module;
     struct Message* ptr_message;
     struct cItem* ptr_menu_item;
     static const char* sz_menu_text[3] = {
                                           "CYBIKO",
                                           "Microsoft",
                                           "Ford"
                                          };
     static const char* sz_right_text[3] = {
                                            "Yang",
                                            "Gates",
                                            "Ford"
                                           };
     ...
     init_module( &main_module );
     ...
     cList_ctor( &menu, 100 );
     BitmapSequence_ctor_Ex( &menu_icons , "logos.pic");
     for( index = 0; index < 3; index++ )
     {
       ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
       cItem_ctor( ptr_menu_item,
                   100,
                   sz_menu_text[index],
                   FALSE,
                   sz_right_text[index],
                   BitmapSeqence_get_bitmap( &menu_icons, index ) );
       cList_AddItem( &menu, ptr_menu_item );
     }
     // Puts the cList object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &menu, 10, 40 );
     ...
     // Menu items will be destroyed automatically.
     cList_dtor( &menu, LEAVE_MEMORY );
     BitmapSequence_dtor( &menu_icons, LEAVE_MEMORY );
   }

void cItem_dtor ( struct cItem * ptr_citem,
int memory_flag )
 

Destructor.
Deletes a cItem object.

Parameters:
ptr_citem   A pointer to the initialized cItem 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 a stack
Returns:
None
   #include <cywin.h>
     ...
   {
     int index;
     struct cList menu;
     struct module_t main_module;
     struct cItem* ptr_menu_item[3];
     static const char* sz_menu_text[3] = {
                                           "Start",
                                           "High Score",
                                           "Exit"
                                          };
     ...
     init_module( &main_module );
     ...
     cList_ctor( &menu, 100 );
     for( index = 0; index < 3; index++ )
     {
       ptr_menu_item[index] = (struct cItem* )malloc ( sizeof ( struct cItem ) );
       cItem_ctor( ptr_menu_item + index, 100, sz_menu_text[index], FALSE, NULL, NULL );
       cList_AddItem( &menu, ptr_menu_item + index );
     }
     // Puts the cList object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &menu, 10, 40 );
     ...
     // "High Score"  will be removed from the list.
     cList_RemItem( &menu, ptr_menu_item + 1 );
     cItem_dtor( ptr_menu_item + 1 );
     ...
     // Menu items will be destroyed automatically.
     cList_dtor( &menu, LEAVE_MEMORY );
   }
See also:
FREE_MEMORY, LEAVE_MEMORY.

bool cItem_proc ( struct cItem * ptr_citem,
struct Message * ptr_message )
 

Message-processing function.

Parameters:
ptr_citem   A pointer to a cList object
ptr_message   A pointer to a Message.
Returns:
TRUE if the message was processed.
   #include <cywin.h>
     ...
     struct module_t main_module;
     struct Message* ptr_message;
     struct cItem menu_item;
     ...
     init_module( &main_module );
     ...
     cItem_ctor( &menu_item, 100, "Item", FALSE, NULL, NULL );
     // Puts the cItem object on the Cybiko screen.
     cWinApp_AddObj( main_module.m_process, &menu_item, 10, 40 );
     ...
     ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER );
     // cItem will be redrawn automatically now.
     cItem_proc( &menu_item, ptr_message );
     ...
     cItem_dtor( &menu_item, LEAVE_MEMORY );

void cItem_update ( struct cItem * ptr_citem )
 

Updates a cItem object.

Parameters:
ptr_citem   A pointer to a cItem object
Returns:
None