DrawButton.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /************************************************************************
  19. ** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  20. ************************************************************************
  21. * *
  22. * Project Name : DrawButton *
  23. * *
  24. * File Name : DRAWBUTTON.H *
  25. * *
  26. * Programmer : Maria del Mar McCready Legg *
  27. * *
  28. * Start Date : May 10, 1994 *
  29. * *
  30. * Last Update : October 5, 2000 [MML] *
  31. *----------------------------------------------------------------------*/
  32. #ifndef DRAWBUTTONS_H
  33. #define DRAWBUTTONS_H
  34. #include <tchar.h>
  35. #include <stdlib.h>
  36. #include "ttfont.h"
  37. //-------------------------------------------------------------------------
  38. // Custom "Button" Class
  39. //-------------------------------------------------------------------------
  40. class DrawButton
  41. {
  42. public:
  43. enum BUTTON_STATE {
  44. NORMAL_STATE = 0,
  45. PRESSED_STATE,
  46. FOCUS_STATE
  47. };
  48. DrawButton ( int id, RECT button_rect, char *normal, char *focus, char *pressed, const char *string, TTFontClass *fontptr );
  49. DrawButton ( int id, RECT button_rect, char *normal, char *focus, char *pressed, const wchar_t *string, TTFontClass *fontptr );
  50. char *Return_Normal_Bitmap ( void ) { return NormalBitmap; };
  51. char *Return_Pressed_Bitmap ( void ) { return PressedBitmap; };
  52. char *Return_Focus_Bitmap ( void ) { return FocusBitmap; };
  53. char *Return_Bitmap ( void );
  54. bool Draw_Bitmaps ( void ) { return( UseBitmaps ); };
  55. void Draw_Text ( HDC hDC );
  56. BUTTON_STATE Get_State ( void ) { return ButtonState; };
  57. bool Is_Mouse_In_Region ( int mouse_x, int mouse_y );
  58. int Return_Id ( void ) { return Id; };
  59. int Return_X_Pos ( void ) { return rect.left; };
  60. int Return_Y_Pos ( void ) { return rect.top; };
  61. int Return_Width ( void ) { return( rect.right - rect.left ); };
  62. int Return_Height ( void ) { return( rect.bottom - rect.top ); };
  63. int Return_Stretched_Width ( void ) { return( StretchedWidth ); };
  64. int Return_Stretched_Height ( void ) { return( StretchedHeight ); };
  65. void Return_Area ( RECT *area );
  66. void Return_Area ( Rect *area );
  67. void Return_Text_Area ( Rect *area );
  68. TTFontClass *Return_Font_Ptr ( void ) { return( MyFontPtr ); };
  69. wchar_t *Return_Text ( void ) { return( String ); };
  70. void Set_State ( BUTTON_STATE state ) { ButtonState = state; };
  71. int Set_Stretched_Width ( int );
  72. int Set_Stretched_Height ( int );
  73. protected:
  74. int Id;
  75. Rect MyRect;
  76. Rect TextRect;
  77. RECT rect;
  78. BUTTON_STATE ButtonState;
  79. int StretchedWidth;
  80. int StretchedHeight;
  81. bool UseBitmaps;
  82. TTFontClass *MyFontPtr;
  83. wchar_t String[ MAX_PATH ];
  84. char NormalBitmap [ _MAX_FNAME ];
  85. char PressedBitmap[ _MAX_FNAME ];
  86. char FocusBitmap [ _MAX_FNAME ];
  87. };
  88. #endif