cXStr Struct Reference

Inheritance diagram for cXStr

Inheritance graph

Collaboration diagram for cXStr:

Collaboration graph


Public Methods

struct cXStr* cXStr_ctor (struct cXStr *ptr_cxstr, int w, char *title, char *st, int sln, int swd, struct Bitmap **lbmp, char *lsel, bool readonly)
void cXStr_dtor (struct cXStr *ptr_cxstr, int memory_flag)
void cXStr_SetStart (struct cXStr *ptr_cxstr)
void cXStr_SelRight (struct cXStr *ptr_cxstr)
void cXStr_OK (struct cXStr *ptr_cxstr)
void cXStr_Esc (struct cXStr *ptr_cxstr)
void cXStr_SaveStr (struct cXStr *ptr_cxstr)
bool cXStr_proc (struct cXStr *ptr_cxstr, struct Message *ptr_message)
void cXStr_Disconnect (struct cXStr *ptr_cxstr)
bool cXStr_Select (struct cXStr *ptr_cxstr)
void cXStr_update (struct cXStr *ptr_cxstr)
struct cClipcXStr_GetParent (struct cXStr *ptr_cxstr)
void cXStr_Hide (struct cXStr *ptr_cxstr)
void cXStr_Show (struct cXStr *ptr_cxstr)
void cXStr_Disable (struct cXStr *ptr_cxstr)
void cXStr_Enable (struct cXStr *ptr_cxstr)
char* cXStr_GetTitle (struct cXStr *ptr_cxstr)
void cXStr_SelLeft (struct cXStr *ptr_cxstr)
void cXStr_SetLeft (struct cXStr *ptr_cxstr, int index)
void cXStr_SetRight (struct cXStr *ptr_cxstr, int index)


Detailed Description

A cXStr object might have an icon on the left and/or additional text on the right. It is possible to input text into the right field. You must call the cXStr_ctor function before use and the cXStr_dtor function after use.

See also:
Controls


Member Function Documentation

void cXStr_Disable ( struct cXStr * ptr_cxstr )
 

Disables a cXStr object so that it cannot be selected.

Parameters:
ptr_cxstr   A pointer to a cXStr object
Returns:
None
See also:
cXStr_Enable.

void cXStr_Disconnect ( struct cXStr * ptr_cxstr )
 

Disconnects a cXStr from its parent object.

Parameters:
ptr_cxstr   A pointer to a cXStr object
Returns:
None

void cXStr_Enable ( struct cXStr * ptr_cxstr )
 

Enables a cXStr object so that it may be selected.

Parameters:
ptr_cxstr   A pointer to a cXStr object.
Returns:
None
See also:
cXStr_Disable.

void cXStr_Esc ( struct cXStr * ptr_cxstr )
 

Clears an edited string and deselects the section on the item's right side(if it was selected).
Behavior for the left side is not changed.

Parameters:
ptr_cxstr   A pointer to the initialized cXStr object
Returns:
None
   #include <cywin.h>
     ...
   {
     struct BitmapSequence sq;
     struct Bitmap* bmps[4];
     char   icon_index = 2;
     struct cItem* ptr_menu_item;
     char   buffer[100];
     init_module(&main_module);
     // Bitmap sequence contains three icons: digit '1', digit '2', digit '3'.
     BitmapSequence_ctor_Ex(&sq, "digits.pic");
     bmps[0] = BitmapSequence_get_bitmap(&sq, 0);
     bmps[1] = BitmapSequence_get_bitmap(&sq, 1);
     bmps[2] = BitmapSequence_get_bitmap(&sq, 2);
     bmps[3] = NULL;
     cWinApp_clear_screen();
     ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
     strcpy( buffer, "Initial value" );
     ...
     // Item will be shown as follows: '3' | "Any item" | "Initial value"
     cXStr_ctor( ptr_menu_item,
                  160,
                  "Any item",
                  buffer,
                  30,
                  80,
                  bmps,
                  &icon_index,
                  FALSE );
     cWinApp_AddObj( main_module.m_process, ptr_menu_item, 0, 40 );
     ...
     // We have made changes then restore the previous state.
     cXStr_Esc(  ptr_menu_item  );
     ...
     cXStr_dtor( ptr_menu_item, FREE_MEMORY );
   }
See also:
cXStr_OK.

struct cClip * cXStr_GetParent ( struct cXStr * ptr_cxstr )
 

Returns a pointer to the cClip of the parent object.

Parameters:
ptr_cxstr   A pointer to a cXStr object
Returns:
A pointer to the cClip of the parent object

