examples/AppFramework/UIControls/CustomControls/CustomControls.h

00001 /*
00002 Copyright (c) 2000-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003 
00004 Redistribution and use in source and binary forms, with or without
00005 modification, are permitted provided that the following conditions are met:
00006 
00007 * Redistributions of source code must retain the above copyright notice, this
00008   list of conditions and the following disclaimer.
00009 * Redistributions in binary form must reproduce the above copyright notice,
00010   this list of conditions and the following disclaimer in the documentation
00011   and/or other materials provided with the distribution.
00012 * Neither the name of Nokia Corporation nor the names of its contributors
00013   may be used to endorse or promote products derived from this software
00014   without specific prior written permission.
00015 
00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027 Description: UI Control Framework example application  
00028 */
00029 #if !defined(__COSMILEY_H__)
00030 #define __COSMILEY_H__
00031 
00033 //
00034 // Include files containing:
00035 //
00036 // 1. Symbol definitions used by C++ code and resource scripts (the *.hrh)
00037 // 2. Resource ids generated by resource compilation of 
00038 //    resource scripts (the *.rsg)
00039 // 3. Class definitions required by this app (the *.h)
00040 //    
00042 
00043 // 1.
00044 #include <eikon.hrh>
00045 #include "CustomControls.hrh"
00046 // 2.
00047 #include <eikon.rsg>
00048 #include <customcontrols.rsg>
00049 // 3.
00050 #include <eikenv.h>
00051 #include <eikappui.h>
00052 #include <eikproc.h>
00053 #include <eikdialg.h>
00054 #include <eikmenub.h>
00055 #include <eikapp.h>
00056 #include <eikdoc.h>
00057 #include <coeutils.h>
00058 #include <barsread.h>
00059 #include <eikfctry.h>
00060 
00061   // The unique identifier for this application.
00062   // NOTE that the number has been arbitrarily chosen for the purpose of
00063   // of the example.
00064 const TUid KUidExampleApp={0xE8000004};
00065 
00066 
00068 //
00069 // -----> CSmileyDialog(definition)
00070 //
00072 class CSmileyDialog : public CEikDialog
00073         {
00074 public:
00075         // Construct and run
00076         static TBool RunDlgLD();
00077 private:
00078         SEikControlInfo CreateCustomControlL(TInt aControlType);
00079         };      
00080 
00082 //
00083 // -----> CSmiley (definition)
00084 //
00086 class CSmiley : public CCoeControl
00087         {
00088 public:
00089         CSmiley(TBool aSmiling);
00090         ~CSmiley();
00091 public:
00092         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00093         TBool IsSmiling();
00094 private:
00095         void Draw(const TRect& aRect) const;
00096         void SizeChanged();
00097 protected:
00098         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00099         void FocusChanged(TDrawNow aDrawNow);
00100 private:
00101         TBool   iSmiling;
00102         TRect   iSmileyRect;
00103         TInt    iSmileyWidth;
00104         TInt    iSmileyHeight;
00105         TRect   iSmileRect;
00106         TRect   iFrownRect;
00107         };
00108 
00110 //
00111 // -----> CSmileyContainer(definition)
00112 //
00114 class CSmileyContainer : public CCoeControl, 
00115                                                  public MCoeControlObserver
00116         {
00117 public:
00118           // Construction
00119         CSmileyContainer();
00120         void ConstructL(const TRect& aRect);
00121           // Destruction
00122         ~CSmileyContainer();
00123         void ConstructFromResourceL(TResourceReader& aReader);
00124         void PrepareForFocusLossL();
00125         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00126 protected:
00127         void FocusChanged(TDrawNow aDrawNow);
00128 private:
00129           // Virtual, defined by CCoeControl; replaces the default implementation
00130           // provided by CCoeControl.
00131         void         Draw(const TRect& aRect) const;
00132         
00133           // Virtual, defined by CCoeControl; replaces the default implementation
00134           // provided by CCoeControl. 
00135     TInt         CountComponentControls() const;
00136 
00137           // Virtual, defined by CCoeControl; replaces the default implementation
00138           // provided by CCoeControl.
00139         CCoeControl* ComponentControl(TInt aIndex) const;
00140 
00141           // Virtual, defined by CCoeControl; empty implementation provided by
00142           // CCoeControl; full implementation provided by this class
00143         void         SizeChanged();
00144         
00145           // Defined as pure virtual by the mixin class MCoeControlObserver 
00146           // inherited by CCoeControl. An empty implementation provided by 
00147           // this class (its containees do not report events).
00148         void         HandleControlEventL(CCoeControl* aControl,
00149                                              TCoeEvent aEventType);
00150 private:
00151           // Member functions defined and used by this class
00152         void            SwapFocus(CCoeControl* aControl);
00153 private:
00154       // Data members defined and used by this class.
00155         CSmiley*        iSmiley1;
00156         CSmiley*        iSmiley2;
00157         };
00158 
00159 
00160 
00162 //
00163 // -----> CMainWinControl (definition)
00164 //
00166 class CMainWinControl : public CCoeControl
00167 {
00168 public:
00169         CMainWinControl();
00170         ~CMainWinControl();
00171         void ConstructL(const TRect& rect);
00172         TInt CountComponentControls() const;
00173         CCoeControl* ComponentControl(TInt aIndex) const;
00174         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
00175 private:
00176         void Draw(const TRect& aRect) const;
00177 private:
00178         CSmileyContainer*       iContainer;
00179 };
00180 
00182 //
00183 // -----> CExampleAppUi (definition)
00184 //
00186 class CExampleAppUi : public CEikAppUi
00187         {
00188 public:
00189           // Destruction.
00190         ~CExampleAppUi();
00191 
00192 public:
00193           // Virtual, defined by CEikAppUi; replaces the implementation 
00194           // provided by CEikAppUi.
00195         void ConstructL();
00196         
00197 private:
00198           // Virtual, defined by CEikAppUi; empty implementation
00199           // provided by CEikAppUi; full implementation provided
00200           // by this class. 
00201         void  HandleCommandL(TInt aCommand);
00202         
00203           // Virtual, defined by CEikAppUi; empty implementation
00204           // provided by CEikAppUi; full implementation provided
00205           // by this class. 
00206         void  HandleModelChangeL();
00207         
00208 private:
00209         void         OnCmdExit();
00210 private:
00211         // Data members defined by this class.
00212         CMainWinControl* iMainWinControl;
00213         };
00214 
00216 //
00217 // -----> CExampleDocument (definition)
00218 //
00220 class CExampleDocument : public CEikDocument
00221         {
00222 public:
00223           // Construction.
00224         static CExampleDocument* NewL(CEikApplication& aApp);
00225     CExampleDocument(CEikApplication& aApp);
00226           // Destruction.
00227         ~CExampleDocument();
00228 
00229 private:
00230           // Defined as pure virtual by CEikDocument; full implementation
00231           // provided by this class
00232         CEikAppUi* CreateAppUiL();              // Construct an app.user interface
00233 
00234           // Defined as pure virtual by CApaDocument; empty implementation 
00235           // provided by CEikDocument; full implementation provided
00236           // by this class.
00237         void       NewDocumentL();      // Build a new document
00238 
00239           // Defined as pure virtual by CApaDocument; empty implementation
00240           // provided by CEikDocument; full implementation provided
00241           // by this class.
00242         void       StoreL(CStreamStore& aStore,
00243                               CStreamDictionary& aStreamDic
00244                                          ) const;
00245         void       RestoreL(const CStreamStore& aStore,
00246                                 const CStreamDictionary& aStreamDic
00247                                );
00248 
00249 public:
00250           // Member functions defined by this class
00251         void       DoNewFileL(const TFileName& aFileName);
00252         void       DoOpenFileL(const TFileName& aFileName);
00253         void       DoSaveToNewFileL(const TFileName& aNewFileName);
00254         TBool      FileNameExists(const TFileName& aFileName) const;
00255 
00256 private:
00257           // Member functions defined by this class
00258         void       CreateModelL();
00259         void       ResetModelL();
00260         };
00261 
00263 //
00264 // -----> CExampleApplication (definition)
00265 //
00267 class CExampleApplication : public CEikApplication
00268         {
00269 private:                
00270           // Defined as pure virtual by CApaApplication; implementation
00271           // provided by this class 
00272         TUid          AppDllUid() const; // Returns Uid associated with app
00273 
00274           // Defined as pure virtual by CEikApplication; implementation
00275           // provided by this class.
00276         CApaDocument* CreateDocumentL(); // Construct new document
00277         };
00278 
00279 
00280 
00281 #endif

Generated by  doxygen 1.6.2