...
// --- Interface tools ---
static Boxs box_box ;
// --- for Propagate Tool ---
static Boxs box_prop ;
static Tool_Propagate tool_propagate ;
// --- defined in tool_propagate_propagate.cpp ---
int Demo_Propagate( void *v_source, void *v_target ) ;
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Register
//
// Parameters: mode (unsigned short *) Used only for Tools.
// If this pointer is not NULL,
// use it to specify to what tool
// window we belong.
// SLICEO_TOOL_2D, _BASIC,_3D...
//
// Returns: (int) Vertical size of your menu (in pixels)
//
// This is called once at the start of the program. We need it to
// know you are using your own func. and how much space to reserve
// in the menu interface. You must also change the "mode" flag to
// reflect in what tool window you want to appear.
//
// Note: If you do not need a graphic interface, just comment out
// the "Ctrl_Register" function.
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Register( unsigned short *mode )
{
// --- this is a 2D TAG tool only ---
if ( mode )
(*mode) = SLICEO_TOOL_2D ;
// --------------------------------------------------------------------
// In the "Config" menu, the user can change the interface's size.
// This action change a number of variables that are used to compute
// the size of the tool in the intearface. We now load a few of these
// variables and use them to compute the dimension of our interface box.
// --------------------------------------------------------------------
short Title_Dim = (short) Fct_Variable_Value( "$INTERFACE_TITLE_DIM_BIG" ) ;
short Space_Dim = (short) Fct_Variable_Value( "$INTERFACE_SPACE_DIM" ) ;
// --- compute the height of the interface ---
short height = Title_Dim // title at top of tool
+ tool_propagate.Height() // propagate
+ Space_Dim ; // space at the bottom
return( height ) ;
}
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Create
//
// Parameters: wnd (HWND) Pointer to Window's created window
// width (int) horiz. size of the window
// height (int) vert. size of the window
// Returns: (int) 0 if error
//
// This is called once when your control window is created
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Create( HWND wnd, int width, int height )
{
char *Title_Font_Name = (char *) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_NAME" ) ;
char *Title_Font_Weight = (char *) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_WEIGHT" ) ;
short Title_Font_Scale = (short) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_SCALE" ) ;
short Border_Dim = (short) Fct_Variable_Value( "$INTERFACE_BORDER_DIM" ) ;
box_box.Name = "------- SliceO Propagate -------" ;
box_box.Flag = OUTIL_DISABLE | OUTIL_NO_3D ;
box_box.Pos_X = 1 ;
box_box.Pos_Y = 1 ;
box_box.Dim_X = width - 2 ;
box_box.Dim_Y = height - 2 ;
box_box.border = Border_Dim;
box_box.color.set( WINDOW_COLOR_TOOL_R,
WINDOW_COLOR_TOOL_G,
WINDOW_COLOR_TOOL_B ) ;
box_box.Font_Name = Title_Font_Name ;
box_box.Font_Scale = Title_Font_Scale ;
box_box.Font_Weight = Title_Font_Weight ;
box_box.Init( wnd ) ;
return( 1 ) ;
}
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Resize
//
// Parameters: wnd (HWND) Pointer to Window's created window
// width (int) horiz. size of the window
// height (int) vert. size of the window
// Returns: (int) 0 if error
//
// This is called once when your control window is created
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Resize( HWND wnd, int width, int height )
{
short p_x, p_y, d_x, d_y ;
// -----------------------------------------------------------------------
// In the "Config" menu, the user can change the interface's size.
// This action change a number of variables that are used to compute
// the size of the tool in the intearface. We now load a few of these
// variables and use them to compute the dimension of our interface tools.
// -----------------------------------------------------------------------
char *Title_Font_Name = (char *) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_NAME" ) ;
char *Title_Font_Weight = (char *) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_WEIGHT" ) ;
short Title_Font_Scale = (short) Fct_Variable_Value( "$INTERFACE_TITLE_FONT_SCALE" ) ;
char *Tools_Font_Name = (char *) Fct_Variable_Value( "$INTERFACE_TOOL_FONT_NAME" ) ;
char *Tools_Font_Weigth = (char *) Fct_Variable_Value( "$INTERFACE_TOOL_FONT_WEIGHT" ) ;
short Tools_Font_Scale = (short) Fct_Variable_Value( "$INTERFACE_TOOL_FONT_SCALE" ) ;
short Space_Dim = (short) Fct_Variable_Value( "$INTERFACE_SPACE_DIM" ) ;
short Border_Dim = (short) Fct_Variable_Value( "$INTERFACE_BORDER_DIM" ) ;
if ( wnd ) {
box_box.Pos_X = 1 ;
box_box.Pos_Y = 1 ;
box_box.Dim_X = width - 2 ;
box_box.Dim_Y = height - 2 ;
box_box.border = Border_Dim;
box_box.Font_Name = Title_Font_Name ;
box_box.Font_Scale = Title_Font_Scale ;
box_box.Font_Weight = Title_Font_Weight ;
box_box.Init( wnd ) ;
} else {
wnd = box_box.wnd ;
}
// ===========================================================================
// --- Brush_Selection Tool
// ===========================================================================
p_x = box_box.Pos_X + Space_Dim ;
p_y = box_box.Pos_Y + Space_Dim ;
d_x = box_box.Dim_X - 2*Space_Dim ;
d_y = tool_propagate.Height() ;
// --- The tool will be inside this box ---
box_prop.Flag = OUTIL_EMPTY ;
box_prop.Pos_X = p_x ;
box_prop.Pos_Y = p_y ;
box_prop.Dim_X = d_x ;
box_prop.Dim_Y = d_y ;
box_prop.border = Border_Dim ;
box_prop.Font_Name = Tools_Font_Name ;
box_prop.Font_Weight = Tools_Font_Weigth ;
box_prop.Font_Scale = Tools_Font_Scale ;
box_prop.color = box_box.color ;
box_prop.Init( wnd ) ;
// --- now prepare the tool itself ---
tool_propagate.Resize( &box_prop ) ;
// --- associate a function to the propagate action ---
tool_propagate.Set( Demo_Propagate ) ;
return( 1 ) ;
}
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Draw
//
// Parameters: (void)
// Returns: (int) 0 if error
//
// This is called each time your menu has to be re-drawn
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Draw( HWND wnd )
{
// --- if the window if off or invible, we can get out ---
if ( ! Flag_Ctrl_Wnd_On )
return( 1 ) ;
if ( ! Flag_Ctrl_Visible )
return( 1 ) ;
box_box.Draw() ;
// --- Propagate Tool ---
tool_propagate.Draw() ;
return( 1 ) ;
}
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Leave
//
// Parameters: (void)
// Returns: (int) 0 if error
//
// This is called each time the cursor leave your menu
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Leave( void )
{
// --- if the window if off or invible, we can get out ---
if ( ! Flag_Ctrl_Wnd_On )
return( 1 ) ;
if ( ! Flag_Ctrl_Visible )
return( 1 ) ;
// --- Propagate Tool ---
tool_propagate.Leave() ;
return( 1 ) ;
}
// ============================================================================
// ============================================================================
// ============================================================================
// ============================================================================
// ============================================================================
// ----------------------------------------------------------------------------
//
// 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 error
//
// 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 refresh the image when we release the button ---
if ( ! up_down ) {
return( 0 ) ;
}
// ------------------------------------------------
// --- Propagate Tool ---
// ------------------------------------------------
if ( tool_propagate.Click( up_down ) >= 0 ) {
// // --- we need to refresh the graphics ---
// Fct_Redraw( REDRAW_CLEAR_2D ) ;
}
// ------------------------------------------------
return( 0 ) ;
}
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Key
//
// Parameters: wnd (HWND) Pointer to Window's generating the signal
// key (int) code of the activated key
// x, y (int) current cursor position
// Returns: (int) 1 if key is used
//
// This is called each time the cursor is inside your menu and a keyboard
// key has been pressed.
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Key( HWND wnd, int key, short x, short y )
{
// --- Propagate Tool ---
if ( tool_propagate.Keyboard( key ) )
return( 1 ) ;
return( 0 ) ;
}
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Motion
//
// 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 error
//
// This is called each time the cursor is inside your menu and the cursor
// has moved.
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Motion( HWND wnd, int up_down, short x, short y )
{
// ------------------------------------------------
// The mouse has moved. By calling "select" we
// insure that the box will get the "select" color
// if the cursor is over it.
// ------------------------------------------------
// --- Propagate Tool ---
if ( box_prop.Select( up_down ) ) {
tool_propagate.Motion( up_down ) ;
return( 1 ) ;
}
return( 0 ) ;
}
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Scroll
//
// Parameters: wnd (HWND) Pointer to Window's generating the signal
// up_down (int) state of the mouse buttons
// x, y (int) current cursor position (in Wnd space)
//
// Returns: (int) 0 if unused
//
// This is called each time the cursor is inside your menu and the mouse
// wheel has been activated.
//
// ----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int Ctrl_Scroll( HWND wnd, int count, short x, short y )
{
// --- Propagate Tool ---
if ( box_prop.Select( KEY_QUERY ) ) {
tool_propagate.Scroll( count ) ;
return( 1 ) ;
}
return( 0 ) ;
}
// ----------------------------------------------------------------------------
//
// Function: Ctrl_Update
//
// Parameters: (void)
// Returns: (int) 0 if error
//
// This is called each time something has been modified from another
// control and sliceO Beleive it may affect you.
//
// ----------------------------------------------------------------------------
int Ctrl_Update( UInt64 flag )
{
if ( ! Flag_Ctrl_Wnd_On )
return( 1 ) ;
// --- We changed the current frame ---
if ( flag & UPDATE_CUR_FRAME ) {
tool_propagate.Update( flag ) ;
}
return( 1 ) ;
}
...
|