Ima_Click

 

The "Ima_Click()" function is called whenever a mouse button is activated while the cursor is over an image window.

 

 

Syntax

 

extern "C" __declspec(dllexportint  Ima_Click(

          HWND wnd,

          SliceO_Window *window

          int up_down,

          short x, short y

)

 

 

Parameters

 

wnd

A handle to the interface's window

 

window

A pointer to the "Window" structure of the image window receiving the action.

 

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 "Ima_Click" function  from the "Edit mode" module.

 

...

 

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

//

//          Function:          Ima_Click

//

//          Parameters:          up_down (int)          state of the mouse buttons

//          Returns:          (int)                    1 if action was used

//

//          This is called each time the cursor is inside an image and the state

//          of the mouse buttons has changed.

//

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

extern "C" __declspec(dllexport) int          Ima_Click( HWND wnd, SliceO_Window *window, int up_down, short x, short y )

{

          if ( ! up_down ) {

              // --- stop recording ---

              Undo_Pixel_TAG *pix_list = Undo_Pixel_Stop_TAG() ;

 

              // --- if there's a list, add it to an undo structure ---

              if ( pix_list ) {

                    char str_size[40] ;

                    unsigned int size = Undo_TAG_Size( pix_list ) ;

                    Undo_Save_Command( NULL, pix_list, "TAG Edit: Stroke \001(%s)", Int_2_Byte(size,str_size) ) ;

                    return( 1 ) ;

              }

              return( 0 ) ;

          }

 

          // --- get a pointer to the "current" frame ---

          SliceO_Frame *Frame_Ovr = (SliceO_Frame *) Fct_Variable_Value( "$FRAME_OVR" ) ;

 

          // --- only edit when over an image ---

          if ( ! Frame_Ovr )

              return( 0 ) ;

 

          // --- only edit if the image is selected ---

          if ( ! Frame_Ovr->Flag_Get_Bit( CLASS_MODE_THIS, window, CLASS_FLAG_SELECT ) )

              return( 0 ) ;

 

          // --- if we do not have an "erase" buffer, load it now ---

          if ( ! Frame_Ovr->Erase_Get() )

              Frame_Ovr->Erase_Load() ;

 

          // --- start recording ---

          Undo_Pixel_Start_TAG() ;

 

          // --- we have the cursor in "Wnd" space, we want it in "Frm" space ---

          Point_2D pos_wnd( COORD_WND, x, y ) ;

          Point_2D pos_inf = window->Wnd_2_Inf( pos_wnd ) ;

          Point_2D pos_frm = Frame_Ovr->Inf_2_Frm( window, pos_inf ) ;

 

          // --- we do not want pixel fractions here ---

          pos_frm[0] = (float) ((int) pos_frm[0]) ;

          pos_frm[1] = (float) ((int) pos_frm[1]) ;

 

          switch( up_down & MOUSE_KEY_MASK ) {

 

          case MOUSE_KEY_LEFT :

              Edit_Paint_Pix_Add( Frame_Ovr, &pos_frm ) ;

              break ;

 

          case MOUSE_KEY_RIGHT :

              Edit_Paint_Pix_Erase( Frame_Ovr, &pos_frm ) ;

              break ;

 

          case MOUSE_KEY_LEFT | MOUSE_KEY_MIDDLE :

              Edit_Paint_Full_Add( Frame_Ovr, &pos_frm ) ;

              break ;

 

          case MOUSE_KEY_RIGHT | MOUSE_KEY_MIDDLE :

              Edit_Paint_Full_Erase( Frame_Ovr, &pos_frm ) ;

              break ;

 

          }

 

          return( 1 ) ;

}

 

...

 

See also