Subversion Repositories Kolibri OS

Rev

Rev 7274 | Rev 7806 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.  
  2. child_window Window_CanvasReSize = {#CanvasReSize_Thread};
  3.  
  4. //===================================================//
  5. //                                                   //
  6. //                       CODE                        //
  7. //                                                   //
  8. //===================================================//
  9.  
  10. char text_columns[4];
  11. char text_rows[4];
  12.  
  13. edit_box edit_columns = {60,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
  14.         0x10000000,sizeof(text_columns)-1,#text_columns,0, 1000000000000010b};
  15. edit_box edit_rows = {60,NULL,NULL,0xffffff,0x94AECE,0xFFFfff,0xffffff,
  16.         0x10000000,sizeof(text_rows)-1,#text_rows,0, 1000000000000000b};
  17.  
  18. #define BTN_APPLY 10
  19.  
  20. void CanvasReSize_Thread()
  21. {
  22.         int id, butw;
  23.  
  24.         sprintf(#text_columns, "%i", image.columns);
  25.         sprintf(#text_rows, "%i", image.rows);
  26.         edit_columns.size = edit_columns.pos = edit_columns.shift = edit_columns.shift_old = strlen(#text_columns);
  27.         edit_rows.size = edit_rows.pos = edit_rows.shift = edit_rows.shift_old = strlen(#text_rows);
  28.  
  29.         SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
  30.         loop() switch(WaitEvent())
  31.         {
  32.         case evMouse:
  33.                 edit_box_mouse stdcall (#edit_columns);
  34.                 edit_box_mouse stdcall (#edit_rows);
  35.                 break;
  36.  
  37.         case evKey:
  38.                 GetKeys();
  39.  
  40.                 if (SCAN_CODE_ESC == key_scancode) ExitProcess();
  41.                 if (SCAN_CODE_ENTER == key_scancode) EventApplyClick();
  42.                 if (SCAN_CODE_TAB == key_scancode) EventTabClick();
  43.  
  44.                 EAX= key_ascii << 8;
  45.                 edit_box_key stdcall (#edit_columns);  
  46.                 edit_box_key stdcall (#edit_rows);     
  47.                 break;
  48.  
  49.         case evButton:
  50.                 id = GetButtonID();
  51.                 if (CLOSE_BTN == id) ExitProcess();
  52.                 if (BTN_APPLY == id) EventApplyClick();
  53.                 break;
  54.  
  55.         case evReDraw:
  56.                 DefineAndDrawWindow(Form.left+canvas.x + 100, Form.top+skin_height+canvas.y+40,
  57.                         200, 170, 0x34, system.color.work, "Canvas", 0);
  58.                 WriteText(20, 20, 0x90, system.color.work_text, "Width");
  59.                 WriteText(20, 60, 0x90, system.color.work_text, "Height");
  60.                 DrawStandartCaptButton(20, 100, BTN_APPLY, "OK");
  61.                 DrawEditBoxes();
  62.         }
  63. }
  64.  
  65. void DrawEditBoxes()
  66. {
  67.         DrawEditBoxPos(20+70, 20-4, #edit_columns);
  68.         DrawEditBoxPos(20+70, 60-4, #edit_rows);
  69. }
  70.  
  71. //===================================================//
  72. //                                                   //
  73. //                      EVENTS                       //
  74. //                                                   //
  75. //===================================================//
  76.  
  77. void EventApplyClick()
  78. {
  79.         int new_rows = atoi(#text_rows);
  80.         int new_columns = atoi(#text_columns);
  81.         if (new_columns>MAX_CELL_SIZE) || (new_rows>MAX_CELL_SIZE) {
  82.                 sprintf(#param,
  83.                         "'Maximum icon size exceeded! Please, try\nsomething less or equal to %ix%i.' -E",
  84.                         MAX_CELL_SIZE, MAX_CELL_SIZE);
  85.                 notify(#param);
  86.                 return;
  87.         }
  88.         image.create(new_rows, new_columns);
  89.         actionsHistory.init();
  90.         ActivateWindow(GetProcessSlot(Form.ID));
  91.         DrawEditArea();
  92.         ExitProcess();
  93. }
  94.  
  95. void EventTabClick()
  96. {
  97.         if (edit_columns.flags & 0b10) { edit_columns.flags -= 0b10; edit_rows.flags += 0b10; }
  98.         else { edit_columns.flags += 0b10; edit_rows.flags -= 0b10; }
  99.         DrawEditBoxes();
  100. }