rbutton.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:8k
- /*
- * rbutton.h
- *
- * Radio button control.
- *
- * Portable Windows Library
- *
- * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.0 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Portable Windows Library.
- *
- * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
- *
- * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
- * All Rights Reserved.
- *
- * Contributor(s): ______________________________________.
- *
- * $Log: rbutton.h,v $
- * Revision 1.18 1999/03/10 03:49:53 robertj
- * More documentation adjustments.
- *
- * Revision 1.17 1999/03/09 08:01:49 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.16 1999/02/16 08:08:46 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.15 1998/09/23 06:28:32 robertj
- * Added open source copyright license.
- *
- * Revision 1.14 1995/03/14 12:42:20 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.13 1995/01/14 06:19:25 robertj
- * Documentation
- *
- * Revision 1.12 1994/10/30 11:47:01 robertj
- * Changed mechanism for doing notification callback functions.
- *
- * Revision 1.11 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.10 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.9 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.8 1994/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * Revision 1.7 1994/01/15 02:50:29 robertj
- * Moved control contructors to common and added a platform dependent Construct() function.
- *
- * Revision 1.6 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.5 1993/12/15 21:10:10 robertj
- * Changed group to use containers reference system.
- *
- * Revision 1.4 1993/09/27 16:35:25 robertj
- * Removed special constructor for dialog resource loading.
- *
- * Revision 1.3 1993/08/21 01:50:33 robertj
- * Made Clone() function optional, default will assert if called.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PRADIOBUTTON
- #ifdef __GNUC__
- #pragma interface
- #endif
- /**A simple radio button control. A set of radio buttons is used to select one
- of a number of choices. A group of radio buttons may be created by passing
- the first radio button created to all the others subsequently created. Then
- whenever one of the buttons is selected all the other buttons in the group
- are automatically deselected.
-
- Note that a radio button can only be in one group at a time.
- */
- class PRadioButton : public PNamedControl
- {
- PCLASSINFO(PRadioButton, PNamedControl);
- public:
- /**Create a radio button with the specified parameters: name, notification
- function and radio button group.
- Add this button to the group that the #groupButton# parameter
- is also contained in. This is typically the first button created.
- */
- PRadioButton(
- PInteractor * parent /// Interactor into which the control is placed
- );
- PRadioButton(
- PInteractor * parent, /// Interactor into which the control is placed.
- const PString & name /// Text string name of the radio button.
- );
- PRadioButton(
- PInteractor * parent, /// Interactor into which the control is placed.
- const PString & name, /// Text string name of the radio button.
- const PNotifier & notify /// Function to call when changes state.
- );
- PRadioButton(
- PInteractor * parent, /// Interactor into which the control is placed.
- const PString & name, /// Text string name of the radio button.
- PRadioButton & groupButton /// A radio button in the group to be added to.
- );
- PRadioButton(
- PInteractor * parent, /// Interactor into which the control is placed.
- const PString & name, /// Text string name of the radio button.
- const PNotifier & notify, /// Function to call when changes state.
- PRadioButton & groupButton /// A radio button in the group to be added to.
- );
- /** Create control from interactor layout with the specified control ID. */
- PRadioButton(
- PInteractorLayout * parent, /// Interactor into which the box is placed.
- PRESOURCE_ID ctlID, /// Identifier for the control in the layout.
- const PNotifier & notify, /// Function to call when changes state.
- PINDEX * valuePtr /// Variable to change to the check box state.
- );
- /** Destroy the radio button, removing it from its group. */
- virtual ~PRadioButton();
- /**@name Overrides from class PControl */
- /**This function transfers the value of the control to or from the variable
- pointed to by the value pointer member variable.
- */
- virtual void TransferValue(
- int option
- /**Transfer value option. When this is -1 when the function transfers
- the value from the value pointer into the control. This is called in
- Ref{PDialog::OnInit()} function. When option is zero then the
- function transfers the value from the control to the value pointer
- variable. This is called just before the callback function every time
- the radio button groups value changes.
- */
- );
- /**@name New functions for class */
- /** Set the default (minimum) dimensions for the control */
- void DefaultDimensions();
- /**Set the value of the radio button group. The buttons are created are
- numbered from one up. This will set the button specifed deselecting all
- the others. If the #newVal# parameter is out of the range 1
- to the number of buttons in the group, all buttons are deselected
- */
- void SetValue(
- PINDEX newVal /// New value for radio button group.
- );
- /**Get the currently selected button in the radio button group. If no
- radio buttons in the group are selected then zero is returned.
- @return
- index of selected radio button or zero if none selected.
- */
- PINDEX GetValue() const;
- /**Get the current value pointer associated with the control. The variable
- pointed to by this is autamatically updated with the current value of
- the radio button group.
- @return
- value pointer associated with the control.
- */
- PINDEX * GetValuePointer() const;
- /**Set the current value pointer associated with the control. The variable
- pointed to by this is autamatically updated with the current value of
- the radio button group.
- */
- void SetValuePointer(
- PINDEX * ptr /// New value pointer to associate with the control.
- );
- /**Add this button to the group that the #groupButton# parameter
- is also contained in. This is typically the first button created.
- */
- void AddToGroup(
- PRadioButton & groupButton /// Radio button in the group to add to.
- );
- protected:
- // Member variables
- PLIST(Group, PRadioButton);
- /**List of buttons in the group. This is a common container for all
- buttons in the group.
- */
- Group group;
- private:
- // New functions for class
- void Construct();
- // Common, platform dependent, constructor code for the cosntructors.
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////