Expose width/height in TApplication constructor, attempt on ECMA48
[fanfix.git] / src / jexer / TEditColorThemeWindow.java
1 /*
2 * Jexer - Java Text User Interface
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (C) 2017 Kevin Lamonte
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 *
26 * @author Kevin Lamonte [kevin.lamonte@gmail.com]
27 * @version 1
28 */
29 package jexer;
30
31 import java.util.List;
32 import java.util.ResourceBundle;
33
34 import jexer.bits.Color;
35 import jexer.bits.ColorTheme;
36 import jexer.bits.CellAttributes;
37 import jexer.bits.GraphicsChars;
38 import jexer.event.TKeypressEvent;
39 import jexer.event.TMouseEvent;
40 import static jexer.TKeypress.*;
41
42 /**
43 * TEditColorThemeWindow provides an easy UI for users to alter the running
44 * color theme.
45 *
46 */
47 public class TEditColorThemeWindow extends TWindow {
48
49 /**
50 * Translated strings.
51 */
52 private static final ResourceBundle i18n = ResourceBundle.getBundle(TEditColorThemeWindow.class.getName());
53
54 /**
55 * The foreground color picker.
56 */
57 class ForegroundPicker extends TWidget {
58
59 /**
60 * The selected color.
61 */
62 Color color;
63
64 /**
65 * The bold flag.
66 */
67 boolean bold;
68
69 /**
70 * Public constructor.
71 *
72 * @param parent parent widget
73 * @param x column relative to parent
74 * @param y row relative to parent
75 * @param width width of text area
76 * @param height height of text area
77 */
78 public ForegroundPicker(final TWidget parent, final int x,
79 final int y, final int width, final int height) {
80
81 super(parent, x, y, width, height);
82 }
83
84 /**
85 * Get the X grid coordinate for this color.
86 *
87 * @param color the Color value
88 * @return the X coordinate
89 */
90 private int getXColorPosition(final Color color) {
91 if (color.equals(Color.BLACK)) {
92 return 2;
93 } else if (color.equals(Color.BLUE)) {
94 return 5;
95 } else if (color.equals(Color.GREEN)) {
96 return 8;
97 } else if (color.equals(Color.CYAN)) {
98 return 11;
99 } else if (color.equals(Color.RED)) {
100 return 2;
101 } else if (color.equals(Color.MAGENTA)) {
102 return 5;
103 } else if (color.equals(Color.YELLOW)) {
104 return 8;
105 } else if (color.equals(Color.WHITE)) {
106 return 11;
107 }
108 throw new IllegalArgumentException("Invalid color: " + color);
109 }
110
111 /**
112 * Get the Y grid coordinate for this color.
113 *
114 * @param color the Color value
115 * @param bold if true use bold color
116 * @return the Y coordinate
117 */
118 private int getYColorPosition(final Color color, final boolean bold) {
119 int dotY = 1;
120 if (color.equals(Color.RED)) {
121 dotY = 2;
122 } else if (color.equals(Color.MAGENTA)) {
123 dotY = 2;
124 } else if (color.equals(Color.YELLOW)) {
125 dotY = 2;
126 } else if (color.equals(Color.WHITE)) {
127 dotY = 2;
128 }
129 if (bold) {
130 dotY += 2;
131 }
132 return dotY;
133 }
134
135 /**
136 * Get the bold value based on Y grid coordinate.
137 *
138 * @param dotY the Y coordinate
139 * @return the bold value
140 */
141 private boolean getBoldFromPosition(final int dotY) {
142 if (dotY > 2) {
143 return true;
144 }
145 return false;
146 }
147
148 /**
149 * Get the color based on (X, Y) grid coordinate.
150 *
151 * @param dotX the X coordinate
152 * @param dotY the Y coordinate
153 * @return the Color value
154 */
155 private Color getColorFromPosition(final int dotX, final int dotY) {
156 int y = dotY;
157 if (y > 2) {
158 y -= 2;
159 }
160 if ((1 <= dotX) && (dotX <= 3) && (y == 1)) {
161 return Color.BLACK;
162 }
163 if ((4 <= dotX) && (dotX <= 6) && (y == 1)) {
164 return Color.BLUE;
165 }
166 if ((7 <= dotX) && (dotX <= 9) && (y == 1)) {
167 return Color.GREEN;
168 }
169 if ((10 <= dotX) && (dotX <= 12) && (y == 1)) {
170 return Color.CYAN;
171 }
172 if ((1 <= dotX) && (dotX <= 3) && (y == 2)) {
173 return Color.RED;
174 }
175 if ((4 <= dotX) && (dotX <= 6) && (y == 2)) {
176 return Color.MAGENTA;
177 }
178 if ((7 <= dotX) && (dotX <= 9) && (y == 2)) {
179 return Color.YELLOW;
180 }
181 if ((10 <= dotX) && (dotX <= 12) && (y == 2)) {
182 return Color.WHITE;
183 }
184
185 throw new IllegalArgumentException("Invalid coordinates: "
186 + dotX + ", " + dotY);
187 }
188
189 /**
190 * Draw the foreground colors grid.
191 */
192 @Override
193 public void draw() {
194 CellAttributes border = getWindow().getBorder();
195 CellAttributes background = getWindow().getBackground();
196 CellAttributes attr = new CellAttributes();
197
198 getScreen().drawBox(0, 0, getWidth(), getHeight(), border,
199 background, 1, false);
200
201 attr.setTo(getTheme().getColor("twindow.background.modal"));
202 if (isActive()) {
203 attr.setForeColor(getTheme().getColor("tlabel").getForeColor());
204 attr.setBold(getTheme().getColor("tlabel").isBold());
205 }
206 getScreen().putStringXY(1, 0, i18n.getString("foregroundLabel"),
207 attr);
208
209 // Have to draw the colors manually because the int value matches
210 // SGR, not CGA.
211 attr.reset();
212 attr.setForeColor(Color.BLACK);
213 putStringXY(1, 1, "\u2588\u2588\u2588", attr);
214 attr.setForeColor(Color.BLUE);
215 putStringXY(4, 1, "\u2588\u2588\u2588", attr);
216 attr.setForeColor(Color.GREEN);
217 putStringXY(7, 1, "\u2588\u2588\u2588", attr);
218 attr.setForeColor(Color.CYAN);
219 putStringXY(10, 1, "\u2588\u2588\u2588", attr);
220 attr.setForeColor(Color.RED);
221 putStringXY(1, 2, "\u2588\u2588\u2588", attr);
222 attr.setForeColor(Color.MAGENTA);
223 putStringXY(4, 2, "\u2588\u2588\u2588", attr);
224 attr.setForeColor(Color.YELLOW);
225 putStringXY(7, 2, "\u2588\u2588\u2588", attr);
226 attr.setForeColor(Color.WHITE);
227 putStringXY(10, 2, "\u2588\u2588\u2588", attr);
228
229 attr.setBold(true);
230 attr.setForeColor(Color.BLACK);
231 putStringXY(1, 3, "\u2588\u2588\u2588", attr);
232 attr.setForeColor(Color.BLUE);
233 putStringXY(4, 3, "\u2588\u2588\u2588", attr);
234 attr.setForeColor(Color.GREEN);
235 putStringXY(7, 3, "\u2588\u2588\u2588", attr);
236 attr.setForeColor(Color.CYAN);
237 putStringXY(10, 3, "\u2588\u2588\u2588", attr);
238 attr.setForeColor(Color.RED);
239 putStringXY(1, 4, "\u2588\u2588\u2588", attr);
240 attr.setForeColor(Color.MAGENTA);
241 putStringXY(4, 4, "\u2588\u2588\u2588", attr);
242 attr.setForeColor(Color.YELLOW);
243 putStringXY(7, 4, "\u2588\u2588\u2588", attr);
244 attr.setForeColor(Color.WHITE);
245 putStringXY(10, 4, "\u2588\u2588\u2588", attr);
246
247 // Draw the dot
248 int dotX = getXColorPosition(color);
249 int dotY = getYColorPosition(color, bold);
250 if (color.equals(Color.BLACK) && !bold) {
251 // Use white-on-black for black. All other colors use
252 // black-on-whatever.
253 attr.reset();
254 getScreen().putCharXY(dotX, dotY, GraphicsChars.CP437[0x07],
255 attr);
256 } else {
257 attr.setForeColor(color);
258 attr.setBold(bold);
259 getScreen().putCharXY(dotX, dotY, '\u25D8', attr);
260 }
261 }
262
263 /**
264 * Handle keystrokes.
265 *
266 * @param keypress keystroke event
267 */
268 @Override
269 public void onKeypress(final TKeypressEvent keypress) {
270 if (keypress.equals(kbRight)) {
271 int dotX = getXColorPosition(color);
272 int dotY = getYColorPosition(color, bold);
273 if (dotX < 10) {
274 dotX += 3;
275 }
276 color = getColorFromPosition(dotX, dotY);
277 } else if (keypress.equals(kbLeft)) {
278 int dotX = getXColorPosition(color);
279 int dotY = getYColorPosition(color, bold);
280 if (dotX > 3) {
281 dotX -= 3;
282 }
283 color = getColorFromPosition(dotX, dotY);
284 } else if (keypress.equals(kbUp)) {
285 int dotX = getXColorPosition(color);
286 int dotY = getYColorPosition(color, bold);
287 if (dotY > 1) {
288 dotY--;
289 }
290 color = getColorFromPosition(dotX, dotY);
291 bold = getBoldFromPosition(dotY);
292 } else if (keypress.equals(kbDown)) {
293 int dotX = getXColorPosition(color);
294 int dotY = getYColorPosition(color, bold);
295 if (dotY < 4) {
296 dotY++;
297 }
298 color = getColorFromPosition(dotX, dotY);
299 bold = getBoldFromPosition(dotY);
300 } else {
301 // Pass to my parent
302 super.onKeypress(keypress);
303 return;
304 }
305
306 // Save this update to the local theme.
307 ((TEditColorThemeWindow) getWindow()).saveToEditTheme();
308 }
309
310 /**
311 * Handle mouse press events.
312 *
313 * @param mouse mouse button press event
314 */
315 @Override
316 public void onMouseDown(final TMouseEvent mouse) {
317 if (mouse.isMouseWheelUp()) {
318 // Do this like kbUp
319 int dotX = getXColorPosition(color);
320 int dotY = getYColorPosition(color, bold);
321 if (dotY > 1) {
322 dotY--;
323 }
324 color = getColorFromPosition(dotX, dotY);
325 bold = getBoldFromPosition(dotY);
326 } else if (mouse.isMouseWheelDown()) {
327 // Do this like kbDown
328 int dotX = getXColorPosition(color);
329 int dotY = getYColorPosition(color, bold);
330 if (dotY < 4) {
331 dotY++;
332 }
333 color = getColorFromPosition(dotX, dotY);
334 bold = getBoldFromPosition(dotY);
335 } else if ((mouse.getX() > 0)
336 && (mouse.getX() < getWidth() - 1)
337 && (mouse.getY() > 0)
338 && (mouse.getY() < getHeight() - 1)
339 ) {
340 color = getColorFromPosition(mouse.getX(), mouse.getY());
341 bold = getBoldFromPosition(mouse.getY());
342 } else {
343 // Let parent class handle it.
344 super.onMouseDown(mouse);
345 return;
346 }
347
348 // Save this update to the local theme.
349 ((TEditColorThemeWindow) getWindow()).saveToEditTheme();
350 }
351
352 }
353
354 /**
355 * The background color picker.
356 */
357 class BackgroundPicker extends TWidget {
358
359 /**
360 * The selected color.
361 */
362 Color color;
363
364 /**
365 * Public constructor.
366 *
367 * @param parent parent widget
368 * @param x column relative to parent
369 * @param y row relative to parent
370 * @param width width of text area
371 * @param height height of text area
372 */
373 public BackgroundPicker(final TWidget parent, final int x,
374 final int y, final int width, final int height) {
375
376 super(parent, x, y, width, height);
377 }
378
379 /**
380 * Get the X grid coordinate for this color.
381 *
382 * @param color the Color value
383 * @return the X coordinate
384 */
385 private int getXColorPosition(final Color color) {
386 if (color.equals(Color.BLACK)) {
387 return 2;
388 } else if (color.equals(Color.BLUE)) {
389 return 5;
390 } else if (color.equals(Color.GREEN)) {
391 return 8;
392 } else if (color.equals(Color.CYAN)) {
393 return 11;
394 } else if (color.equals(Color.RED)) {
395 return 2;
396 } else if (color.equals(Color.MAGENTA)) {
397 return 5;
398 } else if (color.equals(Color.YELLOW)) {
399 return 8;
400 } else if (color.equals(Color.WHITE)) {
401 return 11;
402 }
403 throw new IllegalArgumentException("Invalid color: " + color);
404 }
405
406 /**
407 * Get the Y grid coordinate for this color.
408 *
409 * @param color the Color value
410 * @return the Y coordinate
411 */
412 private int getYColorPosition(final Color color) {
413 int dotY = 1;
414 if (color.equals(Color.RED)) {
415 dotY = 2;
416 } else if (color.equals(Color.MAGENTA)) {
417 dotY = 2;
418 } else if (color.equals(Color.YELLOW)) {
419 dotY = 2;
420 } else if (color.equals(Color.WHITE)) {
421 dotY = 2;
422 }
423 return dotY;
424 }
425
426 /**
427 * Get the color based on (X, Y) grid coordinate.
428 *
429 * @param dotX the X coordinate
430 * @param dotY the Y coordinate
431 * @return the Color value
432 */
433 private Color getColorFromPosition(final int dotX, final int dotY) {
434 if ((1 <= dotX) && (dotX <= 3) && (dotY == 1)) {
435 return Color.BLACK;
436 }
437 if ((4 <= dotX) && (dotX <= 6) && (dotY == 1)) {
438 return Color.BLUE;
439 }
440 if ((7 <= dotX) && (dotX <= 9) && (dotY == 1)) {
441 return Color.GREEN;
442 }
443 if ((10 <= dotX) && (dotX <= 12) && (dotY == 1)) {
444 return Color.CYAN;
445 }
446 if ((1 <= dotX) && (dotX <= 3) && (dotY == 2)) {
447 return Color.RED;
448 }
449 if ((4 <= dotX) && (dotX <= 6) && (dotY == 2)) {
450 return Color.MAGENTA;
451 }
452 if ((7 <= dotX) && (dotX <= 9) && (dotY == 2)) {
453 return Color.YELLOW;
454 }
455 if ((10 <= dotX) && (dotX <= 12) && (dotY == 2)) {
456 return Color.WHITE;
457 }
458
459 throw new IllegalArgumentException("Invalid coordinates: "
460 + dotX + ", " + dotY);
461 }
462
463 /**
464 * Draw the background colors grid.
465 */
466 @Override
467 public void draw() {
468 CellAttributes border = getWindow().getBorder();
469 CellAttributes background = getWindow().getBackground();
470 CellAttributes attr = new CellAttributes();
471
472 getScreen().drawBox(0, 0, getWidth(), getHeight(), border,
473 background, 1, false);
474
475 attr.setTo(getTheme().getColor("twindow.background.modal"));
476 if (isActive()) {
477 attr.setForeColor(getTheme().getColor("tlabel").getForeColor());
478 attr.setBold(getTheme().getColor("tlabel").isBold());
479 }
480 getScreen().putStringXY(1, 0, i18n.getString("backgroundLabel"),
481 attr);
482
483 // Have to draw the colors manually because the int value matches
484 // SGR, not CGA.
485 attr.reset();
486 attr.setForeColor(Color.BLACK);
487 putStringXY(1, 1, "\u2588\u2588\u2588", attr);
488 attr.setForeColor(Color.BLUE);
489 putStringXY(4, 1, "\u2588\u2588\u2588", attr);
490 attr.setForeColor(Color.GREEN);
491 putStringXY(7, 1, "\u2588\u2588\u2588", attr);
492 attr.setForeColor(Color.CYAN);
493 putStringXY(10, 1, "\u2588\u2588\u2588", attr);
494 attr.setForeColor(Color.RED);
495 putStringXY(1, 2, "\u2588\u2588\u2588", attr);
496 attr.setForeColor(Color.MAGENTA);
497 putStringXY(4, 2, "\u2588\u2588\u2588", attr);
498 attr.setForeColor(Color.YELLOW);
499 putStringXY(7, 2, "\u2588\u2588\u2588", attr);
500 attr.setForeColor(Color.WHITE);
501 putStringXY(10, 2, "\u2588\u2588\u2588", attr);
502
503 // Draw the dot
504 int dotX = getXColorPosition(color);
505 int dotY = getYColorPosition(color);
506 if (color.equals(Color.BLACK)) {
507 // Use white-on-black for black. All other colors use
508 // black-on-whatever.
509 attr.reset();
510 getScreen().putCharXY(dotX, dotY, GraphicsChars.CP437[0x07],
511 attr);
512 } else {
513 attr.setForeColor(color);
514 getScreen().putCharXY(dotX, dotY, '\u25D8', attr);
515 }
516
517 }
518
519 /**
520 * Handle keystrokes.
521 *
522 * @param keypress keystroke event
523 */
524 @Override
525 public void onKeypress(final TKeypressEvent keypress) {
526 if (keypress.equals(kbRight)) {
527 int dotX = getXColorPosition(color);
528 int dotY = getYColorPosition(color);
529 if (dotX < 10) {
530 dotX += 3;
531 }
532 color = getColorFromPosition(dotX, dotY);
533 } else if (keypress.equals(kbLeft)) {
534 int dotX = getXColorPosition(color);
535 int dotY = getYColorPosition(color);
536 if (dotX > 3) {
537 dotX -= 3;
538 }
539 color = getColorFromPosition(dotX, dotY);
540 } else if (keypress.equals(kbUp)) {
541 int dotX = getXColorPosition(color);
542 int dotY = getYColorPosition(color);
543 if (dotY == 2) {
544 dotY--;
545 }
546 color = getColorFromPosition(dotX, dotY);
547 } else if (keypress.equals(kbDown)) {
548 int dotX = getXColorPosition(color);
549 int dotY = getYColorPosition(color);
550 if (dotY == 1) {
551 dotY++;
552 }
553 color = getColorFromPosition(dotX, dotY);
554 } else {
555 // Pass to my parent
556 super.onKeypress(keypress);
557 }
558
559 // Save this update to the local theme.
560 ((TEditColorThemeWindow) getWindow()).saveToEditTheme();
561 }
562
563 /**
564 * Handle mouse press events.
565 *
566 * @param mouse mouse button press event
567 */
568 @Override
569 public void onMouseDown(final TMouseEvent mouse) {
570 if (mouse.isMouseWheelUp()) {
571 // Do this like kbUp
572 int dotX = getXColorPosition(color);
573 int dotY = getYColorPosition(color);
574 if (dotY == 2) {
575 dotY--;
576 }
577 color = getColorFromPosition(dotX, dotY);
578 } else if (mouse.isMouseWheelDown()) {
579 // Do this like kbDown
580 int dotX = getXColorPosition(color);
581 int dotY = getYColorPosition(color);
582 if (dotY == 1) {
583 dotY++;
584 }
585 color = getColorFromPosition(dotX, dotY);
586 return;
587 } else if ((mouse.getX() > 0)
588 && (mouse.getX() < getWidth() - 1)
589 && (mouse.getY() > 0)
590 && (mouse.getY() < getHeight() - 1)
591 ) {
592 color = getColorFromPosition(mouse.getX(), mouse.getY());
593 } else {
594 // Let parent class handle it.
595 super.onMouseDown(mouse);
596 return;
597 }
598
599 // Save this update to the local theme.
600 ((TEditColorThemeWindow) getWindow()).saveToEditTheme();
601 }
602
603 }
604
605 /**
606 * The current editing theme.
607 */
608 private ColorTheme editTheme;
609
610 /**
611 * The left-side list of colors pane.
612 */
613 private TList colorNames;
614
615 /**
616 * The foreground color.
617 */
618 private ForegroundPicker foreground;
619
620 /**
621 * The background color.
622 */
623 private BackgroundPicker background;
624
625 /**
626 * Set various widgets/values to the editing theme color.
627 *
628 * @param colorName name of color from theme
629 */
630 private void refreshFromTheme(final String colorName) {
631 CellAttributes attr = editTheme.getColor(colorName);
632 foreground.color = attr.getForeColor();
633 foreground.bold = attr.isBold();
634 background.color = attr.getBackColor();
635 }
636
637 /**
638 * Examines foreground, background, and colorNames and sets the color in
639 * editTheme.
640 */
641 private void saveToEditTheme() {
642 String colorName = colorNames.getSelected();
643 if (colorName == null) {
644 return;
645 }
646 CellAttributes attr = editTheme.getColor(colorName);
647 attr.setForeColor(foreground.color);
648 attr.setBold(foreground.bold);
649 attr.setBackColor(background.color);
650 editTheme.setColor(colorName, attr);
651 }
652
653 /**
654 * Public constructor. The file open box will be centered on screen.
655 *
656 * @param application the TApplication that manages this window
657 */
658 public TEditColorThemeWindow(final TApplication application) {
659
660 // Register with the TApplication
661 super(application, i18n.getString("windowTitle"), 0, 0, 60, 18, MODAL);
662
663 // Initialize with the first color
664 List<String> colors = getTheme().getColorNames();
665 assert (colors.size() > 0);
666 editTheme = new ColorTheme();
667 for (String key: colors) {
668 CellAttributes attr = new CellAttributes();
669 attr.setTo(getTheme().getColor(key));
670 editTheme.setColor(key, attr);
671 }
672
673 colorNames = addList(colors, 2, 2, 38, getHeight() - 7,
674 new TAction() {
675 // When the user presses Enter
676 public void DO() {
677 refreshFromTheme(colorNames.getSelected());
678 }
679 },
680 new TAction() {
681 // When the user navigates with keyboard
682 public void DO() {
683 refreshFromTheme(colorNames.getSelected());
684 }
685 }
686 );
687 foreground = new ForegroundPicker(this, 42, 1, 14, 6);
688 background = new BackgroundPicker(this, 42, 7, 14, 4);
689 refreshFromTheme(colors.get(0));
690 colorNames.setSelectedIndex(0);
691
692 addButton(i18n.getString("okButton"), getWidth() - 37, getHeight() - 4,
693 new TAction() {
694 public void DO() {
695 ColorTheme global = getTheme();
696 List<String> colors = editTheme.getColorNames();
697 for (String key: colors) {
698 CellAttributes attr = new CellAttributes();
699 attr.setTo(editTheme.getColor(key));
700 global.setColor(key, attr);
701 }
702 getApplication().closeWindow(TEditColorThemeWindow.this);
703 }
704 }
705 );
706
707 addButton(i18n.getString("cancelButton"), getWidth() - 25,
708 getHeight() - 4,
709 new TAction() {
710 public void DO() {
711 getApplication().closeWindow(TEditColorThemeWindow.this);
712 }
713 }
714 );
715
716 // Default to the color list
717 activate(colorNames);
718
719 // Add shortcut text
720 newStatusBar(i18n.getString("statusBar"));
721 }
722
723 /**
724 * Draw me on screen.
725 */
726 @Override
727 public void draw() {
728 super.draw();
729 CellAttributes attr = new CellAttributes();
730
731 // Draw the label on colorNames
732 attr.setTo(getTheme().getColor("twindow.background.modal"));
733 if (colorNames.isActive()) {
734 attr.setForeColor(getTheme().getColor("tlabel").getForeColor());
735 attr.setBold(getTheme().getColor("tlabel").isBold());
736 }
737 getScreen().putStringXY(3, 2, i18n.getString("colorName"), attr);
738
739 // Draw the sample text box
740 attr.reset();
741 attr.setForeColor(foreground.color);
742 attr.setBold(foreground.bold);
743 attr.setBackColor(background.color);
744 getScreen().putStringXY(getWidth() - 17, getHeight() - 6,
745 i18n.getString("textTextText"), attr);
746 getScreen().putStringXY(getWidth() - 17, getHeight() - 5,
747 i18n.getString("textTextText"), attr);
748 }
749
750 /**
751 * Handle keystrokes.
752 *
753 * @param keypress keystroke event
754 */
755 @Override
756 public void onKeypress(final TKeypressEvent keypress) {
757 // Escape - behave like cancel
758 if (keypress.equals(kbEsc)) {
759 getApplication().closeWindow(this);
760 return;
761 }
762
763 // Pass to my parent
764 super.onKeypress(keypress);
765 }
766
767 }