home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-24 | 3.7 KB | 175 lines | [TEXT/CWIE] |
- // CLG_CharInfo.cp
- //
- // Pane subClass to display character information
- //
- //****************************************************************************
-
- #ifdef PowerPlant_PCH
- #include PowerPlant_PCH
- #endif
-
- // system headers
- #include <Script.h>
-
- // PowerPlant headers
- #include <LStream.h>
- #include <UDrawingState.h>
-
- // project headers
- #include "LG_Constants.h"
- #include "CLG_CharInfo.h"
-
-
- //****************************************************************************
- #define kVOffset 12
-
-
- //***********************
- // CreateDisplayStream
- //****************************************************************************
- CLG_CharInfo*
- CLG_CharInfo::CreateDisplayStream(
- LStream *inStream)
- {
- return (new CLG_CharInfo(inStream));
- }
-
-
- //***********************
- // CLG_CharInfo
- //****************************************************************************
- CLG_CharInfo::CLG_CharInfo(void)
- {
- this->Init();
- return;
- }
-
- //***********************
- // CLG_CharInfo
- //****************************************************************************
- CLG_CharInfo::CLG_CharInfo( LStream *inStream)
- : LPane( inStream)
- {
- this->Init();
- return;
- }
-
- //***********************
- // Init
- //****************************************************************************
- void CLG_CharInfo::Init(void)
- {
- mCharNum = 0;
- mBaseCharStr[0] = 1;
- mBaseCharStr[1] = '0';
- mHexStr[0]=0;
- mDecStr[0]=0;
-
- return;
- }
-
-
- //***********************
- // ClickSelf
- //****************************************************************************
- void
- CLG_CharInfo::ClickSelf( const SMouseDownEvent &inMouseDown)
- {
- InvalRect( &qd.thePort->portRect);
- return;
- }
-
-
-
- //***********************
- // AdjustCursorSelf
- //****************************************************************************
- void
- CLG_CharInfo::AdjustCursorSelf(
- Point inPortPt ,
- const EventRecord& inMacEvent)
- {
- Point tPt;
- static Rect savR = {0,0,0,0};
-
- tPt = inPortPt;
-
- CursHandle theCursH = ::GetCursor( 2);
- if (theCursH != nil) {
- ::SetCursor(*theCursH);
- }
- }
-
-
- //***********************
- // SetCharNum
- //****************************************************************************
- const char hexNum[] =
- { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
-
- void CLG_CharInfo::SetCharNum( unsigned short inCharNum)
- {
- mCharNum = inCharNum;
-
- mHexStr[0]=4;
-
- mHexStr[1] = hexNum[ (inCharNum&0xF000) >> 12];
- mHexStr[2] = hexNum[ (inCharNum&0xF00) >> 8];
- mHexStr[3] = hexNum[ (inCharNum&0xF0) >> 4];
- mHexStr[4] = hexNum[ inCharNum&0x0F];
-
- NumToString( inCharNum, mDecStr);
-
- Refresh();
- }
-
- //***********************
- // SetCurBaseChar
- //****************************************************************************
- void CLG_CharInfo::SetBaseCharDisp( unsigned short inCharNum)
- {
- NumToString( inCharNum, mBaseCharStr);
-
- Refresh();
- }
-
- //***********************
- // DrawSelf
- //****************************************************************************
- // Why do I have to offset these locations?
-
- void CLG_CharInfo::DrawSelf(void)
- {
- SDimension16 tFrame;
-
- GetFrameSize( tFrame);
-
- PenNormal();
- MoveTo( mFrameLocation.h+ 0, mFrameLocation.v+1 );
- Line( tFrame.width, 0);
- MoveTo( mFrameLocation.h+0, mFrameLocation.v+tFrame.height-1 );
- Line( tFrame.width, 0);
-
- TextFont( monaco); TextSize(9);
- TextFace(0); TextMode( srcOr);
-
- MoveTo( mFrameLocation.h+2, mFrameLocation.v+12);
- DrawString( "\pBase Char: ");
- DrawString( "\p#");
- DrawString( mBaseCharStr);
-
- MoveTo( mFrameLocation.h+2, mFrameLocation.v+22);
- DrawString( "\pHex: ");
- DrawString( "\p0x");
- DrawString( mHexStr);
-
- MoveTo( mFrameLocation.h+2, mFrameLocation.v+32);
- DrawString( "\pDecimal: ");
- DrawString( "\p #");
- DrawString( mDecStr);
-
- return;
- }
-
- //*****************************************************************************
-