simpdlg.h
上传用户:hzhsqp
上传日期:2007-01-06
资源大小:1600k
文件大小:15k
- /*
- * simpdlg.h
- *
- * Simple dialogs.
- *
- * 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: simpdlg.h,v $
- * Revision 1.22 1999/03/10 03:49:53 robertj
- * More documentation adjustments.
- *
- * Revision 1.21 1999/03/09 08:01:50 robertj
- * Changed comments for doc++ support (more to come).
- *
- * Revision 1.20 1999/02/16 08:08:46 robertj
- * MSVC 6.0 compatibility changes.
- *
- * Revision 1.19 1998/09/23 06:29:03 robertj
- * Added open source copyright license.
- *
- * Revision 1.18 1995/06/17 11:13:22 robertj
- * Documentation update.
- *
- * Revision 1.17 1995/03/14 12:42:37 robertj
- * Updated documentation to use HTML codes.
- *
- * Revision 1.16 1995/01/16 09:42:03 robertj
- * Documentation.
- *
- * Revision 1.15 1995/01/15 04:53:07 robertj
- * Fixed problems with stdarg and PString parameter on GNU compiler.
- *
- * Revision 1.14 1995/01/10 11:44:10 robertj
- * Removed PString parameter in stdarg function for GNU C++ compatibility.
- *
- * Revision 1.13 1994/10/30 11:47:07 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/08/21 23:43:02 robertj
- * Changed parameter before variable argument list to NOT be a reference.
- *
- * Revision 1.9 1994/07/27 05:58:07 robertj
- * Synchronisation.
- *
- * Revision 1.8 1994/06/25 11:55:15 robertj
- * Unix version synchronisation.
- *
- * Revision 1.7 1994/03/07 07:38:19 robertj
- * Major enhancementsacross the board.
- *
- * 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/06 22:36:12 robertj
- * Fixed problem with unimplemented icons.
- *
- * Revision 1.4 1993/12/01 16:09:05 robertj
- * Windows NT port.
- *
- * Revision 1.3 1993/10/16 20:33:20 robertj
- * Changed ButtonPressed variable name for X-Windows compatibility.
- * Added protection for not having static icons yet.
- *
- * Revision 1.2 1993/07/14 12:49:16 robertj
- * Fixed RCS keywords.
- *
- */
- #define _PSIMPLEDIALOG
- #ifdef __GNUC__
- #pragma interface
- #endif
- #include "stdresid.h"
- /**A class for displaying a simple, standard dialog for presenting short
- messages and asking simple questions.
-
- A simple dialog consists of a static text item, an optional icon and up to
- three buttons with fixed names. What combination of icons and buttons is
- determined in the constructor parameters.
-
- Even though a PSimpleDialog object can be created and treated in the same
- way as any other modal dialog, it is more usual to use one of the static
- functions provided. For example to ask a simple yes or not question the
- Ref{PSimpleDialog::YesNo()} function would be used.
-
- The value returned by the Ref{PModalDialog::RunModal()} function indicates
- which button was pressed to terminate the modal dialog.
- */
- class PSimpleDialog : public PModalDialog
- {
- PCLASSINFO(PSimpleDialog, PModalDialog);
- public:
- /** Icon selection options for PSimpleDialog constructor. */
- enum IconToShow {
- /// Do not display an icon.
- NoIcon,
- /**Display system standard information (asterisk) icon. This is used
- when the message presented is not very important.
- */
- InformationIcon,
- /**Display system standard question mark icon. This is usually used when
- the simple dialog requires a decision to be made by the user.
- */
- QuestionIcon,
- /**Display system standard exclamation mark icon. This is used when the
- message is important, for example when an error occurs.
- */
- ExclamationIcon,
- /**Display system standard stop sign icon. This is used when the message
- is {bf very} important. For example when a fatal error that will
- terminate the application occurs.
- */
- StopSignIcon
- };
- /** Button selection options for PSimpleDialog constructor. */
- enum ButtonsToHave {
- /// Only display the "Ok" button.
- OkBtn,
- /// Display the "Ok" and "Cancel" buttons.
- OkCancelBtn,
- /// Display the "Retry" and "Cancel" buttons.
- RetryCancelBtn,
- /// Display the "Yes" and "No" buttons.
- YesNoBtn,
- /// Display the "Yes", "No" and "Cancel" buttons.
- YesNoCancelBtn,
- /// Display the "Abort", "Retry" and "Ignore" buttons.
- AbortRetryIgnoreBtn
- };
- /** Return values for Ref{PModalDialog::RunModal()} function. */
- enum ButtonType {
- /// Dialog was terminated by pressing the "Ok" button.
- WasOk,
- /// Dialog was terminated by pressing the "Cancel" button.
- WasCancel,
- /// Dialog was terminated by pressing the "Retry" button.
- WasRetry,
- /// Dialog was terminated by pressing the "Yes" button.
- WasYes,
- /// Dialog was terminated by pressing the "No" button.
- WasNo,
- /// Dialog was terminated by pressing the "Abort" button.
- WasAbort,
- /// Dialog was terminated by pressing the "Ignore" button.
- WasIgnore
- };
- /**Create a simple dialog for quick and easy user interface messages and
- questions.
-
- The default title for the dialog is as for the ultimate
- Ref{PTopLevelWindow} parent interactor.
- */
- PSimpleDialog(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const PString & str, /// Message to display in static text control.
- ButtonsToHave btns = OkBtn, /// Which buttons to display.
- IconToShow icn = NoIcon /// Which icon, if any, to display.
- );
- /**@name New functions for class */
- /**Display the simple dialog using the information icon and the "Ok"
- button only.
-
- The message text may be printf style formatted output unless a
- Ref{PString} expression is used. Then the exact string is used in the
- static text control.
- */
- static void Info(
- PInteractor * parent, /// Parent interactor for modal dialog.
- PRESOURCE_ID resID,
- /// Unique id for resource string to be used a printf style format string.
- ...
- );
- static void Info(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const char * fmt, /// Printf style format string.
- ...
- );
- static void Info(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const PString & str /// Message string to place in static text control.
- );
- /**Display the simple dialog using the exclamation mark icon and the "Ok"
- button only.
-
- The message text may be printf style formatted output unless a
- Ref{PString} expression is used. Then the exact string is used in the
- static text control.
- */
- static void Error(
- PInteractor * parent, /// Parent interactor for modal dialog.
- PRESOURCE_ID resID,
- /// Unique id for resource string to be used a printf style format string.
- ...
- );
- static void Error(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const char * fmt, /// Printf style format string.
- ...
- );
- static void Error(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const PString & str /// Message string to place in static text control.
- );
- /**Display the simple dialog using the stop sign icon and the "Ok" button
- only.
-
- The message text may be printf style formatted output unless a
- Ref{PString} expression is used. Then the exact string is used in the
- static text control.
- */
- static void FatalError(
- PInteractor * parent, /// Parent interactor for modal dialog.
- PRESOURCE_ID resID,
- /// Unique id for resource string to be used a printf style format string.
- ...
- );
- static void FatalError(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const char * fmt, /// Printf style format string.
- ...
- );
- static void FatalError(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const PString & str /// Message string to place in static text control.
- );
- /**Display the simple dialog using the question mark icon and the "Ok" and
- "Cancel" buttons.
-
- The message text may be printf style formatted output unless a
- Ref{PString} expression is used. Then the exact string is used in the
- static text control.
- */
- static BOOL OkCancel(
- PInteractor * parent, /// Parent interactor for modal dialog.
- PRESOURCE_ID resID,
- /// Unique id for resource string to be used a printf style format string.
- ...
- );
- static BOOL OkCancel(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const char * fmt, /// Printf style format string.
- ...
- );
- static BOOL OkCancel(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const PString & str /// Message string to place in static text control.
- );
-
- /**Display the simple dialog using the question mark icon and the "Yes"
- and "No" buttons.
-
- The message text may be printf style formatted output unless a
- Ref{PString} expression is used. Then the exact string is used in the
- static text control.
- */
- static BOOL YesNo(
- PInteractor * parent, /// Parent interactor for modal dialog.
- PRESOURCE_ID resID,
- /// Unique id for resource string to be used a printf style format string.
- ...
- );
- static BOOL YesNo(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const char * fmt, /// Printf style format string.
- ...
- );
- static BOOL YesNo(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const PString & str /// Message string to place in static text control.
- );
- /**Display the simple dialog using the question mark icon and the "Yes",
- "No" and "Cancel" buttons.
-
- The message text may be printf style formatted output unless a
- Ref{PString} expression is used. Then the exact string is used in the
- static text control.
- */
- static ButtonType YesNoCancel(
- PInteractor * parent, /// Parent interactor for modal dialog.
- PRESOURCE_ID resID,
- /// Unique id for resource string to be used a printf style format string.
- ...
- );
- static ButtonType YesNoCancel(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const char * fmt, /// Printf style format string.
- ...
- );
- static ButtonType YesNoCancel(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const PString & str /// Message string to place in static text control.
- );
- /**Display the simple dialog using the exclamation icon and the "Abort",
- "Retry" and "Ignore" buttons.
-
- The message text may be printf style formatted output unless a
- Ref{PString} expression is used. Then the exact string is used in the
- static text control.
- */
- static ButtonType AbortRetryIgnore(
- PInteractor * parent, /// Parent interactor for modal dialog.
- PRESOURCE_ID resID,
- /// Unique id for resource string to be used a printf style format string.
- ...
- );
- static ButtonType AbortRetryIgnore(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const char * fmt, /// Printf style format string.
- ...
- );
- static ButtonType AbortRetryIgnore(
- PInteractor * parent, /// Parent interactor for modal dialog.
- const PString & str /// Message string to place in static text control.
- );
- protected:
- /**@name Member variables */
- /** Static text control for message. */
- PStaticText * text;
- /** Static icon control for icon specified in constructor. */
- PStaticIcon * icon;
- /** First button, may be "Ok", "Yes" or "Abort". */
- PPushButton * btn1;
- /** Second button, may be "Cancel", "No" or "Retry". */
- PPushButton * btn2;
- /** Third button, may be "Cancel" or "Ignore". */
- PPushButton * btn3;
- /** Value to return if button 1 is pressed, eg #WasOK#. */
- ButtonType btn1val;
- /** Value to return if button 2 is pressed, eg #WasCancel#. */
- ButtonType btn2val;
- /** Value to return if button 3 is pressed, eg #WasIgnore#. */
- ButtonType btn3val;
- PDECLARE_NOTIFIER(PPushButton, PSimpleDialog, DoButtonPress);
- /* Called by any of the three button controls. */
- private:
- static ButtonType DoSimple(
- PInteractor * parent, // Parent interactor for modal dialog.
- PRESOURCE_ID resID,
- // Unique id for resource string to be used a printf style format string.
- ButtonsToHave btns, // Which buttons to display.
- IconToShow icn, // Which icon, if any, to display.
- va_list arg // Arguments from stdarg variable argument list.
- );
- static ButtonType DoSimple(
- PInteractor * parent, // Parent interactor for modal dialog.
- const char * fmt, // Printf style format string.
- ButtonsToHave btns, // Which buttons to display.
- IconToShow icn, // Which icon, if any, to display.
- va_list arg // Arguments from stdarg variable argument list.
- );
- static ButtonType DoSimple(
- PInteractor * parent, // Parent interactor for modal dialog.
- const PString & str, // Printf style format string.
- ButtonsToHave btns, // Which buttons to display.
- IconToShow icn // Which icon, if any, to display.
- );
- // Common code for all of the simple dialog static functions.
- #ifdef DOC_PLUS_PLUS
- };
- #endif
- // Class declaration continued in platform specific header file ///////////////