5,7 → 5,6 |
#include "muxps.h" |
#include "pdfapp.h" |
#include "icons/allbtns.h" |
#include "kolibri.c" |
|
// need to be a part of menuet/os.h |
#define BT_DEL 0x80000000 |
78,6 → 77,7 |
/*==== DATA ====*/ |
|
static char Title[1024] = "uPDF"; |
static char * filename = "/hd0/1/yand.pdf"; |
static pdfapp_t gapp; |
char debugstr[256]; |
char do_not_blit=0; |
184,7 → 184,7 |
if (Form.client_width > gapp.image->w) window_center = (Form.client_width - gapp.image->w) / 2; else window_center = 0; |
|
gapp.panx = 0; |
if (gapp.image->n == 4) { |
if (gapp.image->n == 4) |
blit(window_center + Form.client_left, |
Form.client_top + TOOLBAR_HEIGHT, |
Form.client_width, |
196,7 → 196,6 |
gapp.image->w * gapp.image->n, |
gapp.image->samples |
); |
} |
else if (gapp.image->n == 2) |
{ |
int i = gapp.image->w*gapp.image->h; |
234,10 → 233,10 |
if (gapp.image->h < Form.client_height - TOOLBAR_HEIGHT) draw_h = gapp.image->h - gapp.pany; else draw_h = Form.client_height - TOOLBAR_HEIGHT; |
if (gapp.image->w < Form.client_width) |
{ |
kol_paint_bar(0, TOOLBAR_HEIGHT, window_center-1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BG); |
kol_paint_bar(window_center-1, TOOLBAR_HEIGHT, 1, draw_h, DOCUMENT_BORDER); |
kol_paint_bar(window_center + gapp.image->w, TOOLBAR_HEIGHT, 1, draw_h, DOCUMENT_BORDER); |
kol_paint_bar(window_center + gapp.image->w+1, TOOLBAR_HEIGHT, Form.client_width - window_center - gapp.image->w - 1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BG); |
__menuet__bar(0, TOOLBAR_HEIGHT, window_center-1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BG); |
__menuet__bar(window_center-1, TOOLBAR_HEIGHT, 1, draw_h, DOCUMENT_BORDER); |
__menuet__bar(window_center + gapp.image->w, TOOLBAR_HEIGHT, 1, draw_h, DOCUMENT_BORDER); |
__menuet__bar(window_center + gapp.image->w+1, TOOLBAR_HEIGHT, Form.client_width - window_center - gapp.image->w - 1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BG); |
} |
if (gapp.image->w < Form.client_width) |
{ |
248,8 → 247,8 |
window_center = 1; |
draw_w = Form.client_width; |
} |
kol_paint_bar(window_center - 1, gapp.image->h - gapp.pany + TOOLBAR_HEIGHT, draw_w, 1, DOCUMENT_BORDER); |
kol_paint_bar(window_center - 1, gapp.image->h - gapp.pany + TOOLBAR_HEIGHT + 1, draw_w, Form.client_height - gapp.image->h - TOOLBAR_HEIGHT + gapp.pany - 1, DOCUMENT_BG); |
__menuet__bar(window_center - 1, gapp.image->h - gapp.pany + TOOLBAR_HEIGHT, draw_w, 1, DOCUMENT_BORDER); |
__menuet__bar(window_center - 1, gapp.image->h - gapp.pany + TOOLBAR_HEIGHT + 1, draw_w, Form.client_height - gapp.image->h - TOOLBAR_HEIGHT + gapp.pany - 1, DOCUMENT_BG); |
} |
|
|
258,26 → 257,26 |
{ |
char ii, mouse_wheels_state; |
char* original_command_line = *(char**)0x1C; |
kol_board_puts(original_command_line); |
kol_board_puts("\n"); |
__menuet__debug_out(original_command_line); |
|
char buf[128]; |
int resolution = 72; |
int pageno = 1; |
fz_accelerate(); |
kol_board_puts("PDF init\n"); |
__menuet__debug_out("PDF init\n"); |
pdfapp_init(&gapp); |
gapp.scrw = 600; |
gapp.scrh = 400; |
gapp.resolution = resolution; |
gapp.pageno = pageno; |
kol_board_puts("PDF Open\n"); |
__menuet__debug_out("PDF Open\n"); |
pdfapp_open(&gapp, original_command_line, 0, 0); |
kol_board_puts("PDF Opened\n"); |
__menuet__debug_out("PDF Opened\n"); |
wintitle(&gapp, 0); |
|
kol_board_puts("Inital paint\n"); |
|
__menuet__debug_out("Inital paint\n"); |
|
int butt, key, screen_max_x, screen_max_y; |
__menuet__get_screen_max(&screen_max_x, &screen_max_y); |
__menuet__set_bitfield_for_wanted_events(EVENT_REDRAW+EVENT_KEY+EVENT_BUTTON+EVENT_MOUSE_CHANGE); |
290,9 → 289,7 |
case evReDraw: |
// gapp.shrinkwrap = 2; |
__menuet__window_redraw(1); |
__menuet__define_window(screen_max_x / 2 - 350-50+kos_random(50), |
screen_max_y / 2 - 300-50+kos_random(50), |
700, 600, 0x73000000, 0x800000FF, Title); |
__menuet__define_window(screen_max_x / 2 - 350, screen_max_y / 2 - 300, 700, 600, 0x73000000, 0x800000FF, Title); |
__menuet__window_redraw(2); |
__menuet__get_process_table(&Form, PID_WHOAMI); |
if (Form.window_state > 2) continue; //fix rolled up |
325,14 → 322,14 |
case evButton: |
butt = __menuet__get_button_id(); |
if(butt==1) __menuet__sys_exit(); |
if(butt==10) RunApp("/sys/lod", "*pdf* /kolibrios/media/updf"); |
if(butt==10) ;//mag open file |
if(butt==11) PageZoomOut(); //magnify - |
if(butt==12) PageZoomIn(); //magnify + |
if(butt==13) //show help |
{ |
kol_paint_bar(0, TOOLBAR_HEIGHT, Form.client_width, Form.client_height - TOOLBAR_HEIGHT, 0xF2F2F2); |
__menuet__write_text(20, TOOLBAR_HEIGHT + 20 , 0x90000000, "uPDF for KolibriOS v1.2", 0); |
__menuet__write_text(21, TOOLBAR_HEIGHT + 20 , 0x90000000, "uPDF for KolibriOS v1.2", 0); |
__menuet__bar(0, TOOLBAR_HEIGHT, Form.client_width, Form.client_height - TOOLBAR_HEIGHT, 0xF2F2F2); |
__menuet__write_text(20, TOOLBAR_HEIGHT + 20 , 0x90000000, "uPDF for KolibriOS v1.21", 0); |
__menuet__write_text(21, TOOLBAR_HEIGHT + 20 , 0x90000000, "uPDF for KolibriOS v1.21", 0); |
for (ii=0; help[ii]!=0; ii++) { |
__menuet__write_text(20, TOOLBAR_HEIGHT + 60 + ii * 15, 0x80000000, help[ii], 0); |
} |
351,7 → 348,7 |
if (mouse_wheels_state==-1) { PageScrollUp(); PageScrollUp(); } |
} |
//sprintf (debugstr, "mouse_wheels_state: %d \n", mouse_wheels_state); |
//kol_board_puts(debugstr); |
//__menuet__debug_out(debugstr); |
//pdfapp_onmouse(&gapp, int x, int y, int btn, int modifiers, int state) |
break; |
} |
392,7 → 389,7 |
|
itoa(new_page_number, label_new_page, 10); |
strcat(label_new_page, "_"); |
kol_paint_bar(show_area_x, 6, show_area_w, 22, 0xFDF88E); |
__menuet__bar(show_area_x, 6, show_area_w, 22, 0xFDF88E); |
__menuet__write_text(show_area_x + show_area_w/2 - strlen(label_new_page)*6/2, 14, 0x000000, label_new_page, strlen(label_new_page)); |
|
if (new_page_number > gapp.pagecount) ApplyNewPageNumber(); |
408,7 → 405,7 |
void DrawPagination(void) |
{ |
char pages_display[12]; |
kol_paint_bar(show_area_x, 6, show_area_w, 22, 0xF4F4F4); |
__menuet__bar(show_area_x, 6, show_area_w, 22, 0xF4F4F4); |
sprintf (pages_display, "%d/%d", gapp.pageno, gapp.pagecount); |
__menuet__write_text(show_area_x + show_area_w/2 - strlen(pages_display)*6/2, 14, 0x000000, pages_display, strlen(pages_display)); |
} |
418,8 → 415,8 |
|
void DrawWindow(void) |
{ |
kol_paint_bar(0, 0, Form.client_width, TOOLBAR_HEIGHT - 1, 0xe1e1e1); // bar on the top (buttons holder) |
kol_paint_bar(0, TOOLBAR_HEIGHT - 1, Form.client_width, 1, 0x7F7F7F); |
__menuet__bar(0, 0, Form.client_width, TOOLBAR_HEIGHT - 1, 0xe1e1e1); // bar on the top (buttons holder) |
__menuet__bar(0, TOOLBAR_HEIGHT - 1, Form.client_width, 1, 0x7F7F7F); |
DrawToolbarButton(8,0); //open_folder |
DrawToolbarButton(42,1); //magnify - |
DrawToolbarButton(67,2); //magnify + |
430,8 → 427,8 |
DrawToolbarButton(show_area_x - 26,4); //prev page |
DrawToolbarButton(show_area_x + show_area_w,5); //nex page |
__menuet__make_button(show_area_x-1, 5, show_area_w+1, 23, 20 + BT_HIDE, 0xA4A4A4); |
kol_paint_bar(show_area_x, 5, show_area_w, 1, 0xA4A4A4); |
kol_paint_bar(show_area_x, 28, show_area_w, 1, 0xA4A4A4); |
__menuet__bar(show_area_x, 5, show_area_w, 1, 0xA4A4A4); |
__menuet__bar(show_area_x, 28, show_area_w, 1, 0xA4A4A4); |
winblit(&gapp); |
DrawPageSides(); |
} |
475,25 → 472,12 |
gapp.pany = gapp.image->h - SCROLL_H - Form.client_height + TOOLBAR_HEIGHT; |
if (gapp.pany < 0) gapp.pany = 0; |
//sprintf (debugstr, "gapp.pany: %d \n", gapp.pany); |
//kol_board_puts(debugstr); |
//__menuet__debug_out(debugstr); |
winblit(&gapp); |
} |
} |
|
void RunApp(char app[], char param[]) |
{ |
kol_struct70 r; |
r.p00 = 7; |
r.p04 = 0; |
r.p08 = param; |
r.p12 = 0; |
r.p16 = 0; |
r.p20 = 0; |
r.p21 = app; |
kol_file_70(&r); |
} |
|
|
void PageZoomIn(void) |
{ |
pdfapp_onkey(&gapp, '+'); |