2015-03-05 15:45:16 +01:00
|
|
|
#include <menuet/os.h>
|
2014-03-22 22:00:40 +01:00
|
|
|
#define _WIN32
|
|
|
|
#include "fitz.h"
|
|
|
|
#include "mupdf.h"
|
|
|
|
#include "muxps.h"
|
|
|
|
#include "pdfapp.h"
|
2014-03-25 19:02:06 +01:00
|
|
|
#include "icons/allbtns.h"
|
2014-03-22 22:00:40 +01:00
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
// need to be a part of menuet/os.h
|
|
|
|
#define BT_DEL 0x80000000
|
|
|
|
#define BT_HIDE 0x40000000
|
|
|
|
#define BT_NOFRAME 0x20000000
|
|
|
|
|
|
|
|
#define evReDraw 1
|
|
|
|
#define evKey 2
|
|
|
|
#define evButton 3
|
|
|
|
#define evMouse 6
|
|
|
|
#define evNetwork 8
|
|
|
|
|
|
|
|
#define ASCII_KEY_LEFT 176
|
|
|
|
#define ASCII_KEY_RIGHT 179
|
|
|
|
#define ASCII_KEY_DOWN 177
|
|
|
|
#define ASCII_KEY_UP 178
|
|
|
|
#define ASCII_KEY_HOME 180
|
|
|
|
#define ASCII_KEY_END 181
|
|
|
|
#define ASCII_KEY_PGDN 183
|
|
|
|
#define ASCII_KEY_PGUP 184
|
|
|
|
|
|
|
|
#define ASCII_KEY_BS 8
|
|
|
|
#define ASCII_KEY_TAB 9
|
|
|
|
#define ASCII_KEY_ENTER 13
|
|
|
|
#define ASCII_KEY_ESC 27
|
|
|
|
#define ASCII_KEY_DEL 182
|
|
|
|
#define ASCII_KEY_INS 185
|
|
|
|
#define ASCII_KEY_SPACE 032
|
|
|
|
|
|
|
|
struct blit_call
|
2014-03-22 22:00:40 +01:00
|
|
|
{
|
|
|
|
int dstx;
|
|
|
|
int dsty;
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
|
|
|
|
int srcx;
|
|
|
|
int srcy;
|
|
|
|
int srcw;
|
|
|
|
int srch;
|
|
|
|
|
|
|
|
unsigned char *d;
|
|
|
|
int stride;
|
|
|
|
};
|
|
|
|
|
|
|
|
void blit(int dstx, int dsty, int w, int h, int srcx, int srcy,int srcw, int srch, int stride, char *d) //Вызов сисфункции Blitter
|
|
|
|
{
|
2015-03-05 15:45:16 +01:00
|
|
|
struct blit_call image;
|
2014-03-22 22:00:40 +01:00
|
|
|
image.dstx=dstx;
|
|
|
|
image.dsty=dsty;
|
|
|
|
image.w=w;
|
|
|
|
image.h=h;
|
|
|
|
image.srcx=srcx;
|
|
|
|
image.srcy=srcy;
|
|
|
|
image.srcw=srcw;
|
|
|
|
image.srch=srch;
|
|
|
|
image.stride=stride;
|
|
|
|
image.d=d;
|
2015-03-05 15:45:16 +01:00
|
|
|
asm ("int $0x40"::"a"(73),"b"(0),"c"(&image));
|
|
|
|
}
|
2014-03-22 22:00:40 +01:00
|
|
|
|
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
int __menuet__get_mouse_wheels(void)
|
|
|
|
{
|
|
|
|
int val;
|
|
|
|
asm ("int $0x40":"=a"(val):"a"(37),"b"(7));
|
|
|
|
return val;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*==== 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;
|
|
|
|
|
|
|
|
#define TOOLBAR_HEIGHT 34
|
|
|
|
struct process_table_entry Form;
|
|
|
|
|
|
|
|
#define DOCUMENT_BORDER 0x979797
|
|
|
|
#define DOCUMENT_BG 0xABABAB
|
|
|
|
|
2015-03-07 23:35:36 +01:00
|
|
|
#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;
|
2015-03-05 15:45:16 +01:00
|
|
|
|
|
|
|
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",
|
2015-03-07 23:35:36 +01:00
|
|
|
"g - grayscale on/off",
|
2015-03-05 15:45:16 +01:00
|
|
|
" ",
|
|
|
|
"Press Escape to hide help",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
/*==== CODE ====*/
|
|
|
|
|
|
|
|
|
|
|
|
// 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) { }
|
|
|
|
|
2014-03-22 22:00:40 +01:00
|
|
|
|
|
|
|
void winwarn(pdfapp_t *app, char *msg)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "mupdf: %s\n", msg);
|
|
|
|
}
|
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
|
2014-03-22 22:00:40 +01:00
|
|
|
void winerror(pdfapp_t *app, fz_error error)
|
|
|
|
{
|
|
|
|
fz_catch(error, "aborting");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
|
2014-03-22 22:00:40 +01:00
|
|
|
char *winpassword(pdfapp_t *app, char *filename)
|
|
|
|
{
|
|
|
|
char *r = "";
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wintitle(pdfapp_t *app, char *s)
|
|
|
|
{
|
2015-03-05 15:45:16 +01:00
|
|
|
char* param = *(char**)0x1C;
|
|
|
|
sprintf(Title,"%s - uPDF", strrchr(param, '/') + 1 );
|
2014-03-22 22:00:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void winreloadfile(pdfapp_t *app)
|
|
|
|
{
|
2015-03-05 15:45:16 +01:00
|
|
|
//pdfapp_close(app);
|
|
|
|
//pdfapp_open(app, filename, 0, 1);
|
2014-03-22 22:00:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void winclose(pdfapp_t *app)
|
|
|
|
{
|
|
|
|
pdfapp_close(&gapp);
|
|
|
|
__menuet__sys_exit();
|
|
|
|
}
|
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
|
|
|
|
void winrepaint(pdfapp_t *app)
|
2014-03-22 22:00:40 +01:00
|
|
|
{
|
2015-03-05 15:45:16 +01:00
|
|
|
winblit(&gapp);
|
2014-03-22 22:00:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
void winblit(pdfapp_t *app)
|
2014-03-22 22:00:40 +01:00
|
|
|
{
|
2015-03-05 15:45:16 +01:00
|
|
|
|
|
|
|
if (do_not_blit) return;
|
|
|
|
|
2015-03-07 23:35:36 +01:00
|
|
|
if (key_mode_enter_page_number==1) HandleNewPageNumber(0); else DrawPagination();
|
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
if (Form.client_width > gapp.image->w) window_center = (Form.client_width - gapp.image->w) / 2; else window_center = 0;
|
|
|
|
|
|
|
|
if (gapp.image->n == 4)
|
|
|
|
blit(window_center + Form.client_left,
|
|
|
|
Form.client_top + TOOLBAR_HEIGHT,
|
|
|
|
Form.client_width,
|
|
|
|
Form.client_height - TOOLBAR_HEIGHT,
|
|
|
|
gapp.panx,
|
|
|
|
gapp.pany,
|
|
|
|
gapp.image->w,
|
|
|
|
gapp.image->h,
|
|
|
|
gapp.image->w * gapp.image->n,
|
|
|
|
gapp.image->samples
|
|
|
|
);
|
2014-03-22 22:00:40 +01:00
|
|
|
else if (gapp.image->n == 2)
|
|
|
|
{
|
|
|
|
int i = gapp.image->w*gapp.image->h;
|
|
|
|
unsigned char *color = malloc(i*4);
|
|
|
|
if (color != NULL)
|
|
|
|
{
|
|
|
|
unsigned char *s = gapp.image->samples;
|
|
|
|
unsigned char *d = color;
|
|
|
|
for (; i > 0 ; i--)
|
|
|
|
{
|
|
|
|
d[2] = d[1] = d[0] = *s++;
|
|
|
|
d[3] = *s++;
|
|
|
|
d += 4;
|
|
|
|
}
|
2015-03-05 15:45:16 +01:00
|
|
|
blit(window_center + Form.client_left,
|
|
|
|
Form.client_top + TOOLBAR_HEIGHT,
|
|
|
|
Form.client_width,
|
|
|
|
Form.client_height - TOOLBAR_HEIGHT,
|
|
|
|
gapp.panx,
|
|
|
|
gapp.pany,
|
|
|
|
gapp.image->w,
|
|
|
|
gapp.image->h,
|
|
|
|
gapp.image->w * 4,
|
|
|
|
color
|
|
|
|
);
|
2014-03-22 22:00:40 +01:00
|
|
|
free(color);
|
|
|
|
}
|
2015-03-07 23:35:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DrawPageSides(void)
|
|
|
|
{
|
|
|
|
if (Form.client_width > gapp.image->w) window_center = (Form.client_width - gapp.image->w) / 2; else window_center = 0;
|
|
|
|
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)
|
2015-03-05 15:45:16 +01:00
|
|
|
{
|
2015-03-07 23:35:36 +01:00
|
|
|
__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)
|
|
|
|
{
|
|
|
|
draw_w = gapp.image->w + 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window_center = 1;
|
|
|
|
draw_w = Form.client_width;
|
2014-03-22 22:00:40 +01:00
|
|
|
}
|
2015-03-07 23:35:36 +01:00
|
|
|
__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);
|
2014-03-22 22:00:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-07 23:35:36 +01:00
|
|
|
|
2014-03-22 22:00:40 +01:00
|
|
|
int main (void)
|
|
|
|
{
|
2015-03-05 15:45:16 +01:00
|
|
|
char ii, mouse_wheels_state;
|
2014-03-22 22:00:40 +01:00
|
|
|
char* original_command_line = *(char**)0x1C;
|
|
|
|
__menuet__debug_out(original_command_line);
|
|
|
|
|
|
|
|
char buf[128];
|
|
|
|
int resolution = 72;
|
2015-03-05 15:45:16 +01:00
|
|
|
int pageno = 1;
|
|
|
|
fz_accelerate();
|
|
|
|
__menuet__debug_out("PDF init\n");
|
|
|
|
pdfapp_init(&gapp);
|
2014-03-22 22:00:40 +01:00
|
|
|
gapp.scrw = 600;
|
|
|
|
gapp.scrh = 400;
|
|
|
|
gapp.resolution = resolution;
|
|
|
|
gapp.pageno = pageno;
|
|
|
|
__menuet__debug_out("PDF Open\n");
|
|
|
|
pdfapp_open(&gapp, original_command_line, 0, 0);
|
2015-03-05 15:45:16 +01:00
|
|
|
__menuet__debug_out("PDF Opened\n");
|
2015-03-07 23:35:36 +01:00
|
|
|
wintitle(&gapp, 0);
|
2014-03-22 22:00:40 +01:00
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
|
|
|
|
__menuet__debug_out("Inital paint\n");
|
2014-03-22 22:00:40 +01:00
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
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);
|
2014-03-22 22:00:40 +01:00
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
switch(__menuet__wait_for_event())
|
|
|
|
{
|
|
|
|
case evReDraw:
|
2015-03-07 23:35:36 +01:00
|
|
|
// gapp.shrinkwrap = 2;
|
2015-03-05 15:45:16 +01:00
|
|
|
__menuet__window_redraw(1);
|
|
|
|
__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
|
|
|
|
Form.client_width++; //fix for Menuet kernel bug
|
|
|
|
Form.client_height++; //fix for Menuet kernel bug
|
|
|
|
DrawWindow();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case evKey:
|
|
|
|
key = __menuet__getkey();
|
2015-03-07 23:35:36 +01:00
|
|
|
if (key_mode_enter_page_number)
|
|
|
|
{
|
|
|
|
HandleNewPageNumber(key);
|
|
|
|
break;
|
|
|
|
}
|
2015-03-05 15:45:16 +01:00
|
|
|
if (key==ASCII_KEY_ESC) DrawWindow(); //close help
|
|
|
|
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');
|
2015-03-05 17:28:48 +01:00
|
|
|
if (key=='g' ) pdfapp_onkey(&gapp, 'c');
|
|
|
|
if ((key=='[' ) || (key=='l')) PageRotateLeft();
|
|
|
|
if ((key==']' ) || (key=='r')) PageRotateRight();
|
2015-03-05 15:45:16 +01:00
|
|
|
if (key==ASCII_KEY_DOWN ) PageScrollDown();
|
|
|
|
if (key==ASCII_KEY_UP ) PageScrollUp();
|
|
|
|
if (key=='-') PageZoomOut();
|
|
|
|
if ((key=='=') || (key=='+')) PageZoomIn();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case evButton:
|
|
|
|
butt = __menuet__get_button_id();
|
|
|
|
if(butt==1) __menuet__sys_exit();
|
|
|
|
if(butt==10) ;//mag open file
|
|
|
|
if(butt==11) PageZoomOut(); //magnify -
|
|
|
|
if(butt==12) PageZoomIn(); //magnify +
|
|
|
|
if(butt==13) //show help
|
|
|
|
{
|
|
|
|
__menuet__bar(0, TOOLBAR_HEIGHT, Form.client_width, Form.client_height - TOOLBAR_HEIGHT, 0xF2F2F2);
|
2015-03-07 23:35:36 +01:00
|
|
|
__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);
|
2015-03-05 15:45:16 +01:00
|
|
|
for (ii=0; help[ii]!=0; ii++) {
|
|
|
|
__menuet__write_text(20, TOOLBAR_HEIGHT + 60 + ii * 15, 0x80000000, help[ii], 0);
|
2014-03-22 22:00:40 +01:00
|
|
|
}
|
2015-03-05 15:45:16 +01:00
|
|
|
}
|
|
|
|
if(butt==14) pdfapp_onkey(&gapp, '['); //previous page
|
|
|
|
if(butt==15) pdfapp_onkey(&gapp, ']'); //next page
|
2015-03-07 23:35:36 +01:00
|
|
|
if(butt==16) PageRotateLeft();
|
|
|
|
if(butt==17) PageRotateRight();
|
|
|
|
if(butt==20) GetNewPageNumber();
|
2015-03-05 15:45:16 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case evMouse:
|
|
|
|
if (mouse_wheels_state = __menuet__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);
|
|
|
|
//__menuet__debug_out(debugstr);
|
|
|
|
//pdfapp_onmouse(&gapp, int x, int y, int btn, int modifiers, int state)
|
|
|
|
break;
|
|
|
|
}
|
2014-03-22 22:00:40 +01:00
|
|
|
}
|
|
|
|
}
|
2015-03-05 15:45:16 +01:00
|
|
|
|
|
|
|
|
2015-03-07 23:35:36 +01:00
|
|
|
void GetNewPageNumber(void)
|
|
|
|
{
|
|
|
|
new_page_number = gapp.pageno;
|
|
|
|
key_mode_enter_page_number = 1;
|
|
|
|
HandleNewPageNumber(0);
|
|
|
|
}
|
2015-03-05 15:45:16 +01:00
|
|
|
|
2015-03-07 23:35:36 +01:00
|
|
|
void HandleNewPageNumber(unsigned char key)
|
2015-03-05 15:45:16 +01:00
|
|
|
{
|
2015-03-07 23:35:36 +01:00
|
|
|
char label_new_page[8];
|
|
|
|
|
|
|
|
if ((key >= '0') && (key <= '9'))
|
2015-03-05 15:45:16 +01:00
|
|
|
{
|
2015-03-07 23:35:36 +01:00
|
|
|
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;
|
2015-03-05 15:45:16 +01:00
|
|
|
}
|
2015-03-07 23:35:36 +01:00
|
|
|
if (key==ASCII_KEY_ESC)
|
|
|
|
{
|
|
|
|
key_mode_enter_page_number = 0;
|
|
|
|
DrawWindow();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
itoa(new_page_number, label_new_page, 10);
|
|
|
|
strcat(label_new_page, "_");
|
|
|
|
__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();
|
2015-03-05 15:45:16 +01:00
|
|
|
}
|
|
|
|
|
2015-03-07 23:35:36 +01:00
|
|
|
void ApplyNewPageNumber(void)
|
|
|
|
{
|
|
|
|
key_mode_enter_page_number = 0;
|
|
|
|
gapp.pageno = new_page_number -1;
|
|
|
|
pdfapp_onkey(&gapp, ']');
|
|
|
|
}
|
2015-03-05 15:45:16 +01:00
|
|
|
|
|
|
|
void DrawPagination(void)
|
|
|
|
{
|
|
|
|
char pages_display[12];
|
|
|
|
__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));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-03-07 23:35:36 +01:00
|
|
|
|
|
|
|
|
2015-03-05 15:45:16 +01:00
|
|
|
void DrawWindow(void)
|
|
|
|
{
|
|
|
|
__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);
|
2015-03-07 23:35:36 +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
|
|
|
|
DrawToolbarButton(Form.client_width - 160,3); //show help
|
|
|
|
show_area_x = Form.client_width - show_area_w - 34;
|
|
|
|
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);
|
|
|
|
__menuet__bar(show_area_x, 5, show_area_w, 1, 0xA4A4A4);
|
|
|
|
__menuet__bar(show_area_x, 28, show_area_w, 1, 0xA4A4A4);
|
2015-03-05 15:45:16 +01:00
|
|
|
winblit(&gapp);
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
2015-03-07 23:35:36 +01:00
|
|
|
void DrawToolbarButton(int x, char image_id)
|
2015-03-05 15:45:16 +01:00
|
|
|
{
|
2015-03-07 23:35:36 +01:00
|
|
|
__menuet__make_button(x, 5, 26-1, 24-1, 10 + image_id + BT_HIDE, 0);
|
|
|
|
__menuet__putimage(x, 5, 26, 24, image_id * 24 * 26 * 3 + toolbar_image);
|
2015-03-05 15:45:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Actions */
|
|
|
|
|
|
|
|
void PageScrollDown(void)
|
|
|
|
{
|
2015-03-05 17:28:48 +01:00
|
|
|
//pdfapp_onkey(&gapp, 'k'); //move down
|
2015-03-05 15:45:16 +01:00
|
|
|
if (gapp.image->h - gapp.pany - SCROLL_H < Form.client_height - TOOLBAR_HEIGHT)
|
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, '.');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
gapp.pany += SCROLL_H;
|
|
|
|
winblit(&gapp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PageScrollUp(void)
|
|
|
|
{
|
2015-03-05 17:28:48 +01:00
|
|
|
//pdfapp_onkey(&gapp, 'j'); //move up
|
2015-03-05 15:45:16 +01:00
|
|
|
if (gapp.pany >= SCROLL_H) {
|
|
|
|
gapp.pany -= SCROLL_H;
|
|
|
|
winblit(&gapp);
|
|
|
|
}
|
|
|
|
else {
|
2015-03-05 17:28:48 +01:00
|
|
|
//not very nice way of using do_not_blit, but it simple
|
2015-03-05 15:45:16 +01:00
|
|
|
if (gapp.pageno == 1) return;
|
|
|
|
do_not_blit = 1;
|
|
|
|
pdfapp_onkey(&gapp, ',');
|
|
|
|
do_not_blit = 0;
|
|
|
|
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);
|
|
|
|
//__menuet__debug_out(debugstr);
|
|
|
|
winblit(&gapp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PageZoomIn(void)
|
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, '+');
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PageZoomOut(void)
|
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, '-');
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
2015-03-05 17:28:48 +01:00
|
|
|
void PageRotateLeft(void)
|
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, 'L');
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PageRotateRight(void)
|
|
|
|
{
|
|
|
|
pdfapp_onkey(&gapp, 'R');
|
|
|
|
DrawPageSides();
|
|
|
|
}
|
2015-03-05 15:45:16 +01:00
|
|
|
|