char * cXStr_GetTitle ( struct cXStr * ptr_cxstr )
 

Returns the item's title.

Parameters:
ptr_cxstr   A pointer to a cXStr object
Returns:
The item's title

void cXStr_Hide ( struct cXStr * ptr_cxstr )
 

Hides a cXStr object.

Parameters:
ptr_cxstr   A pointer to a cXStr object
Returns:
None
See also:
cXStr_Show.

void cXStr_OK ( struct cXStr * ptr_cxstr )
 

Saves an edited string and deselects the section on the item's right side (if it was selected).
Behavior for the left side is not changed.

Parameters:
ptr_cxstr   A pointer to the initialized cXStr object
Returns:
None
   #include <cywin.h>
     ...
   {
     struct BitmapSequence sq;
     struct Bitmap* bmps[4];
     char   icon_index = 2;
     struct cItem* ptr_menu_item;
     char   buffer[100];
     init_module(&main_module);
     // Bitmap sequence contains three icons: digit '1', digit '2', digit '3'.
     BitmapSequence_ctor_Ex(&sq, "digits.pic");
     bmps[0] = BitmapSequence_get_bitmap(&sq, 0);
     bmps[1] = BitmapSequence_get_bitmap(&sq, 1);
     bmps[2] = BitmapSequence_get_bitmap(&sq, 2);
     bmps[3] = NULL;
     cWinApp_clear_screen();
     ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
     strcpy( buffer, "Initial value" );
     // Item will be shown as follows: '3' | "Any item" | "Initial value"
     cXStr_ctor( ptr_menu_item,
                  160,
                  "Any item",
                  buffer,
                  30,
                  80,
                  bmps,
                  &icon_index,
                  FALSE );
     cWinApp_AddObj( main_module.m_process, ptr_menu_item, 0, 40 );
     ...
     // Saves the current state
     cXStr_OK(  ptr_menu_item  );
     ...
     cXStr_dtor( ptr_menu_item, FREE_MEMORY );
   }
See also:
cXStr_Esc.

void cXStr_SaveStr ( struct cXStr * ptr_cxstr )
 

Saves a Str to an external string.

Parameters:
ptr_cxstr   A pointer to the initialized cXStr object
Returns:
None
   #include <cywin.h>
     ...
   {
     struct BitmapSequence sq;
     struct Bitmap* bmps[4];
     char   icon_index = 2;
     struct cItem* ptr_menu_item;
     char   buffer[100];
     init_module(&main_module);
     // Bitmap sequence contains three icons: digit '1', digit '2', digit '3'.
     BitmapSequence_ctor_Ex(&sq, "digits.pic");
     bmps[0] = BitmapSequence_get_bitmap(&sq, 0);
     bmps[1] = BitmapSequence_get_bitmap(&sq, 1);
     bmps[2] = BitmapSequence_get_bitmap(&sq, 2);
     bmps[3] = NULL;
     cWinApp_clear_screen();
     ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
     strcpy( buffer, "Initial value" );
     ...
     // Item will be shown as follows: '3' | "Any item" | "Initial value"
     cXStr_ctor( ptr_menu_item,
                  160,
                  "Any item",
                  buffer,
                  30,
                  80,
                  bmps,
                  &icon_index,
                  FALSE );
     cWinApp_AddObj( main_module.m_process, ptr_menu_item, 0, 40 );
     ...
     // If we made a change in the right section of the item, this function saves it in the 'buffer'.
     cXStr_SaveStr(  ptr_menu_item  );
     ...
     cXStr_dtor( ptr_menu_item, FREE_MEMORY );
   }

void cXStr_SelLeft ( struct cXStr * ptr_cxstr )
 

Selects the section on the item's left side (only if the item has the focus).

Parameters:
ptr_cxstr   A pointer to the initialized cXStr object
Returns:
None
See also:
cXStr_SelRight.

void cXStr_SelRight ( struct cXStr * ptr_cxstr )
 

Selects the section on the item's right side (only if the item has the focus).

