Subversion Repositories Kolibri OS

Rev

Rev 4696 | Rev 5497 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4696 Rev 5496
1
#include
1
#include 
2
#define _WIN32
2
#define _WIN32
3
#include "fitz.h"
3
#include "fitz.h"
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"
-
 
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
 
-
 
24
}
35
#define ASCII_KEY_SPACE 032
25
 
36
 
26
	struct blit_call
37
struct blit_call
27
{
38
{
28
   int dstx;       
39
   int dstx;       
29
   int dsty;
40
   int dsty;
30
   int w;
41
   int w;
31
   int h;
42
   int h;
32
 
43
 
33
   int srcx;
44
   int srcx;
34
   int srcy;
45
   int srcy;
35
   int srcw;
46
   int srcw;
36
   int srch;
47
   int srch;
37
 
48
 
38
   unsigned char *d;
49
   unsigned char *d;
39
   int   stride;
50
   int   stride;
40
};
51
};
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
{
54
{
44
 
-
 
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;
49
	image.h=h;
59
	image.h=h;
50
	image.srcx=srcx;
60
	image.srcx=srcx;
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
}
-
 
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) { }
57
 
-
 
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
 
62
void winwarn(pdfapp_t *app, char *msg)
122
void winwarn(pdfapp_t *app, char *msg)
63
{
123
{
64
	fprintf(stderr, "mupdf: %s\n", msg);
124
	fprintf(stderr, "mupdf: %s\n", msg);
65
}
125
}
-
 
126
 
66
 
127
 
67
void winerror(pdfapp_t *app, fz_error error)
128
void winerror(pdfapp_t *app, fz_error error)
68
{
129
{
69
	fz_catch(error, "aborting");
130
	fz_catch(error, "aborting");
70
	exit(1);
131
	exit(1);
71
}
132
}
-
 
133
 
72
 
134
 
73
char *winpassword(pdfapp_t *app, char *filename)
135
char *winpassword(pdfapp_t *app, char *filename)
74
{
136
{
75
	char *r = "";
137
	char *r = "";
76
	return r;
138
	return r;
77
}
139
}
78
 
140
 
79
 
-
 
80
void wincursor(pdfapp_t *app, int curs)
-
 
81
{
-
 
82
	
-
 
83
}
-
 
84
 
141
 
85
void wintitle(pdfapp_t *app, char *s)
142
void wintitle(pdfapp_t *app, char *s)
86
{
-
 
87
 
143
{
88
sprintf(Title,"uPDF: %s", s);	
-
 
89
}
-
 
90
 
144
	char* param = *(char**)0x1C;
91
void winhelp(pdfapp_t *app)
-
 
92
{
-
 
93
	
145
	sprintf(Title,"%s - uPDF", strrchr(param, '/') + 1 );
94
}
-
 
95
 
-
 
96
void winresize(pdfapp_t *app, int w, int h)
-
 
97
{
-
 
98
	//here should be something!!!
-
 
99
	
-
 
100
	
-
 
101
}
-
 
102
 
-
 
103
 
-
 
104
void windocopy(pdfapp_t *app)
-
 
105
{
146
}
106
}
147
 
107
 
148
 
108
void winreloadfile(pdfapp_t *app)
149
void winreloadfile(pdfapp_t *app)
109
{
150
{
110
	pdfapp_close(app);
151
	//pdfapp_close(app);
111
 
-
 
112
 
-
 
113
	pdfapp_open(app, filename, 0, 1);
152
	//pdfapp_open(app, filename, 0, 1);
114
}
153
}
115
 
-
 
116
void winopenuri(pdfapp_t *app, char *buf)
-
 
117
{
-
 
118
	/* here can be browser!
-
 
119
	char *browser = getenv("BROWSER");
-
 
120
	if (!browser)
-
 
121
		browser = "open";
-
 
122
	if (fork() == 0)
-
 
123
		execlp(browser, browser, buf, (char*)0);
-
 
124
		* */
-
 
125
		
-
 
126
}
-
 
127
 
-
 
128
 
-
 
129
 
154
 
130
void winclose(pdfapp_t *app)
155
void winclose(pdfapp_t *app)
131
{
156
{
132
	pdfapp_close(&gapp);
157
	pdfapp_close(&gapp);
133
	__menuet__sys_exit();
158
	__menuet__sys_exit();
134
}
159
}
-
 
160
 
