cClip Struct Reference

Inheritance diagram for cClip

Inheritance graph

Collaboration diagram for cClip:

Collaboration graph


Public Types

enum  tScrolls {
  sNone = 0,
  sUp = 1,
  sDown = 2,
  sUpDown = 3
}

Public Methods

void cClip_AddObj (struct cClip *, struct cObject *, int, int)
void cClip_InsObj (struct cClip *, struct cObject *, int, int, int)
void cClip_RemObj (struct cClip *, struct cObject *)
bool cClip_SelectFirst (struct cClip *)
bool cClip_SelectPrev (struct cClip *, bool)
bool cClip_SelectNext (struct cClip *, bool)
void cClip_Scroll (struct cClip *ptr_clip, struct rect_t *rectangle)
void cClip_Scroll_Ex (struct cClip *ptr_clip, int x, int y)
void cClip_SendScroll (struct cClip *ptr_clip)
int cClip_GetShifty (struct cClip *ptr_clip)
int cClip_GetShiftx (struct cClip *ptr_clip)
int cClip_GetCount (struct cClip *ptr_clip)
struct cObjectcClip_get_by_index (struct cClip *, int)
int cClip_FindObj (struct cClip *, struct cObject *)
struct cObjectcClip_GetSelectedObject (struct cClip *ptr_clip)
bool cClip_proc (struct cClip *ptr_clip, struct Message *ptr_message)
void cClip_Disconnect (struct cClip *ptr_clip)
bool cClip_Select (struct cClip *ptr_clip)
void cClip_update (struct cClip *ptr_clip)
struct cClip* cClip_GetParent (struct cClip *ptr_clip)
void cClip_Hide (struct cClip *ptr_clip)
void cClip_Show (struct cObject *ptr_clip)
void cClip_Disable (struct Clip *ptr_clip)
void cClip_Enable (struct cObject *ptr_clip)


Detailed Description

This is a base window structure - a clipped box, which may contain other objects. cClip implements base message-delivery and command-processing functions. It supports scrolling, painting child objects, and so on. You must the initialize structure before use and release object resources after use.

See also:
Base Structures


Member Enumeration Documentation

enum tScrolls
 

Scroll mode.

Enumeration values:
sNone   no scrolling available.
sUp   enable scrolling up.
sDown   enable scrolling down.
sUpDown   enable scrolling both up and down.


Member Function Documentation

void cClip_AddObj ( struct cClip * ptr_clip,
struct cObject * ptr_object,
int x,
int y )
 

Adds the object 'obj' to the cClip in position (x,y).

Parameters:
ptr_clip   A pointer to the initialized cClip structure
ptr_object   A pointer to the initialized cObject structure
x   The x-coordinate of the new object.
y   The y-coordinate of the new 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.
       // It's the same as using the cClip_AddObj( &button ) function.
       cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

void cClip_Disable ( struct Clip * ptr_clip )
 

Disables the cClip object so that it cannot be selected.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
None

void cClip_Disconnect ( struct cClip * ptr_clip )
 

Disconnects the cClip from its parent object.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
None

void cClip_Enable ( struct cObject * ptr_clip )
 

Enables the cClip object - so that it may be selected.

Parameters:
ptr_clip   is A pointer to the initialized cClip structure
Returns:
None

int cClip_FindObj ( struct cClip * ptr_clip,
struct cObject * ptr_object )
 

Returns the child object's index in the cClip.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
ptr_object   A pointer to the needed cObject
Returns:
Object index; -1 if the index cannot be found
       #include <cywin.h>
       ...
       struct cButton button1;
       struct cButton button2;
       struct cButton button3;
       struct module_t main_module;
       struct cObject * currentObj;
       int    nButtonNumber;
       int    i;
       ...
       init_module( &main_module );
       ...
       cButton_ctor( &button1, "Button text 1", mrOk );
       cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
       ...
       cButton_ctor( &button2, "Button text 2", mrOk );
       cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
       ...
       // It's the same as using the cClip_InsObj( &button3 ) function.
       cButton_ctor( &button3, "Button text 3", mrOk );
       cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
       ...
       // Finds the object.
       if ( cClip_FindObj( main_module.m_process, &button2 ) != -1 )
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

int cClip_GetCount ( struct cClip * ptr_clip )
 

