Initial commit of Command & Conquer Generals and Command & Conquer Generals Zero Hour source code.

This commit is contained in:
LFeenanEA 2025-02-27 17:34:39 +00:00
parent 2e338c00cb
commit 3d0ee53a05
No known key found for this signature in database
GPG key ID: C6EBE8C2EA08F7E0
6072 changed files with 2283311 additions and 0 deletions

View file

@ -0,0 +1,390 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: CallbackEditor.cpp ///////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: CallbackEditor.cpp
//
// Created: Colin Day, Sepember 2001
//
// Desc: A handy dandy little dialog to just edit the callbacks for
// user windows ... a super convient luxury at a bargain price!
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Common/Debug.h"
#include "Common/FunctionLexicon.h"
#include "GameClient/Gadget.h"
#include "GameClient/GameWindowManager.h"
#include "GUIEdit.h"
#include "Resource.h"
#include "Properties.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
static char *noNameWindowString = "Un-named Window";
static GameWindow *currentWindow = NULL; ///< current window we're editing
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// SaveCallbacks ==============================================================
/** save the current callbacks for the selected window */
void SaveCallbacks( GameWindow *window, HWND dialog )
{
// sanity
if( window == NULL || dialog == NULL )
return;
// get edit data for window
GameWindowEditData *editData = window->winGetEditData();
DEBUG_ASSERTCRASH( editData, ("No edit data for window saving callbacks!\n") );
// get the currently selected item from each of the combos and save
Int index;
char buffer[ 256 ];
// system
index = SendDlgItemMessage( dialog, COMBO_SYSTEM, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( dialog, COMBO_SYSTEM, CB_GETLBTEXT, index, (LPARAM)buffer );
editData->systemCallbackString = buffer;
// input
index = SendDlgItemMessage( dialog, COMBO_INPUT, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( dialog, COMBO_INPUT, CB_GETLBTEXT, index, (LPARAM)buffer );
editData->inputCallbackString = buffer;
// tooltip
index = SendDlgItemMessage( dialog, COMBO_TOOLTIP, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( dialog, COMBO_TOOLTIP, CB_GETLBTEXT, index, (LPARAM)buffer );
editData->tooltipCallbackString = buffer;
// draw
index = SendDlgItemMessage( dialog, COMBO_DRAW, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( dialog, COMBO_DRAW, CB_GETLBTEXT, index, (LPARAM)buffer );
editData->drawCallbackString = buffer;
// if there was a window we have a change
if( window )
TheEditor->setUnsaved( TRUE );
} // end SaveCallbacks
// setCurrentWindow ===========================================================
/** Set the window passed in as the active window for editing */
//=============================================================================
static void setCurrentWindow( GameWindow *window, HWND dialog )
{
GameWindowEditData *editData = NULL;
// get edit data from window if present
if( window )
editData = window->winGetEditData();
// save window
currentWindow = window;
// sanity
if( dialog == NULL )
return;
// enable the callback combo boxes
EnableWindow( GetDlgItem( dialog, COMBO_SYSTEM ), TRUE );
EnableWindow( GetDlgItem( dialog, COMBO_INPUT ), TRUE );
EnableWindow( GetDlgItem( dialog, COMBO_TOOLTIP ), TRUE );
EnableWindow( GetDlgItem( dialog, COMBO_DRAW ), TRUE );
//
// select the assigned callbacks, if no callback is assigned
// in a slot then we select the "none string" for the combo box
//
AsciiString name;
// system
if( editData )
name = editData->systemCallbackString;
if( name.isEmpty() )
name = GUIEDIT_NONE_STRING;
SendDlgItemMessage( dialog, COMBO_SYSTEM,
CB_SELECTSTRING, -1, (LPARAM)name.str() );
// input
name = NULL;
if( editData )
name = editData->inputCallbackString;
if( name.isEmpty() )
name = GUIEDIT_NONE_STRING;
SendDlgItemMessage( dialog, COMBO_INPUT,
CB_SELECTSTRING, -1, (LPARAM)name.str() );
// tooltip
name = NULL;
if( editData )
name = editData->tooltipCallbackString;
if( name.isEmpty() )
name = GUIEDIT_NONE_STRING;
SendDlgItemMessage( dialog, COMBO_TOOLTIP,
CB_SELECTSTRING, -1, (LPARAM)name.str() );
// draw
name = NULL;
if( editData )
name = editData->drawCallbackString;
if( name.isEmpty() )
name = GUIEDIT_NONE_STRING;
SendDlgItemMessage( dialog, COMBO_DRAW,
CB_SELECTSTRING, -1, (LPARAM)name.str() );
//
// set the name of the window in the static control above
// the callback editor boxes
//
name = GUIEDIT_NONE_STRING;
if( window )
{
WinInstanceData *instData = window->winGetInstanceData();
if( !instData->m_decoratedNameString.isEmpty() )
name = instData->m_decoratedNameString;
else
name = noNameWindowString;
} // end if
SetWindowText( GetDlgItem( dialog, STATIC_WINDOW ), name.str() );
} // end setCurrentWindow
// loadUserWindows ============================================================
/** Given the window list passed in, load the list box passed with the
* names of USER windows found in the hierarchy. */
//=============================================================================
static void loadUserWindows( HWND listbox, GameWindow *root )
{
// end recursion
if( root == NULL )
return;
// is this a candidate
if( TheEditor->windowIsGadget( root ) == FALSE )
{
WinInstanceData *instData = root->winGetInstanceData();
Int index;
AsciiString name;
//
// add name to the listbox, if there is no name we can only put
// an unnamed label in there
//
if( !instData->m_decoratedNameString.isEmpty() )
name = instData->m_decoratedNameString;
else
name = noNameWindowString;
index = SendMessage( listbox, LB_ADDSTRING, 0, (LPARAM)name.str() );
// add data pointer to the window at the index just added
SendMessage( listbox, LB_SETITEMDATA, index, (LPARAM)root );
// check the children
loadUserWindows( listbox, root->winGetChild() );
} // end if
// check the rest of the list
loadUserWindows( listbox, root->winGetNext() );
} // end loadUserWindows
//-------------------------------------------------------------------------------------------------
/** save the layout callbacks */
//-------------------------------------------------------------------------------------------------
static void saveLayoutCallbacks( HWND dialog )
{
char buffer[ MAX_LAYOUT_FUNC_LEN ];
Int sel;
// layout init
sel = SendDlgItemMessage( dialog, COMBO_INIT, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( dialog, COMBO_INIT, CB_GETLBTEXT, sel, (LPARAM)buffer );
TheEditor->setLayoutInit( AsciiString(buffer) );
// layout update
sel = SendDlgItemMessage( dialog, COMBO_UPDATE, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( dialog, COMBO_UPDATE, CB_GETLBTEXT, sel, (LPARAM)buffer );
TheEditor->setLayoutUpdate( AsciiString(buffer) );
// layout shutdown
sel = SendDlgItemMessage( dialog, COMBO_SHUTDOWN, CB_GETCURSEL, 0, 0 );
SendDlgItemMessage( dialog, COMBO_SHUTDOWN, CB_GETLBTEXT, sel, (LPARAM)buffer );
TheEditor->setLayoutShutdown( AsciiString(buffer) );
} // end saveLayoutCallbacks
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// CallbackEditorDialogProc ===================================================
/** Dialog procedure for grid settings dialog */
//=============================================================================
BOOL CALLBACK CallbackEditorDialogProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch( message )
{
// ------------------------------------------------------------------------
case WM_INITDIALOG:
{
// load the combos with the callbacks
InitCallbackCombos( hWndDialog, NULL );
// select the none string at the top index in each combo
SendDlgItemMessage( hWndDialog, COMBO_SYSTEM, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( hWndDialog, COMBO_INPUT, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( hWndDialog, COMBO_TOOLTIP, CB_SETCURSEL, 0, 0 );
SendDlgItemMessage( hWndDialog, COMBO_DRAW, CB_SETCURSEL, 0, 0 );
// load the listbox with all the USER windows in the edit window
loadUserWindows( GetDlgItem( hWndDialog, LIST_WINDOWS ),
TheWindowManager->winGetWindowList() );
// no current window
setCurrentWindow( NULL, hWndDialog );
return TRUE;
} // end init dialog
// ------------------------------------------------------------------------
case WM_COMMAND:
{
Int notifyCode = HIWORD( wParam ); // notification code
// Int controlID = LOWORD( wParam ); // control ID
HWND hWndControl = (HWND)lParam; // control window handle
switch( LOWORD( wParam ) )
{
// --------------------------------------------------------------------
case LIST_WINDOWS:
{
switch( notifyCode )
{
// ----------------------------------------------------------------
case LBN_SELCHANGE:
{
Int selected;
GameWindow *win;
// get the current selection of the window list
selected = SendMessage( hWndControl, LB_GETCURSEL, 0, 0 );
// get the window of the selected listbox item
win = (GameWindow *)SendMessage( hWndControl, LB_GETITEMDATA,
selected, 0 );
// sanity
DEBUG_ASSERTCRASH( win, ("NULL window set in listbox item data") );
// save the callbacks for the curent window selected
SaveCallbacks( currentWindow, hWndDialog );
// set the current window to the new selection
setCurrentWindow( win, hWndDialog );
break;
} // end case selection change
} // end switch
break;
} // end window listbox
// --------------------------------------------------------------------
case IDOK:
{
// save callbacks, set current window to empty and end dialog
SaveCallbacks( currentWindow, hWndDialog );
setCurrentWindow( NULL, hWndDialog );
// save the layout callbacks
saveLayoutCallbacks( hWndDialog );
// end dialog
EndDialog( hWndDialog, TRUE );
break;
} // end ok
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end CallbackEditorDialogProc

View file

@ -0,0 +1,290 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: CheckBoxProperties.cpp ///////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: CheckBoxProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Check box properties
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Properties.h"
#include "Resource.h"
#include "GameClient/GadgetCheckBox.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// checkBoxPropertiesCallback =================================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK checkBoxPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( CHECK_BOX_ENABLED );
GadgetCheckBoxSetEnabledImage( window, info->image );
GadgetCheckBoxSetEnabledColor( window, info->color );
GadgetCheckBoxSetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( CHECK_BOX_ENABLED_UNCHECKED_BOX );
GadgetCheckBoxSetEnabledUncheckedBoxImage( window, info->image );
GadgetCheckBoxSetEnabledUncheckedBoxColor( window, info->color );
GadgetCheckBoxSetEnabledUncheckedBoxBorderColor( window, info->borderColor );
info = GetStateInfo( CHECK_BOX_ENABLED_CHECKED_BOX );
GadgetCheckBoxSetEnabledCheckedBoxImage( window, info->image );
GadgetCheckBoxSetEnabledCheckedBoxColor( window, info->color );
GadgetCheckBoxSetEnabledCheckedBoxBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( CHECK_BOX_DISABLED );
GadgetCheckBoxSetDisabledImage( window, info->image );
GadgetCheckBoxSetDisabledColor( window, info->color );
GadgetCheckBoxSetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( CHECK_BOX_DISABLED_UNCHECKED_BOX );
GadgetCheckBoxSetDisabledUncheckedBoxImage( window, info->image );
GadgetCheckBoxSetDisabledUncheckedBoxColor( window, info->color );
GadgetCheckBoxSetDisabledUncheckedBoxBorderColor( window, info->borderColor );
info = GetStateInfo( CHECK_BOX_DISABLED_CHECKED_BOX );
GadgetCheckBoxSetDisabledCheckedBoxImage( window, info->image );
GadgetCheckBoxSetDisabledCheckedBoxColor( window, info->color );
GadgetCheckBoxSetDisabledCheckedBoxBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( CHECK_BOX_HILITE );
GadgetCheckBoxSetHiliteImage( window, info->image );
GadgetCheckBoxSetHiliteColor( window, info->color );
GadgetCheckBoxSetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( CHECK_BOX_HILITE_UNCHECKED_BOX );
GadgetCheckBoxSetHiliteUncheckedBoxImage( window, info->image );
GadgetCheckBoxSetHiliteUncheckedBoxColor( window, info->color );
GadgetCheckBoxSetHiliteUncheckedBoxBorderColor( window, info->borderColor );
info = GetStateInfo( CHECK_BOX_HILITE_CHECKED_BOX );
GadgetCheckBoxSetHiliteCheckedBoxImage( window, info->image );
GadgetCheckBoxSetHiliteCheckedBoxColor( window, info->color );
GadgetCheckBoxSetHiliteCheckedBoxBorderColor( window, info->borderColor );
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end checkBoxPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitCheckBoxPropertiesDialog ===============================================
/** Bring up the check box properties dialog */
//=============================================================================
HWND InitCheckBoxPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)CHECK_BOX_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)checkBoxPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// store in the image and color table the values for this putton
//
const Image *image;
Color color, borderColor;
// --------------------------------------------------------------------------
image = GadgetCheckBoxGetEnabledImage( window );
color = GadgetCheckBoxGetEnabledColor( window );
borderColor = GadgetCheckBoxGetEnabledBorderColor( window );
StoreImageAndColor( CHECK_BOX_ENABLED, image, color, borderColor );
image = GadgetCheckBoxGetEnabledUncheckedBoxImage( window );
color = GadgetCheckBoxGetEnabledUncheckedBoxColor( window );
borderColor = GadgetCheckBoxGetEnabledUncheckedBoxBorderColor( window );
StoreImageAndColor( CHECK_BOX_ENABLED_UNCHECKED_BOX, image, color, borderColor );
image = GadgetCheckBoxGetEnabledCheckedBoxImage( window );
color = GadgetCheckBoxGetEnabledCheckedBoxColor( window );
borderColor = GadgetCheckBoxGetEnabledCheckedBoxBorderColor( window );
StoreImageAndColor( CHECK_BOX_ENABLED_CHECKED_BOX, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetCheckBoxGetDisabledImage( window );
color = GadgetCheckBoxGetDisabledColor( window );
borderColor = GadgetCheckBoxGetDisabledBorderColor( window );
StoreImageAndColor( CHECK_BOX_DISABLED, image, color, borderColor );
image = GadgetCheckBoxGetDisabledUncheckedBoxImage( window );
color = GadgetCheckBoxGetDisabledUncheckedBoxColor( window );
borderColor = GadgetCheckBoxGetDisabledUncheckedBoxBorderColor( window );
StoreImageAndColor( CHECK_BOX_DISABLED_UNCHECKED_BOX, image, color, borderColor );
image = GadgetCheckBoxGetDisabledCheckedBoxImage( window );
color = GadgetCheckBoxGetDisabledCheckedBoxColor( window );
borderColor = GadgetCheckBoxGetDisabledCheckedBoxBorderColor( window );
StoreImageAndColor( CHECK_BOX_DISABLED_CHECKED_BOX, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetCheckBoxGetHiliteImage( window );
color = GadgetCheckBoxGetHiliteColor( window );
borderColor = GadgetCheckBoxGetHiliteBorderColor( window );
StoreImageAndColor( CHECK_BOX_HILITE, image, color, borderColor );
image = GadgetCheckBoxGetHiliteUncheckedBoxImage( window );
color = GadgetCheckBoxGetHiliteUncheckedBoxColor( window );
borderColor = GadgetCheckBoxGetHiliteUncheckedBoxBorderColor( window );
StoreImageAndColor( CHECK_BOX_HILITE_UNCHECKED_BOX, image, color, borderColor );
image = GadgetCheckBoxGetHiliteCheckedBoxImage( window );
color = GadgetCheckBoxGetHiliteCheckedBoxColor( window );
borderColor = GadgetCheckBoxGetHiliteCheckedBoxBorderColor( window );
StoreImageAndColor( CHECK_BOX_HILITE_CHECKED_BOX, image, color, borderColor );
// select the button enabled state for display
SwitchToState( CHECK_BOX_ENABLED, dialog );
//
// initialize the dialog with values from the window
//
return dialog;
} // end InitCheckBoxPropertiesDialog

View file

@ -0,0 +1,916 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: ColorDialog.cpp //////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: ColorDialog.cpp
//
// Created: Colin Day, March 1999
// Colin Day, July 2001
//
// Desc: Color picker dialog
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Resource.h"
#include "GUIEditColor.h"
#include "Properties.h"
#include "Common/Debug.h"
// DEFINES ////////////////////////////////////////////////////////////////////
#define MODE_RGB 0
#define MODE_HSV 1
///////////////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
static RGBColorInt selectedColor; // picked color
static Int mode = MODE_HSV; // color selection mode
static ICoord2D displayPos; // where to open window
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// rgbToHSV ===================================================================
// Converts the RGB colors passed in to HSV values
// RGB colors ranges from 0 - 1
// hue ranges from 0 - 360
// saturation and value ranges from 0 - 1
// ============================================================================
HSVColorReal rgbToHSV( RGBColorReal rgbColor )
{
Real max, min; // max and min of rgb
Real red, green, blue; // rgb alias
Real hue, saturation, value; // hsv alias
HSVColorReal hsvColor;
red = rgbColor.red;
green = rgbColor.green;
blue = rgbColor.blue;
// find the max and min of the rgb triplet
max = red;
if (green > max)
max = green;
if (blue > max)
max = blue;
min = red;
if (green < red)
min = green;
if (blue < min)
min = blue;
// set the value
value = max;
// calculate saturation
if (max != 0)
saturation = (max - min) / max;
else
saturation = 0; // saturation is 0 if all RGB are 0
// calculate hue
if (saturation == 0) {
hue = 0; // hue is really undefined
} // end if
else { // chromatic case, determine hue
Real delta = max - min;
if (red == max)
hue = (green - blue) / delta; // color between yellow and magenta
else if (green == max)
hue = 2 + (blue - red) / delta; // color between cyan and yellow
else if (blue == max)
hue = 4 + (red - green) / delta; // color between magenta and cyan
hue = hue * 60; // convert hue to degrees
if (hue < 0)
hue += 360; // make sure hue is non negative
} // end else, chromatic case, determine hue
// set and return an HSVColor
hsvColor.hue = hue;
hsvColor.saturation = saturation;
hsvColor.value = value;
// values aren't very nice to lets make them at least 1 ... isn't not
// technically correct but it works nicer for light color dialog
if (hsvColor.hue == 0.0f)
hsvColor.hue = 1.0f;
if (hsvColor.saturation == 0.0f)
hsvColor.saturation += 0.01f;
if (hsvColor.value == 0.0f)
hsvColor.value += 0.01f;
// copy over alpha
hsvColor.alpha = rgbColor.alpha;
return hsvColor;
} // end rgbToHSV
// hsvToRGB ===================================================================
// Converts the HSV colors passed in to RGB values
// RGB colors ranges from 0 - 1
// hue ranges from 0 - 360
// saturation and value ranges from 0 - 1
// ============================================================================
RGBColorReal hsvToRGB( HSVColorReal hsvColor )
{
Int i;
Real f, p, q, t;
Real red, green, blue; // rgb alias
Real hue, saturation, value; // hsv alias
RGBColorReal rgbColor;
hue = hsvColor.hue;
saturation = hsvColor.saturation;
value = hsvColor.value;
if( saturation == 0.0f )
{
// the colors is on the black and white center line
if( hue == 0.0f )
{ // achromatic color ... there is no hue
red = green = blue = value;
} // end if, achromatic color .. there is no hue
else
{
DEBUG_LOG(( "HSVToRGB error, hue should be undefined" ));
} // end else
} // end if
else
{
if( hue == 360.0f )
hue = 0.0f;
hue = hue / 60.0f; // h is now in [0, 6)
i = REAL_TO_INT_FLOOR(hue); // largest int <= h
f = hue - (Real) i; // f is the fractional part of h
p = value * (1.0f - saturation);
q = value * (1.0f - (saturation * f));
t = value * (1.0f - (saturation * (1.0f - f)));
switch (i) {
case 0:
red = value;
green = t;
blue = p;
break;
case 1:
red = q;
green = value;
blue = p;
break;
case 2:
red = p;
green = value;
blue = t;
break;
case 3:
red = p;
green = q;
blue = value;
break;
case 4:
red = t;
green = p;
blue = value;
break;
case 5:
red = value;
green = p;
blue = q;
break;
} // end switch (i)
} // end else, chromatic case
// store and return and RGB color
rgbColor.red = red;
rgbColor.green = green;
rgbColor.blue = blue;
rgbColor.alpha = hsvColor.alpha;
return rgbColor;
} // end hsvToRGB
// FORWARD DECLARATIONS ///////////////////////////////////////////////////////
BOOL CALLBACK SelectColorDlgProc( HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam );
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// SelectColor ================================================================
/** Bring up the color selection requestor.
*
* Returns:
* Pointer to selected color
* NULL for canceled request
*/
// ============================================================================
RGBColorInt *SelectColor( Int red, Int green, Int blue, Int alpha,
Int mouseX, Int mouseY )
{
selectedColor.red = red;
selectedColor.green = green;
selectedColor.blue = blue;
selectedColor.alpha = alpha;
displayPos.x = mouseX;
displayPos.y = mouseY;
if( DialogBox( TheEditor->getInstance(), (LPCTSTR)COLOR_SELECT_DIALOG,
TheEditor->getWindowHandle(), SelectColorDlgProc ) )
return &selectedColor;
else
return NULL;
} // end SelectColor
// SelectColorDlgProc =========================================================
/** Dialog procedure for color selector dialog */
// ============================================================================
BOOL CALLBACK SelectColorDlgProc( HWND hWndDlg, UINT uMsg,
WPARAM wParam, LPARAM lParam )
{
static HWND hWndScrollColor1; // red / hue
static HWND hWndScrollColor2; // green / saturation
static HWND hWndScrollColor3; // blue / value
static HWND hWndScrollAlpha; // alpha scrollbar
static HWND hWndColorBar1; // red / hue
static HWND hWndColorBar2; // green / saturation
static HWND hWndColorBar3; // blue / value
static HWND hWndPreview;
switch (uMsg) {
// ------------------------------------------------------------------------
case WM_INITDIALOG:
{
// save some window handles for later comparing during processing
hWndScrollColor1 = GetDlgItem( hWndDlg, SCROLL_COLOR1 );
hWndScrollColor2 = GetDlgItem( hWndDlg, SCROLL_COLOR2 );
hWndScrollColor3 = GetDlgItem( hWndDlg, SCROLL_COLOR3 );
hWndScrollAlpha = GetDlgItem( hWndDlg, SCROLL_ALPHA );
hWndColorBar1 = GetDlgItem( hWndDlg, BUTTON_COLORBAR1 );
hWndColorBar2 = GetDlgItem( hWndDlg, BUTTON_COLORBAR2 );
hWndColorBar3 = GetDlgItem( hWndDlg, BUTTON_COLORBAR3 );
hWndPreview = GetDlgItem (hWndDlg, BUTTON_PREVIEW);
// init the scroll bars and labels to the current color
if (mode == MODE_HSV)
{
RGBColorReal rgbColor;
HSVColorReal hsvColor;
rgbColor.red = (Real) selectedColor.red / 255.0f;
rgbColor.green = (Real) selectedColor.green / 255.0f;
rgbColor.blue = (Real) selectedColor.blue / 255.0f;
rgbColor.alpha = (Real) selectedColor.alpha;
hsvColor = rgbToHSV (rgbColor);
hsvColor.saturation *= 100.0f;
hsvColor.value *= 100.0f;
// init the HSV and intensity scroll bar extents
SendMessage( hWndScrollColor1, SBM_SETRANGE, 1, 360 );
SendMessage( hWndScrollColor2, SBM_SETRANGE, 1, 100 );
SendMessage( hWndScrollColor3, SBM_SETRANGE, 1, 100 );
SendMessage( hWndScrollAlpha, SBM_SETRANGE, 0, 255 );
// set the scroll bars and labels
SetScrollPos (hWndScrollColor1, SB_CTL, (Int) hsvColor.hue, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR1,
(Int) hsvColor.hue, FALSE);
SetScrollPos (hWndScrollColor2, SB_CTL, (Int) hsvColor.saturation, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR2,
(Int) hsvColor.saturation, FALSE);
SetScrollPos (hWndScrollColor3, SB_CTL, (Int) hsvColor.value, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR3,
(Int) hsvColor.value, FALSE);
SetScrollPos (hWndScrollAlpha, SB_CTL, (Int) hsvColor.alpha, TRUE);
SetDlgItemInt (hWndDlg, LABEL_ALPHA,
(Int) hsvColor.alpha, FALSE);
} // end if
else
{
// init the RGB and intensity scroll bar extents
SendMessage( hWndScrollColor1, SBM_SETRANGE, 1, 255 );
SendMessage( hWndScrollColor2, SBM_SETRANGE, 1, 255 );
SendMessage( hWndScrollColor3, SBM_SETRANGE, 1, 255 );
SendMessage( hWndScrollAlpha, SBM_SETRANGE, 0, 255 );
SetScrollPos (hWndScrollColor1, SB_CTL, selectedColor.red, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR1,
selectedColor.red, FALSE);
SetScrollPos (hWndScrollColor2, SB_CTL, selectedColor.green, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR2,
selectedColor.green, FALSE);
SetScrollPos (hWndScrollColor3, SB_CTL, selectedColor.blue, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR3,
selectedColor.blue, FALSE);
SetScrollPos (hWndScrollAlpha, SB_CTL, selectedColor.alpha, TRUE);
SetDlgItemInt (hWndDlg, LABEL_ALPHA,
selectedColor.alpha, FALSE);
} // end else
//
// move the window to the display position, but keep the whole
// window on the screen
//
PositionWindowOnScreen( hWndDlg, displayPos.x, displayPos.y );
return TRUE;
} // end case WM_INITDIALOG
// ------------------------------------------------------------------------
case WM_DRAWITEM: {
UINT idCtl = (UINT) wParam; // control identifier
LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT) lParam; // item drawing
HWND hWndControl;
RECT rect;
ICoord2D center;
Int radius;
// Get the area we have to draw in
hWndControl = GetDlgItem (hWndDlg, idCtl);
GetClientRect (hWndControl, &rect);
center.x = (rect.right - rect.left) / 2;
center.y = (rect.bottom - rect.top) / 2;
// record radius we have to work with
radius = (rect.right - rect.left) / 2;
switch (idCtl) {
case BUTTON_PREVIEW: {
RGBColorReal rgbColor;
HSVColorReal hsvColor;
HBRUSH hBrushOld, hBrushNew;
if (mode == MODE_RGB) {
rgbColor.red = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR1,
NULL, FALSE);
rgbColor.green = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR2,
NULL, FALSE);
rgbColor.blue = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR3,
NULL, FALSE);
} // end if
else {
hsvColor.hue = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR1,
NULL, FALSE);
hsvColor.saturation = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR2,
NULL, FALSE);
hsvColor.value = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR3,
NULL, FALSE);
// convert to ranges 0 - 1 for RGB conversion
hsvColor.saturation /= 100.0f;
hsvColor.value /= 100.0f;
rgbColor = hsvToRGB (hsvColor);
// convert RGB ranges to 0 - 255
rgbColor.red *= 255;
rgbColor.green *= 255;
rgbColor.blue *= 255;
} // end else
// create a new brush and select it into DC
hBrushNew = CreateSolidBrush (RGB ((BYTE) rgbColor.red,
(BYTE) rgbColor.green,
(BYTE) rgbColor.blue));
hBrushOld = (HBRUSH)SelectObject( lpdis->hDC, hBrushNew );
// draw the rectangle
Rectangle (lpdis->hDC, rect.left, rect.top,
rect.right, rect.bottom);
// put the old brush back and delete the new one
SelectObject (lpdis->hDC, hBrushOld);
DeleteObject (hBrushNew);
// validate this new area
ValidateRect (hWndControl, NULL);
break;
} // end case BUTTON_PREVIEW
// --------------------------------------------------------------------
// Draw the bar of either HUE or RED next to the scroll bar
// --------------------------------------------------------------------
case BUTTON_COLORBAR1: {
Real step;
Int x, y;
RGBColorReal rgbColor;
HSVColorReal hsvColor;
// compute how big of a red increment for each line as we step
// down the bar
if (mode == MODE_HSV)
step = 360.0f / (Real) (rect.right - rect.left);
else
step = 255.0f / (Real) (rect.right - rect.left);
// compute the first color, create pen for it, and save the
// original pen
if (mode == MODE_HSV) {
hsvColor.hue = 1;
hsvColor.saturation = 1;
hsvColor.value = 1;
rgbColor = hsvToRGB (hsvColor);
rgbColor.red *= 255.0f;
rgbColor.green *= 255.0f;
rgbColor.blue *= 255.0f;
} // end if
else {
rgbColor.red = 0;
rgbColor.green = 0;
rgbColor.blue = 0;
} // end else
// loop through each horizontal line available in the bar drawing
// the correct color there
for (x = 0; x < (rect.right - rect.left) - 1; x++) {
// draw a horizontal row of pixels with this color
for (y = 0; y < rect.bottom; y++)
SetPixel (lpdis->hDC, x, y, RGB ((BYTE) rgbColor.red,
(BYTE) rgbColor.green,
(BYTE) rgbColor.blue));
// increment the color, create new pen, and delete old pen
if (mode == MODE_HSV) {
hsvColor.hue += step;
rgbColor = hsvToRGB (hsvColor);
rgbColor.red *= 255;
rgbColor.green *= 255;
rgbColor.blue *= 255;
} // end if
else {
rgbColor.red += step;
} // end else
} // end for i
break;
} // end case BUTTON_COLORBAR1
// --------------------------------------------------------------------
// Draw the bar of either SATURATION or GREEN next to the scroll bar
// --------------------------------------------------------------------
case BUTTON_COLORBAR2: {
Real step;
Int x, y;
RGBColorReal rgbColor;
HSVColorReal hsvColor;
// compute how big of a increment for each line as we step
// down the bar
if (mode == MODE_HSV)
step = 1.0f / (Real) (rect.right - rect.left);
else
step = 255.0f / (Real) (rect.right - rect.left);
// compute the first color, create pen for it, and save the
// original pen
if (mode == MODE_HSV) {
hsvColor.hue = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR1,
NULL, FALSE);
hsvColor.saturation = 1.0f / 100.0f;
hsvColor.value = 1;
rgbColor = hsvToRGB (hsvColor);
rgbColor.red *= 255;
rgbColor.green *= 255;
rgbColor.blue *= 255;
} // end if
else {
rgbColor.red = 0;
rgbColor.green = 0;
rgbColor.blue = 0;
} // end else
// loop through each horizontal line available in the bar drawing
// the correct color there
for (x = 0; x < (rect.right - rect.left) - 1; x++) {
// draw a horizontal row of pixels with this color
for (y = 0; y < rect.bottom; y++)
SetPixel (lpdis->hDC, x, y, RGB ((BYTE) rgbColor.red,
(BYTE) rgbColor.green,
(BYTE) rgbColor.blue));
// increment the color, create new pen, and delete old pen
if (mode == MODE_HSV) {
hsvColor.saturation += step;
rgbColor = hsvToRGB (hsvColor);
rgbColor.red *= 255;
rgbColor.green *= 255;
rgbColor.blue *= 255;
} // end if
else {
rgbColor.green += step;
} // end else
} // end for i
break;
} // end case BUTTON_COLORBAR2
// --------------------------------------------------------------------
// Draw the bar of either VALUE or BLUE next to the scroll bar
// --------------------------------------------------------------------
case BUTTON_COLORBAR3: {
Real step;
Int x, y;
RGBColorReal rgbColor;
HSVColorReal hsvColor;
// compute how big of a increment for each line as we step
// down the bar
if (mode == MODE_HSV)
step = 1.0f / (Real) (rect.right - rect.left);
else
step = 255.0f / (Real) (rect.right - rect.left);
// compute the first color, create pen for it, and save the
// original pen
if (mode == MODE_HSV) {
hsvColor.hue = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR1,
NULL, FALSE);
hsvColor.saturation =
(Real) GetDlgItemInt (hWndDlg, LABEL_COLOR2, NULL, FALSE) / 100.0f;
hsvColor.value = 1.0f / 100.0f;
rgbColor = hsvToRGB (hsvColor);
rgbColor.red *= 255.0f;
rgbColor.green *= 255.0f;
rgbColor.blue *= 255.0f;
} // end if
else {
rgbColor.red = 0;
rgbColor.green = 0;
rgbColor.blue = 0;
} // end else
// loop through each horizontal line available in the bar drawing
// the correct color there
for (x = 0; x < (rect.right - rect.left) - 1; x++) {
// draw a horizontal row of pixels with this color
for (y = 0; y < rect.bottom; y++)
SetPixel (lpdis->hDC, x, y, RGB ((BYTE) rgbColor.red,
(BYTE) rgbColor.green,
(BYTE) rgbColor.blue));
// increment the color, create new pen, and delete old pen
if (mode == MODE_HSV) {
hsvColor.value += step;
rgbColor = hsvToRGB (hsvColor);
rgbColor.red *= 255;
rgbColor.green *= 255;
rgbColor.blue *= 255;
} // end if
else {
rgbColor.blue += step;
} // end else
} // end for i
break;
} // end case BUTTON_COLORBAR3
} // end switch
return TRUE;
} // end case WM_DRAWITEM
// ------------------------------------------------------------------------
// horizontal scrolling on the color bars
// ------------------------------------------------------------------------
case WM_HSCROLL:
{
Int nScrollCode = (Int) LOWORD (wParam); // scroll bar value
Short nPos = (Short) HIWORD (wParam); // for thumbtrack only
HWND hWndScroll = (HWND) lParam; // handle of scroll bar
Int labelID; // identifier of the text label for this scroll bar
Int thumbPos; // current thumb position
Int minPos, maxPos; // max and min of this scrollbar
// get the thumb position for the scrollbar
thumbPos = GetScrollPos (hWndScroll, SB_CTL);
// find out which scroll bar we're talking about and set the correct
// labelID for that control
if (hWndScroll == hWndScrollColor1)
labelID = LABEL_COLOR1;
else if (hWndScroll == hWndScrollColor2)
labelID = LABEL_COLOR2;
else if (hWndScroll == hWndScrollColor3)
labelID = LABEL_COLOR3;
else if( hWndScroll == hWndScrollAlpha )
labelID = LABEL_ALPHA;
// find the max and min extents for this scroll bar
SendMessage (hWndScroll, SBM_GETRANGE, (WPARAM) &minPos, (LPARAM) &maxPos);
switch (nScrollCode) {
case SB_LINELEFT: {
if (thumbPos > minPos)
thumbPos--;
break;
} // end case SB_LINELEFT
case SB_PAGELEFT: {
if (thumbPos - 45 >= minPos)
thumbPos -= 45;
else
thumbPos = minPos;
break;
} // end case SB_PAGELEFT
case SB_LINERIGHT: {
if (thumbPos < maxPos)
thumbPos++;
break;
} // end case SB_LINERIGHT
case SB_PAGERIGHT: {
if (thumbPos + 45 < maxPos)
thumbPos += 45;
else
thumbPos = maxPos;
break;
} // end case SB_PAGERIGHT
case SB_THUMBTRACK: {
thumbPos = nPos;
break;
} // end case SB_THUBTRACK
default: {
return 0;
} // end default
} // end switch nScrollCode
// set the new scrollbar position and the text with it
SendMessage (hWndScroll, SBM_SETPOS, (WPARAM) thumbPos, (LPARAM) TRUE);
SetDlgItemInt (hWndDlg, labelID, thumbPos, FALSE);
// if this was a color scroll bar, save the color change in
// the appropriate color bead
if (hWndScroll == hWndScrollColor1 ||
hWndScroll == hWndScrollColor2 ||
hWndScroll == hWndScrollColor3 ||
hWndScroll == hWndScrollAlpha )
{
RGBColorReal rgbColor;
HSVColorReal hsvColor;
if (mode == MODE_RGB) {
rgbColor.red = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR1,
NULL, FALSE);
rgbColor.green = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR2,
NULL, FALSE);
rgbColor.blue = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR3,
NULL, FALSE);
rgbColor.alpha = (Real) GetDlgItemInt( hWndDlg, LABEL_ALPHA,
NULL, FALSE );
} // end if
else {
hsvColor.hue = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR1,
NULL, FALSE);
hsvColor.saturation = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR2,
NULL, FALSE);
hsvColor.value = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR3,
NULL, FALSE);
hsvColor.alpha = (Real) GetDlgItemInt( hWndDlg, LABEL_ALPHA,
NULL, FALSE );
// convert to ranges 0 - 1 for RGB conversion
hsvColor.saturation /= 100.0f;
hsvColor.value /= 100.0f;
rgbColor = hsvToRGB (hsvColor);
// convert RGB ranges to 0 - 255
rgbColor.red *= 255;
rgbColor.green *= 255;
rgbColor.blue *= 255;
} // end else
// store the color
selectedColor.red = (Int) rgbColor.red;
selectedColor.green = (Int) rgbColor.green;
selectedColor.blue = (Int) rgbColor.blue;
selectedColor.alpha = (Int) rgbColor.alpha;
// force update of preview box
// invalidate the preview box to force an update of its color
InvalidateRect( hWndPreview, NULL, FALSE);
UpdateWindow (hWndPreview);
// force updates of the colorbars
InvalidateRect (hWndColorBar1, NULL, FALSE);
InvalidateRect (hWndColorBar2, NULL, FALSE);
InvalidateRect (hWndColorBar3, NULL, FALSE);
UpdateWindow (hWndColorBar1);
UpdateWindow (hWndColorBar2);
UpdateWindow (hWndColorBar3);
} // end if, color bar scroll message
return 0;
} // end case WM_HSCROLL
// ------------------------------------------------------------------------
case WM_COMMAND: {
// Int wNotifyCode = HIWORD(wParam); // notification code
Int wID = LOWORD(wParam); // id of control
// HWND hWndControl = (HWND) lParam; // handle of control
switch (wID) {
// --------------------------------------------------------------------
// color ok
// --------------------------------------------------------------------
case IDOK: {
EndDialog( hWndDlg, TRUE ); // color selected
break;
} // end case IDOK
// --------------------------------------------------------------------
case IDCANCEL: {
EndDialog( hWndDlg, FALSE ); // selection cancelled
break;
} // end case IDCANCEL
// --------------------------------------------------------------------
// Change from RGB mode to HSV mode and vice versa
// --------------------------------------------------------------------
case BUTTON_RGB_HSV: {
HWND hWndScroll;
RGBColorReal rgbColor;
HSVColorReal hsvColor;
if (mode == MODE_RGB) { // switch to HSV
rgbColor.red = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR1, NULL, FALSE);
rgbColor.green = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR2, NULL, FALSE);
rgbColor.blue = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR3, NULL, FALSE);
// convert rgb to range 0 - 1
rgbColor.red /= 255.0f;
rgbColor.green /= 255.0f;
rgbColor.blue /= 255.0f;
// convert the RGB to HSV
hsvColor = rgbToHSV (rgbColor);
// turn saturation and value to 0 - 100 ranges
hsvColor.saturation *= 100.0f;
hsvColor.value *= 100.0f;
// change the scrollbar extents and positions
hWndScroll = GetDlgItem (hWndDlg, SCROLL_COLOR1);
SetScrollRange (hWndScroll, SB_CTL, 1, 360, FALSE);
SetScrollPos (hWndScroll, SB_CTL, (Int) hsvColor.hue, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR1, (Int) hsvColor.hue, FALSE);
hWndScroll = GetDlgItem (hWndDlg, SCROLL_COLOR2);
SetScrollRange (hWndScroll, SB_CTL, 1, 100, FALSE);
SetScrollPos (hWndScroll, SB_CTL, (Int) hsvColor.saturation, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR2, (Int) hsvColor.saturation, FALSE);
hWndScroll = GetDlgItem (hWndDlg, SCROLL_COLOR3);
SetScrollRange (hWndScroll, SB_CTL, 1, 100, FALSE);
SetScrollPos (hWndScroll, SB_CTL, (Int) hsvColor.value, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR3, (Int) hsvColor.value, FALSE);
mode = MODE_HSV;
// change the text for the button
SetWindowText (GetDlgItem (hWndDlg, BUTTON_RGB_HSV),
"Switch to RGB");
} // end if, switch to HSV
else { // switch to RGB
hsvColor.hue = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR1, NULL, FALSE);
hsvColor.saturation = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR2, NULL, FALSE);
hsvColor.value = (Real) GetDlgItemInt (hWndDlg, LABEL_COLOR3, NULL, FALSE);
// convert saturation and value to range 0 - 1
hsvColor.saturation /= 100.0f;
hsvColor.value /= 100.0f;
// convert the HSV to RGB
rgbColor = hsvToRGB (hsvColor);
// turn the rgb into 0 - 255 range
rgbColor.red *= 255.0f;
rgbColor.green *= 255.0f;
rgbColor.blue *= 255.0f;
// change the scrollbar extents and positions
hWndScroll = GetDlgItem (hWndDlg, SCROLL_COLOR1);
SetScrollRange (hWndScroll, SB_CTL, 1, 255, FALSE);
SetScrollPos (hWndScroll, SB_CTL, (Int) rgbColor.red, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR1, (Int) rgbColor.red, FALSE);
hWndScroll = GetDlgItem (hWndDlg, SCROLL_COLOR2);
SetScrollRange (hWndScroll, SB_CTL, 1, 255, FALSE);
SetScrollPos (hWndScroll, SB_CTL, (Int) rgbColor.green, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR2, (Int) rgbColor.green, FALSE);
hWndScroll = GetDlgItem (hWndDlg, SCROLL_COLOR3);
SetScrollRange (hWndScroll, SB_CTL, 1, 255, FALSE);
SetScrollPos (hWndScroll, SB_CTL, (Int) rgbColor.blue, TRUE);
SetDlgItemInt (hWndDlg, LABEL_COLOR3, (Int) rgbColor.blue, FALSE);
// change the text for the button
SetWindowText (GetDlgItem (hWndDlg, BUTTON_RGB_HSV),
"Switch to HSV");
mode = MODE_RGB;
} // end else, switch to RGB
// invalidate all the vertical color bars so they are redrawn
InvalidateRect (hWndColorBar1, NULL, TRUE);
InvalidateRect (hWndColorBar2, NULL, TRUE);
InvalidateRect (hWndColorBar3, NULL, TRUE);
} // end case BUTTON_RGB_HSV
} // end switch (LOWORD (wParam))
return 0;
} // end case WM_COMMAND
// ------------------------------------------------------------------------
// Only hide the window on a close rather than destroy it since it will
// probably be needed again.
// ------------------------------------------------------------------------
case WM_CLOSE:
ShowWindow(hWndDlg, SW_HIDE);
return 0;
default:
return 0; // for all messages that are not processed
} // end of switch (uMsg)
} // End of SelectColor

