2020-12-18 18:19:31 +01:00
|
|
|
/*==== INCLUDES ====*/
|
|
|
|
|
2020-12-16 19:41:33 +01:00
|
|
|
#include "fitz.h"
|
|
|
|
#include "mupdf.h"
|
|
|
|
#include "pdfapp.h"
|
|
|
|
#include "icons/allbtns.h"
|
2020-12-17 10:02:12 +01:00
|
|
|
#include "kolibri.h"
|
2020-12-16 19:41:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
/*==== DATA ====*/
|
|
|
|
|
|
|
|
static char Title[1024] = "uPDF";
|
|
|
|
static pdfapp_t gapp;
|
|
|
|
char debugstr[256];
|
|
|
|
char do_not_blit=0;
|
|
|
|
|
|
|
|
#define TOOLBAR_HEIGHT 34
|
2021-01-03 16:07:11 +01:00
|
|
|
struct proc_info Form;
|
2020-12-16 19:41:33 +01:00
|
|
|
|
|
|
|
#define DOCUMENT_BORDER 0x979797
|
|
|
|
#define DOCUMENT_BG 0xABABAB
|
|
|
|
|
|
|
|
#define SCROLL_H 25
|
|
|
|
|
|
|
|
short show_area_w = 65;
|
|
|
|
short show_area_x;
|
|
|
|
|
|
|
|
char key_mode_enter_page_number;
|
|
|
|
int new_page_number;
|
|
|
|
|
|
|
|
static short window_center, draw_h, draw_w;
|
|
|
|
|
|
|
|
const char *help[] = {
|
|
|
|
"Keys:",
|
|
|
|
" ",
|
|
|
|
"PageUp - go to previous page",
|
|
|
|
"PageDown - go to next page",
|
|
|
|
"Home - go to first page",
|
|
|
|
"End - go to last page",
|
|
|
|
"Down arrow - scroll current page down",
|
|
|
|
"Up arrow - scroll current page up",
|
|
|
|
"+/- - zoom in/out",
|
|
|
|
"[ or l - rotate page 90 deg to the left",
|
|
|
|
"] or r - rotate page 90 deg to the right",
|
|
|
|
"g - grayscale on/off",
|
|
|
|
" ",
|
|
|
|
"Press Escape to hide help",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
/*==== CODE ====*/
|
2020-12-17 10:02:12 +01:00
|
|
|
// Prototypes //
|
|
|
|
void RunApp(char app[], char param[]);
|
|
|
|
void winblit(pdfapp_t *app);
|
|
|
|
void DrawPagination(void);
|
|
|
|
void HandleNewPageNumber(unsigned char key);
|
|
|
|
void ApplyNewPageNumber(void);
|
2020-12-18 18:19:31 +01:00
|
|
|
void DrawMainWindow(void);
|
2020-12-16 19:41:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
// not implemented yet
|
|
|
|
void wincursor(pdfapp_t *app, int curs) { }
|
|
|
|
void winhelp(pdfapp_t *app) { }
|
|
|
|
void winresize(pdfapp_t *app, int w, int h) { }
|
|
|
|
void windocopy(pdfapp_t *app) { }
|
|
|
|
void winopenuri(pdfapp_t *app, char *buf) { }
|
|
|
|
void winrepaintsearch(pdfapp_t *app) { }
|
|
|
|
|
|
|
|
|
|
|
|
void winwarn(pdfapp_t *app, char *msg)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "mupdf: %s\n", msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winerror(pdfapp_t *app, fz_error error)
|
|
|
|
{
|
|
|
|
fz_catch(error, "aborting");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char *winpassword(pdfapp_t *app, char *filename)
|
|
|
|
{
|
|
|
|
char *r = "";
|
|
|
|
return r;
|
|
|
|
random();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-17 14:43:15 +01:00
|
|
|
void wintitle(pdfapp_t *app, char *s, char param[])
|
2020-12-16 19:41:33 +01:00
|
|
|
{
|
|
|
|
sprintf(Title,"%s - uPDF", strrchr(param, '/') + 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winreloadfile(pdfapp_t *app)
|
|
|
|
{
|
|
|
|
//pdfapp_close(app);
|
|
|
|
//pdfapp_open(app, filename, 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void winclose(pdfapp_t *app)
|
|
|
|
{
|
|
|
|
pdfapp_close(&gapp);
|
2020-12-17 10:02:12 +01:00
|
|
|
exit(0);
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
2020-12-17 10:02:12 +01:00
|
|
|
void RunOpenApp(char name[])
|
2020-12-16 19:41:33 +01:00
|
|
|
{
|
2020-12-17 10:02:12 +01:00
|
|
|
char cmd[250] = "*pdf* ";
|
|
|
|
strcat(cmd, name);
|
|
|
|
RunApp("/sys/lod", cmd);
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winrepaint(pdfapp_t *app)
|
|
|
|
{
|
|
|
|
winblit(&gapp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winblit(pdfapp_t *app)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (do_not_blit) return;
|
|
|
|
|
|
|
|
if (key_mode_enter_page_number==1) HandleNewPageNumber(0); else DrawPagination();
|
|
|
|
|
2021-01-03 16:07:11 +01:00
|
|
|
if (Form.cwidth > gapp.image->w) window_center = (Form.cwidth - gapp.image->w) / 2; else window_center = 0;
|
2020-12-16 19:41:33 +01:00
|
|
|
|
|
|
|
gapp.panx = 0;
|
2020-12-20 17:47:32 +01:00
|
|
|
|
2024-01-14 04:27:17 +01:00
|
|
|
kos_blit(window_center + Form.cleft,
|
|
|
|
Form.ctop + TOOLBAR_HEIGHT,
|
|
|
|
Form.cwidth,
|
|
|
|
Form.cheight - TOOLBAR_HEIGHT,
|
2020-12-20 17:47:32 +01:00
|
|
|
gapp.panx,
|
|
|
|
gapp.pany,
|
|
|
|
gapp.image->w,
|
|
|
|
gapp.image->h,
|
|
|
|
gapp.image->w * gapp.image->n, // stride
|
|
|
|
gapp.image->samples // image
|
|
|
|
);
|
|
|
|
|
|
|
|
/*
|
|
|
|
void kos_blit(int dstx, int dsty, int w, int h, int srcx, int srcy, int srcw, int srch, int stride, char *d)
|
|
|
|
*/
|
|
|
|
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DrawPageSides(void)
|
|
|
|
{
|
2021-01-03 16:07:11 +01:00
|
|
|
if (gapp.image->h < Form.cheight - TOOLBAR_HEIGHT) {
|
2020-12-16 19:41:33 +01:00
|
|
|
draw_h = gapp.image->h - gapp.pany;
|
|
|
|
} else {
|
2021-01-03 16:07:11 +01:00
|
|
|
draw_h = Form.cheight - TOOLBAR_HEIGHT;
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
2021-01-03 16:07:11 +01:00
|
|
|
if (gapp.image->w < Form.cwidth) {
|
|
|
|
window_center = (Form.cwidth - gapp.image->w) / 2;
|
2020-12-16 19:41:33 +01:00
|
|
|
draw_w = gapp.image->w + 2;
|
2021-01-03 16:07:11 +01:00
|
|
|
kol_paint_bar(0, TOOLBAR_HEIGHT, window_center-1, Form.cheight - TOOLBAR_HEIGHT, DOCUMENT_BG);
|
2020-12-16 19:41:33 +01:00
|
|
|
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);
|
2021-01-03 16:07:11 +01:00
|
|
|
kol_paint_bar(window_center + gapp.image->w+1, TOOLBAR_HEIGHT, Form.cwidth - window_center - gapp.image->w - 1, Form.cheight - TOOLBAR_HEIGHT, DOCUMENT_BG);
|
2020-12-16 19:41:33 +01:00
|
|
|
} else {
|
|
|
|
window_center = 1;
|
2021-01-03 16:07:11 +01:00
|
|
|
draw_w = Form.cwidth;
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
kol_paint_bar(window_center - 1, gapp.image->h - gapp.pany + TOOLBAR_HEIGHT, draw_w, 1, DOCUMENT_BORDER);
|
2024-01-14 04:27:17 +01:00
|
|
|
kol_paint_bar(window_center - 1, gapp.image->h - gapp.pany + TOOLBAR_HEIGHT + 1,
|
2021-01-03 16:07:11 +01:00
|
|
|
draw_w, Form.cheight - gapp.image->h - TOOLBAR_HEIGHT + gapp.pany - 1, DOCUMENT_BG);
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GetNewPageNumber(void)
|
|
|
|
{
|
|
|
|
new_page_number = gapp.pageno;
|
|
|
|
key_mode_enter_page_number = 1;
|
|
|
|
HandleNewPageNumber(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HandleNewPageNumber(unsigned char key)
|
|
|
|
{
|
|
|
|
char label_new_page[8];
|
|
|
|
|
|
|
|
if ((key >= '0') && (key <= '9'))
|
|
|
|
{
|
|
|
|
new_page_number = new_page_number * 10 + key - '0';
|
|
|
|
}
|
|
|
|
if (key == ASCII_KEY_BS)
|
|
|
|
{
|
|
|
|
new_page_number /= 10;
|
|
|
|
}
|
|
|
|
if (key == ASCII_KEY_ENTER)
|
|
|
|
{
|
|
|
|
ApplyNewPageNumber();
|
|
|
|
return;
|
|
|
|
}
|
2024-01-14 04:27:17 +01:00
|
|
|
if (key==ASCII_KEY_ESC)
|
2020-12-16 19:41:33 +01:00
|
|
|
{
|
|
|
|
key_mode_enter_page_number = 0;
|
2020-12-18 18:19:31 +01:00
|
|
|
DrawMainWindow();
|
2020-12-16 19:41:33 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
itoa(new_page_number, label_new_page, 10);
|
|
|
|
strcat(label_new_page, "_");
|
|
|
|
kol_paint_bar(show_area_x, 6, show_area_w, 22, 0xFDF88E);
|
2020-12-18 18:19:31 +01:00
|
|
|
kos_text(show_area_x + show_area_w/2 - strlen(label_new_page)*6/2, 14, 0x000000, label_new_page, strlen(label_new_page));
|
2020-12-16 19:41:33 +01:00
|
|
|
|
|
|
|
if (new_page_number > gapp.pagecount) ApplyNewPageNumber();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ApplyNewPageNumber(void)
|
|
|
|
{
|
|
|
|
key_mode_enter_page_number = 0;
|
|
|
|
gapp.pageno = new_page_number -1;
|
|
|
|
pdfapp_onkey(&gapp, ']');
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawPagination(void)
|
|
|
|
{
|
|
|
|
char pages_display[12];
|
|
|
|
kol_paint_bar(show_area_x, 6, show_area_w, 22, 0xF4F4F4);
|
|
|
|
sprintf (pages_display, "%d/%d", gapp.pageno, gapp.pagecount);
|
2020-12-18 18:19:31 +01:00
|
|
|
kos_text(show_area_x + show_area_w/2 - strlen(pages_display)*6/2, 14, 0x000000, pages_display, strlen(pages_display));
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void DrawToolbarButton(int x, char image_id)
|
|
|
|
{
|
2020-12-18 18:19:31 +01:00
|
|
|
kol_btn_define(x, 5, 26-1, 24-1, 10 + image_id + BT_HIDE, 0);
|
2024-01-14 04:27:17 +01:00
|
|
|
kol_paint_image(x, 5, 26, 24, image_id * 24 * 26 * 3 + toolbar_image);
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
2020-12-18 18:19:31 +01:00
|
|
|
void DrawMainWindow(void)
|
2020-12-16 19:41:33 +01:00
|
|
|
{
|
2021-01-03 16:07:11 +01:00
|
|
|
kol_paint_bar(0, 0, Form.cwidth, TOOLBAR_HEIGHT - 1, 0xe1e1e1); // bar on the top (buttons holder)
|
|
|
|
kol_paint_bar(0, TOOLBAR_HEIGHT - 1, Form.cwidth, 1, 0x7F7F7F);
|
2020-12-16 19:41:33 +01:00
|
|
|
DrawToolbarButton(8,0); //open_folder
|
|
|
|
DrawToolbarButton(42,1); //magnify -
|
|
|
|
DrawToolbarButton(67,2); //magnify +
|
|
|
|
DrawToolbarButton(101,6); //rotate left
|
|
|
|
DrawToolbarButton(126,7); //rotate right
|
2021-01-03 16:07:11 +01:00
|
|
|
DrawToolbarButton(Form.cwidth - 160,3); //show help
|
|
|
|
show_area_x = Form.cwidth - show_area_w - 34;
|
2020-12-16 19:41:33 +01:00
|
|
|
DrawToolbarButton(show_area_x - 26,4); //prev page
|
|
|
|
DrawToolbarButton(show_area_x + show_area_w,5); //nex page
|
2020-12-18 18:19:31 +01:00
|
|
|
kol_btn_define(show_area_x-1, 5, show_area_w+1, 23, 20 + BT_HIDE, 0xA4A4A4);
|
2020-12-16 19:41:33 +01:00
|
|
|
kol_paint_bar(show_area_x, 5, show_area_w, 1, 0xA4A4A4);
|
|
|
|
kol_paint_bar(show_area_x, 28, show_area_w, 1, 0xA4A4A4);
|
|
|
|
winblit(&gapp);
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Actions */
|
|
|
|
|
|
|
|
void PageScrollDown(void)
|
|
|
|
{
|
|
|
|
//pdfapp_onkey(&gapp, 'k'); //move down
|
2021-01-03 16:07:11 +01:00
|
|
|
if (gapp.image->h - gapp.pany - SCROLL_H < Form.cheight - TOOLBAR_HEIGHT)
|
2020-12-16 19:41:33 +01:00
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, '.');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gapp.pany += SCROLL_H;
|
|
|
|
winblit(&gapp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PageScrollUp(void)
|
|
|
|
{
|
|
|
|
//pdfapp_onkey(&gapp, 'j'); //move up
|
|
|
|
if (gapp.pany >= SCROLL_H) {
|
|
|
|
gapp.pany -= SCROLL_H;
|
|
|
|
winblit(&gapp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//not very nice way of using do_not_blit, but it simple
|
|
|
|
if (gapp.pageno == 1) return;
|
|
|
|
do_not_blit = 1;
|
|
|
|
pdfapp_onkey(&gapp, ',');
|
|
|
|
do_not_blit = 0;
|
2021-01-03 16:07:11 +01:00
|
|
|
gapp.pany = gapp.image->h - SCROLL_H - Form.cheight + TOOLBAR_HEIGHT;
|
2020-12-16 19:41:33 +01:00
|
|
|
if (gapp.pany < 0) gapp.pany = 0;
|
|
|
|
//sprintf (debugstr, "gapp.pany: %d \n", gapp.pany);
|
|
|
|
//kol_board_puts(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, '+');
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PageZoomOut(void)
|
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, '-');
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageRotateLeft(void)
|
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, 'L');
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageRotateRight(void)
|
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, 'R');
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
2020-12-17 10:02:12 +01:00
|
|
|
int main (int argc, char* argv[])
|
2020-12-16 19:41:33 +01:00
|
|
|
{
|
|
|
|
char ii, mouse_wheels_state;
|
|
|
|
|
2020-12-17 14:43:15 +01:00
|
|
|
// argv without spaces
|
|
|
|
char full_argv[1024];
|
|
|
|
for (int i = 1; i<argc; i++) {
|
|
|
|
if (i != 1) strcat(full_argv, " ");
|
|
|
|
strcat(full_argv, argv[i]);
|
|
|
|
}
|
|
|
|
|
2020-12-17 10:02:12 +01:00
|
|
|
if (argc == 1) {
|
2020-12-20 17:47:32 +01:00
|
|
|
kol_board_puts("uPDF: no param set, showing OpenDialog...\n");
|
2020-12-17 10:02:12 +01:00
|
|
|
RunOpenApp(argv[0]);
|
|
|
|
exit(0);
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
|
|
|
|
2020-12-17 14:43:15 +01:00
|
|
|
kol_board_puts(full_argv);
|
2020-12-16 19:41:33 +01:00
|
|
|
kol_board_puts("\n");
|
|
|
|
|
|
|
|
char buf[128];
|
|
|
|
int resolution = 72;
|
|
|
|
int pageno = 1;
|
|
|
|
fz_accelerate();
|
2020-12-20 17:47:32 +01:00
|
|
|
kol_board_puts("PDF init...\n");
|
2020-12-16 19:41:33 +01:00
|
|
|
pdfapp_init(&gapp);
|
|
|
|
gapp.scrw = 600;
|
|
|
|
gapp.scrh = 400;
|
|
|
|
gapp.resolution = resolution;
|
|
|
|
gapp.pageno = pageno;
|
2020-12-20 17:47:32 +01:00
|
|
|
kol_board_puts("PDF Open...\n");
|
2020-12-17 14:43:15 +01:00
|
|
|
pdfapp_open(&gapp, full_argv, 0, 0);
|
2020-12-20 17:47:32 +01:00
|
|
|
kol_board_puts("PDF Opened!\n");
|
2020-12-17 14:43:15 +01:00
|
|
|
wintitle(&gapp, 0, full_argv);
|
2020-12-16 19:41:33 +01:00
|
|
|
|
|
|
|
kol_board_puts("Inital paint\n");
|
|
|
|
|
|
|
|
int butt, key, screen_max_x, screen_max_y;
|
2020-12-18 18:19:31 +01:00
|
|
|
kos_screen_max(&screen_max_x, &screen_max_y);
|
|
|
|
kol_event_mask(EVENT_REDRAW+EVENT_KEY+EVENT_BUTTON+EVENT_MOUSE_CHANGE);
|
2020-12-16 19:41:33 +01:00
|
|
|
|
2020-12-17 10:02:12 +01:00
|
|
|
for(;;)
|
2020-12-16 19:41:33 +01:00
|
|
|
{
|
2024-01-14 04:27:17 +01:00
|
|
|
switch(kol_event_wait())
|
2020-12-17 10:02:12 +01:00
|
|
|
{
|
|
|
|
case evReDraw:
|
|
|
|
// gapp.shrinkwrap = 2;
|
2024-01-14 04:27:17 +01:00
|
|
|
kol_paint_start();
|
2020-12-18 18:19:31 +01:00
|
|
|
kol_wnd_define(screen_max_x / 2 - 350-50+kos_random(50),
|
2020-12-17 10:02:12 +01:00
|
|
|
screen_max_y / 2 - 300-50+kos_random(50),
|
|
|
|
700, 600, 0x73000000, 0x800000FF, Title);
|
2024-01-14 04:27:17 +01:00
|
|
|
kol_paint_end();
|
|
|
|
kol_process_info(-1, (char*)&Form);
|
2020-12-18 18:19:31 +01:00
|
|
|
|
2024-01-14 04:27:17 +01:00
|
|
|
if (Form.window_state & 4) continue; // if Rolled-up
|
2020-12-17 14:43:15 +01:00
|
|
|
|
2020-12-18 18:19:31 +01:00
|
|
|
// Minimal size (700x600)
|
2024-01-14 04:27:17 +01:00
|
|
|
if (Form.width < 700) kol_wnd_change(-1, -1, 700, -1);
|
|
|
|
if (Form.height < 600) kol_wnd_change(-1, -1, -1, 600);
|
2020-12-17 14:43:15 +01:00
|
|
|
|
2020-12-18 18:19:31 +01:00
|
|
|
DrawMainWindow();
|
2020-12-16 19:41:33 +01:00
|
|
|
break;
|
2020-12-17 10:02:12 +01:00
|
|
|
|
|
|
|
case evKey:
|
2020-12-19 08:53:05 +01:00
|
|
|
key = kos_get_key();
|
2020-12-17 10:02:12 +01:00
|
|
|
if (key_mode_enter_page_number)
|
|
|
|
{
|
|
|
|
HandleNewPageNumber(key);
|
|
|
|
break;
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
2020-12-18 18:19:31 +01:00
|
|
|
if (key==ASCII_KEY_ESC) DrawMainWindow(); //close help
|
2020-12-17 10:02:12 +01:00
|
|
|
if (key==ASCII_KEY_PGDN) pdfapp_onkey(&gapp, ']');
|
|
|
|
if (key==ASCII_KEY_PGUP) pdfapp_onkey(&gapp, '[');
|
|
|
|
if (key==ASCII_KEY_HOME) pdfapp_onkey(&gapp, 'g');
|
|
|
|
if (key==ASCII_KEY_END ) pdfapp_onkey(&gapp, 'G');
|
|
|
|
if (key=='g' ) pdfapp_onkey(&gapp, 'c');
|
|
|
|
if ((key=='[' ) || (key=='l')) PageRotateLeft();
|
|
|
|
if ((key==']' ) || (key=='r')) PageRotateRight();
|
|
|
|
if (key==ASCII_KEY_DOWN ) PageScrollDown();
|
|
|
|
if (key==ASCII_KEY_UP ) PageScrollUp();
|
|
|
|
if (key=='-') PageZoomOut();
|
|
|
|
if ((key=='=') || (key=='+')) PageZoomIn();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case evButton:
|
2024-01-14 04:27:17 +01:00
|
|
|
butt = kol_btn_get();
|
2020-12-17 10:02:12 +01:00
|
|
|
if(butt==1) exit(0);
|
|
|
|
if(butt==10) RunOpenApp(argv[0]);
|
|
|
|
if(butt==11) PageZoomOut(); //magnify -
|
|
|
|
if(butt==12) PageZoomIn(); //magnify +
|
|
|
|
if(butt==13) //show help
|
|
|
|
{
|
2024-01-14 04:27:17 +01:00
|
|
|
kol_paint_bar(0, TOOLBAR_HEIGHT, Form.cwidth, Form.cheight - TOOLBAR_HEIGHT, 0xF2F2F2);
|
2020-12-18 18:19:31 +01:00
|
|
|
kos_text(20, TOOLBAR_HEIGHT + 20 , 0x90000000, "uPDF for KolibriOS v1.2", 0);
|
|
|
|
kos_text(21, TOOLBAR_HEIGHT + 20 , 0x90000000, "uPDF for KolibriOS v1.2", 0);
|
2020-12-17 10:02:12 +01:00
|
|
|
for (ii=0; help[ii]!=0; ii++) {
|
2020-12-18 18:19:31 +01:00
|
|
|
kos_text(20, TOOLBAR_HEIGHT + 60 + ii * 15, 0x80000000, help[ii], 0);
|
2020-12-17 10:02:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(butt==14) pdfapp_onkey(&gapp, '['); //previous page
|
|
|
|
if(butt==15) pdfapp_onkey(&gapp, ']'); //next page
|
|
|
|
if(butt==16) PageRotateLeft();
|
|
|
|
if(butt==17) PageRotateRight();
|
|
|
|
if(butt==20) GetNewPageNumber();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case evMouse:
|
|
|
|
if (mouse_wheels_state = kos_get_mouse_wheels())
|
|
|
|
{
|
|
|
|
if (mouse_wheels_state==1) { PageScrollDown(); PageScrollDown(); }
|
|
|
|
if (mouse_wheels_state==-1) { PageScrollUp(); PageScrollUp(); }
|
|
|
|
}
|
|
|
|
//sprintf (debugstr, "mouse_wheels_state: %d \n", mouse_wheels_state);
|
|
|
|
//kol_board_puts(debugstr);
|
|
|
|
//pdfapp_onmouse(&gapp, int x, int y, int btn, int modifiers, int state)
|
|
|
|
break;
|
|
|
|
}
|
2020-12-16 19:41:33 +01:00
|
|
|
}
|
2020-12-17 10:02:12 +01:00
|
|
|
}
|