control.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:11k
- /*
- * control.h
- *
- * Control interactor ancestor class.
- *
- * 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: control.h,v $
- * Revision 1.23 1999/03/10 03:49:51 robertj
- * More documentation adjustments.
- *
- * Revision 1.22 1999/03/09 08:01:48 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.21 1999/02/16 08:08:45 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.20 1998/09/23 06:23:13 robertj
- * Added open source copyright license.
- *
- * Revision 1.19 1995/06/17 11:10:18 robertj
- * Added function to determine if control is a tab stop.
- * Documentation update.
- *
- * Revision 1.18 1995/04/02 09:27:19 robertj
- * Added "balloon" help.
- *
- * Revision 1.17 1995/03/14 12:41:15 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.16 1995/02/19 04:19:07 robertj
- * Added dynamically linked command processing.
- *
- * Revision 1.15 1994/12/12 10:12:00 robertj
- * Documentation.
- *
- * Revision 1.14 1994/11/18 23:59:30 robertj
- * Added notifier & value to main PControl constructor
- *
- * Revision 1.13 1994/10/30 11:46:35 robertj
- * Changed mechanism for doing notification callback functions.
- *
- * Revision 1.12 1994/08/23 11:32:52 robertj
- * Oops
- *
- * Revision 1.11 1994/08/22 00:46:48 robertj
- * Added pragma fro GNU C++ compiler.
- *
- * Revision 1.10 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.9 1994/04/01 14:10:29 robertj
- * Added DefaultDimensions function.
- *
- * Revision 1.8 1994/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * Revision 1.7 1994/01/03 04:42:23 robertj
- * Mass changes to common container classes and interactors etc etc etc.
- *
- * Revision 1.6 1993/12/16 06:20:57 robertj
- * Changes to callback function definition due to GCC.
- *
- * Revision 1.5 1993/12/01 16:09:05 robertj
- * Windows NT port.
- *
- * Revision 1.4 1993/09/27 16:35:25 robertj
- * Removed special constructor for dialog resource loading.
- *
- * Revision 1.3 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PCONTROL
- #ifdef __GNUC__
- #pragma interface
- #endif
- class PInteractorLayout;
- /**This class defines a user inteface entity that allows the user to control
- some attribute or data within the system. A control is most commonly placed
- on a Ref{PDialog} or Ref{PInteractorLayout} class of interactor.
- The PControl class is an abstract class. No instances of PControl should
- ever be created. Descendents of PControl will implement some particular
- user interface element, eg edit text, list box, radio button etc
- */
- class PControl : public PInteractor
- {
- PCLASSINFO(PControl, PInteractor);
- protected:
- /** Create a new control, storing all the information provided. */
- PControl(
- PInteractor * parent, /// Interactor into which the control is placed.
- const PNotifier & func, /// Function to call when control changes state.
- void * valuePtr /// Variable to change to the controls state.
- );
- /**Create control from interactor layout with the specified control ID.
- This is mainly used in support of resource based dialogs.
- */
- PControl(
- PInteractorLayout * parent, /// Interactor on which the control is placed.
- PRESOURCE_ID ctlID, /// Identifier for the control in the layout.
- const PNotifier & func, /// Function to call when control changes state.
- void * valuePtr /// Variable to change to the controls state.
- );
- public:
- /** Destroy a control. */
- virtual ~PControl();
- /**@name PNotifier codes */
- /**Codes passed to the notification function on changes of state.
- A change to a scroll bar may proceed for some time, for example if the
- mouse button is pressed in the down arrow and held down. An auto-repeat
- would occur to continually change the scroll bar value until it is
- released.
- */
- enum {
- /**This code is passed to the notification function when the system
- wishes the control to be enabled or disabled.
- */
- NotifyEnable,
- /**This code is passed to the notification function when the system
- wishes the control to have its state updated.
- */
- NotifyUpdate,
- /**This code is passed to the notification function when the user has
- changed the state of the control.
- */
- NotifyChange
- };
- /**@name Overrides from class PInteractor */
- /**This function is called whenever a balloon help function for the
- interactor is required.
- */
- virtual PBalloon * OnBalloonHelp();
- /**@name New functions for class */
- /**Determine if the dialog tabbing will stop at this control.
- @return
- TRUE if the system will stop at this control when the tab key is
- pressed, FALSE if the system skips over it.
- */
- virtual BOOL IsTabStop() const;
- /**Get the resource identifier of the control when it was loaded from a
- resource in a dialog.
- @return
- resource identifier for control.
- */
- PRESOURCE_ID GetControlID() const;
- /**Set the resource identifier of the control. This would be used rarely
- as the ID is usually only used to link a resource to its C++ object
- instance.
- */
- void SetControlID(
- PRESOURCE_ID theID /// New ID for the control.
- );
- /**Get the current call back function that is called whenever the control
- needs to notify the application of some change, e.g. when a pushbutton
- is pressed.
- @return
- current notifier for the control.
- */
- const PNotifier & GetNotifier() const;
- /**Get the flag for notification function called when a control requires
- its enable or value state updated.
-
- @return
- current update flag for menu item.
- */
- BOOL WillNotifyOnStateUpdate() const;
- /**Set the call back function that is called whenever the control needs to
- notify the application of some change, eg when a pushbutton is pressed,
- or when the control needs to be updated by the application, eg when
- enable states are changed and the
- Ref{PInteractor::UpdateCommandSources()} function is called.
- */
- void SetNotifier(
- const PNotifier & func, /// New notifier function for the control.
- BOOL notifyForStateUpdate = FALSE
- /**Notification function is to be called when a control requires its
- enable or value state updated. If FALSE the notification function is
- only called when the item is selected.
- */
- );
- /**Get the current value pointer associated with the control. This is a
- pointer to data that is updated whenever the state of the control
- changes. The type of this data and the exact semantics of the updating
- is dependent on the descendent class.
- @return
- current value pointer.
- */
- void * GetValuePointer() const;
- /**Set the current value pointer associated with the control. This is a
- pointer to data that is updated whenever the state of the control
- changes. The type of this data and the exact semantics of the updating
- is dependent on the descendent class.
- */
- void SetValuePointer(
- void * ptr /// New value pointer for the control.
- );
- /**This function transfers the value of the control to or from the variable
- pointed to by the value pointer member variable.
- The default action is to do nothing.
- */
- 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 controls state changes.
- */
- );
- /**Get the balloon help text.
- @return
- balloon help text string for control.
- */
- const PString & GetBalloonHelp() const;
- /**Set the balloon help text.
- */
- void SetBalloonHelp(
- const PString & text /// New the balloon help text.
- );
- /**Set the default (minimum) dimensions for the control. The actual
- dimensions is dependent of the type of the descendent class.
- The default action is to do nothing.
- */
- virtual void DefaultDimensions();
- protected:
- /**@name Overrides from class PInteractor */
- /**Scan through all child interactors and if they are a command source,
- execute their notification function to enable or disable the item.
- The behaviour here is to call the notification function with the code
- #NotifyEnable#.
- This function is used internally by the library. It would normally not
- be called directly.
- */
- virtual void UpdateMyCommandSources();
- /**@name Member variables */
- /** Unique menu ID for resource binding */
- PRESOURCE_ID controlID;
-
- /** Notification function to call on menu selection. */
- PNotifier callback;
-
- /** Pointer to the value that is attached to the control. */
- void * valuePointer;
- /**Flag for notification function called when a control requires its
- enable or value state updated.
- */
- BOOL notifyForStateUpdate;
- /** Help text for balloon help. */
- PString balloonHelpText;
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////