Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXInputDialog.h

00001 /********************************************************************************
00002 *                                                                               *
00003 *                         I n p u t   D i a l o g   B o x                       *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2000,2002 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXInputDialog.h,v 1.9 2002/01/18 22:42:53 jeroen Exp $                   *
00023 ********************************************************************************/
00024 #ifndef FXINPUTDIALOG_H
00025 #define FXINPUTDIALOG_H
00026 
00027 #ifndef FXDIALOGBOX_H
00028 #include "FXDialogBox.h"
00029 #endif
00030 
00031 
00032 
00033 /// Input dialog options
00034 enum {
00035   INPUTDIALOG_STRING   = 0,             /// Ask for a string
00036   INPUTDIALOG_INTEGER  = 0x01000000,    /// Ask for an integer number
00037   INPUTDIALOG_REAL     = 0x02000000,    /// Ask for a real number
00038   INPUTDIALOG_PASSWORD = 0x04000000     /// Do not reveal key-in
00039   };
00040 
00041 
00042 class FXTextField;
00043 
00044 
00045 /**
00046 * An Input Dialog is a simple dialog which is used
00047 * to obtain a text string, integer, or real number from the user.
00048 * A password mode allows the key-in to remain hidden.
00049 */
00050 class FXAPI FXInputDialog : public FXDialogBox {
00051   FXDECLARE(FXInputDialog)
00052 protected:
00053   FXTextField *input;       // Text field widget
00054   FXdouble     limlo;       // Lower limit
00055   FXdouble     limhi;       // Upper limit
00056 protected:
00057   FXInputDialog(){}
00058 private:
00059   FXInputDialog(const FXInputDialog&);
00060   FXInputDialog &operator=(const FXInputDialog&);
00061 public:
00062   long onCmdAccept(FXObject*,FXSelector,void*);
00063 public:
00064 
00065   /// Construct input dialog box with given caption, icon, and prompt text
00066   FXInputDialog(FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* ic=NULL,FXuint opts=INPUTDIALOG_STRING,FXint x=0,FXint y=0,FXint w=0,FXint h=0);
00067 
00068   /// Get input string
00069   FXString getText() const;
00070 
00071   /// Set input string
00072   void setText(const FXString& text);
00073 
00074   /// Change number of visible columns of text
00075   void setNumColumns(FXint num);
00076 
00077   /// Return number of visible columns of text
00078   FXint getNumColumns() const;
00079 
00080   /// Change limits
00081   void setLimits(FXdouble lo,FXdouble hi){ limlo=lo; limhi=hi; }
00082 
00083   /// Return limits
00084   void getLimits(FXdouble& lo,FXdouble& hi){ lo=limlo; hi=limhi; }
00085 
00086   /// Run modal invocation of the dialog
00087   virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR);
00088 
00089   /**
00090   * Prompt for a string, start with the initial value.
00091   * Return TRUE if the new value is accepted, and false otherwise.
00092   */
00093   static FXbool getString(FXString& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* ic=NULL);
00094 
00095   /**
00096   * Prompt for an integer number, start with the given initial value.
00097   * Return TRUE if the new value is accepted, and false otherwise.
00098   * The input is constrained between lo and hi, unless lo>hi, in which
00099   * case the input can be any number.
00100   */
00101   static FXbool getInteger(FXint& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* ic=NULL,FXint lo=1,FXint hi=0);
00102 
00103   /**
00104   * Prompt for an real number, start with the given initial value.
00105   * Return TRUE if the new value is accepted, and false otherwise.
00106   * The input is constrained between lo and hi, unless lo>hi, in which
00107   * case the input can be any number.
00108   */
00109   static FXbool getReal(FXdouble& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* ic=NULL,FXdouble lo=1.0,FXdouble hi=0.0);
00110   };
00111 
00112 
00113 
00114 #endif