Rev 4696 | Rev 5497 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4696 | Rev 5496 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | #include "mupdf.h" |
4 | #include "mupdf.h" |
5 | #include "muxps.h" |
5 | #include "muxps.h" |
6 | #include "pdfapp.h" |
6 | #include "pdfapp.h" |
7 | #include "icons/allbtns.h" |
7 | #include "icons/allbtns.h" |
Line -... | Line 8... | ||
- | 8 | ||
- | 9 | // need to be a part of menuet/os.h |
|
- | 10 | #define BT_DEL 0x80000000 |
|
- | 11 | #define BT_HIDE 0x40000000 |
|
8 | 12 | #define BT_NOFRAME 0x20000000 |
|
- | 13 | ||
- | 14 | #define evReDraw 1 |
|
- | 15 | #define evKey 2 |
|
- | 16 | #define evButton 3 |
|
- | 17 | #define evMouse 6 |
|
9 | 18 | #define evNetwork 8 |
|
- | 19 | ||
- | 20 | #define ASCII_KEY_LEFT 176 |
|
- | 21 | #define ASCII_KEY_RIGHT 179 |
|
10 | 22 | #define ASCII_KEY_DOWN 177 |
|
11 | static char Title[] = "some title"; |
23 | #define ASCII_KEY_UP 178 |
12 | static char * filename = "/hd0/1/yand.pdf"; |
24 | #define ASCII_KEY_HOME 180 |
- | 25 | #define ASCII_KEY_END 181 |
|
- | 26 | #define ASCII_KEY_PGDN 183 |
|
13 | static pdfapp_t gapp; |
27 | #define ASCII_KEY_PGUP 184 |
14 | 28 | ||
15 | void f65(unsigned x, unsigned y, unsigned w, unsigned h, char *d) //Вывод картинки |
- | |
16 | { |
29 | #define ASCII_KEY_BS 8 |
17 | asm ("nop"::"c"(w*65536+h), "d"(x*65536+y), "b"(d)); |
30 | #define ASCII_KEY_TAB 9 |
18 | asm ("xor %eax, %eax"); |
31 | #define ASCII_KEY_ENTER 13 |
19 | asm ("movl %eax, %ebp"); |
32 | #define ASCII_KEY_ESC 27 |
20 | asm ("pushl $32"); |
33 | #define ASCII_KEY_DEL 182 |
21 | asm ("popl %esi"); |
34 | #define ASCII_KEY_INS 185 |
22 | asm ("int $0x40"::"a"(65)); |
- | |
23 | - | ||
Line 24... | Line 35... | ||
24 | } |
35 | #define ASCII_KEY_SPACE 032 |
25 | 36 | ||
26 | struct blit_call |
37 | struct blit_call |
27 | { |
38 | { |
Line 39... | Line 50... | ||
39 | int stride; |
50 | int stride; |
40 | }; |
51 | }; |
Line 41... | Line 52... | ||
41 | 52 | ||
42 | void blit(int dstx, int dsty, int w, int h, int srcx, int srcy,int srcw, int srch, int stride, char *d) //Вызов сисфункции Blitter |
53 | void blit(int dstx, int dsty, int w, int h, int srcx, int srcy,int srcw, int srch, int stride, char *d) //Вызов сисфункции Blitter |
43 | { |
- | |
44 | 54 | { |
|
45 | struct blit_call image; |
55 | struct blit_call image; |
46 | image.dstx=dstx; |
56 | image.dstx=dstx; |
47 | image.dsty=dsty; |
57 | image.dsty=dsty; |
48 | image.w=w; |
58 | image.w=w; |
Line 51... | Line 61... | ||
51 | image.srcy=srcy; |
61 | image.srcy=srcy; |
52 | image.srcw=srcw; |
62 | image.srcw=srcw; |
53 | image.srch=srch; |
63 | image.srch=srch; |
54 | image.stride=stride; |
64 | image.stride=stride; |
55 | image.d=d; |
65 | image.d=d; |
- | 66 | asm ("int $0x40"::"a"(73),"b"(0),"c"(&image)); |
|
- | 67 | } |
|
Line -... | Line 68... | ||
- | 68 | ||
- | 69 | ||
- | 70 | int __menuet__get_mouse_wheels(void) |
|
56 | 71 | { |
|
- | 72 | int val; |
|
- | 73 | asm ("int $0x40":"=a"(val):"a"(37),"b"(7)); |
|
- | 74 | return val; |
|
- | 75 | }; |
|
- | 76 | ||
- | 77 | /*==== DATA ====*/ |
|
- | 78 | ||
- | 79 | static char Title[1024] = "uPDF"; |
|
- | 80 | static char * filename = "/hd0/1/yand.pdf"; |
|
- | 81 | static pdfapp_t gapp; |
|
- | 82 | char debugstr[256]; |
|
- | 83 | char do_not_blit=0; |
|
- | 84 | ||
- | 85 | #define TOOLBAR_HEIGHT 34 |
|
- | 86 | struct process_table_entry Form; |
|
- | 87 | ||
- | 88 | #define DOCUMENT_BORDER 0x979797 |
|
- | 89 | #define DOCUMENT_BG 0xABABAB |
|
- | 90 | ||
- | 91 | #define SCROLL_H 17 |
|
- | 92 | ||
- | 93 | const char *help[] = { |
|
- | 94 | "Keys:", |
|
- | 95 | " ", |
|
- | 96 | "PageUp - go to previous page", |
|
- | 97 | "PageDown - go to next page", |
|
- | 98 | "Home - go to first page", |
|
- | 99 | "End - go to last page", |
|
- | 100 | "Down arrow - scroll current page down", |
|
- | 101 | "Up arrow - scroll current page up", |
|
- | 102 | "+/- - zoom in/out", |
|
- | 103 | "[ or l - rotate page 90 deg to the left", |
|
- | 104 | "] or r - rotate page 90 deg to the right", |
|
- | 105 | " ", |
|
- | 106 | "Press Escape to hide help", |
|
- | 107 | 0 |
|
- | 108 | }; |
|
- | 109 | ||
- | 110 | /*==== CODE ====*/ |
|
- | 111 | ||
- | 112 | ||
- | 113 | // not implemented yet |
|
- | 114 | void wincursor(pdfapp_t *app, int curs) { } |
|
- | 115 | void winhelp(pdfapp_t *app) { } |
|
- | 116 | void winresize(pdfapp_t *app, int w, int h) { } |
|
- | 117 | void windocopy(pdfapp_t *app) { } |
|
Line 57... | Line -... | ||
57 | - | ||
Line 58... | Line 118... | ||
58 | asm ("int $0x40"::"a"(73),"b"(0),"c"(&image)); |
118 | void winopenuri(pdfapp_t *app, char *buf) { } |
59 | 119 | void winrepaintsearch(pdfapp_t *app) { } |
|
60 | } |
120 | |
61 | 121 | ||
Line -... | Line 122... | ||
- | 122 | void winwarn(pdfapp_t *app, char *msg) |
|
62 | void winwarn(pdfapp_t *app, char *msg) |
123 | { |
63 | { |
124 | fprintf(stderr, "mupdf: %s\n", msg); |
64 | fprintf(stderr, "mupdf: %s\n", msg); |
125 | } |
65 | } |
126 | |
66 | 127 | ||
Line -... | Line 128... | ||
- | 128 | void winerror(pdfapp_t *app, fz_error error) |
|
67 | void winerror(pdfapp_t *app, fz_error error) |
129 | { |
68 | { |
130 | fz_catch(error, "aborting"); |
69 | fz_catch(error, "aborting"); |
131 | exit(1); |
70 | exit(1); |
132 | } |
71 | } |
133 | |
Line 72... | Line -... | ||
72 | - | ||
73 | char *winpassword(pdfapp_t *app, char *filename) |
- | |
74 | { |
- | |
75 | char *r = ""; |
- | |
76 | return r; |
- | |
77 | } |
134 | |
78 | 135 | char *winpassword(pdfapp_t *app, char *filename) |
|
79 | - | ||
80 | void wincursor(pdfapp_t *app, int curs) |
136 | { |
81 | { |
- | |
82 | - | ||
83 | } |
137 | char *r = ""; |
84 | - | ||
85 | void wintitle(pdfapp_t *app, char *s) |
- | |
86 | { |
138 | return r; |
Line 87... | Line -... | ||
87 | - | ||
88 | sprintf(Title,"uPDF: %s", s); |
- | |
89 | } |
- | |
90 | - | ||
91 | void winhelp(pdfapp_t *app) |
- | |
92 | { |
- | |
93 | - | ||
94 | } |
- | |
95 | - | ||
96 | void winresize(pdfapp_t *app, int w, int h) |
- | |
97 | { |
- | |
Line 98... | Line 139... | ||
98 | //here should be something!!! |
139 | } |
99 | 140 | ||
100 | 141 | ||
101 | } |
- | |
102 | - | ||
103 | 142 | void wintitle(pdfapp_t *app, char *s) |
|
104 | void windocopy(pdfapp_t *app) |
143 | { |
Line 105... | Line -... | ||
105 | { |
- | |
106 | } |
- | |
107 | - | ||
108 | void winreloadfile(pdfapp_t *app) |
- | |
109 | { |
- | |
110 | pdfapp_close(app); |
- | |
111 | - | ||
112 | - | ||
113 | pdfapp_open(app, filename, 0, 1); |
- | |
114 | } |
- | |
115 | - | ||
116 | void winopenuri(pdfapp_t *app, char *buf) |
- | |
117 | { |
- | |
118 | /* here can be browser! |
- | |
119 | char *browser = getenv("BROWSER"); |
144 | char* param = *(char**)0x1C; |
120 | if (!browser) |
145 | sprintf(Title,"%s - uPDF", strrchr(param, '/') + 1 ); |
121 | browser = "open"; |
146 | } |
122 | if (fork() == 0) |
147 | |
123 | execlp(browser, browser, buf, (char*)0); |
148 | |
Line -... | Line 149... | ||
- | 149 | void winreloadfile(pdfapp_t *app) |
|
124 | * */ |
150 | { |
125 | 151 | //pdfapp_close(app); |
|
126 | } |
152 | //pdfapp_open(app, filename, 0, 1); |
127 | 153 | } |
|
Line 128... | Line 154... | ||
128 | 154 | ||
129 | 155 | void winclose(pdfapp_t *app) |
|
130 | void winclose(pdfapp_t *app) |
- | |
131 | { |
- | |
132 | pdfapp_close(&gapp); |
- | |
133 | __menuet__sys_exit(); |
- | |
134 | } |
- | |
135 | 156 | { |
|
136 | void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c) |
- | |
137 | { |
- | |
138 | asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c)); |
- | |
139 | } |
- | |
140 | - | ||
141 | - | ||
142 | static void winblit(pdfapp_t *app) |
- | |
143 | { |
- | |
144 | char yoba[32]; |
- | |
145 | int x0 = gapp.panx; |
- | |
146 | int y0 = gapp.pany; |
- | |
147 | int x1 = gapp.panx + gapp.image->w; |
- | |
148 | int y1 = gapp.pany + gapp.image->h; |
- | |
149 | __menuet__debug_out(" Window blit\n"); |
- | |
150 | __menuet__bar(0,0,598,370,0xababab); //background of pics |
157 | pdfapp_close(&gapp); |
151 | /* |
- | |
152 | XSetForeground(xdpy, xgc, xbgcolor.pixel); |
- | |
153 | fillrect(0, 0, x0, gapp.winh); |
- | |
154 | fillrect(x1, 0, gapp.winw - x1, gapp.winh); |
- | |
155 | fillrect(0, 0, gapp.winw, y0); |
158 | __menuet__sys_exit(); |
Line -... | Line 159... | ||
- | 159 | } |
|
Line 156... | Line 160... | ||
156 | fillrect(0, y1, gapp.winw, gapp.winh - y1);*/ |
160 | |
- | 161 | ||
157 | if (gapp.image->h-y0 > 0) { |
162 | void winrepaint(pdfapp_t *app) |
158 | kol_paint_bar(0, gapp.image->h-y0, 590, 368, 0xEFEFEF); |
163 | { |
- | 164 | winblit(&gapp); |
|
159 | } |
165 | } |
160 | /*kol_paint_bar(x1, 0, gapp.winw - x1, gapp.winh, 0x00FF00); |
166 | |
161 | kol_paint_bar(0, 0, gapp.winw, y0, 0xFF0000); |
167 | |
162 | kol_paint_bar(0, y1, gapp.winw, gapp.winh - y1, 0xFFFF);*/ |
168 | void winblit(pdfapp_t *app) |
163 | 169 | { |
|
164 | 170 | signed short window_center, draw_w; |
|
165 | /*XSetForeground(xdpy, xgc, xshcolor.pixel); |
- | |
166 | fillrect(x0+2, y1, gapp.image->w, 2); |
- | |
167 | fillrect(x1, y0+2, 2, gapp.image->h);*/ |
- | |
168 | sprintf (yoba, "%d x %d, %d x %d \n", gapp.image->w, gapp.image->h, gapp.winw, gapp.winh); |
171 | |
169 | __menuet__debug_out(yoba); |
172 | if (do_not_blit) return; |
170 | 173 | ||
171 | 174 | if (Form.client_width > gapp.image->w) window_center = (Form.client_width - gapp.image->w) / 2; else window_center = 0; |
|
172 | if (gapp.image->n == 4) |
175 | |
173 | /*ximage_blit(xwin, xgc, |
176 | if (gapp.image->n == 4) |
Line 194... | Line 197... | ||
194 | { |
197 | { |
195 | d[2] = d[1] = d[0] = *s++; |
198 | d[2] = d[1] = d[0] = *s++; |
196 | d[3] = *s++; |
199 | d[3] = *s++; |
197 | d += 4; |
200 | d += 4; |
198 | } |
201 | } |
- | 202 | blit(window_center + Form.client_left, |
|
199 | /*ximage_blit(xwin, xgc, |
203 | Form.client_top + TOOLBAR_HEIGHT, |
200 | x0, y0, |
204 | Form.client_width, |
- | 205 | Form.client_height - TOOLBAR_HEIGHT, |
|
201 | color, |
206 | gapp.panx, |
202 | 0, 0, |
207 | gapp.pany, |
203 | gapp.image->w, |
208 | gapp.image->w, |
204 | gapp.image->h, |
209 | gapp.image->h, |
205 | gapp.image->w * 4); */ |
210 | gapp.image->w * 4, |
206 | //f65(x0,y0,gapp.image->w,gapp.image->h,color); |
211 | color |
207 | blit(6, 24, 588, 368, x0, y0,gapp.image->w, gapp.image->h, gapp.image->w * 4, color); |
- | |
- | 212 | ); |
|
208 | free(color); |
213 | free(color); |
209 | } |
214 | } |
210 | } |
215 | } |
211 | - | ||
212 | - | ||
213 | __menuet__bar(0,0,598,34,0xe1e1e1); // bar on the top (buttons holder) |
- | |
214 | __menuet__bar(590,0,5,400,0xe1e1e1); // sidebar for scrolling |
- | |
215 | - | ||
216 | __menuet__make_button(8,5,26,24,7,0xe1e1e1); //(posirion x, position y, width, height, id, color) |
- | |
217 | __menuet__putimage(8,5,26,24,folder.pixel_data); |
- | |
218 | - | ||
219 | __menuet__make_button(42,5,26,24,6,0xe1e1e1); //magnify - |
- | |
220 | __menuet__putimage(42,5,26,24,minus.pixel_data); |
- | |
221 | - | ||
222 | __menuet__make_button(68,5,26,24,5,0xe1e1e1); //magnify + |
- | |
223 | __menuet__putimage(68,5,26,24,plus.pixel_data); |
- | |
224 | - | ||
225 | - | ||
226 | /* __menuet__make_button(100,0,20,20,10,0xe1e1e1); // rotate + 15 deg |
- | |
227 | __menuet__write_text(105,3,0xFFFFFF,"p",1); |
- | |
228 | - | ||
229 | __menuet__make_button(120,0,20,20,11,0xe1e1e1); // rotate - 15 deg |
216 | if (gapp.image->h - gapp.pany < Form.client_height - TOOLBAR_HEIGHT) |
230 | __menuet__write_text(125,3,0xFFFFFF,"q",1); */ |
- | |
231 | - | ||
232 | __menuet__make_button(500,5,26,24,4,0xe1e1e1); //show help |
- | |
233 | __menuet__putimage(500,5,26,24,help.pixel_data); |
- | |
234 | - | ||
235 | __menuet__make_button(534,5,24,24,2,0xe1e1e1); //prev page |
- | |
236 | __menuet__putimage(534,5,24,24,prev.pixel_data); |
- | |
237 | - | ||
238 | __menuet__make_button(558,5,24,24,3,0xe1e1e1); //nex page |
- | |
239 | __menuet__putimage(558,5,24,24,next.pixel_data); |
- | |
240 | - | ||
241 | __menuet__make_button(573,34,17,17,8,0xe1e1e1); // move up |
- | |
242 | __menuet__putimage(573,34,17,17,scrup.pixel_data); |
- | |
243 | - | ||
244 | __menuet__make_button(573,363,17,17,9,0xe1e1e1); // move down |
- | |
245 | __menuet__putimage(573,363,17,17,scrdn.pixel_data); |
- | |
246 | - | ||
247 | - | ||
248 | } |
- | |
249 | - | ||
250 | void paint(void) |
- | |
251 | { |
- | |
252 | __menuet__window_redraw(1); |
- | |
253 | //__menuet__define_window(10,10,600,400,0x64CFCFCF,0x800000FF,Title); |
- | |
254 | __menuet__define_window(10,10,600,400,0x73CFCFCF,0x800000FF,Title); |
- | |
255 | __menuet__bar(0,0,600,400,0xFFFFFF); |
- | |
256 | winblit(&gapp); |
- | |
257 | __menuet__window_redraw(2); |
- | |
258 | } |
- | |
259 | - | ||
260 | void winrepaint(pdfapp_t *app) |
- | |
261 | { |
217 | { |
262 | winblit(&gapp); |
218 | if (gapp.image->w < Form.client_width) draw_w = gapp.image->w; else draw_w = Form.client_width; |
- | 219 | __menuet__bar(window_center, gapp.image->h - gapp.pany + TOOLBAR_HEIGHT, draw_w, 1, DOCUMENT_BORDER); |
|
- | 220 | __menuet__bar(window_center, gapp.image->h - gapp.pany + TOOLBAR_HEIGHT + 1, draw_w, Form.client_height - gapp.image->h - TOOLBAR_HEIGHT + gapp.pany - 1, DOCUMENT_BG); |
|
263 | } |
221 | } |
264 | - | ||
265 | void winrepaintsearch(pdfapp_t *app) |
- | |
266 | { |
- | |
267 | paint(); |
222 | DrawPagination(); |
268 | //search! |
- | |
269 | } |
223 | } |
Line 270... | Line 224... | ||
270 | 224 | ||
271 | 225 | ||
272 | int main (void) |
- | |
- | 226 | int main (void) |
|
273 | { |
227 | { |
274 | 228 | char ii, mouse_wheels_state; |
|
Line 275... | Line 229... | ||
275 | char* original_command_line = *(char**)0x1C; |
229 | char* original_command_line = *(char**)0x1C; |
276 | __menuet__debug_out(original_command_line); |
230 | __menuet__debug_out(original_command_line); |
277 | 231 | ||
278 | char buf[128]; |
- | |
279 | int resolution = 72; |
232 | char buf[128]; |
280 | int pageno = 1; |
233 | int resolution = 72; |
281 | __menuet__debug_out("\nStarted\n"); |
234 | int pageno = 1; |
282 | fz_accelerate(); |
235 | fz_accelerate(); |
283 | __menuet__debug_out("PDF init\n"); |
236 | __menuet__debug_out("PDF init\n"); |
Line 289... | Line 242... | ||
289 | __menuet__debug_out("PDF Open\n"); |
242 | __menuet__debug_out("PDF Open\n"); |
290 | pdfapp_open(&gapp, original_command_line, 0, 0); |
243 | pdfapp_open(&gapp, original_command_line, 0, 0); |
291 | __menuet__debug_out("PDF Opened\n"); |
244 | __menuet__debug_out("PDF Opened\n"); |
Line -... | Line 245... | ||
- | 245 | ||
- | 246 | ||
Line 292... | Line -... | ||
292 | - | ||
293 | 247 | __menuet__debug_out("Inital paint\n"); |
|
- | 248 | //if (gapp.image) gapp.shrinkwrap = 0; |
|
- | 249 | ||
Line 294... | Line -... | ||
294 | - | ||
295 | int i; |
- | |
296 | int butt; |
- | |
297 | 250 | int butt, key, screen_max_x, screen_max_y; |
|
298 | __menuet__debug_out("Inital paint\n"); |
251 | __menuet__get_screen_max(&screen_max_x, &screen_max_y); |
Line 299... | Line 252... | ||
299 | pdfapp_onresize(&gapp, 600, 400); |
252 | __menuet__set_bitfield_for_wanted_events(EVENT_REDRAW+EVENT_KEY+EVENT_BUTTON+EVENT_MOUSE_CHANGE); |
- | 253 | ||
- | 254 | for(;;) |
|
- | 255 | { |
|
- | 256 | ||
- | 257 | switch(__menuet__wait_for_event()) |
|
- | 258 | { |
|
- | 259 | case evReDraw: |
|
- | 260 | __menuet__window_redraw(1); |
|
- | 261 | __menuet__define_window(screen_max_x / 2 - 350, screen_max_y / 2 - 300, 700, 600, 0x73000000, 0x800000FF, Title); |
|
- | 262 | __menuet__window_redraw(2); |
|
- | 263 | __menuet__get_process_table(&Form, PID_WHOAMI); |
|
- | 264 | if (Form.window_state > 2) continue; //fix rolled up |
|
- | 265 | Form.client_width++; //fix for Menuet kernel bug |
|
- | 266 | Form.client_height++; //fix for Menuet kernel bug |
|
- | 267 | DrawWindow(); |
|
- | 268 | break; |
|
- | 269 | ||
- | 270 | case evKey: |
|
- | 271 | key = __menuet__getkey(); |
|
- | 272 | if (key==ASCII_KEY_ESC) DrawWindow(); //close help |
|
- | 273 | if (key==ASCII_KEY_PGDN) pdfapp_onkey(&gapp, ']'); |
|
- | 274 | if (key==ASCII_KEY_PGUP) pdfapp_onkey(&gapp, '['); |
|
- | 275 | if (key==ASCII_KEY_HOME) pdfapp_onkey(&gapp, 'g'); |
|
- | 276 | if (key==ASCII_KEY_END ) pdfapp_onkey(&gapp, 'G'); |
|
- | 277 | if ((key=='[' ) || (key=='l')) pdfapp_onkey(&gapp, 'L'); |
|
- | 278 | if ((key==']' ) || (key=='r')) pdfapp_onkey(&gapp, 'R'); |
|
- | 279 | if (key==ASCII_KEY_DOWN ) PageScrollDown(); |
|
- | 280 | if (key==ASCII_KEY_UP ) PageScrollUp(); |
|
300 | paint(); |
281 | if (key=='-') PageZoomOut(); |
- | 282 | if ((key=='=') || (key=='+')) PageZoomIn(); |
|
301 | for(;;) |
283 | break; |
- | 284 | ||
- | 285 | case evButton: |
|
- | 286 | butt = __menuet__get_button_id(); |
|
302 | { |
287 | if(butt==1) __menuet__sys_exit(); |
- | 288 | if(butt==10) ;//mag open file |
|
- | 289 | if(butt==11) PageZoomOut(); //magnify - |
|
- | 290 | if(butt==12) PageZoomIn(); //magnify + |
|
- | 291 | if(butt==13) //show help |
|
- | 292 | { |
|
- | 293 | __menuet__bar(0, TOOLBAR_HEIGHT, Form.client_width, Form.client_height - TOOLBAR_HEIGHT, 0xF2F2F2); |
|
- | 294 | __menuet__write_text(20, TOOLBAR_HEIGHT + 20 , 0x90000000, "uPDF for KolibriOS v1.0", 0); |
|
- | 295 | __menuet__write_text(21, TOOLBAR_HEIGHT + 20 , 0x90000000, "uPDF for KolibriOS v1.0", 0); |
|
- | 296 | for (ii=0; help[ii]!=0; ii++) { |
|
- | 297 | __menuet__write_text(20, TOOLBAR_HEIGHT + 60 + ii * 15, 0x80000000, help[ii], 0); |
|
- | 298 | } |
|
- | 299 | } |
|
Line -... | Line 300... | ||
- | 300 | if(butt==14) pdfapp_onkey(&gapp, '['); //previous page |
|
- | 301 | if(butt==15) pdfapp_onkey(&gapp, ']'); //next page |
|
- | 302 | //if(butt==8) pdfapp_onkey(&gapp, 'j'); //move up |
|
- | 303 | //if(butt==9) pdfapp_onkey(&gapp, 'k'); //move down |
|
- | 304 | break; |
|
- | 305 | ||
- | 306 | case evMouse: |
|
303 | 307 | if (mouse_wheels_state = __menuet__get_mouse_wheels()) |
|
- | 308 | { |
|
- | 309 | if (mouse_wheels_state==1) { PageScrollDown(); PageScrollDown(); } |
|
- | 310 | if (mouse_wheels_state==-1) { PageScrollUp(); PageScrollUp(); } |
|
304 | i=__menuet__wait_for_event(); |
311 | } |
- | 312 | //sprintf (debugstr, "mouse_wheels_state: %d \n", mouse_wheels_state); |
|
- | 313 | //__menuet__debug_out(debugstr); |
|
- | 314 | //pdfapp_onmouse(&gapp, int x, int y, int btn, int modifiers, int state) |
|
- | 315 | break; |
|
305 | butt = __menuet__get_button_id(); |
316 | } |
- | 317 | } |
|
- | 318 | } |
|
- | 319 | ||
- | 320 | ||
306 | if (gapp.image) |
321 | |
307 | { |
- | |
308 | - | ||
309 | gapp.shrinkwrap = 0; |
- | |
310 | } |
- | |
311 | switch(i) |
- | |
312 | { |
- | |
313 | case 1: |
- | |
314 | paint(); |
- | |
315 | - | ||
316 | continue; |
- | |
317 | case 2: |
- | |
318 | buf[0]=__menuet__getkey(); |
322 | void DrawPageSides(void) |
319 | pdfapp_onkey(&gapp, buf[0]); |
323 | { |
320 | continue; |
- | |
321 | case 3: |
- | |
322 | if(butt==1) __menuet__sys_exit();//browse file |
- | |
323 | if(butt==2) pdfapp_onkey(&gapp, '['); //previous page |
- | |
324 | if(butt==3) pdfapp_onkey(&gapp, ']'); __menuet__debug_out("\nStarted\n"); //next page |
- | |
325 | if(butt==4) pdfapp_onkey(&gapp, '?'); //show help window |
324 | short window_center; |
326 | if(butt==5) pdfapp_onkey(&gapp, '+'); //magnify + |
325 | if (Form.client_width > gapp.image->w) window_center = (Form.client_width - gapp.image->w) / 2; else window_center = 0; |
327 | if(butt==6) pdfapp_onkey(&gapp, '-'); //mag - |
326 | if (gapp.image->w < Form.client_width) |
- | 327 | { |
|
Line -... | Line 328... | ||
- | 328 | __menuet__bar(0, TOOLBAR_HEIGHT, window_center-1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BG); |
|
- | 329 | __menuet__bar(window_center-1, TOOLBAR_HEIGHT, 1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BORDER); |
|
- | 330 | __menuet__bar(window_center + gapp.image->w, TOOLBAR_HEIGHT, 1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BORDER); |
|
- | 331 | __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); |
|
- | 332 | } |
|
- | 333 | } |
|
- | 334 | ||
- | 335 | ||
- | 336 | void DrawPagination(void) |
|
- | 337 | { |
|
- | 338 | char pages_display[12]; |
|
- | 339 | short show_area_w = 65; |
|
- | 340 | short show_area_x = Form.client_width - show_area_w - 34; |
|
- | 341 | ||
- | 342 | DrawToolbarButton(show_area_x - 26,5,26,24,4); //prev page |
|
- | 343 | DrawToolbarButton(show_area_x + show_area_w,5,26,24,5); //nex page |
|
- | 344 | __menuet__bar(show_area_x, 5, show_area_w, 1, 0xA4A4A4); |
|
- | 345 | __menuet__bar(show_area_x, 6, show_area_w, 22, 0xF4F4F4); |
|
- | 346 | __menuet__bar(show_area_x, 28, show_area_w, 1, 0xA4A4A4); |
|
- | 347 | sprintf (pages_display, "%d/%d", gapp.pageno, gapp.pagecount); |
|
- | 348 | __menuet__write_text(show_area_x + show_area_w/2 - strlen(pages_display)*6/2, 14, 0x000000, pages_display, strlen(pages_display)); |
|
- | 349 | } |
|
- | 350 | ||
- | 351 | ||
- | 352 | void DrawWindow(void) |
|
- | 353 | { |
|
- | 354 | __menuet__bar(0, 0, Form.client_width, TOOLBAR_HEIGHT - 1, 0xe1e1e1); // bar on the top (buttons holder) |
|
- | 355 | __menuet__bar(0, TOOLBAR_HEIGHT - 1, Form.client_width, 1, 0x7F7F7F); |
|
- | 356 | DrawToolbarButton(8,5,26,24,0); //open_folder |
|
- | 357 | DrawToolbarButton(42,5,26,24,1); //magnify - |
|
- | 358 | DrawToolbarButton(67,5,26,24,2); //magnify + |
|
- | 359 | DrawToolbarButton(Form.client_width - 160,5,26,24,3); //show help |
|
- | 360 | winblit(&gapp); |
|
- | 361 | DrawPageSides(); |
|
328 | if(butt==7) ;//mag open file |
362 | } |
- | 363 | ||
- | 364 | ||
- | 365 | void DrawToolbarButton(int x, int y, int w, int h, char image_id) |
|
- | 366 | { |
|
- | 367 | __menuet__make_button(x, y, w-1, h-1, 10 + image_id + BT_HIDE, 0); |
|
- | 368 | __menuet__putimage(x, y, w, h, image_id * 24 * 26 * 3 + toolbar_image); |
|
- | 369 | } |
|
- | 370 | ||
- | 371 | ||
- | 372 | ||
- | 373 | /* Actions */ |
|
- | 374 | ||
- | 375 | void PageScrollDown(void) |
|
- | 376 | { |
|
329 | if(butt==8) pdfapp_onkey(&gapp, 'j'); //move up |
377 | if (gapp.image->h - gapp.pany - SCROLL_H < Form.client_height - TOOLBAR_HEIGHT) |
330 | if(butt==9) pdfapp_onkey(&gapp, 'k'); //move down |
- | |
331 | if(butt==10) pdfapp_onkey(&gapp, 'a'); //rotate +15 deg |
378 | { |
Line -... | Line 379... | ||
- | 379 | pdfapp_onkey(&gapp, '.'); |
|
- | 380 | } |
|
- | 381 | else { |
|
- | 382 | gapp.pany += SCROLL_H; |
|
- | 383 | winblit(&gapp); |
|
- | 384 | } |
|
- | 385 | } |
|
- | 386 | ||
- | 387 | ||
- | 388 | void PageScrollUp(void) |
|
- | 389 | { |
|
- | 390 | if (gapp.pany >= SCROLL_H) { |
|
- | 391 | gapp.pany -= SCROLL_H; |
|
- | 392 | winblit(&gapp); |
|
- | 393 | } |
|
- | 394 | else { |
|
- | 395 | //need to avoid double repaint in future |
|
- | 396 | if (gapp.pageno == 1) return; |
|
- | 397 | do_not_blit = 1; |
|
- | 398 | pdfapp_onkey(&gapp, ','); |
|
- | 399 | do_not_blit = 0; |
|
- | 400 | gapp.pany = gapp.image->h - SCROLL_H - Form.client_height + TOOLBAR_HEIGHT; |
|
- | 401 | if (gapp.pany < 0) gapp.pany = 0; |
|
- | 402 | //sprintf (debugstr, "gapp.pany: %d \n", gapp.pany); |
|
- | 403 | //__menuet__debug_out(debugstr); |
|
- | 404 | winblit(&gapp); |
|
- | 405 | } |
|
- | 406 | } |
|
- | 407 | ||
- | 408 | ||
- | 409 | void PageZoomIn(void) |
|
- | 410 | { |
|
- | 411 | pdfapp_onkey(&gapp, '+'); |
|
- | 412 | DrawPageSides(); |
|
- | 413 | } |
|
- | 414 |