|
// --- I need one OpenGL sub-window ---
HWND Light_Wind ;
// --- Interface tools ---
static Boxs box_box ;
static Boxs box_image ;
...
// ----------------------------------------------------------------------------
//
// 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 )
{
// ====================================================================
// ====================================================================
// =================== !!!! IMPORTANT !!!! =======================
// ====================================================================
// ====================================================================
// --- Since we have child windows, we only want the creation of the main window ---
static char flag ;
if ( flag )
return( 1 ) ;
flag++ ;
// ====================================================================
// ====================================================================
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 = "------- 3D Light Control -------" ;
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.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 ) ;
// ====================================================================
// ====================================================================
// =================== !!!! IMPORTANT !!!! =======================
// ====================================================================
// ====================================================================
// === All child windows of this window must be created here! ===
// == If you give the same ID at the child window, it will be ===
// === processed by the same functions as the parent. ===
// === If you use ID+1, it will not cause any call-backs. ===
// ====================================================================
// ====================================================================
// --- Create the associated OpenGL window ---
HINSTANCE hInstance = (HINSTANCE) GetWindowLong( GetActiveWindow(), GWLP_HINSTANCE ) ;
// --- Get the ID of the parent window ---
LONG window_ID = GetWindowLong( wnd, GWL_ID ) ;
// --- The dimensions are not important, they will be changed in the "resize" section ---
Light_Wind = CreateWindow( "TOOL", NULL,
WS_CHILD | WS_DISABLED | WS_VISIBLE,
0, 0, 10, 10,
wnd, (HMENU) (window_ID), hInstance, NULL ) ;
assert( Light_Wind ) ;
// ====================================================================
// ====================================================================
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 )
{
// ====================================================================
// ====================================================================
// =================== !!!! IMPORTANT !!!! =======================
// ====================================================================
// ====================================================================
// --- Since we have child windows, we only want the creation of the main window ---
// On the first call of the child's resize, its window is not yet defined.
if ( ! Light_Wind )
return( 1 ) ;
if ( wnd && (wnd == Light_Wind) )
return( 1 ) ;
// ====================================================================
// ====================================================================
// --- we need a few variables ---
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" ) ;
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 ;
}
...
// Note: Creating a "box" with the same dim as the sub-window is useful for the
// for the other interface functions (Ctrl_Click()...).
box_image.Flag = OUTIL_DISABLE | OUTIL_EMPTY ;
box_image.Pos_X = ... ;
box_image.Pos_Y = ... ;
box_image.Dim_X = ... ;
box_image.Dim_Y = ... ;
box_image.color = box_box.color ;
box_image.Init( wnd ) ;
// ====================================================================
// ====================================================================
// --- resize the sub-window ---
// Note: window coord are top to bottom instead of bottom to top
MoveWindow( Light_Wind,
box_image.Pos_X,
height - (box_image.Pos_Y + box_image.Dim_Y),
box_image.Dim_X,
box_image.Dim_Y,
NULL ) ;
EnableWindow( Light_Wind, TRUE ) ;
// ====================================================================
// ====================================================================
return( 1 ) ;
}
|