135
 
161
 
136
void kol_paint_bar(unsigned x, unsigned y, unsigned w, unsigned h, unsigned c)
162
void winrepaint(pdfapp_t *app)
137
{
163
{
138
asm ("int $0x40"::"a"(13), "b"(x*65536+w), "c"(y*65536+h), "d"(c));
164
	winblit(&gapp);
139
}
165
}
140
 
166
 
141
 
167
 
142
static void winblit(pdfapp_t *app)
168
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;
169
{
149
__menuet__debug_out(" Window blit\n");
-
 
150
__menuet__bar(0,0,598,370,0xababab); //background of pics
-
 
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);
-
 
156
	fillrect(0, y1, gapp.winw, gapp.winh - y1);*/
-
 
157
	if (gapp.image->h-y0 > 0) {
-
 
158
	kol_paint_bar(0, gapp.image->h-y0, 590, 368, 0xEFEFEF);
-
 
159
}
-
 
160
	/*kol_paint_bar(x1, 0, gapp.winw - x1, gapp.winh, 0x00FF00);
-
 
161
	kol_paint_bar(0, 0, gapp.winw, y0, 0xFF0000);
-
 
162
	kol_paint_bar(0, y1, gapp.winw, gapp.winh - y1, 0xFFFF);*/
-
 
163
	
170
	signed short window_center, draw_w;
164
 
-
 
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
 
-
 
172
	if (do_not_blit) return;
169
__menuet__debug_out(yoba);
173
 
-
 
174
	if (Form.client_width > gapp.image->w) window_center = (Form.client_width - gapp.image->w) / 2; else window_center = 0;
170
 
175
 
171
 
176
	if (gapp.image->n == 4)	 		 
-
 
177
		 	blit(window_center + Form.client_left, 
172
	if (gapp.image->n == 4)
178
		 		Form.client_top + TOOLBAR_HEIGHT, 
173
		/*ximage_blit(xwin, xgc,
179
		 		Form.client_width, 
174
			x0, y0,
180
		 		Form.client_height - TOOLBAR_HEIGHT, 
175
			gapp.image->samples,
181
		 		gapp.panx, 
176
			0, 0,
182
		 		gapp.pany, 
177
			gapp.image->w,
183
		 		gapp.image->w, 
178
			gapp.image->h,
-
 
179
			gapp.image->w * gapp.image->n);*/
-
 
180
		//	f65(x0,y0+32,gapp.image->w,gapp.image->h,gapp.image->samples);
-
 
181
	 		 
184
		 		gapp.image->h, 
182
		 	blit(6, 24, 588, 368, x0, y0,gapp.image->w, gapp.image->h, gapp.image->w * gapp.image->n, gapp.image->samples);
185
		 		gapp.image->w * gapp.image->n, 
183
		 	
186
		 		gapp.image->samples
184
			
187
		 	);
185
	else if (gapp.image->n == 2)
188
	else if (gapp.image->n == 2)
