1 /******************************************************************************** 2 * * 3 * M e n u R a d i o W i d g e t * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 2002,2021 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or modify * 9 * it under the terms of the GNU Lesser General Public License as published by * 10 * the Free Software Foundation; either version 3 of the License, or * 11 * (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public License * 19 * along with this program. If not, see <http://www.gnu.org/licenses/> * 20 ********************************************************************************/ 21 #ifndef FXMENURADIO_H 22 #define FXMENURADIO_H 23 24 #ifndef FXMENUCOMMAND_H 25 #include "FXMenuCommand.h" 26 #endif 27 28 namespace FX { 29 30 31 /** 32 * The menu radio widget is used to invoke a command in the 33 * application from a menu. Menu commands may reflect 34 * the state of the application by graying out, becoming hidden, 35 * or by a bullit. 36 * When activated, a menu radio sends a SEL_COMMAND to its target; 37 * the void* argument of the message contains the new state. 38 * A collection of menu radio widgets which belong to each other 39 * is supposed to be updated by a common SEL_UPDATE handler to 40 * properly maintain the state between them. 41 */ 42 class FXAPI FXMenuRadio : public FXMenuCommand { 43 FXDECLARE(FXMenuRadio) 44 protected: 45 FXColor radioColor; // Color of the radio 46 FXuchar check; // State of menu 47 protected: 48 FXMenuRadio(); 49 private: 50 FXMenuRadio(const FXMenuRadio&); 51 FXMenuRadio &operator=(const FXMenuRadio&); 52 public: 53 long onPaint(FXObject*,FXSelector,void*); 54 long onButtonPress(FXObject*,FXSelector,void*); 55 long onButtonRelease(FXObject*,FXSelector,void*); 56 long onKeyPress(FXObject*,FXSelector,void*); 57 long onKeyRelease(FXObject*,FXSelector,void*); 58 long onHotKeyPress(FXObject*,FXSelector,void*); 59 long onHotKeyRelease(FXObject*,FXSelector,void*); 60 long onCheck(FXObject*,FXSelector,void*); 61 long onUncheck(FXObject*,FXSelector,void*); 62 long onUnknown(FXObject*,FXSelector,void*); 63 long onCmdSetValue(FXObject*,FXSelector,void*); 64 long onCmdSetIntValue(FXObject*,FXSelector,void*); 65 long onCmdGetIntValue(FXObject*,FXSelector,void*); 66 long onCmdAccel(FXObject*,FXSelector,void*); 67 public: 68 69 /// Construct a menu radio 70 FXMenuRadio(FXComposite* p,const FXString& text,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0); 71 72 /// Return default width 73 virtual FXint getDefaultWidth(); 74 75 /// Return default height 76 virtual FXint getDefaultHeight(); 77 78 /// Set radio button state (true, false or maybe) 79 void setCheck(FXuchar s=true); 80 81 /// Get radio button state (true, false or maybe) getCheck()82 FXuchar getCheck() const { return check; } 83 84 /// Get the radio background color getRadioColor()85 FXColor getRadioColor() const { return radioColor; } 86 87 /// Set the radio background color 88 void setRadioColor(FXColor clr); 89 90 /// Save menu to a stream 91 virtual void save(FXStream& store) const; 92 93 /// Load menu from a stream 94 virtual void load(FXStream& store); 95 }; 96 97 } 98 99 #endif 100