desktop.setDimensions(0, 0, resize.getWidth(),
resize.getHeight() - 1);
}
+
+ // Change menu edges if needed.
+ recomputeMenuX();
+
// We are dirty, redraw the screen.
doRepaint();
return;
for (TMenu menu: menus) {
menu.setX(x);
x += menu.getTitle().length() + 2;
+
+ // Don't let the menu window exceed the screen width
+ int rightEdge = menu.getX() + menu.getWidth();
+ if (rightEdge > getScreen().getWidth()) {
+ menu.setX(getScreen().getWidth() - menu.getWidth());
+ }
}
}
*/
private TAction action;
- /**
- * How long to animate dispatch of the event in millis.
- */
- private static final long DISPATCH_TIME = 75;
-
/**
* Act as though the button was pressed. This is useful for other UI
* elements to get the same action as if the user clicked the button.
*/
public static final int NOCLOSEBOX = 0x08;
+ /**
+ * Window has no maximize box (default no).
+ */
+ public static final int NOZOOMBOX = 0x10;
+
// ------------------------------------------------------------------------
// Common window attributes -----------------------------------------------
// ------------------------------------------------------------------------
return false;
}
+ /**
+ * Returns true if this window has a maximize/zoom box.
+ *
+ * @return true if this window has a maximize/zoom box
+ */
+ public final boolean hasZoomBox() {
+ if ((flags & NOZOOMBOX) != 0) {
+ return true;
+ }
+ return false;
+ }
+
/**
* Retrieve the background color.
*
* @return the background color
*/
- public final CellAttributes getBackground() {
+ public CellAttributes getBackground() {
if (!isModal()
&& (inWindowMove || inWindowResize || inKeyboardResize)
) {
}
// Draw the maximize button
- if (!isModal()) {
+ if (!isModal() && ((flags & NOZOOMBOX) == 0)) {
putCharXY(getWidth() - 5, 0, '[', border);
putCharXY(getWidth() - 3, 0, ']', border);
* @return true if the mouse is currently on the maximize/restore button
*/
protected boolean mouseOnMaximize() {
+ if ((flags & NOZOOMBOX) != 0) {
+ return false;
+ }
if ((mouse != null)
&& !isModal()
&& (mouse.getAbsoluteY() == getY())
}
// F5 - zoom
- if (keypress.equals(kbF5)) {
+ if (keypress.equals(kbF5) && ((flags & NOZOOMBOX) == 0)) {
if (maximized) {
restore();
} else {
return;
}
- if (command.equals(cmWindowZoom)) {
+ if (command.equals(cmWindowZoom) && ((flags & NOZOOMBOX) == 0)) {
if (maximized) {
restore();
} else {
return;
}
- if (menu.getId() == TMenu.MID_WINDOW_ZOOM) {
+ if ((menu.getId() == TMenu.MID_WINDOW_ZOOM)
+ && ((flags & NOZOOMBOX) == 0)
+ ) {
if (maximized) {
restore();
} else {
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.Reader;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
* @throws IOException if the I/O fails
*/
public void load(final String filename) throws IOException {
- BufferedReader reader = new BufferedReader(new FileReader(filename));
- String line = reader.readLine();
- for (; line != null; line = reader.readLine()) {
+ load(new FileReader(filename));
+ }
+
+ /**
+ * Read color theme mappings from a Reader. The reader is closed at the
+ * end.
+ *
+ * @param reader the reader to read from
+ * @throws IOException if the I/O fails
+ */
+ public void load(final Reader reader) throws IOException {
+ BufferedReader bufferedReader = new BufferedReader(reader);
+ String line = bufferedReader.readLine();
+ for (; line != null; line = bufferedReader.readLine()) {
String key;
String bold;
String foreColor;
colors.put(key, color);
}
// All done.
- reader.close();
+ bufferedReader.close();
}
/**
return addItemInternal(id, label, key);
}
+ /**
+ * Convenience function to add a custom menu item.
+ *
+ * @param id menu item ID. Must be greater than 1024.
+ * @param label menu item label
+ * @param key global keyboard accelerator
+ * @param enabled default state for enabled
+ * @return the new menu item
+ */
+ public TMenuItem addItem(final int id, final String label,
+ final TKeypress key, final boolean enabled) {
+
+ TMenuItem item = addItem(id, label, key);
+ item.setEnabled(enabled);
+ return item;
+ }
+
/**
* Convenience function to add a custom menu item.
*