Returns the count of child objects.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
Child objects count
       #include <cywin.h>
       ...
       struct cButton button1;
       struct cButton button2;
       struct cButton button3;
       struct module_t main_module;
       int    nButtonNumber;
       ...
       init_module( &main_module );
       ...
       cButton_ctor( &button1, "Button text 1", mrOk );
       cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
       ...
       cButton_ctor( &button2, "Button text 2", mrOk );
       cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
       ...
       // It's the same as using the cClip_InsObj( &button3 ) function.
       cButton_ctor( &button3, "Button text 3", mrOk );
       cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
       ...
       // nButtonNumber will be equal to 3.
       nButtonNumber = cClip_GetCount( main_module.m_process );
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

struct cClip * cClip_GetParent ( struct cClip * ptr_clip )
 

Returns a pointer to the parent object's cClip.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
A pointer to the parent object's cClip

struct cObject * cClip_GetSelectedObject ( struct cClip * ptr_clip )
 

Returns the currently selected object in the cClip.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
The currently selected object in the cClip
       #include <cywin.h>
       ...
       struct cButton button1;
       struct cButton button2;
       struct cButton button3;
       struct module_t main_module;
       struct cObject * selectedObj;
       int    nButtonNumber;
       int    i;
       ...
       init_module( &main_module );
       ...
       cButton_ctor( &button1, "Button text 1", mrOk );
       cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
       ...
       cButton_ctor( &button2, "Button text 2", mrOk );
       cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
       ...
       // It's the same as using the cClip_InsObj( &button3 ) function.
       cButton_ctor( &button3, "Button text 3", mrOk );
       cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
       ...
       cObject_Select( &button2 );
       ...
       // Redraws selected objects.
       cButton_update( cClip_GetSelectedObject( main_module.m_process );
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

int cClip_GetShiftx ( struct cClip * ptr_clip )
 

Returns the 'x' coordinate shift (as a result of scrolling).

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
'x' coordinate shift
       #include <cywin.h>
       ...
       struct cBitmap cbmp;
       struct Bitmap bmp;
       struct module_t main_module;
       int    nShift_X;
       ...
       init_module( &main_module );
       ...
       // Creates a bitmap from the file "root.ico".
       Bitmap_ctor_Ex1( &bmp, "root.ico" );
       cBitmap_ctor( &cbmp, &bmp );
       // Puts the cBitmap object on the Cybiko screen.
       cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
       ...
       // Scrolls the bitmap to the visible area.
       cClip_Scroll_Ex( main_module.m_process, -160, -240 );
       cClip_SendScroll( main_module.m_process );
       // nShift_X will be equal to -160.
       nShift_X = cClip_GetShiftx( main_module.m_process );
       ...
       cBitmap_dtor( &cbmp, LEAVE_MEMORY );
       Bitmap_dtor( &bmp, LEAVE_MEMORY );
See also:
cClip_GetShifty.

int cClip_GetShifty ( struct cClip * ptr_clip )
 

Returns the 'y' coordinate shift (as a result of scrolling).

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
'y' coordinate shift
       #include <cywin.h>
       ...
       struct cBitmap cbmp;
       struct Bitmap bmp;
       struct module_t main_module;
       int    nShift_Y;
       ...
       init_module( &main_module );
       ...
       // Creates a bitmap from the file "root.ico".
       Bitmap_ctor_Ex1( &bmp, "root.ico" );
       cBitmap_ctor( &cbmp, &bmp );
       // Puts the cBitmap object on the Cybiko screen.
       cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
       ...
       // Scrolls the bitmap to the visible area.
       cClip_Scroll_Ex( main_module.m_process, -160, -240 );
       cClip_SendScroll( main_module.m_process );
       // nShift_Y will be equal to -240.
       nShift_Y = cClip_GetShifty( main_module.m_process );
       ...
       cBitmap_dtor( &cbmp, LEAVE_MEMORY );
       Bitmap_dtor( &bmp, LEAVE_MEMORY );
See also:
cClip_GetShiftx.

void cClip_Hide ( struct cClip * ptr_clip )
 

Hides the cClip object.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
None

void cClip_InsObj ( struct cClip * ptr_clip,
struct cObject * ptr_object,
int x,
int y,
int index )
 

Adds the object 'obj' to the cClip in position (x,y), with a z-position index (maximal index is on the top).

Parameters:
ptr_clip   A pointer to the initialized cClip structure
ptr_object   A pointer to initialized cObject structure
x   The x-coordinate of the new object
y   The y-coordinate of the new object
index   The z-position of the new object
Returns:
None
       #include <cywin.h>
       ...
       struct cButton button1;
       struct cButton button2;
       struct cButton button3;
       struct module_t main_module;
       ...
       init_module( &main_module );
       ...
       cButton_ctor( &button1, "Button text 1", mrOk );
       cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
       ...
       cButton_ctor( &button2, "Button text 2", mrOk );
       cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
       ...
       // It's the same as using the cClip_InsObj( &button3 ) function.
       cButton_ctor( &button3, "Button text 3", mrOk );
       cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

void cClip_RemObj ( struct cClip * ptr_clip,
struct cObject * ptr_object )
 

Removes the object from cClip.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
ptr_object   A pointer to the initialized cObject structure
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.
       // It's the same as using the cClip_AddObj( &button ) function.
       cWinApp_AddObj( main_module.m_process, &button, 20, 50 );
       ...
       // It's the same as using the cClip_RemObj( &button ) function.
       cClip_RemObj( main_module.m_process, &button );
       cButton_dtor( &button, LEAVE_MEMORY );

void cClip_Scroll ( struct cClip * ptr_clip,
struct rect_t * rectangle )
 

Scrolls the cClip to make a specified rectangle visible.
Provides minimal scrolling.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
rectangle   A pointer to the initialized rect_t structure
Returns:
None
       #include <cywin.h>
       ...
       struct cBitmap cbmp;
       struct Bitmap bmp;
       struct module_t main_module;
       struct rect_t   rect;
       ...
       init_module( &main_module );
       ...
       // Creates a bitmap from the file "root.ico".
       Bitmap_ctor_Ex1( &bmp, "root.ico" );
       cBitmap_ctor( &cbmp, &bmp );
       // Puts the cBitmap object on the Cybiko screen.
       cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
       ...
       rect_set( &rect, 160, 240, bmp.h, bmp.w );
       // Scrolls the bitmap to the visible area.
       cClip_Scroll( main_module.m_process, &rect );
       ...
       cBitmap_dtor( &cbmp, LEAVE_MEMORY );
       Bitmap_dtor( &bmp, LEAVE_MEMORY );

void cClip_Scroll_Ex ( struct cClip * ptr_clip,
int x,
int y )
 

Scrolls the cClip by ( x, y ), but does not exceed the child's boundaries.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
x   "x" coordinate shift
y   "y" coordinate shift
Returns:
None
       #include <cywin.h>
       ...
       struct cBitmap cbmp;
       struct Bitmap bmp;
       struct module_t main_module;
       ...
       init_module( &main_module );
       ...
       // Creates a bitmap from the file "root.ico".
       Bitmap_ctor_Ex1( &bmp, "root.ico" );
       cBitmap_ctor( &cbmp, &bmp );
       // Puts the cBitmap object on the Cybiko screen.
       cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
       ...
       // Scrolls the bitmap to the visible area.
       cClip_Scroll_Ex( main_module.m_process, -160, -240 );
       ...
       cBitmap_dtor( &cbmp, LEAVE_MEMORY );
       Bitmap_dtor( &bmp, LEAVE_MEMORY );

bool cClip_Select ( struct cClip * ptr_clip )
 

Selects the cClip object.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
TRUE if the object was selected

bool cClip_SelectFirst ( struct cClip * ptr_clip )
 

Selects the first object in the cClip.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
FALSE if the operation failed
       #include <cywin.h>
       ...
       struct cButton button1;
       struct cButton button2;
       struct cButton button3;
       struct module_t main_module;
       ...
       init_module( &main_module );
       ...
       cButton_ctor( &button1, "Button text 1", mrOk );
       cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
       ...
       cButton_ctor( &button2, "Button text 2", mrOk );
       cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
       ...
       // It's the same as using the cClip_InsObj( &button3 ) function.
       cButton_ctor( &button3, "Button text 3", mrOk );
       cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
       ...
       // Selects the first button.
       cClip_SelectFirst( main_module.m_process );
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

bool cClip_SelectNext ( struct cClip * ptr_clip,
bool round )
 

Selects the next object in the cClip.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
round   TRUE if you need to select the last object after selecting the first
Returns:
FALSE if the operation failed
       #include <cywin.h>
       ...
       struct cButton button1;
       struct cButton button2;
       struct cButton button3;
       struct module_t main_module;
       ...
       init_module( &main_module );
       ...
       cButton_ctor( &button1, "Button text 1", mrOk );
       cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
       ...
       cButton_ctor( &button2, "Button text 2", mrOk );
       cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
       ...
       // It's the same as using the cClip_InsObj( &button3 ) function.
       cButton_ctor( &button3, "Button text 3", mrOk );
       cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
       ...
       // Selects the first button.
       cClip_SelectFirst( main_module.m_process );
       ...
       // Selects the next button.
       cClip_SelectNext( main_module.m_process, TRUE );
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

bool cClip_SelectPrev ( struct cClip * ptr_clip,
bool round )
 

Selects the previous object in the cClip.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
round   TRUE if you need to select the last object after selecting the first
Returns:
FALSE if the operation failed
       #include <cywin.h>
       ...
       struct cButton button1;
       struct cButton button2;
       struct cButton button3;
       struct module_t main_module;
       ...
       init_module( &main_module );
       ...
       cButton_ctor( &button1, "Button text 1", mrOk );
       cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
       ...
       cButton_ctor( &button2, "Button text 2", mrOk );
       cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
       ...
       // It's the same as using the cClip_InsObj( &button3 ) function.
       cButton_ctor( &button3, "Button text 3", mrOk );
       cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
       ...
       // Selects the first button.
       cClip_SelectFirst( main_module.m_process );
       ...
       // Selects the previous button.
       cClip_SelectPrev( main_module.m_process, TRUE );
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

void cClip_SendScroll ( struct cClip * ptr_clip )
 

Forces this object to redraw its scrolling arrows.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
None
       #include <cywin.h>
       ...
       struct cBitmap cbmp;
       struct Bitmap bmp;
       struct module_t main_module;
       ...
       init_module( &main_module );
       ...
       // Creates a bitmap from the file "root.ico".
       Bitmap_ctor_Ex1( &bmp, "root.ico" );
       cBitmap_ctor( &cbmp, &bmp );
       // Puts the cBitmap object on the Cybiko screen.
       cWinApp_AddObj( main_module.m_process, &cbmp, 160, 240 );
       ...
       // Scrolls the bitmap to the visible area.
       cClip_Scroll_Ex( main_module.m_process, -160, -240 );
       cClip_SendScroll( main_module.m_process );
       ...
       cBitmap_dtor( &cbmp, LEAVE_MEMORY );
       Bitmap_dtor( &bmp, LEAVE_MEMORY );

void cClip_Show ( struct cObject * ptr_clip )
 

Shows the cClip object.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
None

struct cObject * cClip_get_by_index ( struct cClip * ptr_clip,
int index )
 

Returns an object with its index.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
index   The index of the object in cClip
Returns:
If the index is valid, a pointer to the cObject under the specified index; else NULL.
       #include <cywin.h>
       ...
       struct cButton button1;
       struct cButton button2;
       struct cButton button3;
       struct module_t main_module;
       struct cObject * currentObj;
       int    nButtonNumber;
       int    i;
       ...
       init_module( &main_module );
       ...
       cButton_ctor( &button1, "Button text 1", mrOk );
       cWinApp_AddObj( main_module.m_process, &button1, 20, 50 );
       ...
       cButton_ctor( &button2, "Button text 2", mrOk );
       cWinApp_InsObj( main_module.m_process, &button2, 20, 50, 1 );
       ...
       // It's the same as using the cClip_InsObj( &button3 ) function.
       cButton_ctor( &button3, "Button text 3", mrOk );
       cWinApp_InsObj( main_module.m_process, &button3, 20, 50, 2 );
       ...
       // Redraws all objects.
       for ( i=0; i<cClip_GetCount( main_module.m_process ); i++)
       {
         cButton_update( cClip_get_by_index( main_module.m_process, i) );
       }
       ...
       cButton_dtor( &button, LEAVE_MEMORY );

bool cClip_proc ( struct cClip * ptr_clip,
struct Message * ptr_message )
 

Message-processing function.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
ptr_message   A pointer to the processed message
Returns:
TRUE if the message was processed
  #include <cywin.h>
  ...
  struct cClip* ptr_messages_clip;
  struct Message* ptr_message;
  ...
  case KEY_DOWN:
    cClip_proc( ptr_chat_form->ptr_messages_clip, ptr_message );
    return TRUE;
  ...

void cClip_update ( struct cClip * ptr_clip )
 

Updates a cClip object.

Parameters:
ptr_clip   A pointer to the initialized cClip structure
Returns:
None