CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

CHECKBOX.CPP (6372B)


      1 //
      2 // Copyright 2020 Electronic Arts Inc.
      3 //
      4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 
      5 // software: you can redistribute it and/or modify it under the terms of 
      6 // the GNU General Public License as published by the Free Software Foundation, 
      7 // either version 3 of the License, or (at your option) any later version.
      8 
      9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 
     10 // in the hope that it will be useful, but with permitted additional restrictions 
     11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 
     12 // distributed with this program. You should have received a copy of the 
     13 // GNU General Public License along with permitted additional restrictions 
     14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
     15 
     16 /* $Header: /CounterStrike/CHECKBOX.CPP 1     3/03/97 10:24a Joe_bostic $ */
     17 /***********************************************************************************************
     18  ***              C O N F I D E N T I A L  ---  W E S T W O O D  S T U D I O S               ***
     19  ***********************************************************************************************
     20  *                                                                                             *
     21  *                 Project Name : Command & Conquer                                            *
     22  *                                                                                             *
     23  *                    File Name : CHECKBOX.CPP                                                 *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : 05/26/95                                                     *
     28  *                                                                                             *
     29  *                  Last Update : July 6, 1996 [JLB]                                           *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  *   CheckBoxClass::Action -- Handles a button action on a checkbox object.                    *
     34  *   CheckBoxClass::Draw_Me -- Draws the checkbox imagery.                                     *
     35  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     36 
     37 #include	"function.h"
     38 #include	"checkbox.h"
     39 
     40 
     41 /***********************************************************************************************
     42  * CheckBoxClass::Draw_Me -- Draws the checkbox imagery.                                       *
     43  *                                                                                             *
     44  *    This routine will draw the checkbox either filled or empty as necessary.                 *
     45  *                                                                                             *
     46  * INPUT:   forced   -- Should the check box be drawn even if it doesn't think it needs to?    *
     47  *                                                                                             *
     48  * OUTPUT:  Was the check box rendered?                                                        *
     49  *                                                                                             *
     50  * WARNINGS:   none                                                                            *
     51  *                                                                                             *
     52  * HISTORY:                                                                                    *
     53  *   07/01/1995 JLB : Created.                                                                 *
     54  *=============================================================================================*/
     55 int CheckBoxClass::Draw_Me(int forced)
     56 {
     57 	if (ToggleClass::Draw_Me(forced)) {
     58 
     59 		Hide_Mouse();
     60 		Draw_Box(X, Y, Width, Height, BOXSTYLE_DOWN, false);
     61 		LogicPage->Fill_Rect(X+1, Y+1, X+Width-2, Y+Height-2, DKGREY);
     62 		if (IsOn) {
     63 			LogicPage->Fill_Rect(X+1, Y+1, X+Width-2, Y+Height-2, LTGREEN);
     64 		}
     65 		Show_Mouse();
     66 		return(true);
     67 	}
     68 	return(false);
     69 }
     70 
     71 
     72 /***********************************************************************************************
     73  * CheckBoxClass::Action -- Handles a button action on a checkbox object.                      *
     74  *                                                                                             *
     75  *    This routine will detect if the mouse has been clicked on the checkbox object. If so,    *
     76  *    the check box state will be toggled.                                                     *
     77  *                                                                                             *
     78  * INPUT:   flags -- The event flags that resulted in this routine being called.               *
     79  *                                                                                             *
     80  *          key   -- The key that resulted in this routine being called.                       *
     81  *                                                                                             *
     82  * OUTPUT:  bool; Should normal processing occur?                                              *
     83  *                                                                                             *
     84  * WARNINGS:   none                                                                            *
     85  *                                                                                             *
     86  * HISTORY:                                                                                    *
     87  *   07/06/1996 JLB : Created.                                                                 *
     88  *=============================================================================================*/
     89 int CheckBoxClass::Action(unsigned flags, KeyNumType & key)
     90 {
     91 	if (flags & LEFTRELEASE) {
     92 		if (IsOn) {
     93 			Turn_Off();
     94 		} else {
     95 			Turn_On();
     96 		}
     97 	}
     98 	return(ToggleClass::Action(flags, key));
     99 }