View file

@ -0,0 +1,983 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: ComboBoxProperties.cpp ////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: ComboBoxProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: ComboBox properties dialog
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Properties.h"
#include "LayoutScheme.h"
#include "Resource.h"
#include "GameClient/GadgetComboBox.h"
#include "GameClient/GadgetListBox.h"
#include "GameClient/GadgetSlider.h"
#include "GameClient/GadgetPushButton.h"
#include "GameClient/GadgetTextEntry.h"
#include "GameClient/GameWindowManager.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// comboBoxPropertiesCallback ==================================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK comboBoxPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_SUBCONTROL_COLOR:
{
ImageAndColorInfo *info;
//
// using the current colors in the base of the comboBox, assign a
// reasonable color scheme to all the sub control components
//
info = GetStateInfo( COMBOBOX_ENABLED );
StoreColor( COMBOBOX_LISTBOX_ENABLED, info->color, info->borderColor );
StoreColor( COMBOBOX_DROP_DOWN_BUTTON_ENABLED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_TOP, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED, info->color, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_LEFT );
StoreColor( COMBOBOX_EDIT_BOX_ENABLED_LEFT, info->color, info->borderColor );
StoreColor( COMBOBOX_DROP_DOWN_BUTTON_ENABLED_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_LEFT, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED_PUSHED, info->color, info->borderColor );
info = GetStateInfo( COMBOBOX_DISABLED );
StoreColor( COMBOBOX_DROP_DOWN_BUTTON_DISABLED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_DISABLED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_TOP, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED, info->color, info->borderColor );
info = GetStateInfo( COMBOBOX_DISABLED_SELECTED_ITEM_LEFT );
StoreColor( COMBOBOX_EDIT_BOX_DISABLED_LEFT, info->color, info->borderColor );
StoreColor( COMBOBOX_DROP_DOWN_BUTTON_DISABLED_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_LEFT, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED_PUSHED, info->color, info->borderColor );
info = GetStateInfo( COMBOBOX_HILITE );
StoreColor( COMBOBOX_DROP_DOWN_BUTTON_HILITE, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_HILITE, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_UP_BUTTON_HILITE, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_HILITE_TOP, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE, info->color, info->borderColor );
info = GetStateInfo( COMBOBOX_HILITE_SELECTED_ITEM_LEFT );
StoreColor( COMBOBOX_DROP_DOWN_BUTTON_HILITE_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_EDIT_BOX_HILITE_LEFT, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_LEFT, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_UP_BUTTON_HILITE_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE_PUSHED, info->color, info->borderColor );
StoreColor( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE_PUSHED, info->color, info->borderColor );
break;
} // end case subcontrol color
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_ENABLED );
GadgetComboBoxSetEnabledImage( window, info->image );
GadgetComboBoxSetEnabledColor( window, info->color );
GadgetComboBoxSetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( COMBOBOX_ENABLED_SELECTED_ITEM_LEFT );
GadgetComboBoxSetEnabledSelectedItemImageLeft( window, info->image );
GadgetComboBoxSetEnabledSelectedItemColor( window, info->color );
GadgetComboBoxSetEnabledSelectedItemBorderColor( window, info->borderColor );
info = GetStateInfo( COMBOBOX_ENABLED_SELECTED_ITEM_RIGHT );
GadgetComboBoxSetEnabledSelectedItemImageRight( window, info->image );
info = GetStateInfo( COMBOBOX_ENABLED_SELECTED_ITEM_CENTER );
GadgetComboBoxSetEnabledSelectedItemImageCenter( window, info->image );
info = GetStateInfo( COMBOBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
GadgetComboBoxSetEnabledSelectedItemImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_DISABLED );
GadgetComboBoxSetDisabledImage( window, info->image );
GadgetComboBoxSetDisabledColor( window, info->color );
GadgetComboBoxSetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( COMBOBOX_DISABLED_SELECTED_ITEM_LEFT );
GadgetComboBoxSetDisabledSelectedItemImageLeft( window, info->image );
GadgetComboBoxSetDisabledSelectedItemColor( window, info->color );
GadgetComboBoxSetDisabledSelectedItemBorderColor( window, info->borderColor );
info = GetStateInfo( COMBOBOX_DISABLED_SELECTED_ITEM_RIGHT );
GadgetComboBoxSetDisabledSelectedItemImageRight( window, info->image );
info = GetStateInfo( COMBOBOX_DISABLED_SELECTED_ITEM_CENTER );
GadgetComboBoxSetDisabledSelectedItemImageCenter( window, info->image );
info = GetStateInfo( COMBOBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
GadgetComboBoxSetDisabledSelectedItemImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_HILITE );
GadgetComboBoxSetHiliteImage( window, info->image );
GadgetComboBoxSetHiliteColor( window, info->color );
GadgetComboBoxSetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( COMBOBOX_HILITE_SELECTED_ITEM_LEFT );
GadgetComboBoxSetHiliteSelectedItemImageLeft( window, info->image );
GadgetComboBoxSetHiliteSelectedItemColor( window, info->color );
GadgetComboBoxSetHiliteSelectedItemBorderColor( window, info->borderColor );
info = GetStateInfo( COMBOBOX_HILITE_SELECTED_ITEM_RIGHT );
GadgetComboBoxSetHiliteSelectedItemImageRight( window, info->image );
info = GetStateInfo( COMBOBOX_HILITE_SELECTED_ITEM_CENTER );
GadgetComboBoxSetHiliteSelectedItemImageCenter( window, info->image );
info = GetStateInfo( COMBOBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
GadgetComboBoxSetHiliteSelectedItemImageSmallCenter( window, info->image );
GameWindow *dropDownButton = GadgetComboBoxGetDropDownButton( window );
if (dropDownButton)
{
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_DROP_DOWN_BUTTON_ENABLED );
GadgetButtonSetEnabledImage( dropDownButton, info->image );
GadgetButtonSetEnabledColor( dropDownButton, info->color );
GadgetButtonSetEnabledBorderColor( dropDownButton, info->borderColor );
info = GetStateInfo( COMBOBOX_DROP_DOWN_BUTTON_ENABLED_PUSHED );
GadgetButtonSetEnabledSelectedImage( dropDownButton, info->image );
GadgetButtonSetEnabledSelectedColor( dropDownButton, info->color );
GadgetButtonSetEnabledSelectedBorderColor( dropDownButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_DROP_DOWN_BUTTON_DISABLED );
GadgetButtonSetDisabledImage( dropDownButton, info->image );
GadgetButtonSetDisabledColor( dropDownButton, info->color );
GadgetButtonSetDisabledBorderColor( dropDownButton, info->borderColor );
info = GetStateInfo( COMBOBOX_DROP_DOWN_BUTTON_DISABLED_PUSHED );
GadgetButtonSetDisabledSelectedImage( dropDownButton, info->image );
GadgetButtonSetDisabledSelectedColor( dropDownButton, info->color );
GadgetButtonSetDisabledSelectedBorderColor( dropDownButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_DROP_DOWN_BUTTON_HILITE );
GadgetButtonSetHiliteImage( dropDownButton, info->image );
GadgetButtonSetHiliteColor( dropDownButton, info->color );
GadgetButtonSetHiliteBorderColor( dropDownButton, info->borderColor );
info = GetStateInfo( COMBOBOX_DROP_DOWN_BUTTON_HILITE_PUSHED );
GadgetButtonSetHiliteSelectedImage( dropDownButton, info->image );
GadgetButtonSetHiliteSelectedColor( dropDownButton, info->color );
GadgetButtonSetHiliteSelectedBorderColor( dropDownButton, info->borderColor );
}
GameWindow *editBox = GadgetComboBoxGetEditBox( window );
if (editBox)
{
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_EDIT_BOX_ENABLED_LEFT );
GadgetTextEntrySetEnabledImageLeft( editBox, info->image );
GadgetTextEntrySetEnabledColor( editBox, info->color );
GadgetTextEntrySetEnabledBorderColor( editBox, info->borderColor );
info = GetStateInfo( COMBOBOX_EDIT_BOX_ENABLED_RIGHT );
GadgetTextEntrySetEnabledImageRight( editBox, info->image );
info = GetStateInfo( COMBOBOX_EDIT_BOX_ENABLED_CENTER );
GadgetTextEntrySetEnabledImageCenter( editBox, info->image );
info = GetStateInfo( COMBOBOX_EDIT_BOX_ENABLED_SMALL_CENTER );
GadgetTextEntrySetEnabledImageSmallCenter( editBox, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_EDIT_BOX_DISABLED_LEFT );
GadgetTextEntrySetDisabledImageLeft( editBox, info->image );
GadgetTextEntrySetDisabledColor( editBox, info->color );
GadgetTextEntrySetDisabledBorderColor( editBox, info->borderColor );
info = GetStateInfo( COMBOBOX_EDIT_BOX_DISABLED_RIGHT );
GadgetTextEntrySetDisabledImageRight( editBox, info->image );
info = GetStateInfo( COMBOBOX_EDIT_BOX_DISABLED_CENTER );
GadgetTextEntrySetDisabledImageCenter( editBox, info->image );
info = GetStateInfo( COMBOBOX_EDIT_BOX_DISABLED_SMALL_CENTER );
GadgetTextEntrySetDisabledImageSmallCenter( editBox, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_EDIT_BOX_HILITE_LEFT );
GadgetTextEntrySetHiliteImageLeft( editBox, info->image );
GadgetTextEntrySetHiliteColor( editBox, info->color );
GadgetTextEntrySetHiliteBorderColor( editBox, info->borderColor );
info = GetStateInfo( COMBOBOX_EDIT_BOX_HILITE_RIGHT );
GadgetTextEntrySetHiliteImageRight( editBox, info->image );
info = GetStateInfo( COMBOBOX_EDIT_BOX_HILITE_CENTER );
GadgetTextEntrySetHiliteImageCenter( editBox, info->image );
info = GetStateInfo( COMBOBOX_EDIT_BOX_HILITE_SMALL_CENTER );
GadgetTextEntrySetHiliteImageSmallCenter( editBox, info->image );
}
GameWindow *listBox = GadgetComboBoxGetListBox( window );
if (listBox)
{
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_ENABLED );
GadgetListBoxSetEnabledImage( listBox, info->image );
GadgetListBoxSetEnabledColor( listBox, info->color );
GadgetListBoxSetEnabledBorderColor( listBox, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_LEFT );
GadgetListBoxSetEnabledSelectedItemImageLeft( listBox, info->image );
GadgetListBoxSetEnabledSelectedItemColor( listBox, info->color );
GadgetListBoxSetEnabledSelectedItemBorderColor( listBox, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_RIGHT );
GadgetListBoxSetEnabledSelectedItemImageRight( listBox, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_CENTER );
GadgetListBoxSetEnabledSelectedItemImageCenter( listBox, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
GadgetListBoxSetEnabledSelectedItemImageSmallCenter( listBox, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_DISABLED );
GadgetListBoxSetDisabledImage( listBox, info->image );
GadgetListBoxSetDisabledColor( listBox, info->color );
GadgetListBoxSetDisabledBorderColor( listBox, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_LEFT );
GadgetListBoxSetDisabledSelectedItemImageLeft( listBox, info->image );
GadgetListBoxSetDisabledSelectedItemColor( listBox, info->color );
GadgetListBoxSetDisabledSelectedItemBorderColor( listBox, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_RIGHT );
GadgetListBoxSetDisabledSelectedItemImageRight( listBox, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_CENTER );
GadgetListBoxSetDisabledSelectedItemImageCenter( listBox, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
GadgetListBoxSetDisabledSelectedItemImageSmallCenter( listBox, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_HILITE );
GadgetListBoxSetHiliteImage( listBox, info->image );
GadgetListBoxSetHiliteColor( listBox, info->color );
GadgetListBoxSetHiliteBorderColor( listBox, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_LEFT );
GadgetListBoxSetHiliteSelectedItemImageLeft( listBox, info->image );
GadgetListBoxSetHiliteSelectedItemColor( listBox, info->color );
GadgetListBoxSetHiliteSelectedItemBorderColor( listBox, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_RIGHT );
GadgetListBoxSetHiliteSelectedItemImageRight( listBox, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_CENTER );
GadgetListBoxSetHiliteSelectedItemImageCenter( listBox, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
GadgetListBoxSetHiliteSelectedItemImageSmallCenter( listBox, info->image );
// up button
GameWindow *upButton = GadgetListBoxGetUpButton( listBox );
if( upButton )
{
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED );
GadgetButtonSetEnabledImage( upButton, info->image );
GadgetButtonSetEnabledColor( upButton, info->color );
GadgetButtonSetEnabledBorderColor( upButton, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED_PUSHED );
GadgetButtonSetEnabledSelectedImage( upButton, info->image );
GadgetButtonSetEnabledSelectedColor( upButton, info->color );
GadgetButtonSetEnabledSelectedBorderColor( upButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED );
GadgetButtonSetDisabledImage( upButton, info->image );
GadgetButtonSetDisabledColor( upButton, info->color );
GadgetButtonSetDisabledBorderColor( upButton, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED_PUSHED );
GadgetButtonSetDisabledSelectedImage( upButton, info->image );
GadgetButtonSetDisabledSelectedColor( upButton, info->color );
GadgetButtonSetDisabledSelectedBorderColor( upButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_UP_BUTTON_HILITE );
GadgetButtonSetHiliteImage( upButton, info->image );
GadgetButtonSetHiliteColor( upButton, info->color );
GadgetButtonSetHiliteBorderColor( upButton, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_UP_BUTTON_HILITE_PUSHED );
GadgetButtonSetHiliteSelectedImage( upButton, info->image );
GadgetButtonSetHiliteSelectedColor( upButton, info->color );
GadgetButtonSetHiliteSelectedBorderColor( upButton, info->borderColor );
} // end if
// down button
GameWindow *downButton = GadgetListBoxGetDownButton( listBox );
if( downButton )
{
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED );
GadgetButtonSetEnabledImage( downButton, info->image );
GadgetButtonSetEnabledColor( downButton, info->color );
GadgetButtonSetEnabledBorderColor( downButton, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED_PUSHED );
GadgetButtonSetEnabledSelectedImage( downButton, info->image );
GadgetButtonSetEnabledSelectedColor( downButton, info->color );
GadgetButtonSetEnabledSelectedBorderColor( downButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED );
GadgetButtonSetDisabledImage( downButton, info->image );
GadgetButtonSetDisabledColor( downButton, info->color );
GadgetButtonSetDisabledBorderColor( downButton, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED_PUSHED );
GadgetButtonSetDisabledSelectedImage( downButton, info->image );
GadgetButtonSetDisabledSelectedColor( downButton, info->color );
GadgetButtonSetDisabledSelectedBorderColor( downButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE );
GadgetButtonSetHiliteImage( downButton, info->image );
GadgetButtonSetHiliteColor( downButton, info->color );
GadgetButtonSetHiliteBorderColor( downButton, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE_PUSHED );
GadgetButtonSetHiliteSelectedImage( downButton, info->image );
GadgetButtonSetHiliteSelectedColor( downButton, info->color );
GadgetButtonSetHiliteSelectedBorderColor( downButton, info->borderColor );
} // end if
// slider
GameWindow *slider = GadgetListBoxGetSlider( listBox );
if( slider )
{
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_ENABLED_TOP );
GadgetSliderSetEnabledImageTop( slider, info->image );
GadgetSliderSetEnabledColor( slider, info->color );
GadgetSliderSetEnabledBorderColor( slider, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_ENABLED_BOTTOM );
GadgetSliderSetEnabledImageBottom( slider, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_ENABLED_CENTER );
GadgetSliderSetEnabledImageCenter( slider, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_ENABLED_SMALL_CENTER );
GadgetSliderSetEnabledImageSmallCenter( slider, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_DISABLED_TOP );
GadgetSliderSetDisabledImageTop( slider, info->image );
GadgetSliderSetDisabledColor( slider, info->color );
GadgetSliderSetDisabledBorderColor( slider, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_DISABLED_BOTTOM );
GadgetSliderSetDisabledImageBottom( slider, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_DISABLED_CENTER );
GadgetSliderSetDisabledImageCenter( slider, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_DISABLED_SMALL_CENTER );
GadgetSliderSetDisabledImageSmallCenter( slider, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_HILITE_TOP );
GadgetSliderSetHiliteImageTop( slider, info->image );
GadgetSliderSetHiliteColor( slider, info->color );
GadgetSliderSetHiliteBorderColor( slider, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_HILITE_BOTTOM );
GadgetSliderSetHiliteImageBottom( slider, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_HILITE_CENTER );
GadgetSliderSetHiliteImageCenter( slider, info->image );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_HILITE_SMALL_CENTER );
GadgetSliderSetHiliteImageSmallCenter( slider, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED );
GadgetSliderSetEnabledThumbImage( slider, info->image );
GadgetSliderSetEnabledThumbColor( slider, info->color );
GadgetSliderSetEnabledThumbBorderColor( slider, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED_PUSHED );
GadgetSliderSetEnabledSelectedThumbImage( slider, info->image );
GadgetSliderSetEnabledSelectedThumbColor( slider, info->color );
GadgetSliderSetEnabledSelectedThumbBorderColor( slider, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED );
GadgetSliderSetDisabledThumbImage( slider, info->image );
GadgetSliderSetDisabledThumbColor( slider, info->color );
GadgetSliderSetDisabledThumbBorderColor( slider, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED_PUSHED );
GadgetSliderSetDisabledSelectedThumbImage( slider, info->image );
GadgetSliderSetDisabledSelectedThumbColor( slider, info->color );
GadgetSliderSetDisabledSelectedThumbBorderColor( slider, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE );
GadgetSliderSetHiliteThumbImage( slider, info->image );
GadgetSliderSetHiliteThumbColor( slider, info->color );
GadgetSliderSetHiliteThumbBorderColor( slider, info->borderColor );
info = GetStateInfo( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE_PUSHED );
GadgetSliderSetHiliteSelectedThumbImage( slider, info->image );
GadgetSliderSetHiliteSelectedThumbColor( slider, info->color );
GadgetSliderSetHiliteSelectedThumbBorderColor( slider, info->borderColor );
} // end if
} // end if (listBox)
// save specific list data
ComboBoxData *comboData = (ComboBoxData *)window->winGetUserData();
GadgetComboBoxSetIsEditable(window, IsDlgButtonChecked( hWndDialog, CHECK_IS_EDITABLE ));
GadgetComboBoxSetAsciiOnly(window, IsDlgButtonChecked( hWndDialog, CHECK_ASCII_TEXT ));
GadgetComboBoxSetLettersAndNumbersOnly(window, IsDlgButtonChecked( hWndDialog, CHECK_LETTERS_AND_NUMBERS ));
// change in the size of the comboBox
Int newMaxChars = GetDlgItemInt( hWndDialog, EDIT_MAX_CHARS, NULL, FALSE );
if( newMaxChars != comboData->maxChars)
GadgetComboBoxSetMaxChars( window, newMaxChars );
Int newMaxDisplay = GetDlgItemInt( hWndDialog, EDIT_MAX_ITEMS_DISPLAYED, NULL, FALSE );
if( newMaxDisplay != comboData->maxDisplay )
GadgetComboBoxSetMaxDisplay( window, newMaxDisplay );
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end comboBoxPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitComboBoxPropertiesDialog ================================================
/** Bring up the comboBox properties window */
//=============================================================================
HWND InitComboBoxPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)COMBO_BOX_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)comboBoxPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// store in the image and color table the values for this combo Box
//
const Image *image;
Color color, borderColor;
// --------------------------------------------------------------------------
image = GadgetComboBoxGetEnabledImage( window );
color = GadgetComboBoxGetEnabledColor( window );
borderColor = GadgetComboBoxGetEnabledBorderColor( window );
StoreImageAndColor( COMBOBOX_ENABLED, image, color, borderColor );
image = GadgetComboBoxGetEnabledSelectedItemImageLeft( window );
color = GadgetComboBoxGetEnabledSelectedItemColor( window );
borderColor = GadgetComboBoxGetEnabledSelectedItemBorderColor( window );
StoreImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetComboBoxGetEnabledSelectedItemImageRight( window );
StoreImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetComboBoxGetEnabledSelectedItemImageCenter( window );
StoreImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetComboBoxGetEnabledSelectedItemImageSmallCenter( window );
StoreImageAndColor( COMBOBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetComboBoxGetDisabledImage( window );
color = GadgetComboBoxGetDisabledColor( window );
borderColor = GadgetComboBoxGetDisabledBorderColor( window );
StoreImageAndColor( COMBOBOX_DISABLED, image, color, borderColor );
image = GadgetComboBoxGetDisabledSelectedItemImageLeft( window );
color = GadgetComboBoxGetDisabledSelectedItemColor( window );
borderColor = GadgetComboBoxGetDisabledSelectedItemBorderColor( window );
StoreImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetComboBoxGetDisabledSelectedItemImageRight( window );
StoreImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetComboBoxGetDisabledSelectedItemImageCenter( window );
StoreImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetComboBoxGetDisabledSelectedItemImageSmallCenter( window );
StoreImageAndColor( COMBOBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetComboBoxGetHiliteImage( window );
color = GadgetComboBoxGetHiliteColor( window );
borderColor = GadgetComboBoxGetHiliteBorderColor( window );
StoreImageAndColor( COMBOBOX_HILITE, image, color, borderColor );
image = GadgetComboBoxGetHiliteSelectedItemImageLeft( window );
color = GadgetComboBoxGetHiliteSelectedItemColor( window );
borderColor = GadgetComboBoxGetHiliteSelectedItemBorderColor( window );
StoreImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetComboBoxGetHiliteSelectedItemImageRight( window );
StoreImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetComboBoxGetHiliteSelectedItemImageCenter( window );
StoreImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetComboBoxGetHiliteSelectedItemImageSmallCenter( window );
StoreImageAndColor( COMBOBOX_HILITE_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
GameWindow *listBox = GadgetComboBoxGetListBox( window );
if (listBox)
{
image = GadgetListBoxGetEnabledSelectedItemImageLeft( listBox );
color = GadgetListBoxGetEnabledSelectedItemColor( listBox );
borderColor = GadgetListBoxGetEnabledSelectedItemBorderColor( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetListBoxGetEnabledSelectedItemImageRight( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetEnabledSelectedItemImageCenter( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetEnabledSelectedItemImageSmallCenter( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetListBoxGetDisabledImage( listBox );
color = GadgetListBoxGetDisabledColor( listBox );
borderColor = GadgetListBoxGetDisabledBorderColor( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_DISABLED, image, color, borderColor );
image = GadgetListBoxGetDisabledSelectedItemImageLeft( listBox );
color = GadgetListBoxGetDisabledSelectedItemColor( listBox );
borderColor = GadgetListBoxGetDisabledSelectedItemBorderColor( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetListBoxGetDisabledSelectedItemImageRight( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetDisabledSelectedItemImageCenter( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetDisabledSelectedItemImageSmallCenter( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetListBoxGetHiliteImage( listBox );
color = GadgetListBoxGetHiliteColor( listBox );
borderColor = GadgetListBoxGetHiliteBorderColor( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_HILITE, image, color, borderColor );
image = GadgetListBoxGetHiliteSelectedItemImageLeft( listBox );
color = GadgetListBoxGetHiliteSelectedItemColor( listBox );
borderColor = GadgetListBoxGetHiliteSelectedItemBorderColor( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetListBoxGetHiliteSelectedItemImageRight( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetHiliteSelectedItemImageCenter( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetHiliteSelectedItemImageSmallCenter( listBox );
StoreImageAndColor( COMBOBOX_LISTBOX_HILITE_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
GameWindow *upButton = GadgetListBoxGetUpButton( listBox );
if( upButton )
{
// ------------------------------------------------------------------------
image = GadgetButtonGetEnabledImage( upButton );
color = GadgetButtonGetEnabledColor( upButton );
borderColor = GadgetButtonGetEnabledBorderColor( upButton );
StoreImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED, image, color, borderColor );
image = GadgetButtonGetEnabledSelectedImage( upButton );
color = GadgetButtonGetEnabledSelectedColor( upButton );
borderColor = GadgetButtonGetEnabledSelectedBorderColor( upButton );
StoreImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_ENABLED_PUSHED, image, color, borderColor );
// ------------------------------------------------------------------------
image = GadgetButtonGetDisabledImage( upButton );
color = GadgetButtonGetDisabledColor( upButton );
borderColor = GadgetButtonGetDisabledBorderColor( upButton );
StoreImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED, image, color, borderColor );
image = GadgetButtonGetDisabledSelectedImage( upButton );
color = GadgetButtonGetDisabledSelectedColor( upButton );
borderColor = GadgetButtonGetDisabledSelectedBorderColor( upButton );
StoreImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_DISABLED_PUSHED, image, color, borderColor );
// ------------------------------------------------------------------------
image = GadgetButtonGetHiliteImage( upButton );
color = GadgetButtonGetHiliteColor( upButton );
borderColor = GadgetButtonGetHiliteBorderColor( upButton );
StoreImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_HILITE, image, color, borderColor );
image = GadgetButtonGetHiliteSelectedImage( upButton );
color = GadgetButtonGetHiliteSelectedColor( upButton );
borderColor = GadgetButtonGetHiliteSelectedBorderColor( upButton );
StoreImageAndColor( COMBOBOX_LISTBOX_UP_BUTTON_HILITE_PUSHED, image, color, borderColor );
} // end if
// --------------------------------------------------------------------------
GameWindow *downButton = GadgetListBoxGetDownButton( listBox );
if( downButton )
{
// ------------------------------------------------------------------------
image = GadgetButtonGetEnabledImage( downButton );
color = GadgetButtonGetEnabledColor( downButton );
borderColor = GadgetButtonGetEnabledBorderColor( downButton );
StoreImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED, image, color, borderColor );
image = GadgetButtonGetEnabledSelectedImage( downButton );
color = GadgetButtonGetEnabledSelectedColor( downButton );
borderColor = GadgetButtonGetEnabledSelectedBorderColor( downButton );
StoreImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_ENABLED_PUSHED, image, color, borderColor );
// ------------------------------------------------------------------------
image = GadgetButtonGetDisabledImage( downButton );
color = GadgetButtonGetDisabledColor( downButton );
borderColor = GadgetButtonGetDisabledBorderColor( downButton );
StoreImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED, image, color, borderColor );
image = GadgetButtonGetDisabledSelectedImage( downButton );
color = GadgetButtonGetDisabledSelectedColor( downButton );
borderColor = GadgetButtonGetDisabledSelectedBorderColor( downButton );
StoreImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_DISABLED_PUSHED, image, color, borderColor );
// ------------------------------------------------------------------------
image = GadgetButtonGetHiliteImage( downButton );
color = GadgetButtonGetHiliteColor( downButton );
borderColor = GadgetButtonGetHiliteBorderColor( downButton );
StoreImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE, image, color, borderColor );
image = GadgetButtonGetHiliteSelectedImage( downButton );
color = GadgetButtonGetHiliteSelectedColor( downButton );
borderColor = GadgetButtonGetHiliteSelectedBorderColor( downButton );
StoreImageAndColor( COMBOBOX_LISTBOX_DOWN_BUTTON_HILITE_PUSHED, image, color, borderColor );
} // end if
GameWindow *slider = GadgetListBoxGetSlider( listBox );
if( slider )
{
// --------------------------------------------------------------------------
image = GadgetSliderGetEnabledImageTop( slider );
color = GadgetSliderGetEnabledColor( slider );
borderColor = GadgetSliderGetEnabledBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_TOP, image, color, borderColor );
image = GadgetSliderGetEnabledImageBottom( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_BOTTOM, image, color, borderColor );
image = GadgetSliderGetEnabledImageCenter( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_CENTER, image, color, borderColor );
image = GadgetSliderGetEnabledImageSmallCenter( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_ENABLED_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetDisabledImageTop( slider );
color = GadgetSliderGetDisabledColor( slider );
borderColor = GadgetSliderGetDisabledBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_TOP, image, color, borderColor );
image = GadgetSliderGetDisabledImageBottom( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_BOTTOM, image, color, borderColor );
image = GadgetSliderGetDisabledImageCenter( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_CENTER, image, color, borderColor );
image = GadgetSliderGetDisabledImageSmallCenter( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_DISABLED_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetHiliteImageTop( slider );
color = GadgetSliderGetHiliteColor( slider );
borderColor = GadgetSliderGetHiliteBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_TOP, image, color, borderColor );
image = GadgetSliderGetHiliteImageBottom( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_BOTTOM, image, color, borderColor );
image = GadgetSliderGetHiliteImageCenter( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_CENTER, image, color, borderColor );
image = GadgetSliderGetHiliteImageSmallCenter( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_HILITE_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetEnabledThumbImage( slider );
color = GadgetSliderGetEnabledThumbColor( slider );
borderColor = GadgetSliderGetEnabledThumbBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED, image, color, borderColor );
image = GadgetSliderGetEnabledSelectedThumbImage( slider );
color = GadgetSliderGetEnabledSelectedThumbColor( slider );
borderColor = GadgetSliderGetEnabledSelectedThumbBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_ENABLED_PUSHED, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetDisabledThumbImage( slider );
color = GadgetSliderGetDisabledThumbColor( slider );
borderColor = GadgetSliderGetDisabledThumbBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED, image, color, borderColor );
image = GadgetSliderGetDisabledSelectedThumbImage( slider );
color = GadgetSliderGetDisabledSelectedThumbColor( slider );
borderColor = GadgetSliderGetDisabledSelectedThumbBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_DISABLED_PUSHED, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetHiliteThumbImage( slider );
color = GadgetSliderGetHiliteThumbColor( slider );
borderColor = GadgetSliderGetHiliteThumbBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE, image, color, borderColor );
image = GadgetSliderGetHiliteSelectedThumbImage( slider );
color = GadgetSliderGetHiliteSelectedThumbColor( slider );
borderColor = GadgetSliderGetHiliteSelectedThumbBorderColor( slider );
StoreImageAndColor( COMBOBOX_LISTBOX_SLIDER_THUMB_HILITE_PUSHED, image, color, borderColor );
} // end if
GameWindow *dropDownButton = GadgetComboBoxGetDropDownButton( window );
if ( dropDownButton )
{
image = GadgetButtonGetEnabledImage( dropDownButton );
color = GadgetButtonGetEnabledColor( dropDownButton );
borderColor = GadgetButtonGetEnabledBorderColor( dropDownButton );
StoreImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_ENABLED, image, color, borderColor );
image = GadgetButtonGetEnabledSelectedImage(dropDownButton );
color = GadgetButtonGetEnabledSelectedColor( dropDownButton );
borderColor = GadgetButtonGetEnabledSelectedBorderColor( dropDownButton );
StoreImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_ENABLED_PUSHED, image, color, borderColor );
image = GadgetButtonGetDisabledImage( dropDownButton );
color = GadgetButtonGetDisabledColor( dropDownButton );
borderColor = GadgetButtonGetDisabledBorderColor( dropDownButton );
StoreImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_DISABLED, image, color, borderColor );
image = GadgetButtonGetDisabledSelectedImage( dropDownButton );
color = GadgetButtonGetDisabledSelectedColor( dropDownButton );
borderColor = GadgetButtonGetDisabledSelectedBorderColor( dropDownButton );
StoreImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_DISABLED_PUSHED, image, color, borderColor );
image = GadgetButtonGetHiliteImage( dropDownButton );
color = GadgetButtonGetHiliteColor( dropDownButton );
borderColor = GadgetButtonGetHiliteBorderColor( dropDownButton );
StoreImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_HILITE, image, color, borderColor );
image = GadgetButtonGetHiliteSelectedImage( dropDownButton );
color = GadgetButtonGetHiliteSelectedColor( dropDownButton );
borderColor = GadgetButtonGetHiliteSelectedBorderColor( dropDownButton );
StoreImageAndColor( COMBOBOX_DROP_DOWN_BUTTON_HILITE_PUSHED, image, color, borderColor );
}
GameWindow * editBox = GadgetComboBoxGetEditBox( window );
if ( editBox )
{
// --------------------------------------------------------------------------
image = GadgetTextEntryGetEnabledImageLeft( editBox );
color = GadgetTextEntryGetEnabledColor( editBox );
borderColor = GadgetTextEntryGetEnabledBorderColor( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_LEFT, image, color, borderColor );
image = GadgetTextEntryGetEnabledImageRight( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetEnabledImageCenter( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetEnabledImageSmallCenter( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_ENABLED_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetTextEntryGetDisabledImageLeft( editBox );
color = GadgetTextEntryGetDisabledColor( editBox );
borderColor = GadgetTextEntryGetDisabledBorderColor( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_LEFT, image, color, borderColor );
image = GadgetTextEntryGetDisabledImageRight( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetDisabledImageCenter( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetDisabledImageSmallCenter( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_DISABLED_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetTextEntryGetHiliteImageLeft( editBox );
color = GadgetTextEntryGetHiliteColor( editBox );
borderColor = GadgetTextEntryGetHiliteBorderColor( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_HILITE_LEFT, image, color, borderColor );
image = GadgetTextEntryGetHiliteImageRight( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_HILITE_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetHiliteImageCenter( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_HILITE_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetHiliteImageSmallCenter( editBox );
StoreImageAndColor( COMBOBOX_EDIT_BOX_HILITE_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
}
}
// init comboBox specific property section
ComboBoxData *comboData = (ComboBoxData *)window->winGetUserData();
SetDlgItemInt(dialog, EDIT_MAX_CHARS, comboData->maxChars, true);
SetDlgItemInt(dialog, EDIT_MAX_ITEMS_DISPLAYED, comboData->maxDisplay,true );
CheckDlgButton( dialog, CHECK_IS_EDITABLE, comboData->isEditable);
CheckDlgButton( dialog, CHECK_ASCII_TEXT ,comboData->asciiOnly);
CheckDlgButton( dialog, CHECK_LETTERS_AND_NUMBERS, comboData->lettersAndNumbersOnly);
// select the button enabled state for display
SwitchToState( COMBOBOX_ENABLED, dialog );
//
// initialize the dialog with values from the window
//
return dialog;
} // end InitComboBoxPropertiesDialog

View file

@ -0,0 +1,485 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: GenericProperties.cpp ////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: GenericProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Properties dialog for generic windows
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <assert.h>
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Common/Debug.h"
#include "Common/FunctionLexicon.h"
#include "GUIEdit.h"
#include "Properties.h"
#include "Resource.h"
#include "EditWindow.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// genericPropertiesCallback ==================================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK genericPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_DRAWITEM:
{
UINT controlID = (UINT)wParam; // control identifier
LPDRAWITEMSTRUCT drawItem = (LPDRAWITEMSTRUCT)lParam; // item drawing
RGBColorInt *color = GetControlColor( controlID );
// we only care about color button controls
if( color )
{
HBRUSH hBrushNew, hBrushOld;
RECT rect;
HWND hWndControl = GetDlgItem( hWndDialog, controlID );
// if this control is disabled just let windows handle drawing
if( IsWindowEnabled( hWndControl ) == FALSE )
return FALSE;
// Get the area we have to draw in
GetClientRect( hWndControl, &rect );
// create a new brush and select it into DC
hBrushNew = CreateSolidBrush (RGB ((BYTE)color->red,
(BYTE)color->green,
(BYTE)color->blue));
hBrushOld = (HBRUSH)SelectObject( drawItem->hDC, hBrushNew );
// draw the rectangle
Rectangle( drawItem->hDC, rect.left, rect.top, rect.right, rect.bottom );
// put the old brush back and delete the new one
SelectObject( drawItem->hDC, hBrushOld );
DeleteObject( hBrushNew );
// validate this new area
ValidateRect( hWndControl, NULL );
// we have taken care of it
return TRUE;
} // end if
return FALSE;
} // end draw item
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_ENABLED_COLOR:
case BUTTON_ENABLED_BORDER_COLOR:
case BUTTON_DISABLED_COLOR:
case BUTTON_DISABLED_BORDER_COLOR:
case BUTTON_HILITE_COLOR:
case BUTTON_HILITE_BORDER_COLOR:
{
RGBColorInt *currColor = GetControlColor( controlID );
// bring up color selector for this color control at the mouse
if( currColor )
{
RGBColorInt *newColor;
POINT mouse;
GetCursorPos( &mouse );
newColor = SelectColor( currColor->red, currColor->green,
currColor->blue, currColor->alpha,
mouse.x, mouse.y );
if( newColor )
{
Color newGameColor = GameMakeColor( newColor->red,
newColor->green,
newColor->blue,
newColor->alpha );
SetControlColor( controlID, newGameColor );
InvalidateRect( hWndControl, NULL, TRUE );
} // end if
} // end if
break;
} // end color buttons
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
const Image *image;
RGBColorInt *rgbColor;
Color color;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save callbacks
SaveCallbacks( window, hWndDialog );
// save the enabled colors/images
image = ComboBoxSelectionToImage( GetDlgItem( hWndDialog, COMBO_ENABLED_IMAGE ) );
window->winSetEnabledImage( 0, image );
rgbColor = GetControlColor( BUTTON_ENABLED_COLOR );
color = GameMakeColor( rgbColor->red, rgbColor->green, rgbColor->blue, rgbColor->alpha );
window->winSetEnabledColor( 0, color );
rgbColor = GetControlColor( BUTTON_ENABLED_BORDER_COLOR );
color = GameMakeColor( rgbColor->red, rgbColor->green, rgbColor->blue, rgbColor->alpha );
window->winSetEnabledBorderColor( 0, color );
// save the disabled colors/images
image = ComboBoxSelectionToImage( GetDlgItem( hWndDialog, COMBO_DISABLED_IMAGE ) );
window->winSetDisabledImage( 0, image );
rgbColor = GetControlColor( BUTTON_DISABLED_COLOR );
color = GameMakeColor( rgbColor->red, rgbColor->green, rgbColor->blue, rgbColor->alpha );
window->winSetDisabledColor( 0, color );
rgbColor = GetControlColor( BUTTON_DISABLED_BORDER_COLOR );
color = GameMakeColor( rgbColor->red, rgbColor->green, rgbColor->blue, rgbColor->alpha );
window->winSetDisabledBorderColor( 0, color );
// save the hilite colors/images
image = ComboBoxSelectionToImage( GetDlgItem( hWndDialog, COMBO_HILITE_IMAGE ) );
window->winSetHiliteImage( 0, image );
rgbColor = GetControlColor( BUTTON_HILITE_COLOR );
color = GameMakeColor( rgbColor->red, rgbColor->green, rgbColor->blue, rgbColor->alpha );
window->winSetHiliteColor( 0, color );
rgbColor = GetControlColor( BUTTON_HILITE_BORDER_COLOR );
color = GameMakeColor( rgbColor->red, rgbColor->green, rgbColor->blue, rgbColor->alpha );
window->winSetHiliteBorderColor( 0, color );
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end genericPropertiesCallback
// InitCallbackCombos =========================================================
/** load the callbacks combo boxes with the functions that the user cal
* select to attach to this window */
//=============================================================================
void InitCallbackCombos( HWND dialog, GameWindow *window )
{
HWND combo;
FunctionLexicon::TableEntry *entry;
GameWindowEditData *editData = NULL;
AsciiString name;
// get edit data from window
if( window )
editData = window->winGetEditData();
// load the system combo ----------------------------------------------------
combo = GetDlgItem( dialog, COMBO_SYSTEM );
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_GAME_WIN_SYSTEM );
while( entry && entry ->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
} // end while
SendMessage( combo, CB_INSERTSTRING, 0, (LPARAM)GUIEDIT_NONE_STRING );
// select the current function of the window in the combo if present
name.clear();
if( editData )
name = editData->systemCallbackString;
if( name.isEmpty() )
name = GUIEDIT_NONE_STRING;
SendMessage( combo, CB_SELECTSTRING, -1, (LPARAM)name.str() );
// load the input combo -----------------------------------------------------
combo = GetDlgItem( dialog, COMBO_INPUT );
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_GAME_WIN_INPUT );
while( entry && entry ->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
} // end while
SendMessage( combo, CB_INSERTSTRING, 0, (LPARAM)GUIEDIT_NONE_STRING );
// select the current function of the window in the combo if present
name.clear();
if( editData )
name = editData->inputCallbackString;
if( name.isEmpty() )
name = GUIEDIT_NONE_STRING;
SendMessage( combo, CB_SELECTSTRING, -1, (LPARAM)name.str() );
// load the tooltip combo ---------------------------------------------------
combo = GetDlgItem( dialog, COMBO_TOOLTIP );
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_GAME_WIN_TOOLTIP );
while( entry && entry ->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
} // end while
SendMessage( combo, CB_INSERTSTRING, 0, (LPARAM)GUIEDIT_NONE_STRING );
// select the current function of the window in the combo if present
name.clear();
if( editData )
name = editData->tooltipCallbackString;
if( name.isEmpty() )
name = GUIEDIT_NONE_STRING;
SendMessage( combo, CB_SELECTSTRING, -1, (LPARAM)name.str() );
// load the draw combo ------------------------------------------------------
combo = GetDlgItem( dialog, COMBO_DRAW );
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_GAME_WIN_DRAW );
while( entry && entry ->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
} // end while
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_GAME_WIN_DEVICEDRAW );
while( entry && entry ->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
} // end while
SendMessage( combo, CB_INSERTSTRING, 0, (LPARAM)GUIEDIT_NONE_STRING );
// select the current function of the window in the combo if present
name.clear();
if( editData )
name = editData->drawCallbackString;
if( name.isEmpty() )
name = GUIEDIT_NONE_STRING;
SendMessage( combo, CB_SELECTSTRING, -1, (LPARAM)name.str() );
//=================================================================================================
// callbacks for the layout itself
//=================================================================================================
// init combo
combo = GetDlgItem( dialog, COMBO_INIT );
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_WIN_LAYOUT_INIT );
while( entry && entry->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
}
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_WIN_LAYOUT_DEVICEINIT );
while( entry && entry->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
}
SendMessage( combo, CB_INSERTSTRING, 0, (LPARAM)GUIEDIT_NONE_STRING );
name = TheEditor->getLayoutInit();
SendMessage( combo, CB_SELECTSTRING, -1, (LPARAM)name.str() );
// update combo
combo = GetDlgItem( dialog, COMBO_UPDATE );
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_WIN_LAYOUT_UPDATE );
while( entry && entry->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
}
SendMessage( combo, CB_INSERTSTRING, 0, (LPARAM)GUIEDIT_NONE_STRING );
name = TheEditor->getLayoutUpdate();
SendMessage( combo, CB_SELECTSTRING, -1, (LPARAM)name.str() );
// shutdown combo
combo = GetDlgItem( dialog, COMBO_SHUTDOWN );
entry = TheFunctionLexicon->getTable( FunctionLexicon::TABLE_WIN_LAYOUT_SHUTDOWN );
while( entry && entry->key != NAMEKEY_INVALID )
{
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)entry->name );
entry++;
}
SendMessage( combo, CB_INSERTSTRING, 0, (LPARAM)GUIEDIT_NONE_STRING );
name = TheEditor->getLayoutShutdown();
SendMessage( combo, CB_SELECTSTRING, -1, (LPARAM)name.str() );
} // end InitCallbackCombos
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitUserWinPropertiesDialog ================================================
/** Initialize the generic properties dialog for windows */
//=============================================================================
HWND InitUserWinPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)GENERIC_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)genericPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// initialize the dialog with values from the window
//
// fill out the image combo boxes
LoadImageListComboBox( GetDlgItem( dialog, COMBO_ENABLED_IMAGE ) );
LoadImageListComboBox( GetDlgItem( dialog, COMBO_DISABLED_IMAGE ) );
LoadImageListComboBox( GetDlgItem( dialog, COMBO_HILITE_IMAGE ) );
// select any images in the combo boxes
const Image *image;
image = window->winGetEnabledImage( 0 );
if( image )
SendDlgItemMessage( dialog, COMBO_ENABLED_IMAGE, CB_SELECTSTRING,
-1, (LPARAM)image->getName().str() );
image = window->winGetDisabledImage( 0 );
if( image )
SendDlgItemMessage( dialog, COMBO_DISABLED_IMAGE, CB_SELECTSTRING,
-1, (LPARAM)image->getName().str() );
image = window->winGetHiliteImage( 0 );
if( image )
SendDlgItemMessage( dialog, COMBO_HILITE_IMAGE, CB_SELECTSTRING,
-1, (LPARAM)image->getName().str() );
// initialize the color buttons
SetControlColor( BUTTON_ENABLED_COLOR, window->winGetEnabledColor( 0 ) );
SetControlColor( BUTTON_ENABLED_BORDER_COLOR, window->winGetEnabledBorderColor( 0 ) );
SetControlColor( BUTTON_DISABLED_COLOR, window->winGetDisabledColor( 0 ) );
SetControlColor( BUTTON_DISABLED_BORDER_COLOR, window->winGetDisabledBorderColor( 0 ) );
SetControlColor( BUTTON_HILITE_COLOR, window->winGetHiliteColor( 0 ) );
SetControlColor( BUTTON_HILITE_BORDER_COLOR, window->winGetHiliteBorderColor( 0 ) );
// load the combo boxes with the callbacks the user can use
InitCallbackCombos( dialog, window );
return dialog;
} // end InitUserWinPropertiesDialog

