williamr@2: /* williamr@2: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef __AKNDIALOG_H__ williamr@2: #define __AKNDIALOG_H__ williamr@2: williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: williamr@2: class CAknDialogAttributes; williamr@2: williamr@2: /** williamr@2: * Base class for different types of @c AknDialogs williamr@2: * williamr@2: * Instances of the @c CAikDialog class may be created, and it is possible to williamr@2: * add controls directly to them. However it is more normal to create a williamr@2: * subclass, and to handle the controls appearing on the dialog dynamically. williamr@2: */ williamr@2: class CAknDialog : public CEikDialog, public MEikMenuObserver williamr@2: { williamr@2: public : williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CAknDialog() ; williamr@2: williamr@2: /** williamr@2: * Handles Symbian 2nd phase construction. williamr@2: * williamr@2: * A menu resource MUST be specified - this function will Panic williamr@2: * otherwise. If a menu is not required use @c CEikDialog! williamr@2: * williamr@2: * @param aMenuTitleResourceId Title of the menu. williamr@2: */ williamr@2: IMPORT_C void ConstructL( TInt aMenuTitleResourceId ) ; williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CAknDialog() ; williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Loads, displays, and destroys the dialog. williamr@2: * williamr@2: * This function loads the specified dialog from a resource and williamr@2: * displays it. The method then destroys the dialog when it exits, williamr@2: * therefore there is no need for the application program to williamr@2: * destroy the dialog. williamr@2: * williamr@2: * @param aResourceId The resource ID of the dialog to load. williamr@2: * @return Zero, unless it is a waiting dialog. For a waiting dialog, williamr@2: * the return value is the ID of the button that closed the williamr@2: * dialog, or zero if it was the cancel button williamr@2: * (@c EEikBidCancel). williamr@2: */ williamr@2: IMPORT_C TInt ExecuteLD( TInt aResourceId ) ; williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Prepares the dialog, by constructing it from the specified resource. williamr@2: * williamr@2: * @param aResourceId The resource ID of the dialog. williamr@2: */ williamr@2: IMPORT_C void PrepareLC(TInt aResourceId); williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Runs the dialog and returns the ID of the button used to dismiss it. williamr@2: * williamr@2: * The dialog is destroyed on exit. williamr@2: * williamr@2: * This function is called by the dialog framework (@c ExecuteLD()) to williamr@2: * perform dynamic construction (layout) and to display/destroy the williamr@2: * dialog. Static construction of the dialog must already be complete williamr@2: * before this function is called, e.g. using @c PrepareLC(). williamr@2: * williamr@2: * The function returns immediately unless @c EEikDialogFlagWait has williamr@2: * been specified in the @c DIALOG resource. If @c EEikDialogFlagWait williamr@2: * is specified, it returns when the dialog exits. williamr@2: * williamr@2: * @return The ID of the button used to dismiss the dialog. williamr@2: */ williamr@2: IMPORT_C TInt RunLD(); williamr@2: williamr@2: // From MEikMenuObserver williamr@2: /** williamr@2: * From @c MEikMenuObserver. williamr@2: * williamr@2: * Called by the Uikon framework to handle the emphasising or williamr@2: * de-emphasising of a menu window. williamr@2: * williamr@2: * @c CEikMenuBar objects call this on their observer to emphasise williamr@2: * themselves when they are displayed, and de-emphasise themselves when williamr@2: * they stop displaying. williamr@2: * williamr@2: * @param aMenuControl The menu control. williamr@2: * @param aEmphasis @c ETrue to emphasize the menu, williamr@2: * @c EFalse otherwise. williamr@2: */ williamr@2: IMPORT_C virtual void SetEmphasis( CCoeControl* aMenuControl, williamr@2: TBool aEmphasis ) ; williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aResourceId Not used. williamr@2: * @param aMenuPane Not used. williamr@2: */ williamr@2: IMPORT_C virtual void DynInitMenuPaneL( TInt aResourceId, williamr@2: CEikMenuPane* aMenuPane ) ; williamr@2: williamr@2: /** williamr@2: * From @c MEikMenuObserver. williamr@2: * williamr@2: * Hides the menu. williamr@2: * williamr@2: * @param aCommandId Not used. williamr@2: */ williamr@2: IMPORT_C virtual void ProcessCommandL( TInt aCommandId ) ; williamr@2: williamr@2: // From CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles key events. williamr@2: * williamr@2: * If a control wishes to process key events, it should implement this williamr@2: * function. The implementation must ensure that the function returns williamr@2: * @c EKeyWasNotConsumed if it does not do anything in response to a williamr@2: * key event, otherwise, other controls or dialogs may be prevented williamr@2: * from receiving the key event. If it is able to process the event williamr@2: * it should return @c EKeyWasConsumed. williamr@2: * williamr@2: * When a key event occurs, the control framework calls this function williamr@2: * for each control on the control stack, until one of them can process williamr@2: * the key event (and returns @c EKeyWasConsumed). williamr@2: * williamr@2: * Each keyboard key press results in three separate events: williamr@2: * @c EEventKeyDown, @c EEventKey, and @c EEventKeyUp, in that order. williamr@2: * williamr@2: * To receive key events, which can be processed by this function, williamr@2: * the application should call @c CCoeAppUi::AddToStackL() to add the williamr@2: * control to the stack. This only applies, however, to controls which williamr@2: * are not components of a compound control. Compound controls should williamr@2: * pass key events to their components as necessary: the components williamr@2: * themselves do not go on the stack. williamr@2: * williamr@2: * @param aKeyEvent The key event. williamr@2: * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or williamr@2: * @c EEventKeyDown. williamr@2: * @return Indicates whether or not the key event was used by williamr@2: * this control. williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, williamr@2: TEventCode aType) ; williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Responds to a change in focus. williamr@2: * williamr@2: * This is called whenever the control gains or loses focus, as a williamr@2: * result of a call to @c SetFocus(). A typical use of williamr@2: * @c FocusChanged() is to change the appearance of the control, williamr@2: * for example by drawing a focus rectangle around it. williamr@2: * williamr@2: * @param aDrawNow Contains the value that was passed to it by williamr@2: * @c SetFocus(). williamr@2: */ williamr@2: IMPORT_C void FocusChanged(TDrawNow aDrawNow); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles pointer events. williamr@2: * williamr@2: * This function gets called whenever a pointer event occurs in the williamr@2: * control, i.e. when the pointer is within the control's extent, williamr@2: * or when the control has grabbed the pointer. The control should williamr@2: * implement this function to handle pointer events. williamr@2: * williamr@2: * Note: events of type @c EButton1Down are processed before williamr@2: * @c HandlePointerEventL() is called, in order to transfer keyboard williamr@2: * focus to the control in which the @c EButton1Down event occurred. williamr@2: * williamr@2: * @param aPointerEvent The pointer event williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: private: // formerly from MTopSetMember, now reserved williamr@2: williamr@2: IMPORT_C virtual void Reserved_MtsmPosition(); williamr@2: williamr@2: IMPORT_C virtual void Reserved_MtsmObject(); williamr@2: williamr@2: private: williamr@2: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Handles a dialog button press for the specified button. williamr@2: * williamr@2: * This function is invoked when the user presses a button in the williamr@2: * button panel. It is not called if the Cancel button is activated williamr@2: * unless the @c EEikDialogFlagNotifyEsc flag has been set. williamr@2: * williamr@2: * If there is an Options key then pops up menu, otherwise exits. williamr@2: * williamr@2: * The function should be overridden by the derived class, and is williamr@2: * usually used to validate the values of the dialog's controls. williamr@2: * The function should return @c ETrue if it is OK to exit, and williamr@2: * @c EFalse to keep the dialog active. It should always return williamr@2: * @c ETrue if the button with ID @c EEikBidOK was activated. williamr@2: * williamr@2: * @param aButtonId The ID of the button that was activated. williamr@2: * @return @c ETrue to validate and exit the dialog, williamr@2: * @c EFalse to keep the dialog active. If @c ETrue, the williamr@2: * dialog will be destroyed automatically by @c ExecuteLD(). williamr@2: * The default implementation returns @c ETrue no matter which williamr@2: * button is pressed. williamr@2: */ williamr@2: IMPORT_C virtual TBool OkToExitL( TInt aButtonId ) ; williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Displays menu bar. williamr@2: */ williamr@2: IMPORT_C void DisplayMenuL() ; williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Hides menu bar. williamr@2: */ williamr@2: IMPORT_C void HideMenu() ; williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Checks if menu is displayed. williamr@2: * williamr@2: * @return @c ETrue if menu is displayed, williamr@2: * @c EFalse otherwise. williamr@2: */ williamr@2: IMPORT_C TBool MenuShowing() const ; williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Lays out the dialog's components when the size of the dialog williamr@2: * is changed. williamr@2: */ williamr@2: IMPORT_C virtual void SizeChanged(); williamr@2: williamr@2: /** williamr@2: * From @c CEikDialog. williamr@2: * williamr@2: * Draws the control. williamr@2: * williamr@2: * @param aRect Area to be drawn. williamr@2: */ williamr@2: IMPORT_C virtual void Draw(const TRect &aRect) const; williamr@2: williamr@2: protected: // from MObjectProvider williamr@2: williamr@2: /** williamr@2: * From @c MObjectProvider. williamr@2: * williamr@2: * Gets Mop supply object of the given type. williamr@2: * williamr@2: * @param aId Identifier for the supply object. williamr@2: * @return Pointer to the supply object type ID. williamr@2: */ williamr@2: IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId); williamr@2: williamr@2: private: williamr@2: williamr@2: IMPORT_C virtual void CEikDialog_Reserved_1(); williamr@2: williamr@2: IMPORT_C virtual void CEikDialog_Reserved_2(); williamr@2: williamr@2: private: // new function williamr@2: williamr@2: IMPORT_C virtual void CAknDialog_Reserved(); williamr@2: williamr@2: protected: // new function williamr@2: williamr@2: /** williamr@2: * Creates or replaces dialog's menu bar. williamr@2: * williamr@2: * @param aMenuTitleResourceId Title of the menu bar. williamr@2: */ williamr@2: void CreateMenuBarL(TInt aMenuTitleResourceId); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Dialog's menu bar. williamr@2: * Not owned. williamr@2: */ williamr@2: CEikMenuBar* iMenuBar; williamr@2: williamr@2: private: williamr@2: williamr@2: enum TAknDialogFlag williamr@2: { williamr@2: EAknDialogFlagDialogDeleted = 1, williamr@2: EAknDialogFlagDefaultSounds = 2, williamr@2: EAknDialogFlagNotConstructed = 4 williamr@2: }; williamr@2: williamr@2: CAknDialogAttributes* iAttributes; // Was TInt iSpare; williamr@2: williamr@2: CAknDialogAttributes* AttributesL(); williamr@2: williamr@2: } ; williamr@2: williamr@2: #endif // __AKNDIALOG_H__ williamr@2: williamr@2: williamr@2: // End of file