Parameters:
ptr_cxstr   A pointer to the initialized cXStr object
Returns:
None
   #include <cywin.h>
     ...
   {
     struct BitmapSequence sq;
     struct Bitmap* bmps[4];
     char   icon_index = 2;
     struct cItem* ptr_menu_item;
     char   buffer[100];
     ...
     init_module(&main_module);
     // Bitmap sequence contains three icons: digit '1', digit '2', digit '3'.
     BitmapSequence_ctor_Ex(&sq, "digits.pic");
     bmps[0] = BitmapSequence_get_bitmap(&sq, 0);
     bmps[1] = BitmapSequence_get_bitmap(&sq, 1);
     bmps[2] = BitmapSequence_get_bitmap(&sq, 2);
     bmps[3] = NULL;
     cWinApp_clear_screen();
     ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
     strcpy( buffer, "Initial value" );
     // Item will be shown as follows: '3' | "Any item" | "Initial value"
     cXStr_ctor( ptr_menu_item,
                  160,
                  "Any item",
                  buffer,
                  30,
                  80,
                  bmps,
                  &icon_index,
                  FALSE );
     cWinApp_AddObj( main_module.m_process, ptr_menu_item, 0, 40 );
     ...
     // Selects the right part.
     cXStr_SelRight(  ptr_menu_item  );
     ...
     cXStr_dtor( ptr_menu_item, FREE_MEMORY );
   }
See also:
cXStr_SelLeft.

bool cXStr_Select ( struct cXStr * ptr_cxstr )
 

Selects a cXStr object.

Parameters:
ptr_cxstr   A pointer to a cXStr object
Returns:
TRUE if the object was selected

void cXStr_SetLeft ( struct cXStr * ptr_cxstr,
int index )
 

Changes the left section's value by 'index'.

Parameters:
ptr_cxstr   A pointer to a cXStr object
index   A new left section's value
Returns:
None
See also:
cXStr_SetRight.

void cXStr_SetRight ( struct cXStr * ptr_cxstr,
int index )
 

Changes right section's value by 'index'.

Parameters:
ptr_cxstr   A pointer to a cXStr object.
index   A new right section's value
Returns:
None
See also:
cXStr_SetLeft.

void cXStr_SetStart ( struct cXStr * ptr_cxstr )
 

