|
1 /* |
|
2 * Copyright (c) 2003-2006 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMIDCOMMAND_H |
|
20 #define CMIDCOMMAND_H |
|
21 |
|
22 #include "lcdui.h" |
|
23 |
|
24 class CMIDCommand; |
|
25 class CEikonEnv; |
|
26 |
|
27 /** Commands can have zero or one observer that is allowed to process the command. |
|
28 This is needed for the so called "non-midlet" cmds, commands that exist only in |
|
29 the native side and should never reach java side. They are identified by a negative |
|
30 ID. See CMIDCommand. */ |
|
31 NONSHARABLE_CLASS(MMIDCommandObserver) |
|
32 { |
|
33 public: |
|
34 virtual TBool ProcessCommandL(CMIDCommand*) = 0; |
|
35 }; |
|
36 |
|
37 NONSHARABLE_CLASS(CMIDCommand) : public CBase, public MMIDCommand |
|
38 { |
|
39 public: |
|
40 /** |
|
41 * Constant ID numbers for built-in commands in DateField, List and ChoiceGroup. |
|
42 **/ |
|
43 enum |
|
44 { |
|
45 EAmPmToggleCommandId = -101, |
|
46 EListSelectCommandId = -102, |
|
47 EListMarkCommandId = -103, |
|
48 EListUnmarkCommandId = -104, |
|
49 EChoiceGroupSelectCommandId = -105, |
|
50 EChoiceGroupMarkCommandId = -106, |
|
51 EChoiceGroupUnmarkCommandId = -107 |
|
52 }; |
|
53 |
|
54 /** |
|
55 * Creates a new command object with the given parameters. |
|
56 **/ |
|
57 static MMIDCommand* NewL(const TDesC& aShortLabel,const TDesC& aLongLabel, |
|
58 TCommandType aType, TInt aPriority, TInt aId); |
|
59 |
|
60 /** |
|
61 * Creates a new command object with an unique ID. This is meant to be used |
|
62 * for creating built-in commands needed e.g. to make selections on lists. |
|
63 * Typically a built-in command is set to MSK at appropriate times. |
|
64 **/ |
|
65 static CMIDCommand* NewBuiltInCommandL(const TDesC& aLabel, TCommandType aType, TInt aId); |
|
66 |
|
67 static HBufC* AlertDismissLabelL(); |
|
68 static HBufC* ListSelectLabelL(); |
|
69 |
|
70 public: |
|
71 // |
|
72 // From MMIDCommand |
|
73 // |
|
74 const TDesC& Label() const; |
|
75 TCommandType CommandType() const; |
|
76 TInt Priority() const; |
|
77 TInt Id() const; |
|
78 |
|
79 public: |
|
80 // |
|
81 // From MMIDComponent |
|
82 // |
|
83 void Dispose(); |
|
84 |
|
85 public: |
|
86 void SetObserver(MMIDCommandObserver* aObserver); |
|
87 MMIDCommandObserver* Observer() const; |
|
88 |
|
89 public: |
|
90 const TDesC& ShortLabel() const; |
|
91 |
|
92 void SetMappedToSoftKey(TBool aMapped) const; |
|
93 TBool IsMappedToSoftKey() const; |
|
94 |
|
95 private: |
|
96 CMIDCommand(TCommandType aType,TInt aPriority, TInt aId); |
|
97 ~CMIDCommand(); |
|
98 void ConstructL(const TDesC& aShortLabel,const TDesC& aLongLabel); |
|
99 HBufC* DefaultLabelL(); |
|
100 |
|
101 protected: |
|
102 TCommandType iType; |
|
103 TInt iPriority; |
|
104 TInt iId; |
|
105 |
|
106 HBufC* iShortLabel; |
|
107 HBufC* iLongLabel; |
|
108 |
|
109 mutable TBool iIsMappedToSoftKey; //True when this command is mapped to a sk |
|
110 |
|
111 MMIDCommandObserver* iObserver; //Either an observer or null |
|
112 |
|
113 const CEikonEnv& iEikEnv; |
|
114 }; |
|
115 |
|
116 |
|
117 |
|
118 #endif // CMIDCOMMAND_H |
|
119 |