eikconso.h

Go to the documentation of this file.
00001 // EIKCONSO.H
00002 //
00003 // Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
00004 //
00005 
00006 #if !defined(__EIKCONSO_H__)
00007 #define __EIKCONSO_H__
00008                                                                                                            
00009 #if !defined(__E32CONS_H__)
00010 #include <e32cons.h>
00011 #endif
00012 
00013 #if !defined(__EIKSBOBS_H__)
00014 #include <eiksbobs.h>
00015 #endif
00016 
00017 #if !defined(__EIKSBFRM_H__)
00018 #include <eiksbfrm.h>
00019 #endif
00020 
00021 #include <akncontrol.h>
00022 
00023 #define ATT_DOUBLEWIDTH                                 0x60
00024 #define ATT_DOUBLETOP                           0x20    
00025 #define ATT_DOUBLEBOTTOM                                0x40    
00026 
00027 #define ATT_ITALIC                                              0x08    
00028 #define ATT_INVERSE                                     0x04
00029 #define ATT_UNDERLINE                                   0x02
00030 #define ATT_BOLD                                                0x01
00031 
00032 #define ATT_COLORMASK                                   0x80    // &x!=0 : color
00033 #define ATT_DOUBLEMASK                                  0x60    // &x : only the bits relevant for doublewidth/doubleheight
00034 #define ATT_RIGHTMASK                                   0x10    // |x to set RIGHT indicator
00035 #define ATT_IGNORE_RIGHTLEFT                    0xEF    // &x to clear the RIGHT/LEFT flag
00036 #define ATT_IGNORE_INVERSE                              0xFB    // &x to clear the INVERSE flag
00037 
00038 #define ATT_MAXVALUE                                    0xFF    // all flags set (maximum value of attribute byte)
00039 #define ATT_NORMAL                                              0               // the default character attribute
00040 
00041 enum TEikConsWinUnits
00042         {
00043         EEikConsWinInPixels,
00044         EEikConsWinInChars
00045         };
00046 
00047 
00059 class CEikConsoleControl;
00060 class CEikConsoleScreen : public CConsoleBase
00061         {
00062 public:
00063         enum TEikConsoleFlags
00064                 {
00065                 EUseBackedUpWindow      =0x1,
00066                 ENoInitialCursor        =0x2
00067                 };
00068 public:
00072         IMPORT_C CEikConsoleScreen();
00076         IMPORT_C ~CEikConsoleScreen();
00077 
00085         IMPORT_C TInt Create(const TDesC& aTitle,TSize aSize);
00089         IMPORT_C void Read(TRequestStatus& aStatus);
00093         IMPORT_C void ReadCancel();
00097         IMPORT_C TKeyCode KeyCode() const;
00101         IMPORT_C TUint KeyModifiers() const;
00107         IMPORT_C void ConstructL(const TDesC &aTitle,TInt aFlags);// use full screen 
00115         IMPORT_C void ConstructL(const TDesC &aTitle,const TSize &aSize,TInt aFlags,TEikConsWinUnits aUnit=EEikConsWinInChars); // place the screen at TPoint(0,0)
00124         IMPORT_C void ConstructL(const TDesC &aTitle,TPoint aTopLeft,const TSize &aSize,TInt aFlags,TEikConsWinUnits aUnit=EEikConsWinInChars); 
00129         IMPORT_C void SetConsWin(CEikConsoleControl *aConsWin); // use if you don't want WHOLE screen
00134         inline CEikConsoleControl* ConsoleControl() const {return iConsoleControl;};
00135 
00140         IMPORT_C void SetTitle(const TDesC &aTitle);
00145         IMPORT_C void SetTitleL(const TDesC &aTitle);
00150         inline HBufC *Title() const {return iConsoleTitle;};
00151         
00156         IMPORT_C TSize ScreenSize() const;
00159         IMPORT_C void FlushChars(); //new
00163         IMPORT_C TPoint CursorPos() const;
00168         IMPORT_C void SetCursorPosAbs(const TPoint &aPoint);            
00173         IMPORT_C void SetCursorPosRel(const TPoint &aPoint);            
00178         IMPORT_C void SetCursorHeight(TInt aPercentage);                
00183         IMPORT_C void Write(const TDesC &aDes);                                         
00187         IMPORT_C void ClearScreen();                            
00191         IMPORT_C void ClearToEndOfLine();               
00197         IMPORT_C void ClearChars(const TRect &aRect,TUint aCharacterAttributes);        
00202         IMPORT_C TInt HideCursor(); // returns nonzero if cursor wasn't visible
00205         IMPORT_C void DrawCursor(); 
00210         IMPORT_C void DrawInSight(TPoint aPosition);
00213         IMPORT_C void DrawCursorInSight();
00214 
00218         IMPORT_C void Up(TUint aCount=1);               
00222         IMPORT_C void Down(TUint aCount=1);     
00226         IMPORT_C void Right(TUint aCount=1);    
00230         IMPORT_C void Left(TUint aCount=1);     
00233         IMPORT_C void Cr();                                                     
00236         IMPORT_C void Lf();                                                     
00241         IMPORT_C void ScrollChars(const TRect &anArea,const TPoint &aVector);
00242 
00246         IMPORT_C void Redraw(const TRect &aRect);       // called by CEikConsoleControl
00250         IMPORT_C void MoveTopLeft(TPoint aVector);      // called by CEikConsoleControl
00251 
00255         inline TUint HistorySize() const {return iNoChrExtra;}; // lines ACTUALLY stored                                
00260         IMPORT_C void SetHistorySizeL(TUint aMaxChrExtra,TUint aMaxAttExtra);  // lines of back-scroll history resp. lines of ATTRIBUTED backscroll history (aMaxAttExtra<=aMaxChrExtra)
00261                 
00265         inline TUint Att() const {return iAtt;};
00266         
00270         IMPORT_C void SetAtt(TUint aCharacterAttributes);               
00275         IMPORT_C void SetAtt(TUint aForegroundGray16,TUint aBackgroundGray16); 
00276 
00280         IMPORT_C void SetFontL(const TFontSpec &aFontDesc);     
00284         IMPORT_C const TFontSpec& Font() const;
00285 
00289         IMPORT_C void SetSelection(const TRect &aRange); 
00292         IMPORT_C void SelectCursor(); // empty selection starting and ending at cursor position
00296         IMPORT_C TRect Selection();
00301         IMPORT_C HBufC *RetrieveL(const TRect &aRange); // returns selection in newly allocated buffer
00302         
00306         IMPORT_C void SetPureCRLF(TUint aFlag);
00310         IMPORT_C void SetAllPrintable(TUint aFlag);
00314         IMPORT_C void SetScrollLock(TUint aFlag);
00318         IMPORT_C void SetKeepCursorInSight(TUint aFlag);
00323         IMPORT_C void SetScrollBarVisibilityL(CEikScrollBarFrame::TScrollBarVisibility aHBarVisibility, CEikScrollBarFrame::TScrollBarVisibility aVBarVisibility);
00327         IMPORT_C TBool UpdateScrollBars();
00328 
00329 private:
00330         // high-level history manipulation
00331         void MemScrPut(const TDesC &aString,TPoint aPos,TUint8 aCharacterAttributes);
00332         void MemScrClr(const TRect &aRect,TUint8 aCharacterAttributes);
00333         void MemScrScrollUp(TUint aLines=1);
00334         void MemScrMove(TPoint anOldPt,TPoint aNewPt,TUint aLen);
00335         void MemScrScroll(const TRect &aRect,TPoint aVector);
00336         // low-level history access
00337         TPtr    MemChrPtr(TPoint aPos,TUint aLen);
00338         TPtr8   MemAttPtr(TPoint aPos,TUint aLen);
00339         // console screen-to-visible window conversion
00340         TPoint  ScrToVis(TPoint aPoint);
00341         TRect   ScrToVis(const TRect &aRect);
00342         // recalculates iVisSize and iVisWin
00343         TBool RecalculateSize();        
00344         // calculate a TopLeft that would put aPosition in-sight
00345         TPoint GetAnInSightPosition(TPoint aPosition) const;
00346         // draw cursor or draw cursor in sight, depending on iKeepCursorInSight
00347         void DrawCursorWhereNeeded();
00348         // smart cursor-clipping: clips cursor to within screen, but allows it to be past the last character
00349         void ClipCursor();
00350         // redraw characters with doublewidth LEFT/RIGHT flag set depending on odd/even columns
00351         void RedrawChars(TInt anX,TInt anY,TInt aLength,TUint aCharacterAttributes);
00352         // routines needed for selection
00353         void InvertOverlap(TPoint aStart,TPoint aEnd,TPoint bStart,TPoint bEnd);
00354         void InvertRange(const TRect &aRect);
00355 
00356 private:
00357         CEikConsoleControl *iConsoleControl;// console window (handles redraw events)
00358         TSize iConsoleSize;             // size of console in characters (e.g. 80x24)   
00359         HBufC *iConsoleTitle;           // console title
00360         TRect iSelection;                       // current selection
00361         TPoint iCursor;                         // current cursor position
00362         TUint iAtt;                                     // current character attribute
00363 
00364         TInt iWriteNow;                         // if FALSE, Write()-calls can be buffered
00365         TBuf<256> iWriteBuffer;         // the Write() buffer
00366 
00367         TInt    iMaxChrExtra;           // max nr of extra lines of characters stored
00368         TInt    iNoChrExtra;            // actual nr of extra lines of characters stored
00369         TInt    iMaxAttExtra;           // max nr of extra lines of character attributes stored
00370         TText   *iChrBuf;                       // character history
00371         TUint8  *iAttBuf;                       // attribute history
00372 
00373         TPoint  iTopLeft;                       // coordinates of top left corner of visual display
00374         TRect iVisWin;                          // RECT visible window
00375         TSize iVisSize;                         // SIZE visible window
00376 
00377         // settings
00378         TUint iPureCRLF;                        // FALSE by default. If TRUE, CR and LF are "pure"
00379         TUint iAllPrintable;            // FALSE by default. If TRUE, even chars 0-31 are printed
00380         TUint iScrollLock;                      // FALSE by default. If TRUE, will not scroll at bottom line
00381         TUint iKeepCursorInSight;       // TRUE by default. If FALSE, cursor may be offscreen after a Write()
00382         TUint iCursorBlinking;          // TRUE if cursor should be visible (i.e. user WANTS it to be visible)
00383 
00384         TInt iConsFlags;
00385         };
00386 
00387 class CEikConsoleControl : public CAknControl, public MEikScrollBarObserver
00388         {
00389 public: 
00390         // constructors, destructors, initialization
00393         IMPORT_C CEikConsoleControl();
00396         IMPORT_C ~CEikConsoleControl();
00397     /* ConstructL()
00398      */
00399         IMPORT_C void   ConstructL(TInt aFlags);
00400     /* ConstructL()
00401      */
00402         IMPORT_C void   ConstructL(TPoint aTopLeft,const TSize &aSize,TInt aFlags,TEikConsWinUnits aUnit);
00406         IMPORT_C void   SetRedrawer(CEikConsoleScreen *aConsole);
00407 
00408         // font stuff
00413         IMPORT_C void   SetFontL(const TFontSpec &aFontSpec,const CFbsFont* aFont);             // change to font aFontSpec
00416         inline const TFontSpec& Font() const {return iFontSpec;};       // returns current fontspec
00417 
00420         inline const TSize& CharSize() const {return iCharSize;};       
00424         IMPORT_C TSize  VisibleSize() const;                                            // returns maximal visible nr of visible characters
00425 
00426         // cursor stuff
00430         IMPORT_C void   SetCursorHeight(TUint aPercentage);     // set cursor height (0-100%)
00434         IMPORT_C void   DrawCursor(TPoint aPosition);           // draw cursor at character position
00437         IMPORT_C void   HideCursor();                                           // hide cursor
00438 
00439         // basic graphic functions
00445         IMPORT_C void   DrawChars(const TDesC &aString,const TPoint &aPosition,TUint aCharacterAttributes);     // draw aString at character position aPosition using
00450         IMPORT_C void   ClearChars(const TRect &anArea,TUint aCharacterAttributes);     // clear the character area
00454         IMPORT_C void   InvertChars(const TRect &anArea);       // invert the character area
00459         IMPORT_C void   ScrollChars(const TRect &anArea,const TPoint &aVector); // scroll characters inside anArea by the given vector
00460 
00461         // scrollbar stuff
00466         IMPORT_C TInt   SetScrollBarVisibilityL(CEikScrollBarFrame::TScrollBarVisibility aHBarVisibility, CEikScrollBarFrame::TScrollBarVisibility aVBarVisibility);
00473         IMPORT_C TBool  UpdateScrollbarsL(const TSize &aDataSize,const TSize& aVisibleSize,TPoint aPos);
00478         IMPORT_C void   HandleScrollEventL(CEikScrollBar* aScrollBar,TEikScrollEvent aEventType);
00481         IMPORT_C void   UpdateArea();
00482 
00483 public: // from CCoeControl
00486         IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; // not available before Release 005u
00489         IMPORT_C virtual void HandleResourceChange(TInt aType);                 // not available before Release 005u
00492     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
00493 
00494 protected:      // virtual
00495         // window stuff
00498         IMPORT_C void   Draw(const TRect& aRect) const; 
00501         IMPORT_C void   SizeChanged();
00504         IMPORT_C void FocusChanged(TDrawNow aDrawNow);
00507         IMPORT_C virtual TInt CountComponentControls() const;
00510         IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
00513         IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
00514 
00515 private:  // virtual - Reserved from CCoeControl
00516         IMPORT_C virtual void Reserved_2();
00517 
00518 private:
00522     IMPORT_C void* ExtensionInterface( TUid aInterface );
00523 
00524 private:
00525         TPoint  CharsToPixels(TPoint aPoint);
00526         TRect   CharsToPixels(const TRect &aRect);
00527         TRect   PixelsToChars(const TRect &aRect);
00528         void    ClearPixels(const TRect &anArea,TRgb aColor) const;
00529 
00530         void    NextFontL();                    
00531         void    InterpretAttribute(TUint AnAtt);
00532         void    InterpretColorBits(TUint aCharacterAttributes);
00533         inline  CEikConsoleControl &M() const {return((CEikConsoleControl&)(*this));}
00534         void CreateScrollBarFrameLayout(TEikScrollBarFrameLayout& aLayout) const;
00535         void    InitFontSpecL();
00536 
00537 private:
00538         CEikConsoleScreen *iConsole;    // the console that owns this window
00539         TRgb iBackGray16;                               // current background color 
00540         TRgb iPenGray16;                                // current pen color for characters
00541         TUint iLastAtt;                                 // last attribute, to see if we need to change the gc
00542         TUint iLastFontFlags;                   // last attribute, to see if we need to load another font
00543 
00544         TSize iCharSize;                                // size of a single character (in pixels)
00545         TSize iViewInPixels;                    // size of area available for characters (in pixels)
00546         TSize iViewInChars;                             // size of area available for characters (in characters)
00547 
00548         TTextCursor iTextCursor;                // cursor to use
00549         TUint iCursorHeightPercentage;  // required height of cursor (as a percentage)
00550 
00551         TInt iRedrawing;                                // NONZERO IF BUSY REDRAWING
00552         
00553         CEikScrollBarFrame* iSBFrame;
00554         CEikScrollBarFrame::TScrollBarVisibility        iHBarVisibility;
00555         CEikScrollBarFrame::TScrollBarVisibility        iVBarVisibility;
00556         TPoint  iLastThumbPos;
00557 
00558         const CFont *iCurrentFont;              // Current font
00559         TFontSpec iFontSpec;                    // Current font spec
00560         TFontUnderline iFontUnderline;  // Current font spec underline
00561         TUint iFontHeight;                              // Height of current font when not doubleheight/doublewidth
00562         TUint iFontIsProportional;              // nonzero if font is proportional
00563         };
00564 
00565 
00566 
00567 #endif

Copyright © Nokia Corporation 2001-2008
Back to top