Index: libwps/src/api.h =================================================================== --- libwps/src/api.h (revision 18656) +++ libwps/src/api.h (working copy) @@ -64,9 +64,11 @@ void (*stop_scroll)(); void (*transparent_bitmap_part)(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height); + int stride, int x, int y, int width, int height); void (*bitmap_part)(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height); + int stride, int x, int y, int width, int height); + void (*mono_bitmap_part)(const unsigned char *src, int src_x, int src_y, + int stride, int x, int y, int width, int height); void (*hline)(int x1, int x2, int y); void (*vline)(int x, int y1, int y2); void (*drawpixel)(int x, int y); @@ -86,8 +88,10 @@ void (*set_next_trackstate)(struct trackstate state); void (*set_audio_status)(int status); + bool (*load_font)(const char *path); + pfdebugf debugf; - int verbose; + int verbose; /************************** Index: libwps/src/proxy.c =================================================================== --- libwps/src/proxy.c (revision 18656) +++ libwps/src/proxy.c (working copy) @@ -112,7 +112,7 @@ return 0; } -int wps_init(const char* filename,struct proxy_api *api, bool isfile){ +int wps_init(const char* filename, struct proxy_api *api, bool isfile){ int res; if (!api) return 4; Index: libwps/src/lcd.c =================================================================== --- libwps/src/lcd.c (revision 18656) +++ libwps/src/lcd.c (working copy) @@ -177,3 +177,36 @@ void lcd_scroll_stop(struct viewport* vp){ DEBUGF3("lcd_scroll_stop(struct viewport* vp=%x)\n",vp); } + +static void lcd_putsxyofs(int x, int y, int ofs, const unsigned char *str) +{ + unsigned short ch; + struct font* pf = font_get(current_vp->font); + + while ((ch = *str++) != 0 && x < current_vp->width) + { + int width; + const unsigned char *bits; + + /* get proportional width and glyph bits */ + width = font_get_width(pf,ch); + + if (ofs > width) + { + ofs -= width; + continue; + } + + bits = font_get_bits(pf, ch); + + xapi->mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height); + + x += width - ofs; + ofs = 0; + } +} + +void lcd_putsxy(int x, int y, const unsigned char *str) +{ + lcd_putsxyofs(x, y, 0, str); +} Index: libwps/src/dummies.c =================================================================== --- libwps/src/dummies.c (revision 18656) +++ libwps/src/dummies.c (working copy) @@ -329,11 +329,18 @@ void debugf(const char *fmt, ...) {} -void panicf( const char *fmt, ...) +void panicf(const char *fmt, ...) { } -off_t filesize(int fd){return 0;} +off_t filesize(int fd) +{ + off_t fsize, oldpos; + oldpos = lseek(fd, 0, SEEK_CUR); + fsize = lseek(fd, 0, SEEK_END); + lseek(fd, oldpos, SEEK_SET); + return fsize; +} int playlist_amount(void) { Index: libwps/src/api.c =================================================================== --- libwps/src/api.c (revision 18656) +++ libwps/src/api.c (working copy) @@ -44,6 +44,22 @@ } #endif +bool load_font(const char* filename) +{ + if (filename != NULL) + { + if(font_load(filename) == NULL) + return false; + else + return true; + } + else + { + font_reset(); + return true; + } +} + bool load_wps_backdrop(char* filename) { return xapi->load_wps_backdrop(filename); } @@ -213,7 +229,8 @@ **************************************************************/ -int set_api(struct proxy_api* api) { +int set_api(struct proxy_api* api) +{ if (api->debugf) dbgf = api->debugf; screens[0].screen_type=SCREEN_MAIN; @@ -246,6 +263,8 @@ screens[0].puts_scroll=api->puts_scroll; if (api->transparent_bitmap_part) screens[0].transparent_bitmap_part=api->transparent_bitmap_part; + if (api->mono_bitmap_part) + screens[0].mono_bitmap_part=api->mono_bitmap_part; if (api->update) screens[0].update=api->update; if (api->clear_display) @@ -258,8 +277,9 @@ screens[0].vline=api->vline; if (api->drawpixel) screens[0].drawpixel=api->drawpixel; - if (api->putsxy) - screens[0].putsxy=api->putsxy; + /*if (api->putsxy) + screens[0].putsxy=api->putsxy;*/ + screens[0].putsxy=lcd_putsxy; #if LCD_DEPTH > 1 if (api->get_foreground) screens[0].get_foreground=api->get_foreground; @@ -275,8 +295,9 @@ api->get_current_vp = get_current_vp; api->set_wpsstate = set_wpsstate; api->set_trackstate = set_trackstate; - api->set_next_trackstate= set_next_trackstate; - api->set_audio_status= set_audio_status; + api->set_next_trackstate = set_next_trackstate; + api->set_audio_status = set_audio_status; + api->load_font = load_font; xapi = api; return 0; } Index: libwps/Makefile =================================================================== --- libwps/Makefile (revision 18656) +++ libwps/Makefile (working copy) @@ -86,7 +86,7 @@ -I $(ROOT)/apps \ -I src -CFLAGS = -g -Wall -Wno-format -D__PCTOOL__ -DWPSEDITOR -DDEBUG -DROCKBOX_DIR_LEN=1 -DBUTTON_REMOTE +CFLAGS = -g -Wall -Wno-format -Wno-pointer-sign -D__PCTOOL__ -DWPSEDITOR -DDEBUG -DROCKBOX_DIR_LEN=1 -DBUTTON_REMOTE RESULTS := $(patsubst %,libwps_%$(EXT),$(TARGETS)) Index: gui/src/qwpsdrawer.cpp =================================================================== --- gui/src/qwpsdrawer.cpp (revision 18656) +++ gui/src/qwpsdrawer.cpp (working copy) @@ -59,6 +59,7 @@ api.verbose = v; api.putsxy = &QWpsDrawer::putsxy; api.transparent_bitmap_part = &QWpsDrawer::transparent_bitmap_part; + api.mono_bitmap_part = &QWpsDrawer::mono_bitmap_part; api.bitmap_part = &QWpsDrawer::bitmap_part; api.drawpixel = &QWpsDrawer::drawpixel; api.fillrect = &QWpsDrawer::fillrect; @@ -128,6 +129,10 @@ setMinimumWidth(api.getwidth()); setMinimumHeight(api.getheight()); + + DEBUGF3("Loading font... %x", api.load_font("/home/toor/rockbox/utils/wpseditor/gui/bin/font.fnt")); + + update(); } Index: gui/src/qwpsdrawer.h =================================================================== --- gui/src/qwpsdrawer.h (revision 18656) +++ gui/src/qwpsdrawer.h (working copy) @@ -99,6 +99,8 @@ int stride, int x, int y, int width, int height); static void bitmap_part(const void *src, int src_x, int src_y, int stride, int x, int y, int width, int height); + static void mono_bitmap_part(const unsigned char *src, int src_x, int src_y, + int stride, int x, int y, int width, int height); static void drawpixel(int x, int y); static void fillrect(int x, int y, int width, int height); static void hline(int x1, int x2, int y); Index: gui/src/qwpsdrawer_static.cpp =================================================================== --- gui/src/qwpsdrawer_static.cpp (revision 18656) +++ gui/src/qwpsdrawer_static.cpp (working copy) @@ -36,6 +36,7 @@ p.setFont(font); p.drawText(x+avp.x,y + avp.fontheight + avp.y,(char*)str); } + void QWpsDrawer::transparent_bitmap_part(const void *src, int src_x, int src_y, int stride, int x, int y, int width, int height) { QImage img; @@ -50,30 +51,68 @@ p.drawImage(target, img, source); } + void QWpsDrawer::bitmap_part(const void *src, int src_x, int src_y, - int stride, int x, int y, int width, int height) { - transparent_bitmap_part(src,src_x,src_y,stride,x,y,width,height); + int stride, int x, int y, int width, int height) +{ + QImage img; + img.load((char*)src); + DEBUGF2("bitmap_part(const void *src=%s, int src_x=%d, int src_y=%d, int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d",(char*)src,src_x, src_y, stride, x, y, width, height); + QPainter p(pix); + QPoint target(x, y); + QRectF source(src_x, src_y, width, height); + + p.drawImage(target, img, source); } + +void QWpsDrawer::mono_bitmap_part(const unsigned char *src, int src_x, int src_y, + int stride, int x, int y, int width, int height) +{ + /* move starting point */ + src += stride * (src_y >> 3) + src_x; + + QImage img(src, width, height, QImage::Format_MonoLSB); + + img = img.convertToFormat(QImage::Format_RGB16); + + + DEBUGF2("mono_bitmap_part(const void *src=%x, int src_x=%d, int src_y=%d, int stride=%d, int x=%d, int y=%d, int width=%d, int height=%d", src, src_x, src_y, stride, x, y, width, height); + QPainter p(pix); + QPoint target(x, y); + QRectF source(src_x, src_y, width, height); + + img.invertPixels(); + + QImage white = img.createMaskFromColor(qRgb(255,255,255),Qt::MaskOutColor); + img.setAlphaChannel(white); + + p.drawImage(target, img, source); +} + void QWpsDrawer::drawpixel(int x, int y) { QPainter p(pix); p.setPen(Qt::blue); p.drawPoint(x,y); } + void QWpsDrawer::fillrect(int x, int y, int width, int height) { QPainter p(pix); DEBUGF2("fillrect(int x=%d, int y=%d, int width=%d, int height=%d)\n",x, y, width, height); p.setPen(Qt::green); } + void QWpsDrawer::hline(int x1, int x2, int y) { QPainter p(pix); p.setPen(Qt::black); p.drawLine(x1,y,x2,y); } + void QWpsDrawer::vline(int x, int y1, int y2) { QPainter p(pix); p.setPen(Qt::black); p.drawLine(x,y1,x,y2); } + bool QWpsDrawer::load_wps_backdrop(char* filename) { DEBUGF3("load backdrop: %s", filename); QFile file(filename);