Rev 8389 | Rev 8946 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8389 | Rev 8822 | ||
---|---|---|---|
Line 15... | Line 15... | ||
15 | 15 | ||
16 | #include "../lib/obj/libimg.h" |
16 | #include "../lib/obj/libimg.h" |
Line 17... | Line 17... | ||
17 | #include "../lib/obj/box_lib.h" |
17 | #include "../lib/obj/box_lib.h" |
- | 18 | ||
Line 18... | Line 19... | ||
18 | 19 | #include "../lib/patterns/rgb.h" |
|
Line 19... | Line 20... | ||
19 | #include "../lib/patterns/rgb.h" |
20 | #include "../lib/patterns/toolbar_button.h" |
20 | 21 | ||
Line 34... | Line 35... | ||
34 | char edit_menu_items[] = |
35 | char edit_menu_items[] = |
35 | "ë१ âì|Ctrl+X |
36 | "ë१ âì|Ctrl+X |
36 | ®¯¨à®¢ âì|Ctrl+C |
37 | ®¯¨à®¢ âì|Ctrl+C |
37 | áâ ¢¨âì|Ctrl+V"; |
38 | áâ ¢¨âì|Ctrl+V"; |
38 | char image_menu_items[] = |
39 | char image_menu_items[] = |
39 | "®«¨ç¥á⢮ ¨á¯®«ì§®¢ ëå 梥⮢ |
40 | "®áç¨â âì ª®«¨ç¥á⢮ 㨪 «ìëå 梥⮢ |
40 | ¬¥¨âì ¢á¥ æ¢¥â 1 2"; |
41 | ¬¥¨âì ¢á¥ æ¢¥â 1 2 |
- | 42 | ஢¥à¨âì ¨ª®ªã"; |
|
41 | ?define T_MENU_IMAGE "ª®ª " |
43 | ?define T_MENU_IMAGE "ª®ª " |
42 | ?define T_TEST_ICON "஢¥à¨âì ¨ª®ªã" |
44 | ?define T_TEST_ICON "஢¥àª ¨ª®ª¨" |
43 | ?define T_TITLE "¥¤ ªâ®à ¨ª®®ª 0.70a Beta" |
45 | ?define T_TITLE "¥¤ ªâ®à ¨ª®®ª 0.70a Beta" |
44 | ?define T_UNIC_COLORS_COUNT "'¨ª «ìëå 梥⮢: %i.' -I" |
46 | ?define T_UNIC_COLORS_COUNT "'¨ª «ìëå 梥⮢: %i.' -I" |
45 | ?define T_TOO_BIG_IMAGE_FOR_PREVIEW "'IconEdit |
47 | ?define T_TOO_BIG_IMAGE_FOR_PREVIEW "'IconEdit |
46 | §®¡à ¦¥¨¥ ᫨誮¬ ¡®«ì讥 ¤«ï ¯à¥¤¯à®á¬®âà !' -tE" |
48 | §®¡à ¦¥¨¥ ᫨誮¬ ¡®«ì讥 ¤«ï ¯à¥¤¯à®á¬®âà !' -tE" |
47 | ?define T_ERROR_CROP_TOOL "'«ï ®¡à¥§ª¨ ¨§®¡à ¦¥¨ï ¢ ç «¥ 㦮 ¢ë¤¥«¨âì ®¡« áâì.' -W" |
49 | ?define T_ERROR_CROP_TOOL "'«ï ®¡à¥§ª¨ ¨§®¡à ¦¥¨ï ¢ ç «¥ 㦮 ¢ë¤¥«¨âì ®¡« áâì.' -W" |
Line 51... | Line 53... | ||
51 | char edit_menu_items[] = |
53 | char edit_menu_items[] = |
52 | "Cut|Ctrl+X |
54 | "Cut|Ctrl+X |
53 | Copy|Ctrl+C |
55 | Copy|Ctrl+C |
54 | Paste|Ctrl+V"; |
56 | Paste|Ctrl+V"; |
55 | char image_menu_items[] = |
57 | char image_menu_items[] = |
56 | "Count colors used |
58 | "Count unic colors used |
57 | Replace all colors equal to 1 by 2"; |
59 | Replace all colors equal to 1 by 2 |
- | 60 | Test icon"; |
|
58 | ?define T_MENU_IMAGE "Icon" |
61 | ?define T_MENU_IMAGE "Icon" |
59 | ?define T_TEST_ICON "Test Icon" |
62 | ?define T_TEST_ICON "Test Icon" |
60 | ?define T_TITLE "Icon Editor 0.70 Beta" |
63 | ?define T_TITLE "Icon Editor 0.70 Beta" |
61 | ?define T_UNIC_COLORS_COUNT "'Image has %i unique colors.' -I" |
64 | ?define T_UNIC_COLORS_COUNT "'Image has %i unique colors.' -I" |
62 | ?define T_TOO_BIG_IMAGE_FOR_PREVIEW "'IconEdit |
65 | ?define T_TOO_BIG_IMAGE_FOR_PREVIEW "'IconEdit |
Line 66... | Line 69... | ||
66 | selected image is too big to open!' -E" |
69 | selected image is too big to open!' -E" |
67 | #endif |
70 | #endif |
Line 68... | Line -... | ||
68 | - | ||
69 | - | ||
70 | 71 | ||
Line -... | Line 72... | ||
- | 72 | ||
- | 73 | ||
- | 74 | #define PALLETE_SIZE 116 |
|
71 | #define TOPBAR_H 24+8 |
75 | |
72 | #define LEFTBAR_W 16+5+5+3+3 |
76 | #define TOPBAR_H 24+8 |
73 | #define PALLETE_SIZE 116 |
77 | int leftbar_w; |
Line 74... | Line 78... | ||
74 | 78 | ||
75 | #define PAL_ITEMS_X_COUNT 13 |
79 | #define PAL_ITEMS_X_COUNT 13 |
Line 76... | Line 80... | ||
76 | #define COLSIZE 18 |
80 | #define COLSIZE 18 |
77 | #define RIGHT_BAR_W PAL_ITEMS_X_COUNT*COLSIZE |
81 | #define RIGHT_BAR_W PAL_ITEMS_X_COUNT*COLSIZE |
78 | 82 | ||
79 | #define TO_CANVAS_X(xval) xval - canvas.x/zoom.value |
83 | #define TO_CANVAS_X(xval) xval - canvas.x/zoom.value |
Line 80... | Line 84... | ||
80 | #define TO_CANVAS_Y(yval) yval - canvas.y/zoom.value |
84 | #define TO_CANVAS_Y(yval) yval - canvas.y/zoom.value |
81 | 85 | ||
Line 171... | Line 175... | ||
171 | load_dll(libimg, #libimg_init, 1); |
175 | load_dll(libimg, #libimg_init, 1); |
172 | load_dll(boxlib, #box_lib_init,0); |
176 | load_dll(boxlib, #box_lib_init,0); |
Line 173... | Line 177... | ||
173 | 177 | ||
174 | top_icons.load("/sys/icons16.png"); |
178 | top_icons.load("/sys/icons16.png"); |
- | 179 | left_icons.load("/sys/icons16.png"); |
|
Line 175... | Line 180... | ||
175 | left_icons.load("/sys/icons16.png"); |
180 | leftbar_w = left_icons.w + 16; |
176 | 181 | ||
Line 177... | Line 182... | ||
177 | sc.get(); |
182 | sc.get(); |
Line 298... | Line 303... | ||
298 | DrawWindow(); |
303 | DrawWindow(); |
299 | break; |
304 | break; |
300 | } |
305 | } |
301 | } |
306 | } |
Line 302... | Line 307... | ||
302 | 307 | ||
303 | void DrawTopPanelButton(dword _event, _hotkey, _x, _icon_n) |
308 | void DrawTopPanelButton1(dword _event, _hotkey, _x, _icon_n) |
304 | { |
309 | { |
305 | DrawWideRectangle(_x, 4, 22, 22, 3, semi_white); |
310 | DrawWideRectangle(_x, 4, 22, 22, 3, semi_white); |
306 | PutPixel(_x,4,sc.work); |
311 | PutPixel(_x,4,sc.work); |
307 | PutPixel(_x,4+21,sc.work); |
312 | PutPixel(_x,4+21,sc.work); |
308 | PutPixel(_x+21,4,sc.work); |
313 | PutPixel(_x+21,4,sc.work); |
309 | PutPixel(_x+21,4+21,sc.work); |
314 | PutPixel(_x+21,4+21,sc.work); |
310 | DefineHiddenButton(_x, 4, 21, 21, button.add(_event)); |
315 | DefineHiddenButton(_x, 4, 21, 21, button.add(_event)); |
- | 316 | img_draw stdcall(top_icons.image, -top_icons.w+16/2+_x+3, -top_icons.w+16/2+7, left_icons.w, |
|
- | 317 | left_icons.w, 0, _icon_n*left_icons.w); |
|
311 | img_draw stdcall(top_icons.image, _x+3, 7, 16, 16, 0, _icon_n*16); |
318 | //DrawTopPanelButton(button.add(_event), _x, 5, _icon_n, false); |
312 | if (_hotkey) key.add_n(_hotkey, _event); |
319 | if (_hotkey) key.add_n(_hotkey, _event); |
Line 313... | Line 320... | ||
313 | } |
320 | } |
Line 328... | Line 335... | ||
328 | } |
335 | } |
Line 329... | Line 336... | ||
329 | 336 | ||
330 | void DrawLeftPanelButton(dword _event, _hotkey, _y, _icon_n) |
337 | void DrawLeftPanelButton(dword _event, _hotkey, _y, _icon_n) |
331 | { |
338 | { |
332 | int x = 5; |
339 | int x = 5; |
333 | DrawRectangle(x, _y, 22-1, 22-1, sc.work); |
340 | DrawRectangle(x, _y, left_icons.w + 5, left_icons.w + 5, sc.work); |
334 | DefineHiddenButton(x, _y, 21, 21, button.add(_event)); |
341 | DefineHiddenButton(x, _y, left_icons.w + 5, left_icons.w + 5, button.add(_event)); |
- | 342 | img_draw stdcall(left_icons.image, x+3, _y+3, left_icons.w, |
|
335 | img_draw stdcall(left_icons.image, x+3, _y+3, 16, 16, 0, _icon_n*16); |
343 | left_icons.w, 0, _icon_n*left_icons.w); |
336 | key.add_n(_hotkey, _event); |
344 | key.add_n(_hotkey, _event); |
337 | } |
345 | } |
338 | void DrawStatusBar() |
346 | void DrawStatusBar() |
339 | { |
347 | { |
Line 355... | Line 363... | ||
355 | 363 | ||
356 | void DrawWindow() |
364 | void DrawWindow() |
357 | { |
365 | { |
358 | #define GAPH 27 |
366 | #define GAPH 27 |
- | 367 | #define GAPV 28 |
|
- | 368 | #define GAP_S 26+5 |
|
359 | #define GAPV 28 |
369 | #define GAP_B 26+18 |
360 | #define BLOCK_SPACE 10 |
370 | #define BLOCK_SPACE 10 |
361 | incn tx; |
371 | incn tx; |
362 | incn ty; |
372 | incn ty; |
363 | sc.get(); |
373 | sc.get(); |
Line 372... | Line 382... | ||
372 | right_bar.x = Form.cwidth - right_bar.w; |
382 | right_bar.x = Form.cwidth - right_bar.w; |
373 | b_color_gradient.x = b_last_colors.x = b_default_palette.x = right_bar.x; |
383 | b_color_gradient.x = b_last_colors.x = b_default_palette.x = right_bar.x; |
374 | DrawBar(0, 0, Form.cwidth, TOPBAR_H-1, sc.work); |
384 | DrawBar(0, 0, Form.cwidth, TOPBAR_H-1, sc.work); |
375 | DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, sc.work_graph); |
385 | DrawBar(0, TOPBAR_H-1, Form.cwidth, 1, sc.work_graph); |
Line 376... | Line 386... | ||
376 | 386 | ||
377 | DrawTopPanelButton(#EventCreateNewIcon, ECTRL + SCAN_CODE_KEY_N, tx.set(5), 2); |
387 | DrawTopPanelButton1(#EventCreateNewIcon, ECTRL + SCAN_CODE_KEY_N, tx.set(5), 2); |
378 | DrawTopPanelButton(#EventOpenIcon, ECTRL + SCAN_CODE_KEY_O, tx.inc(GAPH), 0); |
388 | DrawTopPanelButton1(#EventOpenIcon, ECTRL + SCAN_CODE_KEY_O, tx.inc(GAP_S), 0); |
379 | DrawTopPanelButton(#EventSaveIconToFile, ECTRL + SCAN_CODE_KEY_S, tx.inc(GAPH), 5); |
389 | DrawTopPanelButton1(#EventSaveIconToFile, ECTRL + SCAN_CODE_KEY_S, tx.inc(GAP_S), 5); |
380 | DrawTopPanelButton(#EventMoveLeft, ECTRL + SCAN_CODE_LEFT, tx.inc(GAPH+BLOCK_SPACE), 30); |
390 | DrawTopPanelButton1(#EventMoveLeft, ECTRL + SCAN_CODE_LEFT, tx.inc(GAP_B), 30); |
381 | DrawTopPanelButton(#EventMoveRight, ECTRL + SCAN_CODE_RIGHT, tx.inc(GAPH), 31); |
391 | DrawTopPanelButton1(#EventMoveRight, ECTRL + SCAN_CODE_RIGHT, tx.inc(GAP_S), 31); |
382 | DrawTopPanelButton(#EventMoveUp, ECTRL + SCAN_CODE_UP, tx.inc(GAPH), 32); |
392 | DrawTopPanelButton1(#EventMoveUp, ECTRL + SCAN_CODE_UP, tx.inc(GAP_S), 32); |
383 | DrawTopPanelButton(#EventMoveDown, ECTRL + SCAN_CODE_DOWN, tx.inc(GAPH), 33); |
393 | DrawTopPanelButton1(#EventMoveDown, ECTRL + SCAN_CODE_DOWN, tx.inc(GAP_S), 33); |
384 | DrawTopPanelButton(#EventFlipHor, 0, tx.inc(GAPH+BLOCK_SPACE), 34); |
394 | DrawTopPanelButton1(#EventFlipHor, 0, tx.inc(GAP_B), 34); |
385 | DrawTopPanelButton(#EventFlipVer, 0, tx.inc(GAPH), 35); |
395 | DrawTopPanelButton1(#EventFlipVer, 0, tx.inc(GAP_S), 35); |
386 | DrawTopPanelButton(#EventRotateLeft, ECTRL + SCAN_CODE_KEY_L, tx.inc(GAPH), 37); |
396 | DrawTopPanelButton1(#EventRotateLeft, ECTRL + SCAN_CODE_KEY_L, tx.inc(GAP_S), 37); |
387 | DrawTopPanelButton(#EventRotateRight, ECTRL + SCAN_CODE_KEY_R, tx.inc(GAPH), 36); |
- | |
388 | DrawTopPanelButton(#EventTestIcon, ECTRL + SCAN_CODE_KEY_T, tx.inc(GAPH+BLOCK_SPACE), 12); |
397 | DrawTopPanelButton1(#EventRotateRight, ECTRL + SCAN_CODE_KEY_R, tx.inc(GAP_S), 36); |
Line 389... | Line 398... | ||
389 | DrawTopPanelButton(#EventCrop, 0, tx.inc(GAPH+BLOCK_SPACE), 46); |
398 | DrawTopPanelButton1(#EventCrop, 0, tx.inc(GAP_B), 46); |
390 | 399 | ||
391 | image_menu_btn.x = tx.inc(GAPH+BLOCK_SPACE); |
400 | image_menu_btn.x = tx.inc(GAP_B); |
Line 392... | Line 401... | ||
392 | image_menu_btn.w = DrawFlatPanelButton(button.add(#EventShowImageMenu), image_menu_btn.x, image_menu_btn.y, T_MENU_IMAGE); |
401 | image_menu_btn.w = DrawFlatPanelButton(button.add(#EventShowImageMenu), image_menu_btn.x, image_menu_btn.y, T_MENU_IMAGE); |
Line 393... | Line 402... | ||
393 | //tx.inc(image_menu_btn.w + BLOCK_SPACE); |
402 | //tx.inc(image_menu_btn.w + BLOCK_SPACE); |
Line 394... | Line 403... | ||
394 | 403 | ||
Line 395... | Line 404... | ||
395 | DrawEditArea(); |
404 | DrawEditArea(); |
396 | 405 | ||
Line 407... | Line 416... | ||
407 | DrawLeftPanelButton(#EventSelectToolSelect, SCAN_CODE_KEY_S, ty.inc(GAPV), 44); |
416 | DrawLeftPanelButton(#EventSelectToolSelect, SCAN_CODE_KEY_S, ty.inc(GAPV), 44); |
408 | DrawLeftPanelButton(#EventSelectToolScrCopy,SCAN_CODE_KEY_Q, ty.inc(GAPV), 45); |
417 | DrawLeftPanelButton(#EventSelectToolScrCopy,SCAN_CODE_KEY_Q, ty.inc(GAPV), 45); |
409 | DrawLeftPanelSelection(); |
418 | DrawLeftPanelSelection(); |
Line 410... | Line 419... | ||
410 | 419 | ||
- | 420 | button.add_n(1, #EventExitIconEdit); |
|
Line 411... | Line 421... | ||
411 | button.add_n(1, #EventExitIconEdit); |
421 | key.add_n(ECTRL + SCAN_CODE_KEY_T, #EventTestIcon); |
412 | 422 | ||
413 | DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w, |
423 | DrawBar(wrapper.x+wrapper.w, TOPBAR_H, Form.cwidth-wrapper.x-wrapper.w, |
414 | Form.cheight - TOPBAR_H, sc.work); |
424 | Form.cheight - TOPBAR_H, sc.work); |
415 | DrawActiveColor(right_bar.y); |
425 | DrawActiveColor(right_bar.y); |
Line 416... | Line 426... | ||
416 | DrawColorPallets(); |
426 | DrawColorPallets(); |
417 | DrawPreview(); |
427 | DrawPreview(); |
418 | 428 | ||
419 | DrawBar(LEFTBAR_W-1, wrapper.y + wrapper.h, wrapper.w+1, |
429 | DrawBar(leftbar_w-1, wrapper.y + wrapper.h, wrapper.w+1, |
Line 420... | Line 430... | ||
420 | Form.cheight - wrapper.y - wrapper.h, sc.work); |
430 | Form.cheight - wrapper.y - wrapper.h, sc.work); |
421 | DrawStatusBar(); |
431 | DrawStatusBar(); |
422 | } |
432 | } |
423 | 433 | ||
424 | void DrawLeftPanelSelection() |
434 | void DrawLeftPanelSelection() |
Line 425... | Line 435... | ||
425 | { |
435 | { |
426 | if (previousTool!=-1) DrawRectangle3D(5, previousTool*GAPV+right_bar.y-2, 16+3+2, 16+3+2, sc.work, sc.work); |
436 | if (previousTool!=-1) DrawRectangle3D(5, previousTool*GAPV+right_bar.y-2, left_icons.w+5, left_icons.w+5, sc.work, sc.work); |
427 | DrawRectangle3D(5, currentTool*GAPV+right_bar.y-2, 16+3+2, 16+3+2, 0x333333, 0x777777); |
437 | DrawRectangle3D(5, currentTool*GAPV+right_bar.y-2, left_icons.w+5, left_icons.w+5, 0x333333, 0x777777); |
428 | } |
438 | } |
429 | 439 | ||
Line -... | Line 440... | ||
- | 440 | void DrawEditArea() |
|
430 | void DrawEditArea() |
441 | { |
431 | { |
442 | dword color1=0xC0C0C0; |
Line 432... | Line 443... | ||
432 | dword color1=0xC0C0C0; |
443 | int top_side; |
433 | int top_side; |
444 | int left_side; |
Line 759... | Line 770... | ||
759 | EventCountColorsUsed(); |
770 | EventCountColorsUsed(); |
760 | break; |
771 | break; |
761 | case 2: |
772 | case 2: |
762 | EventReplaceImageColors(color1, color2); |
773 | EventReplaceImageColors(color1, color2); |
763 | break; |
774 | break; |
- | 775 | case 3: |
|
- | 776 | EventTestIcon(); |
|
- | 777 | break; |
|
764 | } |
778 | } |
765 | } |
779 | } |
Line 766... | Line 780... | ||
766 | 780 | ||
767 | void EventCountColorsUsed() |
781 | void EventCountColorsUsed() |