186
	{
189
	{
187
		int i = gapp.image->w*gapp.image->h;
190
		int i = gapp.image->w*gapp.image->h;
188
		unsigned char *color = malloc(i*4);
191
		unsigned char *color = malloc(i*4);
189
		if (color != NULL)
192
		if (color != NULL)
190
		{
193
		{
191
			unsigned char *s = gapp.image->samples;
194
			unsigned char *s = gapp.image->samples;
192
			unsigned char *d = color;
195
			unsigned char *d = color;
193
			for (; i > 0 ; i--)
196
			for (; i > 0 ; i--)
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
}
270
 
224
 
271
 
225
 
272
int main (void)
226
int main (void)
273
{
227
{
274
	
-
 
-
 
228
	char ii, mouse_wheels_state;
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];
232
	char buf[128];
279
	int resolution = 72;
233
	int resolution = 72;
280
		int pageno = 1;
234
	int pageno = 1;
281
		__menuet__debug_out("\nStarted\n");
-
 
282
		fz_accelerate();
235
	fz_accelerate();
283
		__menuet__debug_out("PDF init\n");
236
	__menuet__debug_out("PDF init\n");
284
		pdfapp_init(&gapp);
237
	pdfapp_init(&gapp);
285
	gapp.scrw = 600;
238
	gapp.scrw = 600;
286
	gapp.scrh = 400;
239
	gapp.scrh = 400;
287
	gapp.resolution = resolution;
240
	gapp.resolution = resolution;
288
	gapp.pageno = pageno;
241
	gapp.pageno = pageno;
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");
292
	
245
	
-
 
246
 
-
 
247
	__menuet__debug_out("Inital paint\n");
293
	
-
 
294
 
248
	//if (gapp.image) gapp.shrinkwrap = 0;
-
 
249
	
-
 
250
	int butt, key, screen_max_x, screen_max_y;
295
 int i;
-
 
296
 int butt;
-
 
297
 
-
 
298
 __menuet__debug_out("Inital paint\n");
251
	__menuet__get_screen_max(&screen_max_x, &screen_max_y);
299
   pdfapp_onresize(&gapp, 600, 400);
252
	__menuet__set_bitfield_for_wanted_events(EVENT_REDRAW+EVENT_KEY+EVENT_BUTTON+EVENT_MOUSE_CHANGE);
300
 paint();
253
 
301
 for(;;)
254
 for(;;)
302
 {
255
 {
303
 
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();
-
 
281
			if (key=='-') PageZoomOut();
-
 
282
			if ((key=='=') || (key=='+')) PageZoomIn();
-
 
283
			break;
-
 
284
 
304
  i=__menuet__wait_for_event();
285
		case evButton:
-
 
286
			butt = __menuet__get_button_id();
305
  butt = __menuet__get_button_id();
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 +
306
  if (gapp.image)
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
			}
-
 
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:
-
 
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();   }
307
				{
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)
308
					
315
			break;
-
 
316
	}
-
 
317
  }
-
 
318
}
-
 
319
 
309
						gapp.shrinkwrap = 0;
320
 
-
 
321
 
-
 
322
void DrawPageSides(void)
-
 
323
{
-
 
324
	short window_center;
310
				}
325
	if (Form.client_width > gapp.image->w) window_center = (Form.client_width - gapp.image->w) / 2; else window_center = 0;
311
  switch(i)
-
 
312
  {
-
 
313
   case 1:
-
 
314
    paint();
-
 
315
    
-
 
316
    continue;
-
 
317
   case 2:
-
 
318
    buf[0]=__menuet__getkey(); 
-
 
319
    pdfapp_onkey(&gapp, buf[0]);
-
 
320
    continue;
-
 
321
   case 3:
-
 
322
    if(butt==1) __menuet__sys_exit();//browse file
326
	if (gapp.image->w < Form.client_width)
323
    if(butt==2) pdfapp_onkey(&gapp, '['); //previous page
327
	{
324
    if(butt==3) pdfapp_onkey(&gapp, ']'); __menuet__debug_out("\nStarted\n"); //next page
-
 
325
    if(butt==4) pdfapp_onkey(&gapp, '?'); //show help window
-
 
326
    if(butt==5) pdfapp_onkey(&gapp, '+'); //magnify +
-
 
327
    if(butt==6) pdfapp_onkey(&gapp, '-'); //mag -
-
 
328
    if(butt==7) ;//mag open file
-
 
329
    if(butt==8) pdfapp_onkey(&gapp, 'j'); //move up
328
		__menuet__bar(0, TOOLBAR_HEIGHT, window_center-1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BG);
330
    if(butt==9) pdfapp_onkey(&gapp, 'k'); //move down
329
		__menuet__bar(window_center-1, TOOLBAR_HEIGHT, 1, Form.client_height - TOOLBAR_HEIGHT, DOCUMENT_BORDER);
331
    if(butt==10) pdfapp_onkey(&gapp, 'a'); //rotate +15 deg
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();
-
 
362
}
-
 
363
 
-
 
364
 
-
 
365
void DrawToolbarButton(int x, int y, int w, int h, char image_id)
332
    if(butt==11) pdfapp_onkey(&gapp, 's'); //rotate -15deg
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
{
-
 
377
	if (gapp.image->h - gapp.pany - SCROLL_H < Form.client_height - TOOLBAR_HEIGHT)
-
 
378
	{
-
 
379
		pdfapp_onkey(&gapp, '.');
-
 
380
	}
333
    continue;
381
	else {
334
  
-
 
335
  }
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
 
-
 
415
 
-
 
416
void PageZoomOut(void)
-
 
417
{
-
 
418
	pdfapp_onkey(&gapp, '-'); 
336
 }
419
	DrawPageSides();
337
 return 0;
420
}
338
}
-