Fork of LCD-Window which works with Enhanced TextLCD from Wim
Fork of LcdWindow by
Diff: subwindow.cpp
- Revision:
- 2:5ac5bab7daaf
- Parent:
- 1:65f72ed914fa
- Child:
- 3:e5d5e2fe4bf6
--- a/subwindow.cpp Tue Nov 16 20:49:18 2010 +0000
+++ b/subwindow.cpp Sat Nov 27 22:54:13 2010 +0000
@@ -25,38 +25,46 @@
#include "string.h"
-SubWindow::SubWindow(Window* lcd, const unsigned int offsetX, const unsigned int offsetY, const unsigned int width, const unsigned int height) {
+SubWindow::SubWindow(Window* lcd, const unsigned int columnOffset, const unsigned int rowOffset, const unsigned int columns, const unsigned int rows) {
_lcd=lcd;
- _offsetX=offsetX;
- _offsetY=offsetY;
- _width=width;
- _height=height;
+ _columnOffset=columnOffset;
+ _rowOffset=rowOffset;
+ _columns=columns;
+ _rows=rows;
}
-void SubWindow::writeText(const unsigned int line, const unsigned int pos, const char* text) {
- if (line>_height)
+void SubWindow::character(int column, int row, int c)
+{
+ if (column>_columns || row>_rows)
return;
- char* text2=new char[_width-pos+1];
+ _lcd->character(column+_columnOffset, row+_rowOffset, c);
+}
+
+void SubWindow::writeText(const unsigned int column, const unsigned int row, const char* text) {
+ if (row>_rows)
+ return;
+
+ char* text2=new char[_columns-column+1];
int i=0;
- while (i<_width-pos+1) {
+ while (i<_columns-column+1) {
text2[i]=text[i];
if (text[i]=='\0')
break;
i++;
}
- text2[_width-pos]='\0';
+ text2[_columns-column]='\0';
- _lcd->writeText(line+_offsetY, pos+_offsetX, text2);
+ _lcd->writeText(column+_columnOffset, row+_rowOffset, text2);
delete [] text2;
}
void SubWindow::clear() {
- char* spaces=new char[_width+1];
- memset(spaces,32,_width);
- spaces[_width]=0;
- for (int i=0;i<_height;i++) {
- _lcd->writeText(i+_offsetY,_offsetX,spaces);
+ char* spaces=new char[_columns+1];
+ memset(spaces,32,_columns);
+ spaces[_columns]=0;
+ for (int i=0;i<_rows;i++) {
+ _lcd->writeText(_columnOffset,_rowOffset+i,spaces);
}
}
\ No newline at end of file
