| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- /*
- ** Command & Conquer Generals Zero Hour(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: W3DComboBox.cpp ///////////////////////////////////////////////////////
- //-----------------------------------------------------------------------------
- //
- // Westwood Studios Pacific.
- //
- // Confidential Information
- // Copyright (C) 2001 - All Rights Reserved
- //
- //-----------------------------------------------------------------------------
- //
- // Project: RTS3
- //
- // File name: W3DComboBox.cpp
- //
- // Created: Colin Day, June 2001
- //
- // Desc: W3D implementation for the Combo box control
- //
- //-----------------------------------------------------------------------------
- ///////////////////////////////////////////////////////////////////////////////
- // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
- #include <stdlib.h>
- // USER INCLUDES //////////////////////////////////////////////////////////////
- #include "GameClient/GameWindowGlobal.h"
- #include "GameClient/GameWindowManager.h"
- #include "GameClient/GadgetComboBox.h"
- #include "GameClient/GadgetListBox.h"
- #include "W3DDevice/GameClient/W3DGadget.h"
- #include "W3DDevice/GameClient/W3DDisplay.h"
- // DEFINES ////////////////////////////////////////////////////////////////////
- // PRIVATE TYPES //////////////////////////////////////////////////////////////
- // PRIVATE DATA ///////////////////////////////////////////////////////////////
- // PUBLIC DATA ////////////////////////////////////////////////////////////////
- // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////
- // W3DGadgetComboBoxDraw =======================================================
- /** Draw colored list box using standard graphics */
- //=============================================================================
- void W3DGadgetComboBoxDraw( GameWindow *window, WinInstanceData *instData )
- {
- Int width, height, fontHeight, x, y;
- Color background, border, titleColor, titleBorder;
- // ComboBoxData *combo = (ComboBoxData *)window->winGetUserData();
- ICoord2D size;
- DisplayString *title = instData->getTextDisplayString();
- // get window position and size
- window->winGetScreenPosition( &x, &y );
- window->winGetSize( &size.x, &size.y );
- // get font height
- fontHeight = TheWindowManager->winFontHeight( instData->getFont() );
- // alias width and height from size
- width = size.x;
- height = size.y;
- // get the right colors
- if( BitTest( window->winGetStatus(), WIN_STATUS_ENABLED ) == FALSE )
- {
- background = GadgetComboBoxGetDisabledColor( window );
- border = GadgetComboBoxGetDisabledBorderColor( window );
- titleColor = window->winGetDisabledTextColor();
- titleBorder = window->winGetDisabledTextBorderColor();
- } // end if, disabled
- else if( BitTest( instData->getState(), WIN_STATE_HILITED ) )
- {
- background = GadgetComboBoxGetHiliteColor( window );
- border = GadgetComboBoxGetHiliteBorderColor( window );
- titleColor = window->winGetHiliteTextColor();
- titleBorder = window->winGetHiliteTextBorderColor();
- } // end else if, hilited
- else
- {
- background = GadgetComboBoxGetEnabledColor( window );
- border = GadgetComboBoxGetEnabledBorderColor( window );
- titleColor = window->winGetEnabledTextColor();
- titleBorder = window->winGetEnabledTextBorderColor();
- } // end else, enabled
- // Draw the title
- if( title && title->getTextLength() )
- {
-
- // set the font of this text to that of the window if not already
- if( title->getFont() != window->winGetFont() )
- title->setFont( window->winGetFont() );
-
- // draw the text
- title->draw( x + 1, y, titleColor, titleBorder );
- y += fontHeight + 1;
- height -= fontHeight + 1;
- } // end if
- // draw the back border
- if( border != WIN_COLOR_UNDEFINED )
- TheWindowManager->winOpenRect( border, WIN_DRAW_LINE_WIDTH,
- x, y, x + width, y + height );
- // draw background
- if( background != WIN_COLOR_UNDEFINED )
- TheWindowManager->winFillRect( background, WIN_DRAW_LINE_WIDTH,
- x + 1, y + 1,
- x + width - 1, y + height - 1 );
- } // end W3DGadgetComboBoxDraw
- // W3DGadgetComboBoxImageDraw ==================================================
- /** Draw combo box with user supplied images */
- //=============================================================================
- void W3DGadgetComboBoxImageDraw( GameWindow *window, WinInstanceData *instData )
- {
- Int width, height, x, y;
- const Image *image;
- // ComboBoxData *combo = (ComboBoxData *)window->winGetUserData();
- ICoord2D size;
- Color titleColor, titleBorder;
- DisplayString *title = instData->getTextDisplayString();
- // get window position and size
- window->winGetScreenPosition( &x, &y );
- window->winGetSize( &size.x, &size.y );
- // save off width and height so we can change them
- width = size.x;
- height = size.y;
- // get the image
- if( BitTest( window->winGetStatus(), WIN_STATUS_ENABLED ) == FALSE )
- {
- image = GadgetComboBoxGetDisabledImage( window );
- titleColor = window->winGetDisabledTextColor();
- titleBorder = window->winGetDisabledTextBorderColor();
- }
- else if( BitTest( instData->getState(), WIN_STATE_HILITED ) )
- {
- image = GadgetComboBoxGetHiliteImage( window );
- titleColor = window->winGetHiliteTextColor();
- titleBorder = window->winGetHiliteTextBorderColor();
- }
- else
- {
- image = GadgetComboBoxGetEnabledImage( window );
- titleColor = window->winGetEnabledTextColor();
- titleBorder = window->winGetEnabledTextBorderColor();
- }
- // draw the back image
- if( image )
- {
- ICoord2D start, end;
- start.x = x + instData->m_imageOffset.x;
- start.y = y + instData->m_imageOffset.y;
- end.x = start.x + width;
- end.y = start.y + height;
- TheWindowManager->winDrawImage( image,
- start.x, start.y,
- end.x, end.y );
- } // end if
- // Draw the title
- if( title && title->getTextLength() )
- {
- // set font to font of the window if not already
- if( title->getFont() != window->winGetFont() )
- title->setFont( window->winGetFont() );
- // draw the text
- title->draw( x + 1, y, titleColor, titleBorder );
- y += TheWindowManager->winFontHeight( instData->getFont() );
- height -= TheWindowManager->winFontHeight( instData->getFont() ) + 1;
- } // end if
- } // end W3DGadgetComboBoxImageDraw
|