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,2004 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.13 2004/02/08 17:17:33 fox Exp $                     *
00023 ********************************************************************************/
00024 #ifndef FXINPUTDIALOG_H
00025 #define FXINPUTDIALOG_H
00026 
00027 #ifndef FXDIALOGBOX_H
00028 #include "FXDialogBox.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00034 /// Input dialog options
00035 enum {
00036   INPUTDIALOG_STRING   = 0,             /// Ask for a string
00037   INPUTDIALOG_INTEGER  = 0x01000000,    /// Ask for an integer number
00038   INPUTDIALOG_REAL     = 0x02000000,    /// Ask for a real number
00039   INPUTDIALOG_PASSWORD = 0x04000000     /// Do not reveal key-in
00040   };
00041 
00042 
00043 class FXTextField;
00044 
00045 
00046 /**
00047 * An Input Dialog is a simple dialog which is used
00048 * to obtain a text string, integer, or real number from the user.
00049 * A password mode allows the key-in to remain hidden.
00050 */
00051 class FXAPI FXInputDialog : public FXDialogBox {
00052   FXDECLARE(FXInputDialog)
00053 protected:
00054   FXTextField *input;       // Text field widget
00055   FXdouble     limlo;       // Lower limit
00056   FXdouble     limhi;       // Upper limit
00057 protected:
00058   FXInputDialog(){}
00059 private:
00060   FXInputDialog(const FXInputDialog&);
00061   FXInputDialog &operator=(const FXInputDialog&);
00062 public:
00063   long onCmdAccept(FXObject*,FXSelector,void*);
00064 public:
00065 
00066   /// Construct input dialog box with given caption, icon, and prompt text
00067   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);
00068 
00069   /// Get input string
00070   FXString getText() const;
00071 
00072   /// Set input string
00073   void setText(const FXString& text);
00074 
00075   /// Change number of visible columns of text
00076   void setNumColumns(FXint num);
00077 
00078   /// Return number of visible columns of text
00079   FXint getNumColumns() const;
00080 
00081   /// Change limits
00082   void setLimits(FXdouble lo,FXdouble hi){ limlo=lo; limhi=hi; }
00083 
00084   /// Return limits
00085   void getLimits(FXdouble& lo,FXdouble& hi){ lo=limlo; hi=limhi; }
00086 
00087   /// Run modal invocation of the dialog
00088   virtual FXuint execute(FXuint placement=PLACEMENT_CURSOR);
00089 
00090   /**
00091   * Prompt for a string, start with the initial value.
00092   * Return TRUE if the new value is accepted, and false otherwise.
00093   */
00094   static FXbool getString(FXString& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* ic=NULL);
00095 
00096   /**
00097   * Prompt for an integer number, start with the given initial value.
00098   * Return TRUE if the new value is accepted, and false otherwise.
00099   * The input is constrained between lo and hi, unless lo>hi, in which
00100   * case the input can be any number.
00101   */
00102   static FXbool getInteger(FXint& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* ic=NULL,FXint lo=1,FXint hi=0);
00103 
00104   /**
00105   * Prompt for an real number, start with the given initial value.
00106   * Return TRUE if the new value is accepted, and false otherwise.
00107   * The input is constrained between lo and hi, unless lo>hi, in which
00108   * case the input can be any number.
00109   */
00110   static FXbool getReal(FXdouble& result,FXWindow* owner,const FXString& caption,const FXString& label,FXIcon* ic=NULL,FXdouble lo=1.0,FXdouble hi=0.0);
00111   };
00112 
00113 }
00114 
00115 #endif

Copyright © 1997-2004 Jeroen van der Zijp