Ctrl_Click

 

The "Ctrl_Click()" function is called whenever a mouse button is activated while the cursor is over your interface window.

 

Syntax

 

extern "C" __declspec(dllexportint  Ctrl_Click(

          HWND wnd,

          int up_down,

          short x, short y

)

 

 

Parameters

 

wnd

A handle to the interface's window

 

up_down

is an image of the 3 mouse button states. The lower byte contain a code giving the mouse button action (off, on, pressed or double clicked).  The next byte give the state of each of the 3 keys as on or off. The different values for the variable are:

 

KEY_DBLCLK          3

KEY_PRESS          2

KEY_ON          1

KEY_OFF          0

MOUSE_KEY_LEFT          0x010

MOUSE_KEY_MIDDLE          0x020

MOUSE_KEY_RIGHT          0x040

 

So, for example, if you click on the left mouse button, the value of up_down will be (KEY_PRESS | MOUSE_KEY_LEFT). When you release the button the value will be KEY_OFF.

 

x, y

Horizontal (x) and vertical (y) position of the cursor within the current window. (0,0 at bottom left)

 

 

Return value

 

The function returns "1" if the event has been used.

 

 

Remarks

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

Library:

          sliceO_Structures.lib

 

 

Example

 

Sample "Ctrl_Click" function  from the "Edit mode" module.

 

...

 

// ----------------------------------------------------------------------------

//

//          Function:          Ctrl_Click

//

//          Parameters:          wnd (HWND)          Pointer to Window's generating the signal

//                              up_down (int)          state of the mouse buttons

//                              x, y (int)          current cursor position

//          Returns:          (int)                    0 if used

//

//          This is called each time the cursor is inside your menu and the state

//          of the mouse buttons has changed.

//

// ----------------------------------------------------------------------------

extern "C" __declspec(dllexport) int          Ctrl_Click( HWND wnd, int up_down, short x, short y )

{

          // --- we only use the "down" click ---

          if ( ! up_down )

              return( 0 ) ;

 

          // ------------------------------------------------

          // ---              TAG Selection Tool                              ---

          // ------------------------------------------------

          if ( tool_tag.Click( up_down ) >= 0  ) {

              unsigned short *TAG_Cur = (unsigned short *) Fct_Variable_Get( "$TAG_CUR" ) ;

              if ( ! TAG_Cur )

                    return( 0 ) ;

              if ( *TAG_Cur != tool_tag.Read() ) {

                    // --- we changed the current tag ---

                    *TAG_Cur = tool_tag.Read() ;

                    Fct_Update( UPDATE_CUR_TAG ) ;

              }

          }

          // ------------------------------------------------

 

          // ------------------------------------------------

          // ---              Brush Selection Tool                    ---

          // ------------------------------------------------

          if ( tool_brush.Click( up_down ) >= 0  ) {

              unsigned short *Brush_Cur = (unsigned short *) Fct_Variable_Get( "$BRUSH_CUR" ) ;

              if ( ! Brush_Cur )

                    return( 0 ) ;

              if ( *Brush_Cur != tool_brush.Read() ) {

                    // --- we changed the current tag ---

                    *Brush_Cur = tool_brush.Read() ;

                    Fct_Update( UPDATE_CUR_BRUSH ) ;

              }

          }

          // ------------------------------------------------

 

          // -- save the tag_work image to the erase buffer ---

          if ( but_load.Select( up_down ) ) {

              but_load.Cur_Value = 1 ;

              but_load.Adjust() ;

 

              // --- make sure we have an erase buffer ---

              SliceO_Frame **Frame_Cur = (SliceO_Frame **) Fct_Variable_Value( "$FRAME_CUR" ) ;

              SliceO_Window *Window_Cur = (SliceO_Window *) Fct_Variable_Value( "$WINDOW_CUR" ) ;

              if ( Frame_Cur && Window_Cur && Frame_Cur[Window_Cur->Id_Get()] ) {

                    Frame_Cur[Window_Cur->Id_Get()]->Erase_Load() ;

              }

              but_load.Cur_Value = 0 ;

              but_load.Adjust() ;

              return( 1 ) ;

          }

 

          // --- last undo ---

          if ( but_undo.Select( up_down ) ) {

              but_undo.Cur_Value = 1 ;

              but_undo.Adjust() ;

 

              Undo_Undo_Command() ;

 

              but_undo.Cur_Value = 0 ;

              but_undo.Adjust() ;

              return( 1 ) ;

          }

 

          if ( but_erose.Select( up_down ) ) {

              but_erose.Cur_Value = 1 ;

              but_erose.Adjust() ;

              Script_Read_Line( "morpho: erosion" ) ;

              but_erose.Cur_Value = 0 ;

              but_erose.Adjust() ;

              return( 1 ) ;

          }

 

          if ( but_dilat.Select( up_down ) ) {

              but_dilat.Cur_Value = 1 ;

              but_dilat.Adjust() ;

              Script_Read_Line( "morpho: dilatation" ) ;

              but_dilat.Cur_Value = 0 ;

              but_dilat.Adjust() ;

              return( 1 ) ;

          }

 

          if ( but_open1.Select( up_down ) ) {

              but_open1.Cur_Value = 1 ;

              but_open1.Adjust() ;

              Script_Read_Line( "morpho: open 1" ) ;

              but_open1.Cur_Value = 0 ;

              but_open1.Adjust() ;

              return( 1 ) ;

          }

          if ( but_open2.Select( up_down ) ) {

              but_open2.Cur_Value = 1 ;

              but_open2.Adjust() ;

              Script_Read_Line( "morpho: open 2" ) ;

              but_open2.Cur_Value = 0 ;

              but_open2.Adjust() ;

              return( 1 ) ;

          }

          if ( but_close1.Select( up_down ) ) {

              but_close1.Cur_Value = 1 ;

              but_close1.Adjust() ;

              Script_Read_Line( "morpho: close 1" ) ;

              but_close1.Cur_Value = 0 ;

              but_close1.Adjust() ;

              return( 1 ) ;

          }

          if ( but_close2.Select( up_down ) ) {

              but_close2.Cur_Value = 1 ;

              but_close2.Adjust() ;

              Script_Read_Line( "morpho: close 2" ) ;

              but_close2.Cur_Value = 0 ;

              but_close2.Adjust() ;

              return( 1 ) ;

          }

 

          return( 0 ) ;

}

 

...

 

 

See also

 

Ctrl_Blabla