+ // ------------------------------------------------------------------------
+ // TWindow ----------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Draw a top-level menu with title and menu items.
+ */
+ @Override
+ public void draw() {
+ CellAttributes background = getTheme().getColor("tmenu");
+
+ assert (isAbsoluteActive());
+
+ // Fill in the interior background
+ for (int i = 0; i < getHeight(); i++) {
+ hLineXY(0, i, getWidth(), ' ', background);
+ }
+
+ // Draw the box
+ char cTopLeft;
+ char cTopRight;
+ char cBottomLeft;
+ char cBottomRight;
+ char cHSide;
+
+ cTopLeft = GraphicsChars.ULCORNER;
+ cTopRight = GraphicsChars.URCORNER;
+ cBottomLeft = GraphicsChars.LLCORNER;
+ cBottomRight = GraphicsChars.LRCORNER;
+ cHSide = GraphicsChars.SINGLE_BAR;
+
+ // Place the corner characters
+ putCharXY(1, 0, cTopLeft, background);
+ putCharXY(getWidth() - 2, 0, cTopRight, background);
+ putCharXY(1, getHeight() - 1, cBottomLeft, background);
+ putCharXY(getWidth() - 2, getHeight() - 1, cBottomRight, background);
+
+ // Draw the box lines
+ hLineXY(1 + 1, 0, getWidth() - 4, cHSide, background);
+ hLineXY(1 + 1, getHeight() - 1, getWidth() - 4, cHSide, background);
+
+ // Draw a shadow
+ drawBoxShadow(0, 0, getWidth(), getHeight());
+ }
+
+ // ------------------------------------------------------------------------
+ // TMenu ------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+
+ /**
+ * Set the menu title X position.
+ *
+ * @param titleX the position
+ */
+ public void setTitleX(final int titleX) {
+ this.titleX = titleX;
+ }
+
+ /**
+ * Get the menu title X position.
+ *
+ * @return the position
+ */
+ public int getTitleX() {
+ return titleX;
+ }
+
+ /**
+ * Get the mnemonic string.
+ *
+ * @return the full mnemonic string
+ */
+ public MnemonicString getMnemonic() {
+ return mnemonic;
+ }
+
+ /**
+ * Convenience function to add a menu item.
+ *
+ * @param id menu item ID. Must be greater than 1024.
+ * @param label menu item label
+ * @return the new menu item
+ */
+ public TMenuItem addItem(final int id, final String label) {
+ assert (id >= 1024);
+ return addItemInternal(id, label, null);
+ }
+
+ /**
+ * Convenience function to add a menu item.
+ *
+ * @param id menu item ID. Must be greater than 1024.
+ * @param label menu item label
+ * @param enabled default state for enabled
+ * @return the new menu item
+ */
+ public TMenuItem addItem(final int id, final String label,
+ final boolean enabled) {
+
+ assert (id >= 1024);
+ return addItemInternal(id, label, null, enabled);
+ }
+