View file

@ -0,0 +1,265 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: GridSettings.cpp /////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: GridSettings.cpp
//
// Created: Colin Day, July 2001
//
// Desc: New layout dialog procedure
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Lib/BaseType.h"
#include "Resource.h"
#include "EditWindow.h"
#include "GUIEdit.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
static RGBColorInt gridColor = { 0 };
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// initGridSettings ===========================================================
/** Initialize the dialog values */
//=============================================================================
static void initGridSettings( HWND hWndDialog )
{
// set resolution
SetDlgItemInt( hWndDialog, EDIT_RESOLUTION,
TheEditor->getGridResolution(), FALSE );
// check box for on/off
if( TheEditor->isGridVisible() == TRUE )
CheckDlgButton( hWndDialog, CHECK_VISIBLE, BST_CHECKED );
// check box for grid snap on/off
if( TheEditor->isGridSnapOn() == TRUE )
CheckDlgButton( hWndDialog, CHECK_SNAP_TO_GRID, BST_CHECKED );
// style
CheckDlgButton( hWndDialog, RADIO_LINES, BST_CHECKED );
// color
RGBColorInt *color = TheEditor->getGridColor();
gridColor = *color;
} // end initGridSettings
// GridSettingsDialogProc =====================================================
/** Dialog procedure for grid settings dialog */
//=============================================================================
BOOL CALLBACK GridSettingsDialogProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch( message )
{
// ------------------------------------------------------------------------
case WM_INITDIALOG:
{
// initialize the values for the the dialog
initGridSettings( hWndDialog );
return TRUE;
} // end init dialog
// ------------------------------------------------------------------------
case WM_DRAWITEM:
{
UINT controlID = (UINT)wParam; // control identifier
LPDRAWITEMSTRUCT drawItem = (LPDRAWITEMSTRUCT)lParam; // item drawing
RGBColorInt *color = &gridColor;
// we only care about color button controls
if( color )
{
HBRUSH hBrushNew, hBrushOld;
RECT rect;
HWND hWndControl = GetDlgItem( hWndDialog, controlID );
// if this control is disabled just let windows handle drawing
if( IsWindowEnabled( hWndControl ) == FALSE )
return FALSE;
// Get the area we have to draw in
GetClientRect( hWndControl, &rect );
// create a new brush and select it into DC
hBrushNew = CreateSolidBrush (RGB ((BYTE)color->red,
(BYTE)color->green,
(BYTE)color->blue));
hBrushOld = (HBRUSH)SelectObject( drawItem->hDC, hBrushNew );
// draw the rectangle
Rectangle( drawItem->hDC, rect.left, rect.top, rect.right, rect.bottom );
// put the old brush back and delete the new one
SelectObject( drawItem->hDC, hBrushOld );
DeleteObject( hBrushNew );
// validate this new area
ValidateRect( hWndControl, NULL );
// we have taken care of it
return TRUE;
} // end if
return FALSE;
} // end draw item
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
// Int controlID = LOWORD( wParam ); // control ID
HWND hWndControl = (HWND)lParam; // control window handle
switch( LOWORD( wParam ) )
{
// --------------------------------------------------------------------
case BUTTON_COLOR:
{
RGBColorInt *currColor = &gridColor;
// bring up color selector for this color control at the mouse
if( currColor )
{
RGBColorInt *newColor;
POINT mouse;
GetCursorPos( &mouse );
newColor = SelectColor( currColor->red, currColor->green,
currColor->blue, currColor->alpha,
mouse.x, mouse.y );
if( newColor )
{
gridColor = *newColor;
InvalidateRect( hWndControl, NULL, TRUE );
} // end if
} // end if
break;
} // end color buttons
// --------------------------------------------------------------------
case IDOK:
{
Int value;
// get the pixels between marks
value = GetDlgItemInt( hWndDialog, EDIT_RESOLUTION, NULL, FALSE );
TheEditor->setGridResolution( value );
// get grid on/off flag
value = IsDlgButtonChecked( hWndDialog, CHECK_VISIBLE );
TheEditor->setGridVisible( value );
// get snap on/off flag
value = IsDlgButtonChecked( hWndDialog, CHECK_SNAP_TO_GRID );
TheEditor->setGridSnap( value );
// grid color
TheEditor->setGridColor( &gridColor );
// end this dialog
EndDialog( hWndDialog, TRUE );
break;
} // end ok
// --------------------------------------------------------------------
case IDCANCEL:
{
EndDialog( hWndDialog, FALSE );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
EndDialog( hWndDialog, FALSE );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end GridSettingsDialogProc

View file

@ -0,0 +1,972 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: ListboxProperties.cpp ////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: ListboxProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Listbox properties dialog
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Properties.h"
#include "LayoutScheme.h"
#include "Resource.h"
#include "GameClient/GadgetListBox.h"
#include "GameClient/GadgetPushButton.h"
#include "Gameclient/GadgetSlider.h"
#include "GameClient/GameWindowManager.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// addScrollbar ===============================================================
/** Add a scrollbar to a listbox window that doesn't have one */
//=============================================================================
static void addScrollbar( GameWindow *listbox )
{
// create scrollbar stuffs
GadgetListboxCreateScrollbar( listbox );
//
// get the colors for the listbox and reset them to recolor the
// newly created scrollbar parts
//
Color enabled = GadgetListBoxGetEnabledColor( listbox );
Color enabledBorder = GadgetListBoxGetEnabledBorderColor( listbox );
Color enabledSelectedItem = GadgetListBoxGetEnabledSelectedItemColor( listbox );
Color enabledSelectedItemBorder = GadgetListBoxGetEnabledSelectedItemBorderColor( listbox );
Color disabled = GadgetListBoxGetDisabledColor( listbox );
Color disabledBorder = GadgetListBoxGetDisabledBorderColor( listbox );
Color disabledSelectedItem = GadgetListBoxGetDisabledSelectedItemColor( listbox );
Color disabledSelectedItemBorder = GadgetListBoxGetDisabledSelectedItemBorderColor( listbox );
Color hilite = GadgetListBoxGetHiliteColor( listbox );
Color hiliteBorder = GadgetListBoxGetHiliteBorderColor( listbox );
Color hiliteSelectedItem = GadgetListBoxGetHiliteSelectedItemColor( listbox );
Color hiliteSelectedItemBorder = GadgetListBoxGetHiliteSelectedItemBorderColor( listbox );
GadgetListBoxSetColors( listbox,
enabled,
enabledBorder,
enabledSelectedItem,
enabledSelectedItemBorder,
disabled,
disabledBorder,
disabledSelectedItem,
disabledSelectedItemBorder,
hilite,
hiliteBorder,
hiliteSelectedItem,
hiliteSelectedItemBorder );
//
// now that colors are assigned based on the colors of the listbox
// itself, assign the default listbox scroll images
//
ImageAndColorInfo *info;
GameWindow *upButton = GadgetListBoxGetUpButton( listbox );
if( upButton )
{
info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_ENABLED );
GadgetButtonSetEnabledImage( upButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_ENABLED_PUSHED );
GadgetButtonSetEnabledSelectedImage( upButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_DISABLED );
GadgetButtonSetDisabledImage( upButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_DISABLED_PUSHED );
GadgetButtonSetDisabledSelectedImage( upButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_HILITE );
GadgetButtonSetHiliteImage( upButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_UP_BUTTON_HILITE_PUSHED );
GadgetButtonSetHiliteSelectedImage( upButton, info->image );
} // end if
GameWindow *downButton = GadgetListBoxGetDownButton( listbox );
if( downButton )
{
info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_ENABLED );
GadgetButtonSetEnabledImage( downButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_ENABLED_PUSHED );
GadgetButtonSetEnabledSelectedImage( downButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_DISABLED );
GadgetButtonSetDisabledImage( downButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_DISABLED_PUSHED );
GadgetButtonSetDisabledSelectedImage( downButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_HILITE );
GadgetButtonSetHiliteImage( downButton, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_DOWN_BUTTON_HILITE_PUSHED );
GadgetButtonSetHiliteSelectedImage( downButton, info->image );
} // end if
GameWindow *slider = GadgetListBoxGetSlider( listbox );
if( slider )
{
// ----------------------------------------------------------------------
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_TOP );
GadgetSliderSetEnabledImageTop( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_BOTTOM );
GadgetSliderSetEnabledImageBottom( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_CENTER );
GadgetSliderSetEnabledImageCenter( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_ENABLED_SMALL_CENTER );
GadgetSliderSetEnabledImageSmallCenter( slider, info->image );
// ----------------------------------------------------------------------
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_TOP );
GadgetSliderSetDisabledImageTop( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_BOTTOM );
GadgetSliderSetDisabledImageBottom( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_CENTER );
GadgetSliderSetDisabledImageCenter( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_DISABLED_SMALL_CENTER );
GadgetSliderSetDisabledImageSmallCenter( slider, info->image );
// ----------------------------------------------------------------------
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_TOP );
GadgetSliderSetHiliteImageTop( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_BOTTOM );
GadgetSliderSetHiliteImageBottom( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_CENTER );
GadgetSliderSetHiliteImageCenter( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_HILITE_SMALL_CENTER );
GadgetSliderSetHiliteImageSmallCenter( slider, info->image );
//-----------------------------------------------------------------------
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_ENABLED );
GadgetSliderSetEnabledThumbImage( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_ENABLED_PUSHED );
GadgetSliderSetEnabledSelectedThumbImage( slider, info->image );
GadgetSliderSetEnabledSelectedThumbColor( slider, info->color );
GadgetSliderSetEnabledSelectedThumbBorderColor( slider, info->borderColor );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_DISABLED );
GadgetSliderSetDisabledThumbImage( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_DISABLED_PUSHED );
GadgetSliderSetDisabledSelectedThumbImage( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_HILITE );
GadgetSliderSetHiliteThumbImage( slider, info->image );
info = TheDefaultScheme->getImageAndColor( LISTBOX_SLIDER_THUMB_HILITE_PUSHED );
GadgetSliderSetHiliteSelectedThumbImage( slider, info->image );
} // end if, slider
} // end addScrollbar
// removeScrollbar ============================================================
/** Remove all scrollbar constructs froma listbox that has it already */
//=============================================================================
static void removeScrollbar( GameWindow *listbox )
{
ListboxData *listData = (ListboxData *)listbox->winGetUserData();
// delete the up button
TheWindowManager->winDestroy( listData->upButton );
listData->upButton = NULL;
// delete down button
TheWindowManager->winDestroy( listData->downButton );
listData->downButton = NULL;
// delete the slider
TheWindowManager->winDestroy( listData->slider );
listData->slider = NULL;
// remove the scrollbar flag from the listbox data
listData->scrollBar = FALSE;
} // end removeScrollbar
// resizeMaxItems =============================================================
/** Change the max items that a listbox can accomodate */
//=============================================================================
static void resizeMaxItems( GameWindow *listbox, UnsignedInt newMaxItems )
{
// ListboxData *listData = (ListboxData *)listbox->winGetUserData();
} // end resizeMaxItems
// listboxPropertiesCallback ==================================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK listboxPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_SUBCONTROL_COLOR:
{
ImageAndColorInfo *info;
//
// using the current colors in the base of the listbox, assign a
// reasonable color scheme to all the sub control components
//
info = GetStateInfo( LISTBOX_ENABLED );
StoreColor( LISTBOX_UP_BUTTON_ENABLED, info->color, info->borderColor );
StoreColor( LISTBOX_DOWN_BUTTON_ENABLED, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_ENABLED_TOP, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_THUMB_ENABLED, info->color, info->borderColor );
info = GetStateInfo( LISTBOX_ENABLED_SELECTED_ITEM_LEFT );
StoreColor( LISTBOX_UP_BUTTON_ENABLED_PUSHED, info->color, info->borderColor );
StoreColor( LISTBOX_DOWN_BUTTON_ENABLED_PUSHED, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_THUMB_ENABLED_PUSHED, info->color, info->borderColor );
info = GetStateInfo( LISTBOX_DISABLED );
StoreColor( LISTBOX_UP_BUTTON_DISABLED, info->color, info->borderColor );
StoreColor( LISTBOX_DOWN_BUTTON_DISABLED, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_DISABLED_TOP, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_THUMB_DISABLED, info->color, info->borderColor );
info = GetStateInfo( LISTBOX_DISABLED_SELECTED_ITEM_LEFT );
StoreColor( LISTBOX_UP_BUTTON_DISABLED_PUSHED, info->color, info->borderColor );
StoreColor( LISTBOX_DOWN_BUTTON_DISABLED_PUSHED, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_THUMB_DISABLED_PUSHED, info->color, info->borderColor );
info = GetStateInfo( LISTBOX_HILITE );
StoreColor( LISTBOX_UP_BUTTON_HILITE, info->color, info->borderColor );
StoreColor( LISTBOX_DOWN_BUTTON_HILITE, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_HILITE_TOP, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_THUMB_HILITE, info->color, info->borderColor );
info = GetStateInfo( LISTBOX_HILITE_SELECTED_ITEM_LEFT );
StoreColor( LISTBOX_UP_BUTTON_HILITE_PUSHED, info->color, info->borderColor );
StoreColor( LISTBOX_DOWN_BUTTON_HILITE_PUSHED, info->color, info->borderColor );
StoreColor( LISTBOX_SLIDER_THUMB_HILITE_PUSHED, info->color, info->borderColor );
break;
} // end case subcontrol color
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_ENABLED );
GadgetListBoxSetEnabledImage( window, info->image );
GadgetListBoxSetEnabledColor( window, info->color );
GadgetListBoxSetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( LISTBOX_ENABLED_SELECTED_ITEM_LEFT );
GadgetListBoxSetEnabledSelectedItemImageLeft( window, info->image );
GadgetListBoxSetEnabledSelectedItemColor( window, info->color );
GadgetListBoxSetEnabledSelectedItemBorderColor( window, info->borderColor );
info = GetStateInfo( LISTBOX_ENABLED_SELECTED_ITEM_RIGHT );
GadgetListBoxSetEnabledSelectedItemImageRight( window, info->image );
info = GetStateInfo( LISTBOX_ENABLED_SELECTED_ITEM_CENTER );
GadgetListBoxSetEnabledSelectedItemImageCenter( window, info->image );
info = GetStateInfo( LISTBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER );
GadgetListBoxSetEnabledSelectedItemImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_DISABLED );
GadgetListBoxSetDisabledImage( window, info->image );
GadgetListBoxSetDisabledColor( window, info->color );
GadgetListBoxSetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( LISTBOX_DISABLED_SELECTED_ITEM_LEFT );
GadgetListBoxSetDisabledSelectedItemImageLeft( window, info->image );
GadgetListBoxSetDisabledSelectedItemColor( window, info->color );
GadgetListBoxSetDisabledSelectedItemBorderColor( window, info->borderColor );
info = GetStateInfo( LISTBOX_DISABLED_SELECTED_ITEM_RIGHT );
GadgetListBoxSetDisabledSelectedItemImageRight( window, info->image );
info = GetStateInfo( LISTBOX_DISABLED_SELECTED_ITEM_CENTER );
GadgetListBoxSetDisabledSelectedItemImageCenter( window, info->image );
info = GetStateInfo( LISTBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER );
GadgetListBoxSetDisabledSelectedItemImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_HILITE );
GadgetListBoxSetHiliteImage( window, info->image );
GadgetListBoxSetHiliteColor( window, info->color );
GadgetListBoxSetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( LISTBOX_HILITE_SELECTED_ITEM_LEFT );
GadgetListBoxSetHiliteSelectedItemImageLeft( window, info->image );
GadgetListBoxSetHiliteSelectedItemColor( window, info->color );
GadgetListBoxSetHiliteSelectedItemBorderColor( window, info->borderColor );
info = GetStateInfo( LISTBOX_HILITE_SELECTED_ITEM_RIGHT );
GadgetListBoxSetHiliteSelectedItemImageRight( window, info->image );
info = GetStateInfo( LISTBOX_HILITE_SELECTED_ITEM_CENTER );
GadgetListBoxSetHiliteSelectedItemImageCenter( window, info->image );
info = GetStateInfo( LISTBOX_HILITE_SELECTED_ITEM_SMALL_CENTER );
GadgetListBoxSetHiliteSelectedItemImageSmallCenter( window, info->image );
// up button
GameWindow *upButton = GadgetListBoxGetUpButton( window );
if( upButton )
{
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_UP_BUTTON_ENABLED );
GadgetButtonSetEnabledImage( upButton, info->image );
GadgetButtonSetEnabledColor( upButton, info->color );
GadgetButtonSetEnabledBorderColor( upButton, info->borderColor );
info = GetStateInfo( LISTBOX_UP_BUTTON_ENABLED_PUSHED );
GadgetButtonSetEnabledSelectedImage( upButton, info->image );
GadgetButtonSetEnabledSelectedColor( upButton, info->color );
GadgetButtonSetEnabledSelectedBorderColor( upButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_UP_BUTTON_DISABLED );
GadgetButtonSetDisabledImage( upButton, info->image );
GadgetButtonSetDisabledColor( upButton, info->color );
GadgetButtonSetDisabledBorderColor( upButton, info->borderColor );
info = GetStateInfo( LISTBOX_UP_BUTTON_DISABLED_PUSHED );
GadgetButtonSetDisabledSelectedImage( upButton, info->image );
GadgetButtonSetDisabledSelectedColor( upButton, info->color );
GadgetButtonSetDisabledSelectedBorderColor( upButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_UP_BUTTON_HILITE );
GadgetButtonSetHiliteImage( upButton, info->image );
GadgetButtonSetHiliteColor( upButton, info->color );
GadgetButtonSetHiliteBorderColor( upButton, info->borderColor );
info = GetStateInfo( LISTBOX_UP_BUTTON_HILITE_PUSHED );
GadgetButtonSetHiliteSelectedImage( upButton, info->image );
GadgetButtonSetHiliteSelectedColor( upButton, info->color );
GadgetButtonSetHiliteSelectedBorderColor( upButton, info->borderColor );
} // end if
// down button
GameWindow *downButton = GadgetListBoxGetDownButton( window );
if( downButton )
{
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_DOWN_BUTTON_ENABLED );
GadgetButtonSetEnabledImage( downButton, info->image );
GadgetButtonSetEnabledColor( downButton, info->color );
GadgetButtonSetEnabledBorderColor( downButton, info->borderColor );
info = GetStateInfo( LISTBOX_DOWN_BUTTON_ENABLED_PUSHED );
GadgetButtonSetEnabledSelectedImage( downButton, info->image );
GadgetButtonSetEnabledSelectedColor( downButton, info->color );
GadgetButtonSetEnabledSelectedBorderColor( downButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_DOWN_BUTTON_DISABLED );
GadgetButtonSetDisabledImage( downButton, info->image );
GadgetButtonSetDisabledColor( downButton, info->color );
GadgetButtonSetDisabledBorderColor( downButton, info->borderColor );
info = GetStateInfo( LISTBOX_DOWN_BUTTON_DISABLED_PUSHED );
GadgetButtonSetDisabledSelectedImage( downButton, info->image );
GadgetButtonSetDisabledSelectedColor( downButton, info->color );
GadgetButtonSetDisabledSelectedBorderColor( downButton, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_DOWN_BUTTON_HILITE );
GadgetButtonSetHiliteImage( downButton, info->image );
GadgetButtonSetHiliteColor( downButton, info->color );
GadgetButtonSetHiliteBorderColor( downButton, info->borderColor );
info = GetStateInfo( LISTBOX_DOWN_BUTTON_HILITE_PUSHED );
GadgetButtonSetHiliteSelectedImage( downButton, info->image );
GadgetButtonSetHiliteSelectedColor( downButton, info->color );
GadgetButtonSetHiliteSelectedBorderColor( downButton, info->borderColor );
} // end if
// slider
GameWindow *slider = GadgetListBoxGetSlider( window );
if( slider )
{
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_SLIDER_ENABLED_TOP );
GadgetSliderSetEnabledImageTop( slider, info->image );
GadgetSliderSetEnabledColor( slider, info->color );
GadgetSliderSetEnabledBorderColor( slider, info->borderColor );
info = GetStateInfo( LISTBOX_SLIDER_ENABLED_BOTTOM );
GadgetSliderSetEnabledImageBottom( slider, info->image );
info = GetStateInfo( LISTBOX_SLIDER_ENABLED_CENTER );
GadgetSliderSetEnabledImageCenter( slider, info->image );
info = GetStateInfo( LISTBOX_SLIDER_ENABLED_SMALL_CENTER );
GadgetSliderSetEnabledImageSmallCenter( slider, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_SLIDER_DISABLED_TOP );
GadgetSliderSetDisabledImageTop( slider, info->image );
GadgetSliderSetDisabledColor( slider, info->color );
GadgetSliderSetDisabledBorderColor( slider, info->borderColor );
info = GetStateInfo( LISTBOX_SLIDER_DISABLED_BOTTOM );
GadgetSliderSetDisabledImageBottom( slider, info->image );
info = GetStateInfo( LISTBOX_SLIDER_DISABLED_CENTER );
GadgetSliderSetDisabledImageCenter( slider, info->image );
info = GetStateInfo( LISTBOX_SLIDER_DISABLED_SMALL_CENTER );
GadgetSliderSetDisabledImageSmallCenter( slider, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_SLIDER_HILITE_TOP );
GadgetSliderSetHiliteImageTop( slider, info->image );
GadgetSliderSetHiliteColor( slider, info->color );
GadgetSliderSetHiliteBorderColor( slider, info->borderColor );
info = GetStateInfo( LISTBOX_SLIDER_HILITE_BOTTOM );
GadgetSliderSetHiliteImageBottom( slider, info->image );
info = GetStateInfo( LISTBOX_SLIDER_HILITE_CENTER );
GadgetSliderSetHiliteImageCenter( slider, info->image );
info = GetStateInfo( LISTBOX_SLIDER_HILITE_SMALL_CENTER );
GadgetSliderSetHiliteImageSmallCenter( slider, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_SLIDER_THUMB_ENABLED );
GadgetSliderSetEnabledThumbImage( slider, info->image );
GadgetSliderSetEnabledThumbColor( slider, info->color );
GadgetSliderSetEnabledThumbBorderColor( slider, info->borderColor );
info = GetStateInfo( LISTBOX_SLIDER_THUMB_ENABLED_PUSHED );
GadgetSliderSetEnabledSelectedThumbImage( slider, info->image );
GadgetSliderSetEnabledSelectedThumbColor( slider, info->color );
GadgetSliderSetEnabledSelectedThumbBorderColor( slider, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_SLIDER_THUMB_DISABLED );
GadgetSliderSetDisabledThumbImage( slider, info->image );
GadgetSliderSetDisabledThumbColor( slider, info->color );
GadgetSliderSetDisabledThumbBorderColor( slider, info->borderColor );
info = GetStateInfo( LISTBOX_SLIDER_THUMB_DISABLED_PUSHED );
GadgetSliderSetDisabledSelectedThumbImage( slider, info->image );
GadgetSliderSetDisabledSelectedThumbColor( slider, info->color );
GadgetSliderSetDisabledSelectedThumbBorderColor( slider, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( LISTBOX_SLIDER_THUMB_HILITE );
GadgetSliderSetHiliteThumbImage( slider, info->image );
GadgetSliderSetHiliteThumbColor( slider, info->color );
GadgetSliderSetHiliteThumbBorderColor( slider, info->borderColor );
info = GetStateInfo( LISTBOX_SLIDER_THUMB_HILITE_PUSHED );
GadgetSliderSetHiliteSelectedThumbImage( slider, info->image );
GadgetSliderSetHiliteSelectedThumbColor( slider, info->color );
GadgetSliderSetHiliteSelectedThumbBorderColor( slider, info->borderColor );
} // end if
// save specific list data
ListboxData *listData = (ListboxData *)window->winGetUserData();
listData->forceSelect = IsDlgButtonChecked( hWndDialog, CHECK_FORCE_SELECT );
listData->autoScroll = IsDlgButtonChecked( hWndDialog, CHECK_AUTO_SCROLL );
listData->scrollIfAtEnd = IsDlgButtonChecked( hWndDialog, CHECK_SCROLL_IF_AT_END );
listData->autoPurge = IsDlgButtonChecked( hWndDialog, CHECK_AUTO_PURGE );
// addition or subtraction of a scroll bar
Bool wantScrollBar = IsDlgButtonChecked( hWndDialog, CHECK_HAS_SCROLLBAR );
if( wantScrollBar == TRUE && listData->scrollBar == FALSE )
addScrollbar( window );
else if( wantScrollBar == FALSE && listData->scrollBar == TRUE )
removeScrollbar( window );
// change in the size of the listbox
Int newMaxItems = GetDlgItemInt( hWndDialog, EDIT_MAX_ITEMS, NULL, FALSE );
if( newMaxItems != listData->listLength )
GadgetListBoxSetListLength( window, newMaxItems );
// multi-select
Bool wantMultiSelect = IsDlgButtonChecked( hWndDialog, CHECK_MULTI_SELECT );
if( wantMultiSelect == TRUE && listData->multiSelect == FALSE )
GadgetListBoxAddMultiSelect( window );
else if( wantMultiSelect == FALSE && listData->multiSelect == TRUE )
GadgetListBoxRemoveMultiSelect( window );
// Wordwrap
UnsignedInt bit = WIN_STATUS_ONE_LINE;
window->winClearStatus( bit );
if( IsDlgButtonChecked( hWndDialog, CHECK_NO_WORDWRAP ) )
window->winSetStatus( bit );
// Multi-column
Int newColumns = GetDlgItemInt( hWndDialog, EDIT_NUM_COLUMNS,NULL,FALSE);
if(newColumns > 1)
{
char *percentages = new char[60];
char *token;
GetDlgItemText(hWndDialog,EDIT_COLUMN_PERCENT,percentages,200);
if(strlen(percentages) == 0)
{
MessageBox(NULL,"You have specified a column amount greater then 1, please enter the same about of percentages","whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL);
break;
}
Int *newPercentages = new Int[newColumns];
Int i = 0;
Int total = 0;
token = strtok( percentages, "," );
while( token != NULL )
{
newPercentages[i] = atoi(token);
total += newPercentages[i];
token = strtok( NULL, "," );
i++;
if(i > newColumns && token)
{
Char *whoopsMsg = new char[250];
sprintf(whoopsMsg,"You have Specified %d columns but I have read in more then that for the percentages, please double check your data", newColumns);
MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL);
return 0;
}
else if( i < newColumns && !token )
{
Char *whoopsMsg = new char[250];
sprintf(whoopsMsg,"You have Specified %d columns but I have read in only %d for the percentages, please double check your data", newColumns, i );
MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL);
return 0;
}
else if((total > 100 ) || (total < 100 && !token ))
{
Char *whoopsMsg = new char[250];
sprintf(whoopsMsg,"Please Double check to make sure your percentages add up to 100.", newColumns, i - 1);
MessageBox(NULL, whoopsMsg,"Whoops",MB_OK | MB_ICONSTOP | MB_APPLMODAL);
return 0;
}
}
listData->columnWidthPercentage = newPercentages;
}
listData->columns = newColumns;
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end listboxPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitListboxPropertiesDialog ================================================
/** Bring up the listbox properties window */
//=============================================================================
HWND InitListboxPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)LISTBOX_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)listboxPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// store in the image and color table the values for this putton
//
const Image *image;
Color color, borderColor;
// --------------------------------------------------------------------------
image = GadgetListBoxGetEnabledImage( window );
color = GadgetListBoxGetEnabledColor( window );
borderColor = GadgetListBoxGetEnabledBorderColor( window );
StoreImageAndColor( LISTBOX_ENABLED, image, color, borderColor );
image = GadgetListBoxGetEnabledSelectedItemImageLeft( window );
color = GadgetListBoxGetEnabledSelectedItemColor( window );
borderColor = GadgetListBoxGetEnabledSelectedItemBorderColor( window );
StoreImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetListBoxGetEnabledSelectedItemImageRight( window );
StoreImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetEnabledSelectedItemImageCenter( window );
StoreImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetEnabledSelectedItemImageSmallCenter( window );
StoreImageAndColor( LISTBOX_ENABLED_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetListBoxGetDisabledImage( window );
color = GadgetListBoxGetDisabledColor( window );
borderColor = GadgetListBoxGetDisabledBorderColor( window );
StoreImageAndColor( LISTBOX_DISABLED, image, color, borderColor );
image = GadgetListBoxGetDisabledSelectedItemImageLeft( window );
color = GadgetListBoxGetDisabledSelectedItemColor( window );
borderColor = GadgetListBoxGetDisabledSelectedItemBorderColor( window );
StoreImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetListBoxGetDisabledSelectedItemImageRight( window );
StoreImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetDisabledSelectedItemImageCenter( window );
StoreImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetDisabledSelectedItemImageSmallCenter( window );
StoreImageAndColor( LISTBOX_DISABLED_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetListBoxGetHiliteImage( window );
color = GadgetListBoxGetHiliteColor( window );
borderColor = GadgetListBoxGetHiliteBorderColor( window );
StoreImageAndColor( LISTBOX_HILITE, image, color, borderColor );
image = GadgetListBoxGetHiliteSelectedItemImageLeft( window );
color = GadgetListBoxGetHiliteSelectedItemColor( window );
borderColor = GadgetListBoxGetHiliteSelectedItemBorderColor( window );
StoreImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_LEFT, image, color, borderColor );
image = GadgetListBoxGetHiliteSelectedItemImageRight( window );
StoreImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetHiliteSelectedItemImageCenter( window );
StoreImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetListBoxGetHiliteSelectedItemImageSmallCenter( window );
StoreImageAndColor( LISTBOX_HILITE_SELECTED_ITEM_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
GameWindow *upButton = GadgetListBoxGetUpButton( window );
if( upButton )
{
// ------------------------------------------------------------------------
image = GadgetButtonGetEnabledImage( upButton );
color = GadgetButtonGetEnabledColor( upButton );
borderColor = GadgetButtonGetEnabledBorderColor( upButton );
StoreImageAndColor( LISTBOX_UP_BUTTON_ENABLED, image, color, borderColor );
image = GadgetButtonGetEnabledSelectedImage( upButton );
color = GadgetButtonGetEnabledSelectedColor( upButton );
borderColor = GadgetButtonGetEnabledSelectedBorderColor( upButton );
StoreImageAndColor( LISTBOX_UP_BUTTON_ENABLED_PUSHED, image, color, borderColor );
// ------------------------------------------------------------------------
image = GadgetButtonGetDisabledImage( upButton );
color = GadgetButtonGetDisabledColor( upButton );
borderColor = GadgetButtonGetDisabledBorderColor( upButton );
StoreImageAndColor( LISTBOX_UP_BUTTON_DISABLED, image, color, borderColor );
image = GadgetButtonGetDisabledSelectedImage( upButton );
color = GadgetButtonGetDisabledSelectedColor( upButton );
borderColor = GadgetButtonGetDisabledSelectedBorderColor( upButton );
StoreImageAndColor( LISTBOX_UP_BUTTON_DISABLED_PUSHED, image, color, borderColor );
// ------------------------------------------------------------------------
image = GadgetButtonGetHiliteImage( upButton );
color = GadgetButtonGetHiliteColor( upButton );
borderColor = GadgetButtonGetHiliteBorderColor( upButton );
StoreImageAndColor( LISTBOX_UP_BUTTON_HILITE, image, color, borderColor );
image = GadgetButtonGetHiliteSelectedImage( upButton );
color = GadgetButtonGetHiliteSelectedColor( upButton );
borderColor = GadgetButtonGetHiliteSelectedBorderColor( upButton );
StoreImageAndColor( LISTBOX_UP_BUTTON_HILITE_PUSHED, image, color, borderColor );
} // end if
// --------------------------------------------------------------------------
GameWindow *downButton = GadgetListBoxGetDownButton( window );
if( downButton )
{
// ------------------------------------------------------------------------
image = GadgetButtonGetEnabledImage( downButton );
color = GadgetButtonGetEnabledColor( downButton );
borderColor = GadgetButtonGetEnabledBorderColor( downButton );
StoreImageAndColor( LISTBOX_DOWN_BUTTON_ENABLED, image, color, borderColor );
image = GadgetButtonGetEnabledSelectedImage( downButton );
color = GadgetButtonGetEnabledSelectedColor( downButton );
borderColor = GadgetButtonGetEnabledSelectedBorderColor( downButton );
StoreImageAndColor( LISTBOX_DOWN_BUTTON_ENABLED_PUSHED, image, color, borderColor );
// ------------------------------------------------------------------------
image = GadgetButtonGetDisabledImage( downButton );
color = GadgetButtonGetDisabledColor( downButton );
borderColor = GadgetButtonGetDisabledBorderColor( downButton );
StoreImageAndColor( LISTBOX_DOWN_BUTTON_DISABLED, image, color, borderColor );
image = GadgetButtonGetDisabledSelectedImage( downButton );
color = GadgetButtonGetDisabledSelectedColor( downButton );
borderColor = GadgetButtonGetDisabledSelectedBorderColor( downButton );
StoreImageAndColor( LISTBOX_DOWN_BUTTON_DISABLED_PUSHED, image, color, borderColor );
// ------------------------------------------------------------------------
image = GadgetButtonGetHiliteImage( downButton );
color = GadgetButtonGetHiliteColor( downButton );
borderColor = GadgetButtonGetHiliteBorderColor( downButton );
StoreImageAndColor( LISTBOX_DOWN_BUTTON_HILITE, image, color, borderColor );
image = GadgetButtonGetHiliteSelectedImage( downButton );
color = GadgetButtonGetHiliteSelectedColor( downButton );
borderColor = GadgetButtonGetHiliteSelectedBorderColor( downButton );
StoreImageAndColor( LISTBOX_DOWN_BUTTON_HILITE_PUSHED, image, color, borderColor );
} // end if
GameWindow *slider = GadgetListBoxGetSlider( window );
if( slider )
{
// --------------------------------------------------------------------------
image = GadgetSliderGetEnabledImageTop( slider );
color = GadgetSliderGetEnabledColor( slider );
borderColor = GadgetSliderGetEnabledBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_ENABLED_TOP, image, color, borderColor );
image = GadgetSliderGetEnabledImageBottom( slider );
StoreImageAndColor( LISTBOX_SLIDER_ENABLED_BOTTOM, image, color, borderColor );
image = GadgetSliderGetEnabledImageCenter( slider );
StoreImageAndColor( LISTBOX_SLIDER_ENABLED_CENTER, image, color, borderColor );
image = GadgetSliderGetEnabledImageSmallCenter( slider );
StoreImageAndColor( LISTBOX_SLIDER_ENABLED_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetDisabledImageTop( slider );
color = GadgetSliderGetDisabledColor( slider );
borderColor = GadgetSliderGetDisabledBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_DISABLED_TOP, image, color, borderColor );
image = GadgetSliderGetDisabledImageBottom( slider );
StoreImageAndColor( LISTBOX_SLIDER_DISABLED_BOTTOM, image, color, borderColor );
image = GadgetSliderGetDisabledImageCenter( slider );
StoreImageAndColor( LISTBOX_SLIDER_DISABLED_CENTER, image, color, borderColor );
image = GadgetSliderGetDisabledImageSmallCenter( slider );
StoreImageAndColor( LISTBOX_SLIDER_DISABLED_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetHiliteImageTop( slider );
color = GadgetSliderGetHiliteColor( slider );
borderColor = GadgetSliderGetHiliteBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_HILITE_TOP, image, color, borderColor );
image = GadgetSliderGetHiliteImageBottom( slider );
StoreImageAndColor( LISTBOX_SLIDER_HILITE_BOTTOM, image, color, borderColor );
image = GadgetSliderGetHiliteImageCenter( slider );
StoreImageAndColor( LISTBOX_SLIDER_HILITE_CENTER, image, color, borderColor );
image = GadgetSliderGetHiliteImageSmallCenter( slider );
StoreImageAndColor( LISTBOX_SLIDER_HILITE_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetEnabledThumbImage( slider );
color = GadgetSliderGetEnabledThumbColor( slider );
borderColor = GadgetSliderGetEnabledThumbBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_THUMB_ENABLED, image, color, borderColor );
image = GadgetSliderGetEnabledSelectedThumbImage( slider );
color = GadgetSliderGetEnabledSelectedThumbColor( slider );
borderColor = GadgetSliderGetEnabledSelectedThumbBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_THUMB_ENABLED_PUSHED, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetDisabledThumbImage( slider );
color = GadgetSliderGetDisabledThumbColor( slider );
borderColor = GadgetSliderGetDisabledThumbBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_THUMB_DISABLED, image, color, borderColor );
image = GadgetSliderGetDisabledSelectedThumbImage( slider );
color = GadgetSliderGetDisabledSelectedThumbColor( slider );
borderColor = GadgetSliderGetDisabledSelectedThumbBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_THUMB_DISABLED_PUSHED, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetHiliteThumbImage( slider );
color = GadgetSliderGetHiliteThumbColor( slider );
borderColor = GadgetSliderGetHiliteThumbBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_THUMB_HILITE, image, color, borderColor );
image = GadgetSliderGetHiliteSelectedThumbImage( slider );
color = GadgetSliderGetHiliteSelectedThumbColor( slider );
borderColor = GadgetSliderGetHiliteSelectedThumbBorderColor( slider );
StoreImageAndColor( LISTBOX_SLIDER_THUMB_HILITE_PUSHED, image, color, borderColor );
} // end if
// init listbox specific property section
ListboxData *listData = (ListboxData *)window->winGetUserData();
CheckDlgButton( dialog, CHECK_HAS_SCROLLBAR, listData->scrollBar );
CheckDlgButton( dialog, CHECK_MULTI_SELECT, listData->multiSelect );
CheckDlgButton( dialog, CHECK_FORCE_SELECT, listData->forceSelect );
CheckDlgButton( dialog, CHECK_AUTO_SCROLL, listData->autoScroll );
CheckDlgButton( dialog, CHECK_SCROLL_IF_AT_END, listData->scrollIfAtEnd );
CheckDlgButton( dialog, CHECK_AUTO_PURGE, listData->autoPurge );
SetDlgItemInt( dialog, EDIT_MAX_ITEMS, listData->listLength, FALSE );
SetDlgItemInt( dialog, EDIT_NUM_COLUMNS, listData->columns, FALSE );
if(listData->columns > 1)
{
char *percentages = new char[60];
char *tempStr = new char[60];
sprintf(percentages,"%d",listData->columnWidthPercentage[0]);
for(Int i = 1; i < listData->columns; i++ )
{
strcat(percentages,",");
strcat(percentages,itoa(listData->columnWidthPercentage[i],tempStr,10));
}
SetDlgItemText(dialog,EDIT_COLUMN_PERCENT,percentages);
}
// WordWrap Check Box
if( BitTest( window->winGetStatus(), WIN_STATUS_ONE_LINE ) )
CheckDlgButton( dialog, CHECK_NO_WORDWRAP, BST_CHECKED );
// select the button enabled state for display
SwitchToState( LISTBOX_ENABLED, dialog );
//
// initialize the dialog with values from the window
//
return dialog;
} // end InitListboxPropertiesDialog