Highlights the entire whole right-side string, and positions the cursor at its end (only when the section on the item's right side is selected).

Parameters:
ptr_cxstr   A pointer to the initialized cXStr object
Returns:
None
   #include <cywin.h>
     ...
   {
     struct BitmapSequence sq;
     struct Bitmap* bmps[4];
     char   icon_index = 2;
     struct cItem* ptr_menu_item;
     char   buffer[100];
     ...
     init_module(&main_module);
     // Bitmap sequence contains three icons: digit '1', digit '2', digit '3'.
     BitmapSequence_ctor_Ex(&sq, "digits.pic");
     bmps[0] = BitmapSequence_get_bitmap(&sq, 0);
     bmps[1] = BitmapSequence_get_bitmap(&sq, 1);
     bmps[2] = BitmapSequence_get_bitmap(&sq, 2);
     bmps[3] = NULL;
     cWinApp_clear_screen();
     ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
     strcpy( buffer, "Initial value" );
     ...
     // Item will be shown as follows: '3' | "Any item" | "Initial value"
     cXStr_ctor( ptr_menu_item,
                  160,
                  "Any item",
                  buffer,
                  30,
                  80,
                  bmps,
                  &icon_index,
                  FALSE );
     cWinApp_AddObj( main_module.m_process, ptr_menu_item, 0, 40 );
     ...
     // Highlights the right part.
     cXStr_SetStart(  ptr_menu_item  );
     ...
     cXStr_dtor( ptr_menu_item, FREE_MEMORY );
   }

void cXStr_Show ( struct cXStr * ptr_cxstr )
 

Shows a cXStr object.

Parameters:
ptr_cxstr   A pointer to a cXStr object
Returns:
None
See also:
cXStr_Hide.

struct cXStr * cXStr_ctor ( struct cXStr * ptr_cxstr,
int w,
char * title,
char * st,
int sln,
int swd,
struct Bitmap ** lbmp,
char * lsel,
bool readonly )
 

Constructor.
Creates a cXStr object.

Parameters:
ptr_cxstr   A pointer to the cXStr structure
w   An item's width in pixels (including left and right sections)
title   A title string
st   The initial value for the string on the item's right side
sln   Maximum character length of the string on the item's right side (not including '\0')
swd   Maximum width, in pixels, of the viewable portion of the string on the item's right side (not including 2 pixels for surrounding the frame)
lbmp   The bitmap lost for the section on the item's left side - an array of pointers to bitmaps, with last pointer equaling 0
lsel   A reference to a variable that can be used to access the current left-side index
readonly   Forbids entering and changing the section on the item's right side
Returns:
A pointer to the initialized cXStr object
   #include <cywin.h>
     ...
   {
     struct BitmapSequence sq;
     struct Bitmap* bmps[4];
     char   icon_index = 2;
     struct cItem* ptr_menu_item;
     char   buffer[100];
     init_module(&main_module);
     // Bitmap sequence contains three icons: digit '1', digit '2', digit '3'.
     BitmapSequence_ctor_Ex(&sq, "digits.pic");
     bmps[0] = BitmapSequence_get_bitmap(&sq, 0);
     bmps[1] = BitmapSequence_get_bitmap(&sq, 1);
     bmps[2] = BitmapSequence_get_bitmap(&sq, 2);
     bmps[3] = NULL;
     cWinApp_clear_screen();
     ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
     strcpy( buffer, "Initial value" );
     // Item will be shown as follows: '3' | "Any item" | "Initial value"
     cXStr_ctor( ptr_menu_item,
                  160,
                  "Any item",
                  buffer,
                  30,
                  80,
                  bmps,
                  &icon_index,
                  FALSE );
     cWinApp_AddObj( main_module.m_process, ptr_menu_item, 0, 40 );
     ...
     cXStr_dtor( ptr_menu_item, FREE_MEMORY );
   }

void cXStr_dtor ( struct cXStr * ptr_cxstr,
int memory_flag )
 

Destructor.
Deletes the cXStr object.

Parameters:
ptr_cxstr   A pointer to the initialized cXStr 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>
     ...
   {
     struct BitmapSequence sq;
     struct Bitmap* bmps[4];
     char   icon_index = 2;
     struct cItem* ptr_menu_item;
     char   buffer[100];
     init_module(&main_module);
     // Bitmap sequence contains three icons: digit '1', digit '2', digit '3'.
     BitmapSequence_ctor_Ex(&sq, "digits.pic");
     bmps[0] = BitmapSequence_get_bitmap(&sq, 0);
     bmps[1] = BitmapSequence_get_bitmap(&sq, 1);
     bmps[2] = BitmapSequence_get_bitmap(&sq, 2);
     bmps[3] = NULL;
     cWinApp_clear_screen();
     ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
     strcpy( buffer, "Initial value" );
     ...
     // Item will be shown as follows: '3' | "Any item" | "Initial value"
     cXStr_ctor( ptr_menu_item,
                  160,
                  "Any item",
                  buffer,
                  30,
                  80,
                  bmps,
                  &icon_index,
                  FALSE );
     cWinApp_AddObj( main_module.m_process, ptr_menu_item, 0, 40 );
     ...
     cXStr_dtor( ptr_menu_item, FREE_MEMORY );
   }
See also:
FREE_MEMORY, LEAVE_MEMORY.

bool cXStr_proc ( struct cXStr * ptr_cxstr,
struct Message * ptr_message )
 

The Message-processing function.

Parameters:
ptr_cxstr   A pointer to the initialized cXStr object
ptr_message   A pointer to a Message
Returns:
TRUE if the message was processed
   #include <cywin.h>
     ...
   {
     struct BitmapSequence sq;
     struct Bitmap* bmps[4];
     char   icon_index = 2;
     struct cItem* ptr_menu_item;
     char   buffer[100];
     struct Message* ptr_message;
     ...
     init_module(&main_module);
     // Bitmap sequence contains three icons: digit '1', digit '2', digit '3'.
     BitmapSequence_ctor_Ex(&sq, "digits.pic");
     bmps[0] = BitmapSequence_get_bitmap(&sq, 0);
     bmps[1] = BitmapSequence_get_bitmap(&sq, 1);
     bmps[2] = BitmapSequence_get_bitmap(&sq, 2);
     bmps[3] = NULL;
     cWinApp_clear_screen();
     ptr_menu_item = (struct cItem* )malloc ( sizeof ( struct cItem ) );
     strcpy( buffer, "Initial value" );
     ...
     // Item will be shown as follows: '3' | "Any item" | "Initial value"
     cXStr_ctor( ptr_menu_item,
                  160,
                  "Any item",
                  buffer,
                  30,
                  80,
                  bmps,
                  &icon_index,
                  FALSE );
     cWinApp_AddObj( main_module.m_process, ptr_menu_item, 0, 40 );
     ...
     ptr_message = cWinApp_get_message( main_module.m_process, 0, 1, MSG_USER );
     // Processes the messages that the cXStr control manages.
     cXStr_proc( ptr_menu_item, ptr_message );
     ...
     // If we made change in the right item part this function saves it in the 'buffer'.
     cXStr_SaveStr(  ptr_menu_item  );
     ...
     cXStr_dtor( ptr_menu_item, FREE_MEMORY );
   }

void cXStr_update ( struct cXStr * ptr_cxstr )
 

Updates a cXStr object.

Parameters:
ptr_cxstr   A pointer to a cXStr object
Returns:
None