You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.8 KiB
57 lines
1.8 KiB
#include "logWidget.h"
|
|
|
|
sdlLog::sdlLog(int x, int y, int width, int height, sdlCoreWidget * pWnd) :sdlCoreWidget(x, y, width, height, true, pWnd){
|
|
m_nLines = 1 + height / SDL_DEFAULT_LOG_ROW_SIZE;
|
|
m_nCurrentLine = 0;
|
|
m_ppLines = (sdlLabel**)calloc( m_nLines, sizeof(sdlLabel*) );
|
|
if(m_ppLines != NULL) memset( m_ppLines, 0, m_nLines * sizeof(sdlLabel*) );
|
|
sdlGraphicElement::setType(GEL_PANEL);
|
|
m_pGUI->registerGEL(this);
|
|
};
|
|
|
|
sdlLog::~sdlLog(){
|
|
m_pGUI->removeGEL(this);
|
|
if (m_ppLines != NULL){
|
|
for (int index = 0; index < m_nLines; index++) delete(m_ppLines[index]);
|
|
free(m_ppLines);
|
|
};
|
|
};
|
|
|
|
void sdlLog::logMessage(const char *Msg){
|
|
if (m_ppLines != NULL){
|
|
if (m_nCurrentLine < m_nLines){
|
|
m_ppLines[m_nCurrentLine] = new sdlLabel(
|
|
NULL,
|
|
1,
|
|
1 + (m_nCurrentLine*SDL_DEFAULT_LOG_ROW_SIZE),
|
|
m_sGeometry.w - 2,
|
|
SDL_DEFAULT_LOG_ROW_SIZE,
|
|
this,
|
|
SDL_DEFAULT_LOG_FONT_SIZE
|
|
);
|
|
if( m_ppLines[m_nCurrentLine] != NULL ){
|
|
m_ppLines[m_nCurrentLine]->setAlign(ALIGN_LEFT);
|
|
m_ppLines[m_nCurrentLine]->setBgColor(0x34, 0x83, 0xae, 10);
|
|
m_ppLines[m_nCurrentLine]->setColor(255, 255, 255);
|
|
m_nCurrentLine++;
|
|
};
|
|
for (int index = m_nCurrentLine - 1; index > 0; index--){
|
|
char tBuf[SDL_DEFAULT_TEXT_SIZE];
|
|
memcpy(tBuf, m_ppLines[index - 1]->getText(), SDL_DEFAULT_TEXT_SIZE);
|
|
m_ppLines[index]->setText(tBuf);
|
|
};
|
|
m_ppLines[0]->setText((CSTR)Msg);
|
|
} else {
|
|
for (int index = m_nLines - 1; index > 0; index-- ){
|
|
char tBuf[SDL_DEFAULT_TEXT_SIZE];
|
|
memcpy(tBuf, m_ppLines[index-1]->getText(), SDL_DEFAULT_TEXT_SIZE);
|
|
m_ppLines[index]->setText(tBuf);
|
|
};
|
|
m_ppLines[0]->setText((CSTR)Msg);
|
|
};
|
|
};
|
|
};
|
|
|
|
void sdlLog::logMessage(CSTR Msg){
|
|
logMessage((const char*)Msg);
|
|
};
|