Rev 8741 | Rev 8772 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8741 | Rev 8762 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | *) |
18 | *) |
Line 19... | Line 19... | ||
19 | 19 | ||
Line 20... | Line 20... | ||
20 | MODULE CEdit; |
20 | MODULE CEdit; |
21 | 21 | ||
22 | IMPORT |
22 | IMPORT |
23 | SYSTEM, OpenDlg, K := KolibriOS, |
23 | OpenDlg, K := KolibriOS, |
24 | U := Utils, Lines, Menu, List, |
24 | U := Utils, Lines, Menu, List, |
25 | G := Graph, T := Text, E := Encodings, |
25 | G := Graph, T := Text, E := Encodings, |
26 | CB := Clipboard, Languages, |
26 | CB := Clipboard, Languages, |
Line 27... | Line 27... | ||
27 | ChangeLog, Scroll, |
27 | ChangeLog, Scroll, |
28 | RW, Ini, box_lib, LibImg; |
28 | RW, Ini, box_lib, Icons; |
Line 29... | Line 29... | ||
29 | 29 | ||
30 | CONST |
30 | CONST |
Line 31... | Line 31... | ||
31 | header = "CEdit (24-may-2021)"; |
31 | header = "CEdit (03-jun-2021)"; |
32 | 32 | ||
33 | ShellFilter = "";(* "SH|"; *) |
33 | ShellFilter = ""; |
Line 71... | Line 71... | ||
71 | btnProgram = 75; |
71 | btnProgram = 75; |
72 | btnTools = 76; |
72 | btnTools = 76; |
Line 73... | Line 73... | ||
73 | 73 | ||
Line 74... | Line -... | ||
74 | MainMenuHeight = fontHeight + 7; |
- | |
75 | 74 | MainMenuHeight = fontHeight + 7; |
|
76 | btnColor = 0CCCCCCH; |
75 | |
77 | btnHeight = 25; |
76 | btnHeight = 25; |
78 | btnWidth = 75; |
77 | btnWidth = 75; |
79 | btnTop = MainMenuHeight + 3; |
78 | btnTop = MainMenuHeight + 3; |
Line 80... | Line 79... | ||
80 | toolBtnSize = 24; |
79 | toolBtnSize = 24; |
81 | toolbarDelim = 7; |
80 | toolbarDelim = 7; |
82 | 81 | ||
Line 83... | Line 82... | ||
83 | TOP = btnTop + toolBtnSize + 7; |
82 | TOP = btnTop + toolBtnSize + 7; |
84 | RIGHT = scrollWidth - 2; |
- | |
85 | BOTTOM = scrollWidth + 25; |
- | |
Line 86... | Line 83... | ||
86 | 83 | RIGHT = scrollWidth - 2; |
|
87 | winColor = K.winColor; minWinWidth = 635; minWinHeight = 542; |
84 | BOTTOM = scrollWidth + 25; |
88 | 85 | ||
89 | toolbarColor = 0DFDFDFH; |
86 | minWinWidth = 635; minWinHeight = 542; |
Line 119... | Line 116... | ||
119 | menuSaveAs = 13; |
116 | menuSaveAs = 13; |
120 | menuFolder = 14; |
117 | menuFolder = 14; |
121 | menuExit = 15; |
118 | menuExit = 15; |
Line 122... | Line 119... | ||
122 | 119 | ||
123 | menuNumbers = 20; |
- | |
124 | (*menuSettings = 21;*) |
120 | menuNumbers = 20; |
125 | menuColors = 1000; |
121 | menuColors = 1000; |
Line 126... | Line 122... | ||
126 | menuMaxColors = menuColors + Ini.MAX_SECTIONS - 1; |
122 | menuMaxColors = menuColors + Ini.MAX_SECTIONS - 1; |
127 | 123 | ||
Line 146... | Line 142... | ||
146 | menuWin1251 = 63; |
142 | menuWin1251 = 63; |
Line 147... | Line 143... | ||
147 | 143 | ||
148 | menuPipet = 70; |
144 | menuPipet = 70; |
Line -... | Line 145... | ||
- | 145 | menuSysFunc = 71; |
|
149 | menuSysFunc = 71; |
146 | |
150 | 147 | ||
151 | VAR |
148 | VAR |
152 | canvas: G.tCanvas; |
149 | canvas: G.tCanvas; |
153 | font: G.tFont; |
150 | font: G.tFont; |
Line 188... | Line 185... | ||
188 | T.getPos(text, col, line); |
185 | T.getPos(text, col, line); |
189 | U.int2str(line, s1); |
186 | U.int2str(line, s1); |
190 | U.int2str(col, s2); |
187 | U.int2str(col, s2); |
191 | U.append(s1, ": "); |
188 | U.append(s1, ": "); |
192 | U.append(s1, s2); |
189 | U.append(s1, s2); |
193 | K.DrawText(LEFT, y, 0, s1) |
190 | K.DrawText(LEFT, y, K.textColor, s1) |
194 | END WritePos; |
191 | END WritePos; |
Line 195... | Line 192... | ||
195 | 192 | ||
196 | 193 | ||
Line 204... | Line 201... | ||
204 | IF value THEN |
201 | IF value THEN |
205 | edit.flags := ORD(BITS(edit.flags) + {1}) |
202 | edit.flags := ORD(BITS(edit.flags) + {1}) |
206 | ELSE |
203 | ELSE |
207 | edit.flags := ORD(BITS(edit.flags) - {1}) |
204 | edit.flags := ORD(BITS(edit.flags) - {1}) |
208 | END; |
205 | END; |
209 | (* IF value THEN |
- | |
210 | edit.color := 0FFFFFFH |
- | |
211 | ELSE |
- | |
212 | edit.color := 0D0D0D0H |
- | |
213 | END;*) |
- | |
214 | IF search THEN |
206 | IF search THEN |
215 | box_lib.edit_box_draw(edit) |
207 | box_lib.edit_box_draw(edit) |
216 | END |
208 | END |
217 | END EditBox_SetFocus; |
209 | END EditBox_SetFocus; |
Line 239... | Line 231... | ||
239 | top := (canvas.height - height) DIV 2 + TOP; |
231 | top := (canvas.height - height) DIV 2 + TOP; |
240 | bottom := top + height - 1; |
232 | bottom := top + height - 1; |
241 | right := left + width - 1; |
233 | right := left + width - 1; |
242 | x := minWidth DIV 2 + left; |
234 | x := minWidth DIV 2 + left; |
243 | y := (height - fontHeight) DIV 2 + top; |
235 | y := (height - fontHeight) DIV 2 + top; |
244 | K.DrawRect(left, top, width, height, winColor); |
236 | K.DrawRect(left, top, width, height, K.winColor); |
245 | Rect(left, top, right, bottom, borderColor); |
237 | Rect(left, top, right, bottom, borderColor); |
246 | K.DrawText(x, y, 0, s); |
238 | K.DrawText(x, y, K.textColor, s); |
247 | END Message; |
239 | END Message; |
Line 248... | Line 240... | ||
248 | 240 | ||
249 | 241 | ||
Line 274... | Line 266... | ||
274 | EditBox_SetFocus(GotoEdit, FALSE) |
266 | EditBox_SetFocus(GotoEdit, FALSE) |
275 | END |
267 | END |
276 | END Replaced; |
268 | END Replaced; |
Line 277... | Line -... | ||
277 | - | ||
278 | - | ||
279 | PROCEDURE icons16 (icons, n, x, y: INTEGER); |
- | |
280 | VAR |
- | |
281 | sizeX, sizeY, data: INTEGER; |
- | |
282 | BEGIN |
- | |
283 | LibImg.GetInf(icons, sizeX, sizeY, data); |
- | |
284 | K.DrawImage(data + 16*16*3*n, 16, 16, x, y) |
- | |
285 | END icons16; |
- | |
286 | 269 | ||
287 | 270 | ||
288 | PROCEDURE toolbarIcons; |
271 | PROCEDURE toolbarIcons; |
289 | CONST |
272 | CONST |
290 | iconPad = (toolBtnSize - 16) DIV 2; |
273 | iconPad = (toolBtnSize - 16) DIV 2; |
291 | VAR |
274 | VAR |
292 | x, color: INTEGER; |
275 | x, color: INTEGER; |
293 | BEGIN |
276 | BEGIN |
294 | x := searchLeft + (toolBtnSize + 5)*2; |
277 | x := searchLeft + (toolBtnSize + 5)*2; |
295 | IF text.modified THEN |
278 | IF text.modified THEN |
296 | icons16(icons, 5, x + iconPad, btnTop + iconPad) |
279 | Icons.draw(icons, 5, x + iconPad, btnTop + iconPad) |
297 | ELSE |
280 | ELSE |
Line 298... | Line 281... | ||
298 | icons16(grayIcons, 5, x + iconPad, btnTop + iconPad) |
281 | Icons.draw(grayIcons, 5, x + iconPad, btnTop + iconPad) |
299 | END; |
282 | END; |
300 | 283 | ||
301 | IF text.edition # NIL THEN |
284 | IF text.edition # NIL THEN |
302 | x := searchLeft + (toolBtnSize + 5)*4 + toolbarDelim*2; |
285 | x := searchLeft + (toolBtnSize + 5)*4 + toolbarDelim*2; |
303 | IF ChangeLog.isFirstGuard(text.edition) THEN |
286 | IF ChangeLog.isFirstGuard(text.edition) THEN |
304 | icons16(grayIcons, 37, x + iconPad, btnTop + iconPad) |
287 | Icons.draw(grayIcons, 37, x + iconPad, btnTop + iconPad) |
Line 305... | Line 288... | ||
305 | ELSE |
288 | ELSE |
306 | icons16(icons, 37, x + iconPad, btnTop + iconPad) |
289 | Icons.draw(icons, 37, x + iconPad, btnTop + iconPad) |
307 | END; |
290 | END; |
308 | 291 | ||
309 | x := searchLeft + (toolBtnSize + 5)*5 + toolbarDelim*2; |
292 | x := searchLeft + (toolBtnSize + 5)*5 + toolbarDelim*2; |
310 | IF ChangeLog.isLastGuard(text.edition) THEN |
293 | IF ChangeLog.isLastGuard(text.edition) THEN |
311 | icons16(grayIcons, 36, x + iconPad, btnTop + iconPad) |
- | |
312 | ELSE |
- | |
313 | icons16(icons, 36, x + iconPad, btnTop + iconPad) |
- | |
314 | END |
- | |
315 | (* ELSE |
- | |
316 | x := searchLeft + (toolBtnSize + 5)*4; |
294 | Icons.draw(grayIcons, 36, x + iconPad, btnTop + iconPad) |
Line 317... | Line 295... | ||
317 | icons16(grayIcons, 37, x + iconPad, btnTop + iconPad); |
295 | ELSE |
318 | x := searchLeft + (toolBtnSize + 5)*5; |
296 | Icons.draw(icons, 36, x + iconPad, btnTop + iconPad) |
319 | icons16(grayIcons, 36, x + iconPad, btnTop + iconPad)*) |
297 | END |
320 | END; |
298 | END; |
321 | 299 | ||
Line 322... | Line 300... | ||
322 | IF T.selected(text) THEN |
300 | IF T.selected(text) THEN |
323 | color := 00000FFH |
301 | color := K.caseColor |
324 | ELSE |
302 | ELSE |
325 | color := 0808080H |
303 | color := K.disCaseColor |
326 | END; |
304 | END; |
327 | 305 | ||
Line 328... | Line 306... | ||
328 | x := searchLeft + (toolBtnSize + 5)*6 + toolbarDelim*3; |
306 | x := searchLeft + (toolBtnSize + 5)*6 + toolbarDelim*3; |
329 | K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, toolbarColor); |
307 | K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, K.toolbarColor); |
330 | K.DrawText69(x + (toolBtnSize - 12) DIV 2, btnTop + (toolBtnSize - 9) DIV 2 + 2, color, "AB"); |
308 | K.DrawText69(x + (toolBtnSize - 12) DIV 2, btnTop + (toolBtnSize - 9) DIV 2 + 2, color, "AB"); |
331 | INC(x, toolBtnSize + 5); |
309 | INC(x, toolBtnSize + 5); |
332 | K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, toolbarColor); |
310 | K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, K.toolbarColor); |
333 | K.DrawText69(x + (toolBtnSize - 12) DIV 2, btnTop + (toolBtnSize - 9) DIV 2 + 2, color, "ab"); |
311 | K.DrawText69(x + (toolBtnSize - 12) DIV 2, btnTop + (toolBtnSize - 9) DIV 2 + 2, color, "ab"); |
334 | 312 | ||
335 | x := searchLeft + (toolBtnSize + 5)*8 + toolbarDelim*4; |
313 | x := searchLeft + (toolBtnSize + 5)*8 + toolbarDelim*4; |
336 | IF buildScript # "" THEN |
314 | IF buildScript # "" THEN |
337 | icons16(icons, 54, x + iconPad, btnTop + iconPad) |
315 | Icons.draw(icons, 54, x + iconPad, btnTop + iconPad) |
338 | ELSE |
316 | ELSE |
339 | icons16(grayIcons, 54, x + iconPad, btnTop + iconPad) |
317 | Icons.draw(grayIcons, 54, x + iconPad, btnTop + iconPad) |
340 | END; |
318 | END; |
Line 341... | Line 319... | ||
341 | INC(x, toolBtnSize + 5); |
319 | INC(x, toolBtnSize + 5); |
342 | IF runScript # "" THEN |
320 | IF runScript # "" THEN |
343 | icons16(icons, 53, x + iconPad, btnTop + iconPad) |
321 | Icons.draw(icons, 53, x + iconPad, btnTop + iconPad) |
344 | ELSE |
322 | ELSE |
345 | icons16(grayIcons, 53, x + iconPad, btnTop + iconPad) |
323 | Icons.draw(grayIcons, 53, x + iconPad, btnTop + iconPad) |
346 | END |
324 | END |
347 | END toolbarIcons; |
325 | END toolbarIcons; |
348 | 326 | ||
Line 349... | Line 327... | ||
349 | 327 | ||
Line 368... | Line 346... | ||
368 | confirm := FALSE |
346 | confirm := FALSE |
369 | END; |
347 | END; |
370 | T.draw(text); |
348 | T.draw(text); |
371 | K.ClientSize(width, height); |
349 | K.ClientSize(width, height); |
372 | y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2; |
350 | y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2; |
373 | K.DrawRect(LEFT, TOP + canvas.height + scrollWidth - 1, 16*fontWidth, BOTTOM - scrollWidth + 1, winColor); |
351 | K.DrawRect(LEFT, TOP + canvas.height + scrollWidth - 1, 16*fontWidth, BOTTOM - scrollWidth + 1, K.winColor); |
374 | WritePos(y); |
352 | WritePos(y); |
Line 375... | Line 353... | ||
375 | 353 | ||
376 | IF modified # text.modified THEN |
354 | IF modified # text.modified THEN |
377 | WriteModified(width - 9*fontWidth, y) |
355 | WriteModified(width - 9*fontWidth, y) |
Line 419... | Line 397... | ||
419 | VAR |
397 | VAR |
420 | y, right, bottom, color: INTEGER; |
398 | y, right, bottom, color: INTEGER; |
421 | BEGIN |
399 | BEGIN |
422 | right := left + EditBox_Width + SEARCH_PADDING*2; |
400 | right := left + EditBox_Width + SEARCH_PADDING*2; |
423 | bottom := top + 395 + btnHeight + SEARCH_PADDING; |
401 | bottom := top + 395 + btnHeight + SEARCH_PADDING; |
424 | color := T.colors.border; |
402 | color := K.borderColor; |
425 | Rect(left, top, right, bottom, color); |
403 | Rect(left, top, right, bottom, color); |
426 | K.CreateButton(btnCloseFind, right - 20, top, 20, 20, 0EF999FH, ""); |
404 | K.CreateButton(btnCloseFind, right - 20, top, 20, 20, 0EF999FH, ""); |
427 | K.DrawLine(right - 14, top + 5, right - 5, top + 14, 0FFFFFFH); |
405 | K.DrawLine(right - 14, top + 5, right - 5, top + 14, 0FFFFFFH); |
428 | K.DrawLine(right - 15, top + 5, right - 5, top + 15, 0FFFFFFH); |
406 | K.DrawLine(right - 15, top + 5, right - 5, top + 15, 0FFFFFFH); |
429 | K.DrawLine(right - 15, top + 6, right - 6, top + 15, 0FFFFFFH); |
407 | K.DrawLine(right - 15, top + 6, right - 6, top + 15, 0FFFFFFH); |
Line 431... | Line 409... | ||
431 | K.DrawLine(right - 15, top + 15, right - 5, top + 5, 0FFFFFFH); |
409 | K.DrawLine(right - 15, top + 15, right - 5, top + 5, 0FFFFFFH); |
432 | K.DrawLine(right - 14, top + 15, right - 5, top + 6, 0FFFFFFH); |
410 | K.DrawLine(right - 14, top + 15, right - 5, top + 6, 0FFFFFFH); |
Line 433... | Line 411... | ||
433 | 411 | ||
434 | INC(top, 15); |
412 | INC(top, 15); |
435 | INC(left, SEARCH_PADDING); |
413 | INC(left, SEARCH_PADDING); |
436 | K.DrawText866(left, top, 0, "find"); |
414 | K.DrawText866(left, top, K.textColor, "find"); |
437 | K.DrawText866(left, top + 55, 0, "replace with"); |
415 | K.DrawText866(left, top + 55, K.textColor, "replace with"); |
438 | K.CreateButton(btnFindEdit + ORD({30}), left, top + 20, EditBox_Width, fontHeight + 5, 0, ""); |
416 | K.CreateButton(btnFindEdit + ORD({30}), left, top + 20, EditBox_Width, fontHeight + 5, 0, ""); |
439 | K.CreateButton(btnReplaceEdit + ORD({30}), left, top + 75, EditBox_Width, fontHeight + 5, 0, ""); |
417 | K.CreateButton(btnReplaceEdit + ORD({30}), left, top + 75, EditBox_Width, fontHeight + 5, 0, ""); |
440 | K.DrawText866(left, top + 330, 0, "go to line"); |
418 | K.DrawText866(left, top + 330, K.textColor, "go to line"); |
441 | K.CreateButton(btnGotoEdit + ORD({30}), left, top + 350, EditBox_Width, fontHeight + 5, 0, ""); |
419 | K.CreateButton(btnGotoEdit + ORD({30}), left, top + 350, EditBox_Width, fontHeight + 5, 0, ""); |
442 | BKW.top_s := BKW.top_s MOD 65536 + (top + 110) * 65536; |
420 | BKW.top_s := BKW.top_s MOD 65536 + (top + 110) * 65536; |
443 | CS.top_s := CS.top_s MOD 65536 + (top + 140) * 65536; |
421 | CS.top_s := CS.top_s MOD 65536 + (top + 140) * 65536; |
444 | WH.top_s := WH.top_s MOD 65536 + (top + 170) * 65536; |
422 | WH.top_s := WH.top_s MOD 65536 + (top + 170) * 65536; |
Line 452... | Line 430... | ||
452 | ReplaceEdit.left := left; |
430 | ReplaceEdit.left := left; |
453 | GotoEdit.left := left; |
431 | GotoEdit.left := left; |
454 | box_lib.edit_box_draw(FindEdit); |
432 | box_lib.edit_box_draw(FindEdit); |
455 | box_lib.edit_box_draw(ReplaceEdit); |
433 | box_lib.edit_box_draw(ReplaceEdit); |
456 | box_lib.edit_box_draw(GotoEdit); |
434 | box_lib.edit_box_draw(GotoEdit); |
457 | box_lib.check_box_draw2(BKW); K.DrawText866(left + 20, top + 110, 0, "backward"); |
435 | box_lib.check_box_draw2(BKW); K.DrawText866(left + 20, top + 110, K.textColor, "backward"); |
458 | box_lib.check_box_draw2(CS); K.DrawText866(left + 20, top + 140, 0, "match case"); |
436 | box_lib.check_box_draw2(CS); K.DrawText866(left + 20, top + 140, K.textColor, "match case"); |
459 | box_lib.check_box_draw2(WH); K.DrawText866(left + 20, top + 170, 0, "whole word"); |
437 | box_lib.check_box_draw2(WH); K.DrawText866(left + 20, top + 170, K.textColor, "whole word"); |
460 | y := top + 200; |
438 | y := top + 200; |
461 | K.CreateButton(btnFindNext, left, y, btnWidth, btnHeight, btnColor, "next"); INC(y, btnHeight + 10); |
439 | K.CreateButton(btnFindNext, left, y, btnWidth, btnHeight, K.btnColor, "next"); INC(y, btnHeight + 10); |
462 | K.CreateButton(btnReplace, left, y, btnWidth, btnHeight, btnColor, "replace"); INC(y, btnHeight + 10); |
440 | K.CreateButton(btnReplace, left, y, btnWidth, btnHeight, K.btnColor, "replace"); INC(y, btnHeight + 10); |
463 | K.CreateButton(btnReplaceAll, left, y, btnWidth + 5*fontWidth - 2, btnHeight, btnColor, "replace all"); |
441 | K.CreateButton(btnReplaceAll, left, y, btnWidth + 5*fontWidth - 2, btnHeight, K.btnColor, "replace all"); |
464 | K.CreateButton(btnGoto, left, top + 380, btnWidth, btnHeight, btnColor, "go"); |
442 | K.CreateButton(btnGoto, left, top + 380, btnWidth, btnHeight, K.btnColor, "go"); |
465 | END SearchPanel; |
443 | END SearchPanel; |
Line 466... | Line -... | ||
466 | - | ||
467 | - | ||
468 | PROCEDURE gray (icons: INTEGER); |
- | |
469 | VAR |
- | |
470 | sizeX, sizeY, data, x, y: INTEGER; |
- | |
471 | b, g, r, gr: BYTE; |
- | |
472 | BEGIN |
- | |
473 | LibImg.GetInf(icons, sizeX, sizeY, data); |
- | |
474 | FOR y := 0 TO sizeY - 1 DO |
- | |
475 | FOR x := 0 TO sizeX - 1 DO |
- | |
476 | SYSTEM.GET8(data, b); |
- | |
477 | SYSTEM.GET8(data + 1, g); |
- | |
478 | SYSTEM.GET8(data + 2, r); |
- | |
479 | gr := (r + g + b) DIV 3; |
- | |
480 | SYSTEM.PUT8(data, gr); |
- | |
481 | SYSTEM.PUT8(data + 1, gr); |
- | |
482 | SYSTEM.PUT8(data + 2, gr); |
- | |
483 | INC(data, 3); |
- | |
484 | END |
- | |
485 | END |
- | |
486 | END gray; |
- | |
487 | - | ||
488 | - | ||
489 | PROCEDURE iconsBackColor (icons: INTEGER); |
- | |
490 | VAR |
- | |
491 | sizeX, sizeY, data, x, y: INTEGER; |
- | |
492 | b, g, r: BYTE; |
- | |
493 | BEGIN |
- | |
494 | LibImg.GetInf(icons, sizeX, sizeY, data); |
- | |
495 | FOR y := 0 TO sizeY - 1 DO |
- | |
496 | FOR x := 0 TO sizeX - 1 DO |
- | |
497 | SYSTEM.GET8(data, b); |
- | |
498 | SYSTEM.GET8(data + 1, g); |
- | |
499 | SYSTEM.GET8(data + 2, r); |
- | |
500 | IF b + g + r = 765 THEN |
- | |
501 | b := toolbarColor MOD 256; |
- | |
502 | g := toolbarColor DIV 256 MOD 256; |
- | |
503 | r := toolbarColor DIV 65536 MOD 256 |
- | |
504 | END; |
- | |
505 | SYSTEM.PUT8(data, b); |
- | |
506 | SYSTEM.PUT8(data + 1, g); |
- | |
507 | SYSTEM.PUT8(data + 2, r); |
- | |
508 | INC(data, 3); |
- | |
509 | END |
- | |
510 | END |
- | |
511 | END iconsBackColor; |
- | |
512 | 444 | ||
513 | 445 | ||
514 | PROCEDURE draw_window; |
- | |
515 | CONST |
446 | PROCEDURE draw_window; |
516 | selMenuColor = 0CCE8FFH; |
447 | CONST |
517 | iconPad = (toolBtnSize - 16) DIV 2; |
448 | iconPad = (toolBtnSize - 16) DIV 2; |
Line 518... | Line 449... | ||
518 | VAR |
449 | VAR |
519 | width, height, x, y: INTEGER; |
450 | width, height, x, y: INTEGER; |
520 | 451 | ||
521 | 452 | ||
522 | PROCEDURE drawToolbarBtn (id, x: INTEGER); |
453 | PROCEDURE drawToolbarBtn (id, x: INTEGER); |
523 | BEGIN |
454 | BEGIN |
524 | K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, toolbarColor); |
455 | K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, K.toolbarColor); |
Line 525... | Line 456... | ||
525 | K.DrawLine(x, btnTop + toolBtnSize, x + toolBtnSize, btnTop + toolBtnSize, 0808080H); |
456 | K.DrawLine(x, btnTop + toolBtnSize, x + toolBtnSize, btnTop + toolBtnSize, K.shadowColor); |
526 | K.DrawLine(x + toolBtnSize, btnTop, x + toolBtnSize, btnTop + toolBtnSize, 0808080H); |
457 | K.DrawLine(x + toolBtnSize, btnTop, x + toolBtnSize, btnTop + toolBtnSize, K.shadowColor); |
527 | K.CreateButton(id + ORD({30}), x, btnTop, toolBtnSize, toolBtnSize, btnColor, ""); |
458 | K.CreateButton(id + ORD({30}), x, btnTop, toolBtnSize, toolBtnSize, K.btnColor, ""); |
528 | END drawToolbarBtn; |
459 | END drawToolbarBtn; |
529 | 460 | ||
530 | 461 | ||
531 | PROCEDURE drawMainMenu (menu: Menu.tMenu; x: INTEGER; btn: INTEGER; caption: ARRAY OF WCHAR); |
462 | PROCEDURE drawMainMenu (menu: Menu.tMenu; x: INTEGER; btn: INTEGER; caption: ARRAY OF WCHAR); |
532 | VAR |
463 | VAR |
533 | menuColor, n: INTEGER; |
464 | menuColor, n: INTEGER; |
534 | BEGIN |
465 | BEGIN |
535 | IF menu.tid # 0 THEN |
466 | IF menu.tid # 0 THEN |
536 | menuColor := selMenuColor |
467 | menuColor := K.selMenuColor |
- | 468 | ELSE |
|
537 | ELSE |
469 | menuColor := K.winColor |
Line 538... | Line 470... | ||
538 | menuColor := winColor |
470 | END; |
539 | END; |
471 | n := LENGTH(caption); |
540 | n := LENGTH(caption); |
472 | K.DrawRect(x, 0, n*fontWidth + 2, MainMenuHeight, menuColor); |
541 | K.DrawRect(x, 0, n*fontWidth + 2, MainMenuHeight, menuColor); |
473 | K.CreateButton(btn + ORD({30}), x, 0, n*fontWidth + 2, MainMenuHeight, K.btnColor, ""); |
542 | K.CreateButton(btn + ORD({30}), x, 0, n*fontWidth + 2, MainMenuHeight, btnColor, caption); |
474 | K.DrawText(x + 1, (MainMenuHeight - fontHeight) DIV 2 + 1, K.textColor, caption) |
543 | END drawMainMenu; |
475 | END drawMainMenu; |
Line 544... | Line 476... | ||
544 | 476 | ||
545 | 477 | ||
546 | BEGIN |
478 | BEGIN |
Line 547... | Line 479... | ||
547 | K.BeginDraw; |
479 | K.BeginDraw; |
548 | K.CreateWindow(50 + K.GetTickCount() MOD 128, 50 + K.GetTickCount() MOD 128, winWidth, winHeight, winColor, 73H, 0, 0, header); |
480 | K.CreateWindow(50 + K.GetTickCount() MOD 128, 50 + K.GetTickCount() MOD 128, winWidth, winHeight, K.winColor, 73H, 0, 0, header); |
549 | IF (text # NIL) & ~K.RolledUp() THEN |
481 | IF (text # NIL) & ~K.RolledUp() THEN |
550 | confirm := FALSE; |
482 | confirm := FALSE; |
Line 563... | Line 495... | ||
563 | drawMainMenu(menuTools, menuToolsX, btnTools, "tools"); |
495 | drawMainMenu(menuTools, menuToolsX, btnTools, "tools"); |
Line 564... | Line 496... | ||
564 | 496 | ||
Line 565... | Line 497... | ||
565 | x := searchLeft; |
497 | x := searchLeft; |
566 | 498 | ||
567 | drawToolbarBtn(btnNew, x); |
499 | drawToolbarBtn(btnNew, x); |
Line 568... | Line 500... | ||
568 | icons16(icons, 2, x + iconPad, btnTop + iconPad); |
500 | Icons.draw(icons, 2, x + iconPad, btnTop + iconPad); |
569 | INC(x, toolBtnSize + 5); |
501 | INC(x, toolBtnSize + 5); |
570 | 502 | ||
Line 571... | Line 503... | ||
571 | drawToolbarBtn(btnOpen, x); |
503 | drawToolbarBtn(btnOpen, x); |
572 | icons16(icons, 0, x + iconPad, btnTop + iconPad); |
504 | Icons.draw(icons, 0, x + iconPad, btnTop + iconPad); |
Line 573... | Line 505... | ||
573 | INC(x, toolBtnSize + 5); |
505 | INC(x, toolBtnSize + 5); |
574 | 506 | ||
575 | drawToolbarBtn(btnSave, x); |
507 | drawToolbarBtn(btnSave, x); |
Line 576... | Line 508... | ||
576 | INC(x, toolBtnSize + 5 + toolbarDelim); |
508 | INC(x, toolBtnSize + 5 + toolbarDelim); |
577 | 509 | ||
Line 578... | Line 510... | ||
578 | drawToolbarBtn(btnSearch, x); |
510 | drawToolbarBtn(btnSearch, x); |
579 | icons16(icons, 49, x + iconPad, btnTop + iconPad); |
511 | Icons.draw(icons, 49, x + iconPad, btnTop + iconPad); |
Line 580... | Line 512... | ||
580 | INC(x, toolBtnSize + 5 + toolbarDelim); |
512 | INC(x, toolBtnSize + 5 + toolbarDelim); |
581 | - | ||
582 | drawToolbarBtn(btnUndo, x); |
513 | |
Line 583... | Line 514... | ||
583 | INC(x, toolBtnSize + 5); |
514 | drawToolbarBtn(btnUndo, x); |
584 | - | ||
585 | drawToolbarBtn(btnRedo, x); |
515 | INC(x, toolBtnSize + 5); |
Line 586... | Line 516... | ||
586 | INC(x, toolBtnSize + 5 + toolbarDelim); |
516 | |
587 | 517 | drawToolbarBtn(btnRedo, x); |
|
588 | drawToolbarBtn(btnUpper, x); |
518 | INC(x, toolBtnSize + 5 + toolbarDelim); |
Line 589... | Line 519... | ||
589 | K.DrawText69(x + (toolBtnSize - 12) DIV 2, btnTop + (toolBtnSize - 9) DIV 2 + 2, 0, "AB"); |
519 | |
590 | INC(x, toolBtnSize + 5); |
520 | drawToolbarBtn(btnUpper, x); |
591 | 521 | INC(x, toolBtnSize + 5); |
|
Line 592... | Line 522... | ||
592 | drawToolbarBtn(btnLower, x); |
522 | |
593 | K.DrawText69(x + (toolBtnSize - 12) DIV 2, btnTop + (toolBtnSize - 9) DIV 2 + 2, 0, "ab"); |
523 | drawToolbarBtn(btnLower, x); |
594 | INC(x, toolBtnSize + 5 + toolbarDelim); |
524 | INC(x, toolBtnSize + 5 + toolbarDelim); |
595 | 525 | ||
596 | drawToolbarBtn(btnBuild, x); |
526 | drawToolbarBtn(btnBuild, x); |
597 | icons16(icons, 54, x + iconPad, btnTop + iconPad); |
527 | Icons.draw(icons, 54, x + iconPad, btnTop + iconPad); |
598 | INC(x, toolBtnSize + 5); |
528 | INC(x, toolBtnSize + 5); |
599 | 529 | ||
600 | drawToolbarBtn(btnRun, x); |
530 | drawToolbarBtn(btnRun, x); |
- | 531 | Icons.draw(icons, 53, x + iconPad, btnTop + iconPad); |
|
- | 532 | INC(x, toolBtnSize + 5); |
|
- | 533 | ||
Line 601... | Line 534... | ||
601 | icons16(icons, 53, x + iconPad, btnTop + iconPad); |
534 | K.CreateButton(btnUp, LEFT + canvas.width - 1, TOP, scrollWidth - 1, scrollWidth, K.btnColor, 0X); |
602 | INC(x, toolBtnSize + 5); |
535 | K.DrawText69(LEFT + canvas.width - 1 + (scrollWidth - 6) DIV 2, TOP + (scrollWidth - 9) DIV 2, K.btnTextColor, 18X); |
603 | 536 | K.CreateButton(btnDown, LEFT + canvas.width - 1, TOP + canvas.height - scrollWidth - 1, scrollWidth - 1, scrollWidth, K.btnColor, 0X); |
|
604 | K.CreateButton(btnUp, LEFT + canvas.width - 1, TOP, scrollWidth - 1, scrollWidth, btnColor, 0X); |
537 | K.DrawText69(LEFT + canvas.width - 1 + (scrollWidth - 6) DIV 2, TOP + canvas.height - scrollWidth + (scrollWidth - 9) DIV 2, K.btnTextColor, 19X); |
605 | K.DrawText69(LEFT + canvas.width - 1 + (scrollWidth - 6) DIV 2, TOP + (scrollWidth - 9) DIV 2, 0, 18X); |
538 | |
606 | K.CreateButton(btnDown, LEFT + canvas.width - 1, TOP + canvas.height - scrollWidth - 1, scrollWidth - 1, scrollWidth, btnColor, 0X); |
539 | K.CreateButton(btnLeft, LEFT, TOP + canvas.height - 1, scrollWidth, scrollWidth - 1, K.btnColor, 0X); |
607 | K.DrawText69(LEFT + canvas.width - 1 + (scrollWidth - 6) DIV 2, TOP + canvas.height - scrollWidth + (scrollWidth - 9) DIV 2, 0, 19X); |
540 | K.DrawText69(LEFT + (scrollWidth - 6) DIV 2, TOP + canvas.height - 1 + (scrollWidth - 9) DIV 2 + 1, K.btnTextColor, 1BX); |
608 | 541 | K.CreateButton(btnRight, LEFT + canvas.width - scrollWidth - 1, TOP + canvas.height - 1, scrollWidth, scrollWidth - 1, K.btnColor, 0X); |
|
609 | K.CreateButton(btnLeft, LEFT, TOP + canvas.height - 1, scrollWidth, scrollWidth - 1, btnColor, 0X); |
542 | K.DrawText69(LEFT + canvas.width - scrollWidth - 1 + (scrollWidth - 6) DIV 2, TOP + canvas.height - 1 + (scrollWidth - 9) DIV 2 + 1, K.btnTextColor, 1AX); |
610 | K.DrawText69(LEFT + (scrollWidth - 6) DIV 2, TOP + canvas.height - 1 + (scrollWidth - 9) DIV 2 + 1, 0, 1BX); |
543 | |
Line 611... | Line 544... | ||
611 | K.CreateButton(btnRight, LEFT + canvas.width - scrollWidth - 1, TOP + canvas.height - 1, scrollWidth, scrollWidth - 1, btnColor, 0X); |
544 | K.PutPixel(LEFT + canvas.width + scrollWidth - 2, TOP, K.winColor); |
612 | K.DrawText69(LEFT + canvas.width - scrollWidth - 1 + (scrollWidth - 6) DIV 2, TOP + canvas.height - 1 + (scrollWidth - 9) DIV 2 + 1, 0, 1AX); |
545 | K.PutPixel(LEFT, TOP + canvas.height + scrollWidth - 2, K.winColor); |
613 | 546 | ||
614 | y := (btnHeight - fontHeight) DIV 2 + btnTop; |
547 | y := (btnHeight - fontHeight) DIV 2 + btnTop; |
615 | CASE text.enc OF |
548 | CASE text.enc OF |
616 | |E.UTF8: K.DrawText866(width - 6*fontWidth, y, 0, "UTF-8") |
549 | |E.UTF8: K.DrawText866(width - 6*fontWidth, y, K.textColor, "UTF-8") |
617 | |E.UTF8BOM: K.DrawText866(width - 10*fontWidth, y, 0, "UTF-8-BOM") |
550 | |E.UTF8BOM: K.DrawText866(width - 10*fontWidth, y, K.textColor, "UTF-8-BOM") |
618 | |E.CP866: K.DrawText866(width - 6*fontWidth, y, 0, "CP866") |
551 | |E.CP866: K.DrawText866(width - 6*fontWidth, y, K.textColor, "CP866") |
Line 761... | Line 694... | ||
761 | confirm := TRUE; |
694 | confirm := TRUE; |
762 | left := (canvas.width - width) DIV 2 + LEFT; |
695 | left := (canvas.width - width) DIV 2 + LEFT; |
763 | top := (canvas.height - height) DIV 2 + TOP; |
696 | top := (canvas.height - height) DIV 2 + TOP; |
764 | right := left + width - 1; |
697 | right := left + width - 1; |
765 | bottom := top + height - 1; |
698 | bottom := top + height - 1; |
766 | K.DrawRect(left, top, width, height, winColor); |
699 | K.DrawRect(left, top, width, height, K.winColor); |
767 | Rect(left, top, right, bottom, lineColor); |
700 | Rect(left, top, right, bottom, lineColor); |
768 | K.DrawText866(left + (width - 10*fontWidth) DIV 2, top + 10, 0, "save file?"); |
701 | K.DrawText866(left + (width - 10*fontWidth) DIV 2, top + 10, K.textColor, "save file?"); |
769 | K.CreateButton(btnYes, left + 10, top + 35, btnWidth, btnHeight, btnColor, "yes"); |
702 | K.CreateButton(btnYes, left + 10, top + 35, btnWidth, btnHeight, K.btnColor, "yes"); |
770 | K.CreateButton(btnNo, left + 20 + btnWidth, top + 35, btnWidth, btnHeight, btnColor, "no"); |
703 | K.CreateButton(btnNo, left + 20 + btnWidth, top + 35, btnWidth, btnHeight, K.btnColor, "no"); |
771 | END Confirm; |
704 | END Confirm; |
Line 772... | Line 705... | ||
772 | 705 | ||
773 | 706 | ||
Line 1119... | Line 1052... | ||
1119 | idx: INTEGER; |
1052 | idx: INTEGER; |
1120 | BEGIN |
1053 | BEGIN |
1121 | menu := List.create(NIL); |
1054 | menu := List.create(NIL); |
1122 | Menu.AddMenuItem(menu, menuNumbers, "line numbers"); |
1055 | Menu.AddMenuItem(menu, menuNumbers, "line numbers"); |
1123 | Menu.delimiter(menu); |
1056 | Menu.delimiter(menu); |
1124 | (*Menu.AddMenuItem(menu, menuSettings, "settings");*) |
- | |
Line 1125... | Line 1057... | ||
1125 | 1057 | ||
1126 | colors := Ini.sections.first(Ini.tSection); |
1058 | colors := Ini.sections.first(Ini.tSection); |
1127 | idx := menuColors; |
1059 | idx := menuColors; |
1128 | WHILE colors # NIL DO |
1060 | WHILE colors # NIL DO |
Line 1237... | Line 1169... | ||
1237 | Menu.setCheck(menu, menuUTF8, ORD(text.enc = E.UTF8)*2); |
1169 | Menu.setCheck(menu, menuUTF8, ORD(text.enc = E.UTF8)*2); |
1238 | Menu.setCheck(menu, menuCP866, ORD(text.enc = E.CP866)*2); |
1170 | Menu.setCheck(menu, menuCP866, ORD(text.enc = E.CP866)*2); |
1239 | Menu.setCheck(menu, menuWin1251, ORD(text.enc = E.W1251)*2); |
1171 | Menu.setCheck(menu, menuWin1251, ORD(text.enc = E.W1251)*2); |
1240 | INC(x, menuEncodingX) |
1172 | INC(x, menuEncodingX) |
1241 | ELSIF menu = menuView THEN |
1173 | ELSIF menu = menuView THEN |
1242 | (*Menu.setEnabled(menu, menuSettings, FALSE);*) |
- | |
1243 | Menu.setCheck(menu, menuNumbers, ORD(text.numbers)); |
1174 | Menu.setCheck(menu, menuNumbers, ORD(text.numbers)); |
1244 | FOR i := 0 TO Ini.sections.count - 1 DO |
1175 | FOR i := 0 TO Ini.sections.count - 1 DO |
1245 | Menu.setCheck(menu, menuColors + i, ORD(Ini.curSectionNum = i)*2) |
1176 | Menu.setCheck(menu, menuColors + i, ORD(Ini.curSectionNum = i)*2) |
1246 | END; |
1177 | END; |
1247 | INC(x, menuViewX) |
1178 | INC(x, menuViewX) |
Line 1278... | Line 1209... | ||
1278 | key: INTEGER; |
1209 | key: INTEGER; |
1279 | msState: SET; |
1210 | msState: SET; |
1280 | scroll: INTEGER; |
1211 | scroll: INTEGER; |
1281 | err: INTEGER; |
1212 | err: INTEGER; |
1282 | fileName, filePath: RW.tFileName; |
1213 | fileName, filePath: RW.tFileName; |
- | 1214 | cliWidth, cliHeight: INTEGER; |
|
1283 | resized: BOOLEAN; |
1215 | resized: BOOLEAN; |
1284 | firstClickX, firstClickY, time: INTEGER; |
1216 | firstClickX, firstClickY, time: INTEGER; |
1285 | BEGIN |
1217 | BEGIN |
- | 1218 | K.GetSystemColors; |
|
- | 1219 | Icons.get(icons, grayIcons); |
|
1286 | modified := FALSE; |
1220 | modified := FALSE; |
1287 | mainTID := K.ThreadID(); |
1221 | mainTID := K.ThreadID(); |
1288 | K.SetIPC(IPC); |
1222 | K.SetIPC(IPC); |
1289 | U.ptr2str(K.GetName(), AppPath); |
1223 | U.ptr2str(K.GetName(), AppPath); |
1290 | (* U.getPath(AppPath, fileName); |
- | |
1291 | U.append8(fileName, "/Icons16.png");*) |
- | |
1292 | icons := LibImg.LoadFromFile("/rd/1/Icons16.png", 16, y); |
- | |
1293 | grayIcons := LibImg.LoadFromFile("/rd/1/Icons16.png", 16, y); |
- | |
1294 | gray(grayIcons); |
- | |
1295 | iconsBackColor(icons); |
- | |
1296 | iconsBackColor(grayIcons); |
- | |
1297 | Ini.load(AppPath); |
1224 | Ini.load(AppPath); |
1298 | K.SetEventsMask({0, 1, 2, 5, 6, 31}); |
1225 | K.SetEventsMask({0, 1, 2, 5, 6, 31}); |
1299 | LeftButtonUp; |
1226 | LeftButtonUp; |
1300 | resized := FALSE; |
1227 | resized := FALSE; |
1301 | shift := {}; |
1228 | shift := {}; |
1302 | winWidth := minWinWidth; |
1229 | winWidth := minWinWidth; |
1303 | winHeight := minWinHeight; |
1230 | winHeight := minWinHeight; |
- | 1231 | cliWidth := winWidth; |
|
- | 1232 | cliHeight := winHeight; |
|
1304 | LEFT := 10; |
1233 | LEFT := 10; |
1305 | canvas := G.CreateCanvas(winWidth - (LEFT + RIGHT + 10), winHeight - (TOP + BOTTOM + 4) - K.SkinHeight()); |
1234 | canvas := G.CreateCanvas(winWidth - (LEFT + RIGHT + 10), winHeight - (TOP + BOTTOM + 4) - K.SkinHeight()); |
1306 | font := G.CreateFont(1, "", {}); |
1235 | font := G.CreateFont(1, "", {}); |
1307 | G.SetFont(canvas, font); |
1236 | G.SetFont(canvas, font); |
1308 | T.init(NIL); |
1237 | T.init(NIL); |
Line 1328... | Line 1257... | ||
1328 | U.getPath(fileName, filePath) |
1257 | U.getPath(fileName, filePath) |
1329 | END |
1258 | END |
1330 | END; |
1259 | END; |
1331 | OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, ""); |
1260 | OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, ""); |
Line 1332... | Line 1261... | ||
1332 | 1261 | ||
1333 | vScroll := Scroll.create(scrollWidth, canvas.height - scrollWidth*2 + 1, 0A0A0A0H, winColor); |
1262 | vScroll := Scroll.create(scrollWidth, canvas.height - scrollWidth*2 + 1); |
1334 | hScroll := Scroll.create(canvas.width - scrollWidth*2, scrollWidth, 0A0A0A0H, winColor); |
1263 | hScroll := Scroll.create(canvas.width - scrollWidth*2, scrollWidth); |
1335 | T.resize(canvas.width, canvas.height); |
1264 | T.resize(canvas.width, canvas.height); |
1336 | T.SetPos(text, 0, 0); |
1265 | T.SetPos(text, 0, 0); |
1337 | confirm := FALSE; |
1266 | confirm := FALSE; |
1338 | notFound := FALSE; |
1267 | notFound := FALSE; |
Line 1349... | Line 1278... | ||
1349 | runScript := ""; |
1278 | runScript := ""; |
1350 | debugScript := ""; |
1279 | debugScript := ""; |
1351 | WHILE TRUE DO |
1280 | WHILE TRUE DO |
1352 | CASE K.WaitForEvent() OF |
1281 | CASE K.WaitForEvent() OF |
1353 | |1: |
1282 | |1: |
- | 1283 | K.GetSystemColors; |
|
- | 1284 | Icons.get(icons, grayIcons); |
|
1354 | IF ~K.RolledUp() THEN |
1285 | IF ~K.RolledUp() THEN |
1355 | K.WinSize(width, height); |
1286 | K.ClientSize(width, height); |
1356 | IF (width # winWidth) OR (height # winHeight) THEN |
1287 | IF (width # cliWidth) OR (height # cliHeight) THEN |
- | 1288 | cliWidth := width; |
|
- | 1289 | cliHeight := height; |
|
1357 | resize; |
1290 | resize; |
1358 | resized := TRUE |
1291 | resized := TRUE |
1359 | END; |
1292 | END; |
1360 | K.SetEventsMask({0, 1, 2, 5, 6, 31}) |
1293 | K.SetEventsMask({0, 1, 2, 5, 6, 31}) |
1361 | ELSE |
1294 | ELSE |