javauis/lcdui_akn/lcdui/inc/CMIDTextBoxQueryDialog.h
branchRCL_3
changeset 66 2455ef1f5bbc
equal deleted inserted replaced
65:ae942d28ec0e 66:2455ef1f5bbc
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Pop-up Textbox dialog implementation for S60
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMIDTEXTBOXQUERYDIALOG_H
       
    20 #define CMIDTEXTBOXQUERYDIALOG_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <lcdui.h>
       
    25 #include <AknQueryDialog.h>
       
    26 #include "CMIDDisplayable.h"
       
    27 
       
    28 #include <eikedwob.h>
       
    29 // for MCoeCaptionRetrieverForFep
       
    30 #include <fepbase.h>
       
    31 
       
    32 #include "CMIDEdwinUtils.h"
       
    33 
       
    34 // CLASS DECLARATION
       
    35 NONSHARABLE_CLASS(CMIDTextBoxQueryDialog)
       
    36         : public CAknTextQueryDialog, MMIDTextBox, public MMIDCommandObserver,
       
    37         public MEikEdwinObserver, public MCoeCaptionRetrieverForFep
       
    38 {
       
    39 
       
    40 public:
       
    41     static CMIDTextBoxQueryDialog* NewLC(TInt aConstraints,
       
    42     TDes& aResult,
       
    43     TInt aMaxSize,
       
    44     CMIDDisplayable* aDisplayable,
       
    45     const TDesC& aText);
       
    46     ~CMIDTextBoxQueryDialog();
       
    47 
       
    48 private:
       
    49     void ConstructL(TInt aConstraints,
       
    50                     TInt aMaxSize,
       
    51                     CMIDDisplayable* aDisplayable,
       
    52                     const TDesC& aText);
       
    53 
       
    54     CMIDTextBoxQueryDialog(TDes& aResult);
       
    55 
       
    56 public:
       
    57     //
       
    58     //From CAknTextQueryDialog
       
    59     //
       
    60     TInt RouseSleepingDialog();
       
    61     void ExitSleepingDialog();
       
    62     void TryExitL(TInt aButtonId);
       
    63 
       
    64     //
       
    65     // From MMIDCommandObserver
       
    66     //
       
    67     TBool ProcessCommandL(CMIDCommand* aCommand);
       
    68 
       
    69     //
       
    70     // From MMIDTextBox
       
    71     //
       
    72     /**
       
    73      * Deletes editor's text.
       
    74      *
       
    75      * @param aOffset   the beginning of the region to be deleted
       
    76      * @param aLength   the number of characters to be deleted
       
    77      *
       
    78      * @since S60 5.0
       
    79      */
       
    80     void DeleteTextL(TInt aOffset,TInt aLength);
       
    81 
       
    82     /**
       
    83      * Sets the contents of the editor in dialog, replacing the previous contents.
       
    84      *
       
    85      * @param aText   the new value of the editor
       
    86      *
       
    87      * @since S60 5.0
       
    88      */
       
    89     void SetTextL(const TDesC& aText);
       
    90 
       
    91     /**
       
    92      * Inserts a string into the contents of the editor.
       
    93      *
       
    94      * @param aText   the text to be inserted in the editor
       
    95      * @param aPosition   the position at which insertion is to occur
       
    96      *
       
    97      * @since S60 5.0
       
    98      */
       
    99     void InsertTextL(const TDesC& aText,TInt aPosition);
       
   100 
       
   101     /**
       
   102     * Sets constraints for the text editor
       
   103     *
       
   104     * @param aConstraints   new input constraints
       
   105     */
       
   106     void SetConstraintsL(TUint aConstraints);
       
   107 
       
   108     /**
       
   109      * Sets the maximum size (number of characters) that can be contained in editor.
       
   110      *
       
   111      * @param aSize          the new maximum size
       
   112      *
       
   113      * @return TInt          Indicates assigned maximum capacity - may be smaller than requested.
       
   114      *
       
   115      * @since S60 5.0
       
   116      */
       
   117     TInt SetMaxSizeL(TInt aSize);
       
   118 
       
   119     /**
       
   120      * Returns the maximum size (number of characters) that can be stored in editor.
       
   121      *
       
   122      * @return TInt          the maximum size in characters
       
   123      *
       
   124      * @since S60 5.0
       
   125      */
       
   126     TInt GetMaxSize();
       
   127 
       
   128     /**
       
   129      * Gets the number of characters that are currently stored in editor.
       
   130      *
       
   131      * @return TInt          the number of characters
       
   132      *
       
   133      * @since S60 5.0
       
   134      */
       
   135     TInt Size();
       
   136 
       
   137     /**
       
   138      * Gets the current input position of the editor.
       
   139      *
       
   140      * @return TInt          the current caret position, 0 if at the beginning
       
   141      *
       
   142      * @since S60 5.0
       
   143      */
       
   144     TInt GetCaretPosition();
       
   145 
       
   146     /**
       
   147      * Gets a new buffer containing a copy of the whole text of the editor.
       
   148      * Note: Caller is responsible of deleting the buffer.
       
   149      *
       
   150      * @return HBufC*          A new copy of the text.
       
   151      *
       
   152      * @since S60 5.0
       
   153      */
       
   154     HBufC* GetTextL();
       
   155 
       
   156     /**
       
   157      * Sets initial input mode for the editor.
       
   158      *
       
   159      * @param aCharacterSubset         a string naming a Unicode character subset
       
   160      *
       
   161      * @since S60 5.0
       
   162      */
       
   163     void SetInitialInputModeL(const TDesC& aCharacterSubset);
       
   164 
       
   165     /**
       
   166      * Sets prompt (title) for dialog. Accepts null, which indicates empty string.
       
   167      *
       
   168      * @param aString         new title
       
   169      *
       
   170      * @since S60 5.0
       
   171      */
       
   172     void SetTitleL(const TDesC* aString);
       
   173 
       
   174     /**
       
   175      * Moves cursor position of the editor.
       
   176      *
       
   177      * @param aString         new position, if bigger than editor max size then
       
   178      *                                      cursor is set at the end of the editor.
       
   179      *
       
   180      * @since S60 5.0
       
   181      */
       
   182     void SetCursorPositionL(TInt aPosition);
       
   183 
       
   184     /**
       
   185      * Size of the dialog.
       
   186      *
       
   187      * @return TSize          Size of the dialog.
       
   188      *
       
   189      * @since S60 5.0
       
   190      */
       
   191     TSize ContentSize() const;
       
   192 
       
   193     // From MMIDComponent
       
   194     //
       
   195     inline void Dispose();
       
   196 
       
   197     //
       
   198     // From CCoeControl
       
   199     void FocusChanged(TDrawNow aDrawNow);
       
   200     void MakeVisible(TBool aVisible);
       
   201     void SizeChanged();
       
   202     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
   203     void HandleResourceChange(TInt aType);
       
   204 #ifdef RD_SCALABLE_UI_V2
       
   205     void HandlePointerEventL(const TPointerEvent &aPointerEvent);
       
   206 #endif // RD_SCALABLE_UI_V2
       
   207     TCoeInputCapabilities InputCapabilities() const;
       
   208 
       
   209     // From MEikEdwinObserver
       
   210     void HandleEdwinEventL(CEikEdwin* aEdwin, TEdwinEvent aEventType);
       
   211 
       
   212     // From MCoeCaptionRetrieverForFep
       
   213     void GetCaptionForFep(TDes& aCaption) const;
       
   214 
       
   215     /**
       
   216      * Set text  input modifiers according to TextBox constraints.
       
   217      *
       
   218      * @since S60 5.0
       
   219      */
       
   220     void ProcessModifiers();
       
   221 
       
   222     /**
       
   223      * Either makes dialog visible or hides the dialog.
       
   224      *
       
   225      * @param TBool          Show or hide the dialog.
       
   226      *
       
   227      * @since S60 5.0
       
   228      */
       
   229     void ShowL(TBool aShow);
       
   230 
       
   231     /**
       
   232      * Tries to add replace text in editor when conmstraints have been changed.
       
   233      * Should be called after changing constraints.
       
   234      *
       
   235      * @param TBool          Show or hide the dialog.
       
   236      *
       
   237      * @since S60 5.0
       
   238      */
       
   239     void SetTextWithNewConstraintsL(HBufC* aText);
       
   240 
       
   241     /**
       
   242      * Initializes the editor
       
   243      *
       
   244      * @since S60 5.0
       
   245      */
       
   246     void SetEditorL();
       
   247 
       
   248     /**
       
   249      * Returns TextBox current intput constraints
       
   250      *
       
   251      * @param TInt         input constraints
       
   252      *
       
   253      * @since S60 5.0
       
   254      */
       
   255     TInt Constraints();
       
   256 
       
   257     /**
       
   258      * Returns whether dialog is currently visible on the display
       
   259      *
       
   260      * @param TBool         iShowing
       
   261      *
       
   262      * @since S60 5.0
       
   263      */
       
   264     TBool Showing();
       
   265 
       
   266 protected:
       
   267     //
       
   268     //From CAknTextQueryDialog
       
   269     //
       
   270     void UpdateLeftSoftKeyL();
       
   271     TBool OkToExitL(TInt aButtonId);
       
   272     void PreLayoutDynInitL();
       
   273 
       
   274 private:
       
   275     /**
       
   276      * Sets the input constraints of the editor.
       
   277      *
       
   278      * @since S60 5.0
       
   279      */
       
   280     void SetFEPModeAndCharFormat();
       
   281 
       
   282     void UpdateCbasL();
       
   283 
       
   284     TBool IsNumberConversionNeeded();
       
   285 
       
   286     void HandleMinusCharEventL(MEikEdwinObserver::TEdwinEvent aEventType);
       
   287 
       
   288     /**
       
   289      * Prevents changes that would result in an illegal string
       
   290      *
       
   291      * @param TEdwinEvent aEventType
       
   292      */
       
   293     void HandleTextUpdateL(TEdwinEvent aEventType);
       
   294 
       
   295     TPtrC Read() const;
       
   296 
       
   297     void CreateNonMidletCommandsL();
       
   298     void AddCommandToEdwinL(TInt aCommandResIdShort,
       
   299                             TInt aCommandResIdLong,
       
   300                             TInt aCommandId);
       
   301     void AddCommandToEdwinL(TInt aCommandResId, TInt aCommandId);
       
   302     void RemoveNonMidletCommands();
       
   303     void AddCommandToEdwinL(MMIDCommand& aCommand);
       
   304     void CreatePhoneCallL();
       
   305 
       
   306     void CreatePasswordTextL();
       
   307 
       
   308     /**
       
   309      * Updates editor's input mode. Must be called after changing input modes
       
   310      * and after the dialog is set visible.
       
   311      *
       
   312      * @since S60 5.0
       
   313      */
       
   314     void UpdateInitialInputModes();
       
   315 
       
   316     TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
   317 
       
   318     void UpdateScrollBarPositionL();
       
   319 
       
   320 private:
       
   321     inline TUint GetConstraints() const;
       
   322     inline TBool IsConstraintSet(TUint aConstraints);
       
   323 
       
   324 private:
       
   325     /**
       
   326      * Pointer to CMIDEdwinUtils
       
   327      */
       
   328     CMIDEdwinUtils*             iEdwinUtils;
       
   329 
       
   330     /**
       
   331      * Pointer to the editor
       
   332      */
       
   333     CEikEdwin*                  iEditor;
       
   334 
       
   335     /**
       
   336      * Boolean value indicating whether the dialog is currently visible or not.
       
   337      */
       
   338     TBool                       iShowing;
       
   339 
       
   340     /**
       
   341      * Maximum size (number of characters) of the editor.
       
   342      */
       
   343     TInt                        iMaxSize;
       
   344 
       
   345     /**
       
   346      * Text input constraints
       
   347      */
       
   348     TUint                       iConstraints;
       
   349 
       
   350     /**
       
   351      * Pointer to Displayable
       
   352      */
       
   353     CMIDDisplayable*            iDisplayable;
       
   354 
       
   355     /**
       
   356      * Text case (abc/ABC/etc.) to be set when coming visible
       
   357      */
       
   358     TInt                        iInitialCurrentCase;
       
   359 
       
   360     /**
       
   361      * Input mode (text/numeric) to be set when coming visible
       
   362      */
       
   363     TInt                        iInitialCurrentInputMode;
       
   364 
       
   365     /**
       
   366      * Input mode language to be set when coming visible
       
   367      */
       
   368     TLanguage                   iInitialCurrentLanguage;
       
   369 
       
   370     /**
       
   371      * Stores keycode of the current key; used in multitap transaction exceeding editor limit.
       
   372      */
       
   373     TInt                        iThisMultitapKey;
       
   374 
       
   375     /**
       
   376      * stores keycode of the last key; used in multitap transaction exceeding editor limit
       
   377      */
       
   378     TInt                        iLastMultitapKey;
       
   379 
       
   380     /**
       
   381      * Decimal separator character based on locale
       
   382      */
       
   383     TChar                       iDecimalSeparator;
       
   384 
       
   385     /**
       
   386      * Needed when accessing to phonebook
       
   387      */
       
   388     CMIDAiwPbk2Client*          iAiwPbkClient;
       
   389 
       
   390     /**
       
   391      * Boolean value indicating whether key events are pending.
       
   392      */
       
   393     TBool                       iKeyEventsPending;
       
   394     /**
       
   395      * Used key event
       
   396      */
       
   397     const TKeyEvent*            iusedKeyEvent;
       
   398 
       
   399     /**
       
   400      * Used when ConstraintsValidForText decide
       
   401      * whatever to test text using stric options or not
       
   402      */
       
   403     TBool iStrict;
       
   404 };
       
   405 
       
   406 
       
   407 inline void CMIDTextBoxQueryDialog::Dispose()
       
   408 {
       
   409     delete this;
       
   410 }
       
   411 
       
   412 inline TUint CMIDTextBoxQueryDialog::GetConstraints() const
       
   413 {
       
   414     return iConstraints;
       
   415 }
       
   416 
       
   417 inline TBool CMIDTextBoxQueryDialog::IsConstraintSet(TUint aConstraints)
       
   418 {
       
   419     return (iConstraints & MMIDTextField::EConstraintMask) == aConstraints ;
       
   420 }
       
   421 #endif // CMIDTEXTBOXQUERYDIALOG_H