📄 oggcontrols.h
字号:
/*
* Copyright (c) 2003 L. H. Wilden.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef OggControls_h
#define OggControls_h
#include <OggOs.h>
#include <e32base.h>
#include <coecntrl.h>
#include <eikclbd.h>
#include <gulicon.h>
#include <badesca.h>
#include <flogger.h>
#include <f32file.h>
// MOggControlObserver:
// Observe mouse pointer down/drag/up events for COggControls
class COggControl;
class COggCanvas;
class MOggControlObserver {
public:
virtual void OggPointerEvent(COggControl* /*c*/, const TPointerEvent& /*p*/) {}
virtual void OggControlEvent(COggControl* /*c*/, TInt /*aEventType*/, TInt /*aValue*/) {}
virtual void AddControlToFocusList(COggControl* /*c*/) {}
};
enum TAnalyzerModes {
EZero,
EOne,
EPeak,
EDecay /** Peak hold, constant decay for S60 DCT analyzer (masks dropouts) */
};
const TInt KDCTAnalyzerDynamic = 50;
const TInt KDecaySteplength = 3;
_LIT(KBeginToken,"{");
_LIT(KEndToken,"}");
// TOggParser:
// Read the skin defintion file
// ----------------------------
class TOggParser {
public:
enum TState {
ESuccess, EFileNotFound, ENoOggSkin,
EUnknownVersion, EFlipOpenExpected,
ESyntaxError, EBeginExpected,
EEndExpected, EBitmapNotFound, EIntegerExpected,
EOutOfRange};
TOggParser(RFs& aFs, const TFileName& aFileName, TInt aScaleFactor = 1);
~TOggParser();
TBool ReadSkin(COggCanvas* fo, COggCanvas* fc);
void ReportError();
void Debug(const TDesC& txt, TInt level=0);
TBool ReadHeader();
TBool ReadToken();
TBool ReadToken(TInt& aValue);
CGulIcon* ReadIcon(const TFileName& aBitmapFile);
TBool ReadColor(TRgb& aColor);
CFont* ReadFont();
// protected:
TBool iDebug;
TState iState;
TInt iLine;
TBuf<128> iToken;
TInt iVersion;
TInt iScaleFactor;
HBufC8* iBuffer;
const TUint8* iBufferPtr;
};
// COggControl:
// Abstract base type for objects displayed on a COggCanvas
// --------------------------------------------------------
class COggControl : public CBase {
public:
COggControl();
COggControl(TBool aHighFrequency);
virtual ~COggControl();
virtual void SetPosition(TInt ax, TInt ay, TInt aw, TInt ah);
void SetObserver(MOggControlObserver* obs);
virtual void MakeVisible(TBool isVisible);
TBool IsVisible();
void SetDimmed(TBool aDimmed);
TBool IsDimmed();
void SetFocus(TBool aFocus);
TBool Focus();
virtual void PointerEvent(const TPointerEvent& p);
virtual void ControlEvent(TInt anEventType, TInt aValue);
virtual void Redraw(TBool doRedraw = ETrue);
virtual void SetFocusIcon(CGulIcon* anIcon);
TRect Rect();
TSize Size();
TInt ix;
TInt iy;
TInt iw;
TInt ih;
CGulIcon* iFocusIcon;
TDblQueLink iDlink;
virtual void SetBitmapFile(const TFileName& aBitmapFile);
virtual TBool Read(TOggParser& p);
TBool HighFrequency();
protected:
// these can/must be overriden to create specific behaviour:
virtual void Cycle() {}
virtual void Draw(CBitmapContext& aBitmapContext) = 0;
virtual void DrawFocus(CBitmapContext& aBitmapContext);
void DrawCenteredIcon(CBitmapContext& aBitmapContext, CGulIcon* anIcon);
// utility functions:
virtual TBool ReadArguments(TOggParser& p);
TBool iRedraw; // if true: something has changed with the control and the control needs to be redrawn
TInt iCycle; // frame nmber of an animation etc. (1 cycle = 10ms)
TBool iVisible; // if false the control will not be drawn
TBool iDimmed; // if false the control is disabled and rejects pointer and keyboard focus events
TBool iAcceptsFocus; // if true the control can accept keyboard focus, else it's never focussed.
TBool iFocus; // if true, control has focus.
MOggControlObserver* iObserver;
TFileName iBitmapFile;
TBool iHighFrequency;
friend class COggCanvas;
};
// COggText:
// A line of scrollable text
//--------------------------
class COggText : public COggControl {
public:
COggText();
virtual ~COggText();
void SetText(const TDesC& aText);
void SetFont(CFont* aFont, TBool ownedByControl = EFalse);
void SetFontColor(TRgb aColor);
void ScrollNow(); // restart the text scrolling
enum ScrollStyle {
EOnce=0,
EEndless,
ETilBorder,
EBackAndForth,
ERoundabout // not implemented
};
void SetScrollStyle(TInt aStyle);
void SetScrollDelay(TInt aDelay);
void SetScrollStep(TInt aStep);
protected:
virtual void Cycle();
virtual void Draw(CBitmapContext& aBitmapContext);
virtual void PointerEvent(const TPointerEvent& p);
virtual TBool ReadArguments(TOggParser& p);
HBufC* iText;
CFont* iFont;
TBool iOwnedByControl;
TRgb iFontColor;
TInt iFontHeight;
TInt iFontAscent;
TInt iLinePadding;
TInt iTextWidth;
TBool iNeedsScrolling;
TBool iHasScrolled;
TInt iScrollDelay;
TInt iScrollStep;
TInt iScrollStyle;
TInt iDrawOffset;
TInt iScrollBackward;
private:
// scroll to the left off the textarea and repeat
void CycleOff();
// ... don't repeat
void CycleOnce();
// only scroll until the right text border touches the textarea and repeat
void CycleBorder();
// ... and repeat by scrolling to the right
void CycleBackAndForth();
};
// COggIcon:
// An icon (bitmap+mask) that can blink.
// Ownership of the CGulIcon is taken!
//--------------------------------------
class COggIcon : public COggControl {
public:
COggIcon();
virtual ~COggIcon();
void SetIcon(CGulIcon* anIcon);
void Blink();
void Show();
void Hide();
void SetBlinkFrequency(TInt aFrequency);
protected:
virtual TBool ReadArguments(TOggParser& p);
virtual void Cycle();
virtual void Draw(CBitmapContext& aBitmapContext);
CGulIcon* iIcon;
TBool iBlinkFrequency;
TBool iBlinking;
};
// COggAnimation
// Display a sequence of bitmaps.
//-------------------------------
class COggAnimation : public COggControl {
public:
COggAnimation();
virtual ~COggAnimation();
void SetBitmaps(TInt aFirstBitmap, TInt aNumBitmaps);
void ClearBitmaps();
void Start();
void Stop();
void SetPause(TInt aPause);
void SetFrequency(TInt aFrequency);
void SetStyle(TInt aStyle);
protected:
virtual TBool ReadArguments(TOggParser& p);
virtual void Cycle();
virtual void Draw(CBitmapContext& aBitmapContext);
//CFbsBitmap* iBitmaps;
CArrayPtrFlat<CFbsBitmap> iBitmaps;
TBool iPause;
TInt iFrequency;
TInt iFirstBitmap;
//TInt iNumBitmaps;
TInt iStyle;
};
// COggDigits
// Display numbers with custom bitmaps.
//-------------------------------------
class COggDigits : public COggControl {
public:
enum Digits { EDigit0=0, EDigit1, EDigit2, EDitit3, EDigit4,
EDigit5, EDigit6, EDigit7, EDigit8, EDigit9,
EDigitColon, EDigitDash, EDigitSlash, EDigitDot,
ENumDigits };
COggDigits();
virtual ~COggDigits();
void SetText(const TDesC& aText);
void SetBitmaps(TInt aFirstBitmap);
void SetMasks(TInt aFirstMask);
void ClearBitmaps();
void ClearMasks();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -