This is a little routine i wrote for debugging. It will scroll the screen
when it gets to the bottom and you can set the lineCount if you dont want to
use the whole screen.
You just need to call something like
CDebug::Instance()->Write("My debug message");
//--------- .h file --------------------
//Mike Margerum 11/22/2002 a simple scrolling status window
class CDebug
{
public:
CDebug();
void Write(char* msg);
void SetLineCount(Int16 lineCount, Int16 yOffset=-1);
static CDebug* Instance();
private:
Int16 fLine; //Current Line Number
Int16 fLineCount;
RectangleType fRect;
void Scroll();
};
//--------------- CPP------------------
#include <PalmOs.h>
#include "Debug.h"
#define kLineHeight 12
CDebug* CDebug::Instance()
{
static CDebug status;
return &status;
}
CDebug::CDebug()
{
SetLineCount(10);
}
void CDebug::SetLineCount(Int16 lineCount, Int16 yOffset)
{
fLineCount=lineCount;
fLine=0;
if (yOffset==-1)
yOffset=16;
//Make sure length divisble by kLineHeight
fRect.topLeft.x=3;
fRect.topLeft.y=yOffset;
fRect.extent.x=155;
int y = kLineHeight * lineCount;
fRect.extent.y=y;
}
void CDebug::Write(char* msg)
{
char blanks[]=" ";
Coord x=3;
Coord y=fRect.topLeft.y+fLine * kLineHeight;
RectangleType rect;
static Boolean first=true;
if (fLine==fLineCount-1)
{
if (!first)
Scroll();
else
first = false;
}
rect.topLeft.x = fRect.topLeft.x;
rect.topLeft.y = y;
rect.extent.x = fRect.extent.x;
rect.extent.y = kLineHeight;
WinEraseRectangle(&rect,0);
WinDrawChars(msg, StrLen(msg), x,y);
if (fLine<fLineCount-1)
fLine++;
}
void CDebug::Scroll()
{
RectangleType dRect;
WinScrollRectangle(&fRect, winUp, kLineHeight, &dRect);
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/