View file

@ -0,0 +1,155 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: NewLayoutDialog.cpp //////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: NewLayoutDialog.cpp
//
// Created: Colin Day, July 2001
//
// Desc: New layout dialog procedure
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <windows.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Lib/BaseType.h"
#include "Resource.h"
#include "EditWindow.h"
#include "GUIEdit.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// initNewLayoutDialog ========================================================
/** The new layout dialog is being shown, initialize anything we need to */
//=============================================================================
static void initNewLayoutDialog( HWND hWndDialog )
{
// set default keyboard focus
SetFocus( GetDlgItem( hWndDialog, IDOK ) );
} // end initNewLayoutDialog
// NewLayoutDialogProc ========================================================
/** Dialog procedure for the new layout dialog when starting an entire
* new layout in the editor */
//=============================================================================
LRESULT CALLBACK NewLayoutDialogProc( HWND hWndDialog, UINT message,
WPARAM wParam, LPARAM lParam )
{
switch( message )
{
// ------------------------------------------------------------------------
case WM_INITDIALOG:
{
// initialize the values for the the dialog
initNewLayoutDialog( hWndDialog );
return FALSE;
} // end init dialog
// ------------------------------------------------------------------------
case WM_COMMAND:
{
switch( LOWORD( wParam ) )
{
// --------------------------------------------------------------------
case IDOK:
{
// reset the editor
TheEditor->newLayout();
// end this dialog
EndDialog( hWndDialog, TRUE );
break;
} // end ok
// --------------------------------------------------------------------
case IDCANCEL:
{
EndDialog( hWndDialog, FALSE );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
EndDialog( hWndDialog, FALSE );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end NewLayoutDialogProc

View file

@ -0,0 +1,333 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: ProgressBarProperties.cpp ////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: ProgressBarProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Progress bar properties
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Properties.h"
#include "Resource.h"
#include "GameClient/GadgetProgressBar.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// progressBarPropertiesCallback ==============================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK progressBarPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( PROGRESS_BAR_ENABLED_LEFT );
GadgetProgressBarSetEnabledImageLeft( window, info->image );
GadgetProgressBarSetEnabledColor( window, info->color );
GadgetProgressBarSetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( PROGRESS_BAR_ENABLED_RIGHT );
GadgetProgressBarSetEnabledImageRight( window, info->image );
info = GetStateInfo( PROGRESS_BAR_ENABLED_CENTER );
GadgetProgressBarSetEnabledImageCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_ENABLED_SMALL_CENTER );
GadgetProgressBarSetEnabledImageSmallCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_ENABLED_BAR_LEFT );
GadgetProgressBarSetEnabledBarImageLeft( window, info->image );
GadgetProgressBarSetEnabledBarColor( window, info->color );
GadgetProgressBarSetEnabledBarBorderColor( window, info->borderColor );
info = GetStateInfo( PROGRESS_BAR_ENABLED_BAR_RIGHT );
GadgetProgressBarSetEnabledBarImageRight( window, info->image );
info = GetStateInfo( PROGRESS_BAR_ENABLED_BAR_CENTER );
GadgetProgressBarSetEnabledBarImageCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_ENABLED_BAR_SMALL_CENTER );
GadgetProgressBarSetEnabledBarImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( PROGRESS_BAR_DISABLED_LEFT );
GadgetProgressBarSetDisabledImageLeft( window, info->image );
GadgetProgressBarSetDisabledColor( window, info->color );
GadgetProgressBarSetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( PROGRESS_BAR_DISABLED_RIGHT );
GadgetProgressBarSetDisabledImageRight( window, info->image );
info = GetStateInfo( PROGRESS_BAR_DISABLED_CENTER );
GadgetProgressBarSetDisabledImageCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_DISABLED_SMALL_CENTER );
GadgetProgressBarSetDisabledImageSmallCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_DISABLED_BAR_LEFT );
GadgetProgressBarSetDisabledBarImageLeft( window, info->image );
GadgetProgressBarSetDisabledBarColor( window, info->color );
GadgetProgressBarSetDisabledBarBorderColor( window, info->borderColor );
info = GetStateInfo( PROGRESS_BAR_DISABLED_BAR_RIGHT );
GadgetProgressBarSetDisabledBarImageRight( window, info->image );
info = GetStateInfo( PROGRESS_BAR_DISABLED_BAR_CENTER );
GadgetProgressBarSetDisabledBarImageCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_DISABLED_BAR_SMALL_CENTER );
GadgetProgressBarSetDisabledBarImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( PROGRESS_BAR_HILITE_LEFT );
GadgetProgressBarSetHiliteImageLeft( window, info->image );
GadgetProgressBarSetHiliteColor( window, info->color );
GadgetProgressBarSetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( PROGRESS_BAR_HILITE_RIGHT );
GadgetProgressBarSetHiliteImageRight( window, info->image );
info = GetStateInfo( PROGRESS_BAR_HILITE_CENTER );
GadgetProgressBarSetHiliteImageCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_HILITE_SMALL_CENTER );
GadgetProgressBarSetHiliteImageSmallCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_HILITE_BAR_LEFT );
GadgetProgressBarSetHiliteBarImageLeft( window, info->image );
GadgetProgressBarSetHiliteBarColor( window, info->color );
GadgetProgressBarSetHiliteBarBorderColor( window, info->borderColor );
info = GetStateInfo( PROGRESS_BAR_HILITE_BAR_RIGHT );
GadgetProgressBarSetHiliteBarImageRight( window, info->image );
info = GetStateInfo( PROGRESS_BAR_HILITE_BAR_CENTER );
GadgetProgressBarSetHiliteBarImageCenter( window, info->image );
info = GetStateInfo( PROGRESS_BAR_HILITE_BAR_SMALL_CENTER );
GadgetProgressBarSetHiliteBarImageSmallCenter( window, info->image );
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end progressBarPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitProgressBarPropertiesDialog ============================================
/** Bring up the progress bar properties dialog */
//=============================================================================
HWND InitProgressBarPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)PROGRESS_BAR_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)progressBarPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// store in the image and color table the values for this putton
//
const Image *image;
Color color, borderColor;
// --------------------------------------------------------------------------
image = GadgetProgressBarGetEnabledImageLeft( window );
color = GadgetProgressBarGetEnabledColor( window );
borderColor = GadgetProgressBarGetEnabledBorderColor( window );
StoreImageAndColor( PROGRESS_BAR_ENABLED_LEFT, image, color, borderColor );
image = GadgetProgressBarGetEnabledImageRight( window );
StoreImageAndColor( PROGRESS_BAR_ENABLED_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetEnabledImageCenter( window );
StoreImageAndColor( PROGRESS_BAR_ENABLED_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetEnabledImageSmallCenter( window );
StoreImageAndColor( PROGRESS_BAR_ENABLED_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetEnabledBarImageLeft( window );
color = GadgetProgressBarGetEnabledBarColor( window );
borderColor = GadgetProgressBarGetEnabledBarBorderColor( window );
StoreImageAndColor( PROGRESS_BAR_ENABLED_BAR_LEFT, image, color, borderColor );
image = GadgetProgressBarGetEnabledBarImageRight( window );
StoreImageAndColor( PROGRESS_BAR_ENABLED_BAR_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetEnabledBarImageCenter( window );
StoreImageAndColor( PROGRESS_BAR_ENABLED_BAR_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetEnabledBarImageSmallCenter( window );
StoreImageAndColor( PROGRESS_BAR_ENABLED_BAR_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetProgressBarGetDisabledImageLeft( window );
color = GadgetProgressBarGetDisabledColor( window );
borderColor = GadgetProgressBarGetDisabledBorderColor( window );
StoreImageAndColor( PROGRESS_BAR_DISABLED_LEFT, image, color, borderColor );
image = GadgetProgressBarGetDisabledImageRight( window );
StoreImageAndColor( PROGRESS_BAR_DISABLED_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetDisabledImageCenter( window );
StoreImageAndColor( PROGRESS_BAR_DISABLED_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetDisabledImageSmallCenter( window );
StoreImageAndColor( PROGRESS_BAR_DISABLED_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetDisabledBarImageLeft( window );
color = GadgetProgressBarGetDisabledBarColor( window );
borderColor = GadgetProgressBarGetDisabledBarBorderColor( window );
StoreImageAndColor( PROGRESS_BAR_DISABLED_BAR_LEFT, image, color, borderColor );
image = GadgetProgressBarGetDisabledBarImageRight( window );
StoreImageAndColor( PROGRESS_BAR_DISABLED_BAR_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetDisabledBarImageCenter( window );
StoreImageAndColor( PROGRESS_BAR_DISABLED_BAR_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetDisabledBarImageSmallCenter( window );
StoreImageAndColor( PROGRESS_BAR_DISABLED_BAR_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetProgressBarGetHiliteImageLeft( window );
color = GadgetProgressBarGetHiliteColor( window );
borderColor = GadgetProgressBarGetHiliteBorderColor( window );
StoreImageAndColor( PROGRESS_BAR_HILITE_LEFT, image, color, borderColor );
image = GadgetProgressBarGetHiliteImageRight( window );
StoreImageAndColor( PROGRESS_BAR_HILITE_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetHiliteImageCenter( window );
StoreImageAndColor( PROGRESS_BAR_HILITE_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetHiliteImageSmallCenter( window );
StoreImageAndColor( PROGRESS_BAR_HILITE_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetHiliteBarImageLeft( window );
color = GadgetProgressBarGetHiliteBarColor( window );
borderColor = GadgetProgressBarGetHiliteBarBorderColor( window );
StoreImageAndColor( PROGRESS_BAR_HILITE_BAR_LEFT, image, color, borderColor );
image = GadgetProgressBarGetHiliteBarImageRight( window );
StoreImageAndColor( PROGRESS_BAR_HILITE_BAR_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetHiliteBarImageCenter( window );
StoreImageAndColor( PROGRESS_BAR_HILITE_BAR_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetProgressBarGetHiliteBarImageSmallCenter( window );
StoreImageAndColor( PROGRESS_BAR_HILITE_BAR_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// select the button enabled state for display
SwitchToState( PROGRESS_BAR_ENABLED_LEFT, dialog );
//
// initialize the dialog with values from the window
//
return dialog;
} // end InitProgressBarPropertiesDialog

View file

@ -0,0 +1,266 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: PushButtonProperties.cpp /////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: PushButtonProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Push button properties
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Properties.h"
#include "Resource.h"
#include "GameClient/GadgetPushButton.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// pushButtonPropertiesCallback ===============================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK pushButtonPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( BUTTON_ENABLED );
GadgetButtonSetEnabledImage( window, info->image );
GadgetButtonSetEnabledColor( window, info->color );
GadgetButtonSetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( BUTTON_ENABLED_PUSHED );
GadgetButtonSetEnabledSelectedImage( window, info->image );
GadgetButtonSetEnabledSelectedColor( window, info->color );
GadgetButtonSetEnabledSelectedBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( BUTTON_DISABLED );
GadgetButtonSetDisabledImage( window, info->image );
GadgetButtonSetDisabledColor( window, info->color );
GadgetButtonSetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( BUTTON_DISABLED_PUSHED );
GadgetButtonSetDisabledSelectedImage( window, info->image );
GadgetButtonSetDisabledSelectedColor( window, info->color );
GadgetButtonSetDisabledSelectedBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( BUTTON_HILITE );
GadgetButtonSetHiliteImage( window, info->image );
GadgetButtonSetHiliteColor( window, info->color );
GadgetButtonSetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( BUTTON_HILITE_PUSHED );
GadgetButtonSetHiliteSelectedImage( window, info->image );
GadgetButtonSetHiliteSelectedColor( window, info->color );
GadgetButtonSetHiliteSelectedBorderColor( window, info->borderColor );
UnsignedInt bit;
bit = WIN_STATUS_RIGHT_CLICK;
window->winClearStatus( bit );
if( IsDlgButtonChecked( hWndDialog, CHECK_RIGHT_CLICK ) )
window->winSetStatus( bit );
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end pushButtonPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitPushButtonPropertiesDialog =============================================
/** Bring up the push button properties dialog */
//=============================================================================
HWND InitPushButtonPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)PUSH_BUTTON_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)pushButtonPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// store in the image and color table the values for this putton
//
const Image *image;
Color color, borderColor;
image = GadgetButtonGetEnabledImage( window );
color = GadgetButtonGetEnabledColor( window );
borderColor = GadgetButtonGetEnabledBorderColor( window );
StoreImageAndColor( BUTTON_ENABLED, image, color, borderColor );
image = GadgetButtonGetEnabledSelectedImage( window );
color = GadgetButtonGetEnabledSelectedColor( window );
borderColor = GadgetButtonGetEnabledSelectedBorderColor( window );
StoreImageAndColor( BUTTON_ENABLED_PUSHED, image, color, borderColor );
image = GadgetButtonGetDisabledImage( window );
color = GadgetButtonGetDisabledColor( window );
borderColor = GadgetButtonGetDisabledBorderColor( window );
StoreImageAndColor( BUTTON_DISABLED, image, color, borderColor );
image = GadgetButtonGetDisabledSelectedImage( window );
color = GadgetButtonGetDisabledSelectedColor( window );
borderColor = GadgetButtonGetDisabledSelectedBorderColor( window );
StoreImageAndColor( BUTTON_DISABLED_PUSHED, image, color, borderColor );
image = GadgetButtonGetHiliteImage( window );
color = GadgetButtonGetHiliteColor( window );
borderColor = GadgetButtonGetHiliteBorderColor( window );
StoreImageAndColor( BUTTON_HILITE, image, color, borderColor );
image = GadgetButtonGetHiliteSelectedImage( window );
color = GadgetButtonGetHiliteSelectedColor( window );
borderColor = GadgetButtonGetHiliteSelectedBorderColor( window );
StoreImageAndColor( BUTTON_HILITE_PUSHED, image, color, borderColor );
// select the button enabled state for display
SwitchToState( BUTTON_ENABLED, dialog );
//
// initialize the dialog with values from the window
//
if( BitTest( window->winGetStatus(), WIN_STATUS_RIGHT_CLICK ) )
CheckDlgButton( dialog, CHECK_RIGHT_CLICK, BST_CHECKED );
return dialog;
} // end InitPushButtonPropertiesDialog

View file

@ -0,0 +1,361 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: RadioButtonProperties.cpp ////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: RadioButtonProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Radio button properties
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Common/NameKeyGenerator.h"
#include "GameClient/GameWindowManager.h"
#include "GUIEdit.h"
#include "Properties.h"
#include "Resource.h"
#include "GameClient/GadgetRadioButton.h"
#include "GameClient/Gadget.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// radioButtonPropertiesCallback ==============================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK radioButtonPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_CLEAR_GROUP:
{
SetDlgItemInt( hWndDialog, COMBO_GROUP, 0, FALSE );
break;
} // end clear group
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( RADIO_ENABLED );
GadgetRadioSetEnabledImage( window, info->image );
GadgetRadioSetEnabledColor( window, info->color );
GadgetRadioSetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( RADIO_ENABLED_UNCHECKED_BOX );
GadgetRadioSetEnabledUncheckedBoxImage( window, info->image );
GadgetRadioSetEnabledUncheckedBoxColor( window, info->color );
GadgetRadioSetEnabledUncheckedBoxBorderColor( window, info->borderColor );
info = GetStateInfo( RADIO_ENABLED_CHECKED_BOX );
GadgetRadioSetEnabledCheckedBoxImage( window, info->image );
GadgetRadioSetEnabledCheckedBoxColor( window, info->color );
GadgetRadioSetEnabledCheckedBoxBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( RADIO_DISABLED );
GadgetRadioSetDisabledImage( window, info->image );
GadgetRadioSetDisabledColor( window, info->color );
GadgetRadioSetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( RADIO_DISABLED_UNCHECKED_BOX );
GadgetRadioSetDisabledUncheckedBoxImage( window, info->image );
GadgetRadioSetDisabledUncheckedBoxColor( window, info->color );
GadgetRadioSetDisabledUncheckedBoxBorderColor( window, info->borderColor );
info = GetStateInfo( RADIO_DISABLED_CHECKED_BOX );
GadgetRadioSetDisabledCheckedBoxImage( window, info->image );
GadgetRadioSetDisabledCheckedBoxColor( window, info->color );
GadgetRadioSetDisabledCheckedBoxBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( RADIO_HILITE );
GadgetRadioSetHiliteImage( window, info->image );
GadgetRadioSetHiliteColor( window, info->color );
GadgetRadioSetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( RADIO_HILITE_UNCHECKED_BOX );
GadgetRadioSetHiliteUncheckedBoxImage( window, info->image );
GadgetRadioSetHiliteUncheckedBoxColor( window, info->color );
GadgetRadioSetHiliteUncheckedBoxBorderColor( window, info->borderColor );
info = GetStateInfo( RADIO_HILITE_CHECKED_BOX );
GadgetRadioSetHiliteCheckedBoxImage( window, info->image );
GadgetRadioSetHiliteCheckedBoxColor( window, info->color );
GadgetRadioSetHiliteCheckedBoxBorderColor( window, info->borderColor );
// save group
Int group = GetDlgItemInt( hWndDialog, COMBO_GROUP, NULL, FALSE );
Int screen = TheNameKeyGenerator->nameToKey( AsciiString(TheEditor->getSaveFilename()) );
GadgetRadioSetGroup( window, group, screen );
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end radioButtonPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// loadExistingGroupsCombo ====================================================
/** fill the group combo box with all the other groups in the screen */
//=============================================================================
static void loadExistingGroupsCombo( HWND combo, GameWindow *window )
{
// sanity
if( combo == NULL )
return;
// end of recursion
if( window == NULL )
return;
// if this is a radio button get the group
if( BitTest( window->winGetStyle(), GWS_RADIO_BUTTON ) )
{
RadioButtonData *radioData = (RadioButtonData *)window->winGetUserData();
char buffer[ 64 ];
// convert to string
sprintf( buffer, "%d", radioData->group );
// only add it not already there
if( SendMessage( combo, CB_FINDSTRINGEXACT, -1, (LPARAM)buffer ) == CB_ERR )
SendMessage( combo, CB_ADDSTRING, 0, (LPARAM)buffer );
} // end if
// search our children
GameWindow *child;
for( child = window->winGetChild(); child; child = child->winGetNext() )
loadExistingGroupsCombo( combo, child );
// search the next in line
loadExistingGroupsCombo( combo, window->winGetNext() );
} // end loadExistingGroupsCombo
// InitRadioButtonPropertiesDialog ============================================
/** Bring up the radio button properties dialog */
//=============================================================================
HWND InitRadioButtonPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)RADIO_BUTTON_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)radioButtonPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// store in the image and color table the values for this putton
//
const Image *image;
Color color, borderColor;
// --------------------------------------------------------------------------
image = GadgetRadioGetEnabledImage( window );
color = GadgetRadioGetEnabledColor( window );
borderColor = GadgetRadioGetEnabledBorderColor( window );
StoreImageAndColor( RADIO_ENABLED, image, color, borderColor );
image = GadgetRadioGetEnabledUncheckedBoxImage( window );
color = GadgetRadioGetEnabledUncheckedBoxColor( window );
borderColor = GadgetRadioGetEnabledUncheckedBoxBorderColor( window );
StoreImageAndColor( RADIO_ENABLED_UNCHECKED_BOX, image, color, borderColor );
image = GadgetRadioGetEnabledCheckedBoxImage( window );
color = GadgetRadioGetEnabledCheckedBoxColor( window );
borderColor = GadgetRadioGetEnabledCheckedBoxBorderColor( window );
StoreImageAndColor( RADIO_ENABLED_CHECKED_BOX, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetRadioGetDisabledImage( window );
color = GadgetRadioGetDisabledColor( window );
borderColor = GadgetRadioGetDisabledBorderColor( window );
StoreImageAndColor( RADIO_DISABLED, image, color, borderColor );
image = GadgetRadioGetDisabledUncheckedBoxImage( window );
color = GadgetRadioGetDisabledUncheckedBoxColor( window );
borderColor = GadgetRadioGetDisabledUncheckedBoxBorderColor( window );
StoreImageAndColor( RADIO_DISABLED_UNCHECKED_BOX, image, color, borderColor );
image = GadgetRadioGetDisabledCheckedBoxImage( window );
color = GadgetRadioGetDisabledCheckedBoxColor( window );
borderColor = GadgetRadioGetDisabledCheckedBoxBorderColor( window );
StoreImageAndColor( RADIO_DISABLED_CHECKED_BOX, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetRadioGetHiliteImage( window );
color = GadgetRadioGetHiliteColor( window );
borderColor = GadgetRadioGetHiliteBorderColor( window );
StoreImageAndColor( RADIO_HILITE, image, color, borderColor );
image = GadgetRadioGetHiliteUncheckedBoxImage( window );
color = GadgetRadioGetHiliteUncheckedBoxColor( window );
borderColor = GadgetRadioGetHiliteUncheckedBoxBorderColor( window );
StoreImageAndColor( RADIO_HILITE_UNCHECKED_BOX, image, color, borderColor );
image = GadgetRadioGetHiliteCheckedBoxImage( window );
color = GadgetRadioGetHiliteCheckedBoxColor( window );
borderColor = GadgetRadioGetHiliteCheckedBoxBorderColor( window );
StoreImageAndColor( RADIO_HILITE_CHECKED_BOX, image, color, borderColor );
// radio data
RadioButtonData *radioData = (RadioButtonData *)window->winGetUserData();
// fill the group combo box with all the other groups in the screen
loadExistingGroupsCombo( GetDlgItem( dialog, COMBO_GROUP ),
TheWindowManager->winGetWindowList() );
// set the group for this radio button
SetDlgItemInt( dialog, COMBO_GROUP, radioData->group, FALSE );
// select the button enabled state for display
SwitchToState( RADIO_ENABLED, dialog );
//
// initialize the dialog with values from the window
//
return dialog;
} // end InitRadioButtonPropertiesDialog

View file

@ -0,0 +1,484 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: SliderProperties.cpp /////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: SliderProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Slider properties
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Properties.h"
#include "Resource.h"
#include "GameClient/GadgetSlider.h"
#include "GameClient/Gadget.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// sliderPropertiesCallback ===================================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK sliderPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_SUBCONTROL_COLOR:
{
ImageAndColorInfo *info;
GameWindow *window = TheEditor->getPropertyTarget();
Bool vert = FALSE;
if( window )
vert = BitTest( window->winGetStyle(), GWS_VERT_SLIDER );
//
// using the current colors in the base of the slider, assign a
// reasonable color scheme to all the sub control components
//
if( vert )
{
info = GetStateInfo( VSLIDER_ENABLED_TOP );
StoreColor( VSLIDER_THUMB_ENABLED, info->color, info->borderColor );
StoreColor( VSLIDER_THUMB_ENABLED_PUSHED, info->borderColor, info->color );
info = GetStateInfo( VSLIDER_DISABLED_TOP );
StoreColor( VSLIDER_THUMB_DISABLED, info->color, info->borderColor );
StoreColor( VSLIDER_THUMB_DISABLED_PUSHED, info->borderColor, info->color );
info = GetStateInfo( VSLIDER_HILITE_TOP );
StoreColor( VSLIDER_THUMB_HILITE, info->color, info->borderColor );
StoreColor( VSLIDER_THUMB_HILITE_PUSHED, info->borderColor, info->color );
} // end if, vertical slider
else
{
info = GetStateInfo( HSLIDER_ENABLED_LEFT );
StoreColor( HSLIDER_THUMB_ENABLED, info->color, info->borderColor );
StoreColor( HSLIDER_THUMB_ENABLED_PUSHED, info->borderColor, info->color );
info = GetStateInfo( HSLIDER_DISABLED_LEFT );
StoreColor( HSLIDER_THUMB_DISABLED, info->color, info->borderColor );
StoreColor( HSLIDER_THUMB_DISABLED_PUSHED, info->borderColor, info->color );
info = GetStateInfo( HSLIDER_HILITE_LEFT );
StoreColor( HSLIDER_THUMB_HILITE, info->color, info->borderColor );
StoreColor( HSLIDER_THUMB_HILITE_PUSHED, info->borderColor, info->color );
} // end else horizontal slider
break;
} // end case subcontrol color
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
Bool vert = BitTest( window->winGetStyle(), GWS_VERT_SLIDER );
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
if( vert )
{
info = GetStateInfo( VSLIDER_ENABLED_TOP );
GadgetSliderSetEnabledImageTop( window, info->image );
GadgetSliderSetEnabledColor( window, info->color );
GadgetSliderSetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( VSLIDER_ENABLED_BOTTOM );
GadgetSliderSetEnabledImageBottom( window, info->image );
} // end if
else
{
info = GetStateInfo( HSLIDER_ENABLED_LEFT );
GadgetSliderSetEnabledImageLeft( window, info->image );
GadgetSliderSetEnabledColor( window, info->color );
GadgetSliderSetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( HSLIDER_ENABLED_RIGHT );
GadgetSliderSetEnabledImageRight( window, info->image );
} // end else
info = GetStateInfo( vert ? VSLIDER_ENABLED_CENTER : HSLIDER_ENABLED_CENTER );
GadgetSliderSetEnabledImageCenter( window, info->image );
info = GetStateInfo( vert ? VSLIDER_ENABLED_SMALL_CENTER : HSLIDER_ENABLED_SMALL_CENTER );
GadgetSliderSetEnabledImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
if( vert )
{
info = GetStateInfo( VSLIDER_DISABLED_TOP );
GadgetSliderSetDisabledImageTop( window, info->image );
GadgetSliderSetDisabledColor( window, info->color );
GadgetSliderSetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( VSLIDER_DISABLED_BOTTOM );
GadgetSliderSetDisabledImageBottom( window, info->image );
} // end if
else
{
info = GetStateInfo( HSLIDER_DISABLED_LEFT );
GadgetSliderSetDisabledImageLeft( window, info->image );
GadgetSliderSetDisabledColor( window, info->color );
GadgetSliderSetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( HSLIDER_DISABLED_RIGHT );
GadgetSliderSetDisabledImageRight( window, info->image );
} // end else
info = GetStateInfo( vert ? VSLIDER_DISABLED_CENTER : HSLIDER_DISABLED_CENTER );
GadgetSliderSetDisabledImageCenter( window, info->image );
info = GetStateInfo( vert ? VSLIDER_DISABLED_SMALL_CENTER : HSLIDER_DISABLED_SMALL_CENTER );
GadgetSliderSetDisabledImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
if( vert )
{
info = GetStateInfo( VSLIDER_HILITE_TOP );
GadgetSliderSetHiliteImageTop( window, info->image );
GadgetSliderSetHiliteColor( window, info->color );
GadgetSliderSetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( VSLIDER_HILITE_BOTTOM );
GadgetSliderSetHiliteImageBottom( window, info->image );
} // end if
else
{
info = GetStateInfo( HSLIDER_HILITE_LEFT );
GadgetSliderSetHiliteImageLeft( window, info->image );
GadgetSliderSetHiliteColor( window, info->color );
GadgetSliderSetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( HSLIDER_HILITE_RIGHT );
GadgetSliderSetHiliteImageRight( window, info->image );
} // end else
info = GetStateInfo( vert ? VSLIDER_HILITE_CENTER : HSLIDER_HILITE_CENTER );
GadgetSliderSetHiliteImageCenter( window, info->image );
info = GetStateInfo( vert ? VSLIDER_HILITE_SMALL_CENTER : HSLIDER_HILITE_SMALL_CENTER );
GadgetSliderSetHiliteImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( vert ? VSLIDER_THUMB_ENABLED : HSLIDER_THUMB_ENABLED );
GadgetSliderSetEnabledThumbImage( window, info->image );
GadgetSliderSetEnabledThumbColor( window, info->color );
GadgetSliderSetEnabledThumbBorderColor( window, info->borderColor );
info = GetStateInfo( vert ? VSLIDER_THUMB_ENABLED_PUSHED : HSLIDER_THUMB_ENABLED_PUSHED );
GadgetSliderSetEnabledSelectedThumbImage( window, info->image );
GadgetSliderSetEnabledSelectedThumbColor( window, info->color );
GadgetSliderSetEnabledSelectedThumbBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( vert ? VSLIDER_THUMB_DISABLED : HSLIDER_THUMB_DISABLED );
GadgetSliderSetDisabledThumbImage( window, info->image );
GadgetSliderSetDisabledThumbColor( window, info->color );
GadgetSliderSetDisabledThumbBorderColor( window, info->borderColor );
info = GetStateInfo( vert ? VSLIDER_THUMB_DISABLED_PUSHED : HSLIDER_THUMB_DISABLED_PUSHED );
GadgetSliderSetDisabledSelectedThumbImage( window, info->image );
GadgetSliderSetDisabledSelectedThumbColor( window, info->color );
GadgetSliderSetDisabledSelectedThumbBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( vert ? VSLIDER_THUMB_HILITE : HSLIDER_THUMB_HILITE );
GadgetSliderSetHiliteThumbImage( window, info->image );
GadgetSliderSetHiliteThumbColor( window, info->color );
GadgetSliderSetHiliteThumbBorderColor( window, info->borderColor );
info = GetStateInfo( vert ? VSLIDER_THUMB_HILITE_PUSHED : HSLIDER_THUMB_HILITE_PUSHED );
GadgetSliderSetHiliteSelectedThumbImage( window, info->image );
GadgetSliderSetHiliteSelectedThumbColor( window, info->color );
GadgetSliderSetHiliteSelectedThumbBorderColor( window, info->borderColor );
// slider data
SliderData *sliderData = (SliderData *)window->winGetUserData();
sliderData->minVal = GetDlgItemInt( hWndDialog, EDIT_SLIDER_MIN, NULL, FALSE );
sliderData->maxVal = GetDlgItemInt( hWndDialog, EDIT_SLIDER_MAX, NULL, FALSE );
// sanity
if( sliderData->minVal > sliderData->maxVal )
{
Int temp = sliderData->minVal;
sliderData->minVal = sliderData->maxVal;
sliderData->maxVal = temp;
MessageBox( NULL, "Slider min greated than max, the values were swapped",
"Warning", MB_OK | MB_ICONINFORMATION );
} // end if
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end sliderPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitSliderPropertiesDialog =================================================
/** Slider properties dialog */
//=============================================================================
HWND InitSliderPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)SLIDER_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)sliderPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// init values
//
const Image *image;
Color color, borderColor;
Bool vert = BitTest( window->winGetStyle(), GWS_VERT_SLIDER );
// --------------------------------------------------------------------------
if( vert )
image = GadgetSliderGetEnabledImageTop( window );
else
image = GadgetSliderGetEnabledImageLeft( window );
color = GadgetSliderGetEnabledColor( window );
borderColor = GadgetSliderGetEnabledBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_ENABLED_TOP : HSLIDER_ENABLED_LEFT, image, color, borderColor );
if( vert )
image = GadgetSliderGetEnabledImageBottom( window );
else
image = GadgetSliderGetEnabledImageRight( window );
StoreImageAndColor( vert ? VSLIDER_ENABLED_BOTTOM : HSLIDER_ENABLED_RIGHT, image, color, borderColor );
image = GadgetSliderGetEnabledImageCenter( window );
StoreImageAndColor( vert ? VSLIDER_ENABLED_CENTER : HSLIDER_ENABLED_CENTER, image, color, borderColor );
image = GadgetSliderGetEnabledImageSmallCenter( window );
StoreImageAndColor( vert ? VSLIDER_ENABLED_SMALL_CENTER : HSLIDER_ENABLED_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
if( vert )
image = GadgetSliderGetDisabledImageTop( window );
else
image = GadgetSliderGetDisabledImageLeft( window );
color = GadgetSliderGetDisabledColor( window );
borderColor = GadgetSliderGetDisabledBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_DISABLED_TOP : HSLIDER_DISABLED_LEFT, image, color, borderColor );
if( vert )
image = GadgetSliderGetDisabledImageBottom( window );
else
image = GadgetSliderGetDisabledImageRight( window );
StoreImageAndColor( vert ? VSLIDER_DISABLED_BOTTOM : HSLIDER_DISABLED_RIGHT, image, color, borderColor );
image = GadgetSliderGetDisabledImageCenter( window );
StoreImageAndColor( vert ? VSLIDER_DISABLED_CENTER : HSLIDER_DISABLED_CENTER, image, color, borderColor );
image = GadgetSliderGetDisabledImageSmallCenter( window );
StoreImageAndColor( vert ? VSLIDER_DISABLED_SMALL_CENTER : HSLIDER_DISABLED_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
if( vert )
image = GadgetSliderGetHiliteImageTop( window );
else
image = GadgetSliderGetHiliteImageLeft( window );
color = GadgetSliderGetHiliteColor( window );
borderColor = GadgetSliderGetHiliteBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_HILITE_TOP : HSLIDER_HILITE_LEFT, image, color, borderColor );
if( vert )
image = GadgetSliderGetHiliteImageBottom( window );
else
image = GadgetSliderGetHiliteImageRight( window );
StoreImageAndColor( vert ? VSLIDER_HILITE_BOTTOM : HSLIDER_HILITE_RIGHT, image, color, borderColor );
image = GadgetSliderGetHiliteImageCenter( window );
StoreImageAndColor( vert ? VSLIDER_HILITE_CENTER : HSLIDER_HILITE_CENTER, image, color, borderColor );
image = GadgetSliderGetHiliteImageSmallCenter( window );
StoreImageAndColor( vert ? VSLIDER_HILITE_SMALL_CENTER : HSLIDER_HILITE_SMALL_CENTER, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetEnabledThumbImage( window );
color = GadgetSliderGetEnabledThumbColor( window );
borderColor = GadgetSliderGetEnabledThumbBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_THUMB_ENABLED : HSLIDER_THUMB_ENABLED, image, color, borderColor );
image = GadgetSliderGetEnabledSelectedThumbImage( window );
color = GadgetSliderGetEnabledSelectedThumbColor( window );
borderColor = GadgetSliderGetEnabledSelectedThumbBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_THUMB_ENABLED_PUSHED : HSLIDER_THUMB_ENABLED_PUSHED, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetDisabledThumbImage( window );
color = GadgetSliderGetDisabledThumbColor( window );
borderColor = GadgetSliderGetDisabledThumbBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_THUMB_DISABLED : HSLIDER_THUMB_DISABLED, image, color, borderColor );
image = GadgetSliderGetDisabledSelectedThumbImage( window );
color = GadgetSliderGetDisabledSelectedThumbColor( window );
borderColor = GadgetSliderGetDisabledSelectedThumbBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_THUMB_DISABLED_PUSHED : HSLIDER_THUMB_DISABLED_PUSHED, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetSliderGetHiliteThumbImage( window );
color = GadgetSliderGetHiliteThumbColor( window );
borderColor = GadgetSliderGetHiliteThumbBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_THUMB_HILITE : HSLIDER_THUMB_HILITE, image, color, borderColor );
image = GadgetSliderGetHiliteSelectedThumbImage( window );
color = GadgetSliderGetHiliteSelectedThumbColor( window );
borderColor = GadgetSliderGetHiliteSelectedThumbBorderColor( window );
StoreImageAndColor( vert ? VSLIDER_THUMB_HILITE_PUSHED : HSLIDER_THUMB_HILITE_PUSHED, image, color, borderColor );
// slider data
SliderData *sliderData = (SliderData *)window->winGetUserData();
SetDlgItemInt( dialog, EDIT_SLIDER_MIN, sliderData->minVal, FALSE );
SetDlgItemInt( dialog, EDIT_SLIDER_MAX, sliderData->maxVal, FALSE );
// select the enabled state for display
SwitchToState( vert ? VSLIDER_ENABLED_TOP : HSLIDER_ENABLED_LEFT, dialog );
return dialog;
} // end InitSliderPropertiesDialog

View file

@ -0,0 +1,257 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: StaticTextProperties.cpp /////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: StaticTextSliderProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Static text properties
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Properties.h"
#include "Resource.h"
#include "GameClient/GadgetStaticText.h"
#include "GameClient/Gadget.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
static Bool currCentered = FALSE;
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// staticTextPropertiesCallback ===============================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK staticTextPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case BUTTON_CENTERED:
{
currCentered = 1 - currCentered;
if( currCentered == TRUE )
SetDlgItemText( hWndDialog, BUTTON_CENTERED, "Yes" );
else
SetDlgItemText( hWndDialog, BUTTON_CENTERED, "No" );
break;
} // end centered
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( STATIC_TEXT_ENABLED );
GadgetStaticTextSetEnabledImage( window, info->image );
GadgetStaticTextSetEnabledColor( window, info->color );
GadgetStaticTextSetEnabledBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( STATIC_TEXT_DISABLED );
GadgetStaticTextSetDisabledImage( window, info->image );
GadgetStaticTextSetDisabledColor( window, info->color );
GadgetStaticTextSetDisabledBorderColor( window, info->borderColor );
// ----------------------------------------------------------------
info = GetStateInfo( STATIC_TEXT_HILITE );
GadgetStaticTextSetHiliteImage( window, info->image );
GadgetStaticTextSetHiliteColor( window, info->color );
GadgetStaticTextSetHiliteBorderColor( window, info->borderColor );
// text data
TextData *textData = (TextData *)window->winGetUserData();
textData->centered = currCentered;
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end staticTextPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitStaticTextPropertiesDialog =============================================
/** Bring up the static text properties dialog */
//=============================================================================
HWND InitStaticTextPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)STATIC_TEXT_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)staticTextPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// store in the image and color table the values for this putton
//
const Image *image;
Color color, borderColor;
// --------------------------------------------------------------------------
image = GadgetStaticTextGetEnabledImage( window );
color = GadgetStaticTextGetEnabledColor( window );
borderColor = GadgetStaticTextGetEnabledBorderColor( window );
StoreImageAndColor( STATIC_TEXT_ENABLED, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetStaticTextGetDisabledImage( window );
color = GadgetStaticTextGetDisabledColor( window );
borderColor = GadgetStaticTextGetDisabledBorderColor( window );
StoreImageAndColor( STATIC_TEXT_DISABLED, image, color, borderColor );
// --------------------------------------------------------------------------
image = GadgetStaticTextGetHiliteImage( window );
color = GadgetStaticTextGetHiliteColor( window );
borderColor = GadgetStaticTextGetHiliteBorderColor( window );
StoreImageAndColor( STATIC_TEXT_HILITE, image, color, borderColor );
// text data
TextData *textData = (TextData *)window->winGetUserData();
if( textData->centered )
SetDlgItemText( dialog, BUTTON_CENTERED, "Yes" );
else
SetDlgItemText( dialog, BUTTON_CENTERED, "No" );
currCentered = textData->centered;
// select the button enabled state for display
SwitchToState( STATIC_TEXT_ENABLED, dialog );
return dialog;
} // end InitStaticTextPropertiesDialog

View file

@ -0,0 +1,622 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: C:\projects\RTS\code\Tools\GUIEdit\Source\Dialog Procedures\TabControlProperties.cpp
//
// Created: Graham Smallwood, November 2001
//
// Desc: Tab Control properties
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "Common/NameKeyGenerator.h"
#include "GameClient/GameWindowManager.h"
#include "GUIEdit.h"
#include "HierarchyView.h"
#include "Properties.h"
#include "Resource.h"
#include "GameClient/GadgetTabControl.h"
#include "GameClient/Gadget.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///< Pane names are derived off the Tab Control's name.
static void GadgetTabControlUpdatePaneNames( GameWindow *tabControl )
{
TabControlData *tabData = (TabControlData *)tabControl->winGetUserData();
WinInstanceData *controlInstData = tabControl->winGetInstanceData();
for( Int paneIndex = 0; paneIndex < NUM_TAB_PANES; paneIndex++ )
{
WinInstanceData *paneInstData = tabData->subPanes[paneIndex]->winGetInstanceData();
char buffer[128];//legal limit is 64, which will be checked at save.
sprintf( buffer, "%s Pane %d", controlInstData->m_decoratedNameString.str() ,paneIndex );
paneInstData->m_decoratedNameString = buffer;
if( TheHierarchyView )
TheHierarchyView->updateWindowName( tabData->subPanes[paneIndex] );
}
}
// radioButtonPropertiesCallback ==============================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK tabControlPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *tabControl = TheEditor->getPropertyTarget();
// sanity
if( tabControl )
{
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, tabControl ) == FALSE )
break;
ImageAndColorInfo *info;
info = GetStateInfo( TC_TAB_0_ENABLED );
GadgetTabControlSetEnabledImageTabZero( tabControl, info->image );
GadgetTabControlSetEnabledColorTabZero( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorTabZero( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_1_ENABLED );
GadgetTabControlSetEnabledImageTabOne( tabControl, info->image );
GadgetTabControlSetEnabledColorTabOne( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorTabOne( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_2_ENABLED );
GadgetTabControlSetEnabledImageTabTwo( tabControl, info->image );
GadgetTabControlSetEnabledColorTabTwo( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorTabTwo( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_3_ENABLED );
GadgetTabControlSetEnabledImageTabThree( tabControl, info->image );
GadgetTabControlSetEnabledColorTabThree( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorTabThree( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_4_ENABLED );
GadgetTabControlSetEnabledImageTabFour( tabControl, info->image );
GadgetTabControlSetEnabledColorTabFour( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorTabFour( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_5_ENABLED );
GadgetTabControlSetEnabledImageTabFive( tabControl, info->image );
GadgetTabControlSetEnabledColorTabFive( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorTabFive( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_6_ENABLED );
GadgetTabControlSetEnabledImageTabSix( tabControl, info->image );
GadgetTabControlSetEnabledColorTabSix( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorTabSix( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_7_ENABLED );
GadgetTabControlSetEnabledImageTabSeven( tabControl, info->image );
GadgetTabControlSetEnabledColorTabSeven( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorTabSeven( tabControl, info->borderColor );
info = GetStateInfo( TAB_CONTROL_ENABLED );
GadgetTabControlSetEnabledImageBackground( tabControl, info->image );
GadgetTabControlSetEnabledColorBackground( tabControl, info->color );
GadgetTabControlSetEnabledBorderColorBackground( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_0_DISABLED );
GadgetTabControlSetDisabledImageTabZero( tabControl, info->image );
GadgetTabControlSetDisabledColorTabZero( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorTabZero( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_1_DISABLED );
GadgetTabControlSetDisabledImageTabOne( tabControl, info->image );
GadgetTabControlSetDisabledColorTabOne( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorTabOne( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_2_DISABLED );
GadgetTabControlSetDisabledImageTabTwo( tabControl, info->image );
GadgetTabControlSetDisabledColorTabTwo( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorTabTwo( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_3_DISABLED );
GadgetTabControlSetDisabledImageTabThree( tabControl, info->image );
GadgetTabControlSetDisabledColorTabThree( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorTabThree( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_4_DISABLED );
GadgetTabControlSetDisabledImageTabFour( tabControl, info->image );
GadgetTabControlSetDisabledColorTabFour( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorTabFour( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_5_DISABLED );
GadgetTabControlSetDisabledImageTabFive( tabControl, info->image );
GadgetTabControlSetDisabledColorTabFive( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorTabFive( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_6_DISABLED );
GadgetTabControlSetDisabledImageTabSix( tabControl, info->image );
GadgetTabControlSetDisabledColorTabSix( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorTabSix( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_7_DISABLED );
GadgetTabControlSetDisabledImageTabSeven( tabControl, info->image );
GadgetTabControlSetDisabledColorTabSeven( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorTabSeven( tabControl, info->borderColor );
info = GetStateInfo( TAB_CONTROL_DISABLED );
GadgetTabControlSetDisabledImageBackground( tabControl, info->image );
GadgetTabControlSetDisabledColorBackground( tabControl, info->color );
GadgetTabControlSetDisabledBorderColorBackground( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_0_HILITE );
GadgetTabControlSetHiliteImageTabZero( tabControl, info->image );
GadgetTabControlSetHiliteColorTabZero( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorTabZero( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_1_HILITE );
GadgetTabControlSetHiliteImageTabOne( tabControl, info->image );
GadgetTabControlSetHiliteColorTabOne( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorTabOne( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_2_HILITE );
GadgetTabControlSetHiliteImageTabTwo( tabControl, info->image );
GadgetTabControlSetHiliteColorTabTwo( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorTabTwo( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_3_HILITE );
GadgetTabControlSetHiliteImageTabThree( tabControl, info->image );
GadgetTabControlSetHiliteColorTabThree( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorTabThree( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_4_HILITE );
GadgetTabControlSetHiliteImageTabFour( tabControl, info->image );
GadgetTabControlSetHiliteColorTabFour( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorTabFour( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_5_HILITE );
GadgetTabControlSetHiliteImageTabFive( tabControl, info->image );
GadgetTabControlSetHiliteColorTabFive( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorTabFive( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_6_HILITE );
GadgetTabControlSetHiliteImageTabSix( tabControl, info->image );
GadgetTabControlSetHiliteColorTabSix( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorTabSix( tabControl, info->borderColor );
info = GetStateInfo( TC_TAB_7_HILITE );
GadgetTabControlSetHiliteImageTabSeven( tabControl, info->image );
GadgetTabControlSetHiliteColorTabSeven( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorTabSeven( tabControl, info->borderColor );
info = GetStateInfo( TAB_CONTROL_HILITE );
GadgetTabControlSetHiliteImageBackground( tabControl, info->image );
GadgetTabControlSetHiliteColorBackground( tabControl, info->color );
GadgetTabControlSetHiliteBorderColorBackground( tabControl, info->borderColor );
TabControlData *tabData = (TabControlData *)tabControl->winGetUserData();
tabData->tabWidth = GetDlgItemInt( hWndDialog, TAB_WIDTH, NULL, FALSE );
tabData->tabHeight = GetDlgItemInt(hWndDialog, TAB_HEIGHT, NULL, FALSE );
tabData->tabCount = GetDlgItemInt(hWndDialog, TAB_COUNT, NULL, FALSE );
tabData->paneBorder = GetDlgItemInt(hWndDialog, BORDER_WIDTH, NULL, FALSE );
tabData->activeTab = GetDlgItemInt(hWndDialog, ACTIVE_TAB, NULL, FALSE );
if( IsDlgButtonChecked( hWndDialog, DISABLE_TAB_0 ) )
tabData->subPaneDisabled[0] = TRUE;
else
tabData->subPaneDisabled[0] = FALSE;
if( IsDlgButtonChecked( hWndDialog, DISABLE_TAB_1 ) )
tabData->subPaneDisabled[1] = TRUE;
else
tabData->subPaneDisabled[1] = FALSE;
if( IsDlgButtonChecked( hWndDialog, DISABLE_TAB_2 ) )
tabData->subPaneDisabled[2] = TRUE;
else
tabData->subPaneDisabled[2] = FALSE;
if( IsDlgButtonChecked( hWndDialog, DISABLE_TAB_3 ) )
tabData->subPaneDisabled[3] = TRUE;
else
tabData->subPaneDisabled[3] = FALSE;
if( IsDlgButtonChecked( hWndDialog, DISABLE_TAB_4 ) )
tabData->subPaneDisabled[4] = TRUE;
else
tabData->subPaneDisabled[4] = FALSE;
if( IsDlgButtonChecked( hWndDialog, DISABLE_TAB_5 ) )
tabData->subPaneDisabled[5] = TRUE;
else
tabData->subPaneDisabled[5] = FALSE;
if( IsDlgButtonChecked( hWndDialog, DISABLE_TAB_6 ) )
tabData->subPaneDisabled[6] = TRUE;
else
tabData->subPaneDisabled[6] = FALSE;
if( IsDlgButtonChecked( hWndDialog, DISABLE_TAB_7 ) )
tabData->subPaneDisabled[7] = TRUE;
else
tabData->subPaneDisabled[7] = FALSE;
if( IsDlgButtonChecked( hWndDialog, LEFT_JUSTIFY) )
tabData->tabOrientation = TP_TOPLEFT;
else if( IsDlgButtonChecked( hWndDialog, CENTER_JUSTIFY ) )
tabData->tabOrientation = TP_CENTER;
else if( IsDlgButtonChecked( hWndDialog, RIGHT_JUSTIFY ) )
tabData->tabOrientation = TP_BOTTOMRIGHT;
if( IsDlgButtonChecked( hWndDialog, TOP_SIDE ) )
tabData->tabEdge = TP_TOP_SIDE;
else if( IsDlgButtonChecked( hWndDialog, RIGHT_SIDE ) )
tabData->tabEdge = TP_RIGHT_SIDE;
else if( IsDlgButtonChecked( hWndDialog, LEFT_SIDE ) )
tabData->tabEdge = TP_LEFT_SIDE;
else if( IsDlgButtonChecked( hWndDialog, BOTTOM_SIDE ) )
tabData->tabEdge = TP_BOTTOM_SIDE;
//safeties
tabData->tabCount = max( tabData->tabCount, 1 );
tabData->tabCount = min( tabData->tabCount, NUM_TAB_PANES );
GadgetTabControlComputeTabRegion( tabControl );
GadgetTabControlResizeSubPanes( tabControl );
GadgetTabControlShowSubPane( tabControl, tabData->activeTab );
GadgetTabControlUpdatePaneNames( tabControl );
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end tabControlPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitTabControlPropertiesDialog ============================================
/** Bring up the tab control properties dialog */
//=============================================================================
HWND InitTabControlPropertiesDialog( GameWindow *tabControl )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)TAB_CONTROL_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)tabControlPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( tabControl, dialog );
//
// store in the image and color table the values for this button
//
const Image *image;
Color color, borderColor;
image = GadgetTabControlGetEnabledImageTabZero( tabControl );
color = GadgetTabControlGetEnabledColorTabZero( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorTabZero( tabControl );
StoreImageAndColor( TC_TAB_0_ENABLED, image, color, borderColor );
image = GadgetTabControlGetEnabledImageTabOne( tabControl );
color = GadgetTabControlGetEnabledColorTabOne( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorTabOne( tabControl );
StoreImageAndColor( TC_TAB_1_ENABLED, image, color, borderColor );
image = GadgetTabControlGetEnabledImageTabTwo( tabControl );
color = GadgetTabControlGetEnabledColorTabTwo( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorTabTwo( tabControl );
StoreImageAndColor( TC_TAB_2_ENABLED, image, color, borderColor );
image = GadgetTabControlGetEnabledImageTabThree( tabControl );
color = GadgetTabControlGetEnabledColorTabThree( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorTabThree( tabControl );
StoreImageAndColor( TC_TAB_3_ENABLED, image, color, borderColor );
image = GadgetTabControlGetEnabledImageTabFour( tabControl );
color = GadgetTabControlGetEnabledColorTabFour( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorTabFour( tabControl );
StoreImageAndColor( TC_TAB_4_ENABLED, image, color, borderColor );
image = GadgetTabControlGetEnabledImageTabFive( tabControl );
color = GadgetTabControlGetEnabledColorTabFive( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorTabFive( tabControl );
StoreImageAndColor( TC_TAB_5_ENABLED, image, color, borderColor );
image = GadgetTabControlGetEnabledImageTabSix( tabControl );
color = GadgetTabControlGetEnabledColorTabSix( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorTabSix( tabControl );
StoreImageAndColor( TC_TAB_6_ENABLED, image, color, borderColor );
image = GadgetTabControlGetEnabledImageTabSeven( tabControl );
color = GadgetTabControlGetEnabledColorTabSeven( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorTabSeven( tabControl );
StoreImageAndColor( TC_TAB_7_ENABLED, image, color, borderColor );
image = GadgetTabControlGetEnabledImageBackground( tabControl );
color = GadgetTabControlGetEnabledColorBackground( tabControl );
borderColor = GadgetTabControlGetEnabledBorderColorBackground( tabControl );
StoreImageAndColor( TAB_CONTROL_ENABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageTabZero( tabControl );
color = GadgetTabControlGetDisabledColorTabZero( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorTabZero( tabControl );
StoreImageAndColor( TC_TAB_0_DISABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageTabOne( tabControl );
color = GadgetTabControlGetDisabledColorTabOne( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorTabOne( tabControl );
StoreImageAndColor( TC_TAB_1_DISABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageTabTwo( tabControl );
color = GadgetTabControlGetDisabledColorTabTwo( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorTabTwo( tabControl );
StoreImageAndColor( TC_TAB_2_DISABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageTabThree( tabControl );
color = GadgetTabControlGetDisabledColorTabThree( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorTabThree( tabControl );
StoreImageAndColor( TC_TAB_3_DISABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageTabFour( tabControl );
color = GadgetTabControlGetDisabledColorTabFour( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorTabFour( tabControl );
StoreImageAndColor( TC_TAB_4_DISABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageTabFive( tabControl );
color = GadgetTabControlGetDisabledColorTabFive( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorTabFive( tabControl );
StoreImageAndColor( TC_TAB_5_DISABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageTabSix( tabControl );
color = GadgetTabControlGetDisabledColorTabSix( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorTabSix( tabControl );
StoreImageAndColor( TC_TAB_6_DISABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageTabSeven( tabControl );
color = GadgetTabControlGetDisabledColorTabSeven( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorTabSeven( tabControl );
StoreImageAndColor( TC_TAB_7_DISABLED, image, color, borderColor );
image = GadgetTabControlGetDisabledImageBackground( tabControl );
color = GadgetTabControlGetDisabledColorBackground( tabControl );
borderColor = GadgetTabControlGetDisabledBorderColorBackground( tabControl );
StoreImageAndColor( TAB_CONTROL_DISABLED, image, color, borderColor );
image = GadgetTabControlGetHiliteImageTabZero( tabControl );
color = GadgetTabControlGetHiliteColorTabZero( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorTabZero( tabControl );
StoreImageAndColor( TC_TAB_0_HILITE, image, color, borderColor );
image = GadgetTabControlGetHiliteImageTabOne( tabControl );
color = GadgetTabControlGetHiliteColorTabOne( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorTabOne( tabControl );
StoreImageAndColor( TC_TAB_1_HILITE, image, color, borderColor );
image = GadgetTabControlGetHiliteImageTabTwo( tabControl );
color = GadgetTabControlGetHiliteColorTabTwo( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorTabTwo( tabControl );
StoreImageAndColor( TC_TAB_2_HILITE, image, color, borderColor );
image = GadgetTabControlGetHiliteImageTabThree( tabControl );
color = GadgetTabControlGetHiliteColorTabThree( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorTabThree( tabControl );
StoreImageAndColor( TC_TAB_3_HILITE, image, color, borderColor );
image = GadgetTabControlGetHiliteImageTabFour( tabControl );
color = GadgetTabControlGetHiliteColorTabFour( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorTabFour( tabControl );
StoreImageAndColor( TC_TAB_4_HILITE, image, color, borderColor );
image = GadgetTabControlGetHiliteImageTabFive( tabControl );
color = GadgetTabControlGetHiliteColorTabFive( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorTabFive( tabControl );
StoreImageAndColor( TC_TAB_5_HILITE, image, color, borderColor );
image = GadgetTabControlGetHiliteImageTabSix( tabControl );
color = GadgetTabControlGetHiliteColorTabSix( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorTabSix( tabControl );
StoreImageAndColor( TC_TAB_6_HILITE, image, color, borderColor );
image = GadgetTabControlGetHiliteImageTabSeven( tabControl );
color = GadgetTabControlGetHiliteColorTabSeven( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorTabSeven( tabControl );
StoreImageAndColor( TC_TAB_7_HILITE, image, color, borderColor );
image = GadgetTabControlGetHiliteImageBackground( tabControl );
color = GadgetTabControlGetHiliteColorBackground( tabControl );
borderColor = GadgetTabControlGetHiliteBorderColorBackground( tabControl );
StoreImageAndColor( TAB_CONTROL_HILITE, image, color, borderColor );
// tab data
TabControlData *tabData = (TabControlData *)tabControl->winGetUserData();
//
// initialize the dialog with values from the window
//
SetDlgItemInt(dialog, TAB_WIDTH, tabData->tabWidth, FALSE);
SetDlgItemInt(dialog, TAB_HEIGHT, tabData->tabHeight, FALSE);
SetDlgItemInt(dialog, TAB_COUNT, tabData->tabCount, FALSE);
SetDlgItemInt(dialog, BORDER_WIDTH, tabData->paneBorder, FALSE);
SetDlgItemInt(dialog, ACTIVE_TAB, tabData->activeTab, FALSE);
if( tabData->subPaneDisabled[0] )
CheckDlgButton( dialog, DISABLE_TAB_0, BST_CHECKED );
else
CheckDlgButton( dialog, DISABLE_TAB_0, BST_UNCHECKED );
if( tabData->subPaneDisabled[1] )
CheckDlgButton( dialog, DISABLE_TAB_1, BST_CHECKED );
else
CheckDlgButton( dialog, DISABLE_TAB_1, BST_UNCHECKED );
if( tabData->subPaneDisabled[2] )
CheckDlgButton( dialog, DISABLE_TAB_2, BST_CHECKED );
else
CheckDlgButton( dialog, DISABLE_TAB_2, BST_UNCHECKED );
if( tabData->subPaneDisabled[3] )
CheckDlgButton( dialog, DISABLE_TAB_3, BST_CHECKED );
else
CheckDlgButton( dialog, DISABLE_TAB_3, BST_UNCHECKED );
if( tabData->subPaneDisabled[4] )
CheckDlgButton( dialog, DISABLE_TAB_4, BST_CHECKED );
else
CheckDlgButton( dialog, DISABLE_TAB_4, BST_UNCHECKED );
if( tabData->subPaneDisabled[5] )
CheckDlgButton( dialog, DISABLE_TAB_5, BST_CHECKED );
else
CheckDlgButton( dialog, DISABLE_TAB_5, BST_UNCHECKED );
if( tabData->subPaneDisabled[6] )
CheckDlgButton( dialog, DISABLE_TAB_6, BST_CHECKED );
else
CheckDlgButton( dialog, DISABLE_TAB_6, BST_UNCHECKED );
if( tabData->subPaneDisabled[7] )
CheckDlgButton( dialog, DISABLE_TAB_7, BST_CHECKED );
else
CheckDlgButton( dialog, DISABLE_TAB_7, BST_UNCHECKED );
if( tabData->tabOrientation == TP_TOPLEFT )
CheckDlgButton( dialog, LEFT_JUSTIFY, BST_CHECKED );
else if( tabData->tabOrientation == TP_CENTER )
CheckDlgButton( dialog, CENTER_JUSTIFY, BST_CHECKED );
else if( tabData->tabOrientation == TP_BOTTOMRIGHT )
CheckDlgButton( dialog, RIGHT_JUSTIFY, BST_CHECKED );
if( tabData->tabEdge == TP_TOP_SIDE )
CheckDlgButton( dialog, TOP_SIDE, BST_CHECKED );
else if( tabData->tabEdge == TP_RIGHT_SIDE )
CheckDlgButton( dialog, RIGHT_SIDE, BST_CHECKED );
else if( tabData->tabEdge == TP_LEFT_SIDE )
CheckDlgButton( dialog, LEFT_SIDE, BST_CHECKED );
else if( tabData->tabEdge == TP_BOTTOM_SIDE )
CheckDlgButton( dialog, BOTTOM_SIDE, BST_CHECKED );
return dialog;
} // end InitTabControlPropertiesDialog

View file

@ -0,0 +1,310 @@
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
// FILE: TextEntryProperties.cpp //////////////////////////////////////////////
//-----------------------------------------------------------------------------
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright (C) 2001 - All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Project: GUIEdit
//
// File name: TextEntryProperties.cpp
//
// Created: Colin Day, August 2001
//
// Desc: Text entry properties
//
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// SYSTEM INCLUDES ////////////////////////////////////////////////////////////
// USER INCLUDES //////////////////////////////////////////////////////////////
#include "GUIEdit.h"
#include "Properties.h"
#include "Resource.h"
#include "GameClient/GadgetTextEntry.h"
// DEFINES ////////////////////////////////////////////////////////////////////
// PRIVATE TYPES //////////////////////////////////////////////////////////////
// PRIVATE DATA ///////////////////////////////////////////////////////////////
// PUBLIC DATA ////////////////////////////////////////////////////////////////
// PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// textEntryPropertiesCallback ================================================
/** Dialog callback for properties */
//=============================================================================
static LRESULT CALLBACK textEntryPropertiesCallback( HWND hWndDialog,
UINT message,
WPARAM wParam,
LPARAM lParam )
{
Int returnCode;
//
// handle any common messages between all property dialogs cause they
// are designed to have controls doing the same functionality
// and names
//
if( HandleCommonDialogMessages( hWndDialog, message,
wParam, lParam, &returnCode ) == TRUE )
return returnCode;
switch( message )
{
// ------------------------------------------------------------------------
case WM_COMMAND:
{
// Int notifyCode = HIWORD( wParam ); // notification code
Int controlID = LOWORD( wParam ); // control ID
// HWND hWndControl = (HWND)lParam; // control window handle
switch( controlID )
{
// --------------------------------------------------------------------
case IDOK:
{
GameWindow *window = TheEditor->getPropertyTarget();
// sanity
if( window )
{
ImageAndColorInfo *info;
// save the common properties
if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
break;
// save the image and color data
// ----------------------------------------------------------------
info = GetStateInfo( TEXT_ENTRY_ENABLED_LEFT );
GadgetTextEntrySetEnabledImageLeft( window, info->image );
GadgetTextEntrySetEnabledColor( window, info->color );
GadgetTextEntrySetEnabledBorderColor( window, info->borderColor );
info = GetStateInfo( TEXT_ENTRY_ENABLED_RIGHT );
GadgetTextEntrySetEnabledImageRight( window, info->image );
info = GetStateInfo( TEXT_ENTRY_ENABLED_CENTER );
GadgetTextEntrySetEnabledImageCenter( window, info->image );
info = GetStateInfo( TEXT_ENTRY_ENABLED_SMALL_CENTER );
GadgetTextEntrySetEnabledImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( TEXT_ENTRY_DISABLED_LEFT );
GadgetTextEntrySetDisabledImageLeft( window, info->image );
GadgetTextEntrySetDisabledColor( window, info->color );
GadgetTextEntrySetDisabledBorderColor( window, info->borderColor );
info = GetStateInfo( TEXT_ENTRY_DISABLED_RIGHT );
GadgetTextEntrySetDisabledImageRight( window, info->image );
info = GetStateInfo( TEXT_ENTRY_DISABLED_CENTER );
GadgetTextEntrySetDisabledImageCenter( window, info->image );
info = GetStateInfo( TEXT_ENTRY_DISABLED_SMALL_CENTER );
GadgetTextEntrySetDisabledImageSmallCenter( window, info->image );
// ----------------------------------------------------------------
info = GetStateInfo( TEXT_ENTRY_HILITE_LEFT );
GadgetTextEntrySetHiliteImageLeft( window, info->image );
GadgetTextEntrySetHiliteColor( window, info->color );
GadgetTextEntrySetHiliteBorderColor( window, info->borderColor );
info = GetStateInfo( TEXT_ENTRY_HILITE_RIGHT );
GadgetTextEntrySetHiliteImageRight( window, info->image );
info = GetStateInfo( TEXT_ENTRY_HILITE_CENTER );
GadgetTextEntrySetHiliteImageCenter( window, info->image );
info = GetStateInfo( TEXT_ENTRY_HILITE_SMALL_CENTER );
GadgetTextEntrySetHiliteImageSmallCenter( window, info->image );
// text entry props
EntryData *entryData = (EntryData *)window->winGetUserData();
entryData->maxTextLen = GetDlgItemInt( hWndDialog, EDIT_MAX_CHARS, NULL, TRUE );
entryData->secretText = IsDlgButtonChecked( hWndDialog, CHECK_SECRET_TEXT );
entryData->aSCIIOnly = IsDlgButtonChecked( hWndDialog, CHECK_ASCII_TEXT );
if( IsDlgButtonChecked( hWndDialog, RADIO_LETTERS_AND_NUMBERS ) )
{
entryData->alphaNumericalOnly = TRUE;
entryData->numericalOnly = FALSE;
} // end if
else if( IsDlgButtonChecked( hWndDialog, RADIO_NUMBERS ) )
{
entryData->alphaNumericalOnly = FALSE;
entryData->numericalOnly = TRUE;
} // end else if
else
{
entryData->alphaNumericalOnly = FALSE;
entryData->numericalOnly = FALSE;
} // end else
} // end if
DestroyWindow( hWndDialog );
break;
} // end OK
// --------------------------------------------------------------------
case IDCANCEL:
{
DestroyWindow( hWndDialog );
break;
} // end cancel
} // end switch( LOWORD( wParam ) )
return 0;
} // end of WM_COMMAND
// ------------------------------------------------------------------------
case WM_CLOSE:
{
DestroyWindow( hWndDialog );
return 0;
} // end close
// ------------------------------------------------------------------------
default:
return 0;
} // end of switch
} // end textEntryPropertiesCallback
///////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// InitTextEntryPropertiesDialog ==============================================
/** Bring up the text entry properties dialog */
//=============================================================================
HWND InitTextEntryPropertiesDialog( GameWindow *window )
{
HWND dialog;
// create the dialog box
dialog = CreateDialog( TheEditor->getInstance(),
(LPCTSTR)TEXT_ENTRY_PROPERTIES_DIALOG,
TheEditor->getWindowHandle(),
(DLGPROC)textEntryPropertiesCallback );
if( dialog == NULL )
return NULL;
// do the common initialization
CommonDialogInitialize( window, dialog );
//
// store in the image and color table the values for this putton
//
const Image *image;
Color color, borderColor;
// --------------------------------------------------------------------------
image = GadgetTextEntryGetEnabledImageLeft( window );
color = GadgetTextEntryGetEnabledColor( window );
borderColor = GadgetTextEntryGetEnabledBorderColor( window );
StoreImageAndColor( TEXT_ENTRY_ENABLED_LEFT, image, color, borderColor );
image = GadgetTextEntryGetEnabledImageRight( window );
StoreImageAndColor( TEXT_ENTRY_ENABLED_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetEnabledImageCenter( window );
StoreImageAndColor( TEXT_ENTRY_ENABLED_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetEnabledImageSmallCenter( window );
StoreImageAndColor( TEXT_ENTRY_ENABLED_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetTextEntryGetDisabledImageLeft( window );
color = GadgetTextEntryGetDisabledColor( window );
borderColor = GadgetTextEntryGetDisabledBorderColor( window );
StoreImageAndColor( TEXT_ENTRY_DISABLED_LEFT, image, color, borderColor );
image = GadgetTextEntryGetDisabledImageRight( window );
StoreImageAndColor( TEXT_ENTRY_DISABLED_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetDisabledImageCenter( window );
StoreImageAndColor( TEXT_ENTRY_DISABLED_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetDisabledImageSmallCenter( window );
StoreImageAndColor( TEXT_ENTRY_DISABLED_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// --------------------------------------------------------------------------
image = GadgetTextEntryGetHiliteImageLeft( window );
color = GadgetTextEntryGetHiliteColor( window );
borderColor = GadgetTextEntryGetHiliteBorderColor( window );
StoreImageAndColor( TEXT_ENTRY_HILITE_LEFT, image, color, borderColor );
image = GadgetTextEntryGetHiliteImageRight( window );
StoreImageAndColor( TEXT_ENTRY_HILITE_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetHiliteImageCenter( window );
StoreImageAndColor( TEXT_ENTRY_HILITE_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
image = GadgetTextEntryGetHiliteImageSmallCenter( window );
StoreImageAndColor( TEXT_ENTRY_HILITE_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
// fill out text entry properties
EntryData *entryData = (EntryData *)window->winGetUserData();
SetDlgItemInt( dialog, EDIT_MAX_CHARS, entryData->maxTextLen, TRUE );
if( entryData->secretText )
CheckDlgButton( dialog, CHECK_SECRET_TEXT, BST_CHECKED );
if( entryData->aSCIIOnly )
CheckDlgButton( dialog, CHECK_ASCII_TEXT, BST_CHECKED );
if( entryData->numericalOnly )
CheckDlgButton( dialog, RADIO_NUMBERS, BST_CHECKED );
else if( entryData->alphaNumericalOnly )
CheckDlgButton( dialog, RADIO_LETTERS_AND_NUMBERS, BST_CHECKED );
else
CheckDlgButton( dialog, RADIO_ANY_TEXT, BST_CHECKED );
// select the button enabled state for display
SwitchToState( TEXT_ENTRY_ENABLED_LEFT, dialog );
//
// initialize the dialog with values from the window
//
return dialog;
} // end InitTextEntryPropertiesDialog