examples/AppFramework/txtshell/txtexamp.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:� 
00028 */
00029 
00030 
00031 #ifndef __TXTEXAMP_H
00032 #define __TXTEXAMP_H
00033 
00034 #include <coemain.h>
00035 #include <coecntrl.h>
00036 #include <s32file.h>
00037 #include <txtglobl.h>
00038 #include <frmtview.h>
00039 #include <txtfmlyr.h>
00040 
00041 //
00042 // class MGraphicsExampleObserver
00043 //
00044 
00045 class MGraphicsExampleObserver
00046         // Defines an interface that controls can call to inform the shell 
00047         // that they have finished, or that the status message display needs 
00048         // updating. It is implemented by CExampleShellContainer        
00049         {
00050 public:
00051         // Notify user that example has finished
00052         virtual void NotifyGraphicExampleFinished()=0;
00053         // Notify user of the current status of the example
00054         virtual void NotifyStatus(const TDesC& aMessage)=0;
00055         };
00056 
00057 //
00058 // class CGraphicExampleControl
00059 //
00060 
00061 /*
00062         Usage
00063 
00064                 This class is used as a base class for graphics and text 
00065                 examples. It uses CONE's facilities to provide an initialized 
00066                 graphics environment.
00067 
00068                 It creates a 600x200 window in which drawing can be done.
00069 
00070                 It supports multiple phases, so different drawings can be 
00071                 done from one phase to another.  Tap the spacebar or click the
00072                 mouse (anywhere) to advance a phase.
00073 
00074                 Quit the program by pressing the exit button.
00075 
00076         Writing derived classes
00077 
00078                 A minimal derived class should have a Draw() function
00079                 which puts a drawing onto the screen.
00080 
00081                 If you are using multiple phases, code a constructor which
00082                 calls SetMaxPhases() specifying the number of phases.  Have
00083                 Draw() honour the phase number, available using Phase().
00084 */
00085 
00086 #pragma warning(disable : 4100)
00087                 // disable "parameter not used" warning on HandleKey()
00088 
00089 class CGraphicExampleControl : public CCoeControl
00090         {
00091 public:
00092         // construct/destruct
00093         void ConstructL(const TRect& aRect, MGraphicsExampleObserver* aObserver, const CCoeControl& aParent);
00094                 // second-phase construction
00095         ~CGraphicExampleControl();
00096         // public so container can offer keys
00097         TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
00098                 // intercepts space; offers other keys to derived classes
00099 protected:
00100         // derived classes must provide the next 2 functions
00101         virtual void UpdateModelL() =0; // empty update model function
00102         virtual void Draw(const TRect& /* aRect */) const {}; // empty draw function
00103         // use Phase() in Draw() to tell what phase we're in
00104         TInt Phase() const { return iPhase; }; // get phase number
00105         void SetMaxPhases(TInt aMaxPhases) { iMaxPhases=aMaxPhases; };
00106                         // use this from derived-class constructor to set number of phases
00107         CFont* iMessageFont; // font for messages
00108 private:
00109         // functions provided for CCoeControl protocol
00110         void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00111                 // advances phase on pointer-down
00112         void Quit(); // does termination
00113         void NextPhaseL(); // advances phase: quits if all phases done
00114         // phase control for graphics examples
00115         TInt iPhase; // phase number
00116         TInt iMaxPhases; // maximum phases
00117 protected:
00118         MGraphicsExampleObserver* iFormObserver;
00119         TBool iUpdateModelDoesRedraw; // whether UpdateModelL() does a redraw for us
00120         };
00121 
00122 // sundry derived classes
00123 
00124 class CGlobalText;
00125 class CRichText;
00126 class CParaFormatLayer;
00127 class CCharFormatLayer;
00128 class CTextLayout;
00129 class CTextView;
00130 class CStyleList;
00131 class CParagraphStyle;
00132 
00133 
00134 class CGlobalControl : public CGraphicExampleControl
00135         {
00136         // Demonstrates the use of global text
00137 public:
00138         CGlobalControl() { SetMaxPhases(16); };
00139         void UpdateModelL();
00140         void Draw(const TRect& aRect) const;
00141         ~CGlobalControl();
00142 private:
00143         CGlobalText* iGlobalText; // global text object
00144         CParaFormatLayer* iParaFormatLayer;
00145         CCharFormatLayer* iCharFormatLayer;
00146         TStreamId iStreamId; // required when storing and restoring global text
00147         // text layout and view stuff
00148         CTextLayout* iLayout; // text layout
00149         CTextView* iTextView; // text view
00150         TRect iViewRect; // rectangle through which to view text
00151         TCharFormat iCharFormat;
00152         TCharFormatMask iCharFormatMask;
00153         };
00154 
00155 class CRichControl : public CGraphicExampleControl
00156         {
00157         // Demonstrates the use of rich text
00158 public:
00159         CRichControl() { SetMaxPhases(14);}; 
00160         ~CRichControl(); // destructor
00161         void UpdateModelL();
00162         void Draw(const TRect& aRect) const;
00163 private:
00164         CRichText* iRichText; // global text object
00165         CParaFormatLayer* iParaFormatLayer;
00166         CCharFormatLayer* iCharFormatLayer;
00167         TStreamId iStreamId; // required when storing and restoring global text
00168         // text layout and view stuff
00169         CTextLayout* iLayout; // text layout
00170         CTextView* iTextView; // text view
00171         TRect iViewRect; // rectangle through which to view text
00172         TCharFormat iCharFormat;
00173         TCharFormatMask iCharFormatMask;
00174         };
00175 
00176 class CStyleControl : public CGraphicExampleControl
00177         {
00178         // Demonstrates the use of styles in rich text
00179 public:
00180         CStyleControl() { SetMaxPhases(9);}; 
00181         ~CStyleControl(); // destructor
00182         void UpdateModelL();
00183         void Draw(const TRect& aRect) const;
00184 private:
00185         void CreateNormalL(); // Create Normal style (the global layers) 
00186         void CreateStylesL(); // Create some paragraph styles
00187 private:
00188         CRichText* iRichText; // rich text object
00189         CParaFormatLayer* iNormalParaFormatLayer;
00190         CCharFormatLayer* iNormalCharFormatLayer;
00191         TStreamId iStreamId; // required when storing and restoring global text
00192         // text layout and view stuff
00193         CTextLayout* iLayout; // text layout
00194         CTextView* iTextView; // text view
00195         TRect iViewRect; // rectangle through which to view text
00196         CStyleList* iStyleList; // Style list holds the two styles
00197         CParagraphStyle* iStyleOne;
00198         CParagraphStyle* iStyleTwo;
00199         TCharFormat iCharFormat;
00200         TCharFormatMask iCharFormatMask;
00201         };
00202 
00203 class CViewControl : public CGraphicExampleControl
00204         {
00205         // Demonstrates the use of the text view and text layout classes
00206 public:
00207         CViewControl() { SetMaxPhases(14);}; 
00208         ~CViewControl(); 
00209         void UpdateModelL();
00210         void Draw(const TRect& aRect) const;
00211 private:
00212         CRichText* iRichText; // rich text object
00213         CParaFormatLayer* iParaFormatLayer;
00214         CCharFormatLayer* iCharFormatLayer;
00215         // text layout and view stuff
00216         CTextLayout* iLayout; // text layout
00217         CTextView* iTextView; // text view
00218         TRect iViewRect; // rectangle through which to view text
00219         CFbsBitmap* iBitmap; // line cursor bitmap
00220         TCharFormat iCharFormat;
00221         TCharFormatMask iCharFormatMask;
00222         };
00223 
00224 #endif
00225 

Generated by  doxygen 1.6.2