Crossfire JXClient, Trunk
Gui.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff
19  * Copyright (C) 2006-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.gui.gui;
24 
31 import java.awt.Component;
32 import java.awt.Container;
33 import java.awt.Dimension;
34 import java.awt.event.KeyEvent;
35 import java.util.Collection;
36 import java.util.EnumSet;
37 import javax.swing.JComponent;
38 import javax.swing.JFrame;
39 import org.jetbrains.annotations.NotNull;
40 import org.jetbrains.annotations.Nullable;
41 
49 public class Gui {
50 
54  @NotNull
55  private final JComponent component = new JComponent() {
56 
60  private static final long serialVersionUID = 1L;
61 
62  };
63 
67  @NotNull
68  private final KeyBindings keyBindings;
69 
74  @Nullable
75  private Extent autoSize;
76 
80  private boolean saveDialog;
81 
85  private boolean modal;
86 
91  private boolean userResizable;
92 
96  @NotNull
97  private final Collection<RendererGuiState> hideInStates = EnumSet.noneOf(RendererGuiState.class);
98 
103  @Nullable
105 
110  @Nullable
112 
116  private boolean initialPositionSet;
117 
122  @Nullable
124 
129  @Nullable
131 
136  @Nullable
138 
143  @Nullable
144  private GUIPicture help;
145 
151  public Gui(@NotNull final String name, @NotNull final KeyBindings keyBindings) {
152  this.keyBindings = keyBindings;
153  component.setName(name);
154  }
155 
160  @NotNull
161  public JComponent getComponent() {
162  return component;
163  }
164 
170  public void setAutoSize(@Nullable final Extent autoSize) {
171  this.autoSize = autoSize;
172  }
173 
179  public boolean isAutoSize() {
180  return autoSize != null;
181  }
182 
187  public void setModal(final boolean modal) {
188  this.modal = modal;
189  }
190 
195  public boolean isModal() {
196  return modal;
197  }
198 
203  public void setUserResizable(final boolean userResizable) {
204  this.userResizable = userResizable;
205  }
206 
211  public boolean isUserResizable() {
212  return userResizable;
213  }
214 
219  @Nullable
221  final int count = component.getComponentCount();
222  for (int i = 0; i < count; i++) {
223  final Component component = this.component.getComponent(i);
224  if (component.isVisible() && component instanceof final ActivatableGUIElement element && element.isDefault()) {
225  return element;
226  }
227  }
228 
229  return null;
230  }
231 
235  public void activateDefaultElement() {
236  final ActivatableGUIElement defaultElement = getDefaultElement();
237  if (defaultElement != null) {
238  defaultElement.setActive(true);
239  }
240  }
241 
250  @Nullable
251  public <T extends GUIElement> T getFirstElementEndingWith(@NotNull final Class<T> class_, @NotNull final String ending) {
252  final int count = component.getComponentCount();
253  for (int i = 0; i < count; i++) {
254  final Component component = this.component.getComponent(i);
255  if (component.isVisible() && component instanceof final GUIElement element && class_.isAssignableFrom(element.getClass()) && element.getName().endsWith(ending)) {
256  return class_.cast(element);
257  }
258  }
259 
260  return null;
261  }
262 
271  @Nullable
272  public <T extends GUIElement> T getFirstElementNotEndingWith(@NotNull final Class<T> class_, @NotNull final String ending) {
273  final int count = component.getComponentCount();
274  for (int i = 0; i < count; i++) {
275  final Component component = this.component.getComponent(i);
276  if (component.isVisible() && component instanceof final GUIElement element && class_.isAssignableFrom(element.getClass()) && !element.getName().endsWith(ending)) {
277  return class_.cast(element);
278  }
279  }
280 
281  return null;
282  }
283 
290  @Nullable
291  public <T extends GUIElement> T getFirstElement(@NotNull final Class<T> class_) {
292  final int count = component.getComponentCount();
293  for (int i = 0; i < count; i++) {
294  final Component component = this.component.getComponent(i);
295  if (component.isVisible() && component instanceof final GUIElement element && class_.isAssignableFrom(element.getClass())) {
296  return class_.cast(element);
297  }
298  }
299 
300  return null;
301  }
302 
310  @Nullable
311  public AbstractGUIElement getElementFromPoint(final int x, final int y) {
312  Component component = this.component.findComponentAt(x, y);
313  while (component != null) {
314  if (component instanceof AbstractGUIElement) {
316  }
317  component = component.getParent();
318  }
319  return null;
320  }
321 
327  public void setActiveElement(@NotNull final ActivatableGUIElement activeElement, final boolean active) {
328  final ActivatableGUIElement previousActiveElement = this.activeElement;
329  if (active) {
330  if (forcedActive != null && forcedActive != activeElement) {
331  return;
332  }
333 
335  return;
336  }
337 
338  this.activeElement = activeElement;
339  if (previousActiveElement != null) {
340  previousActiveElement.activeChanged();
341  }
342  assert this.activeElement != null;
343  this.activeElement.activeChanged();
344 
345  guiAutoCloseListener = null;
346  } else {
348  return;
349  }
350 
351  this.activeElement = null;
352  assert previousActiveElement != null;
353  previousActiveElement.activeChanged();
354 
355  if (guiAutoCloseListener != null) {
357  guiAutoCloseListener = null;
358  listener.autoClosed();
359  }
360  }
361  }
362 
369  public boolean isActiveElement(@Nullable final ActivatableGUIElement activeElement) {
370  return this.activeElement != null && this.activeElement == activeElement;
371  }
372 
378  public void setActiveElementActive(final boolean active) {
379  if (activeElement != null) {
380  activeElement.setActive(active);
381  }
382  }
383 
389  public boolean handleKeyPress(@NotNull final KeyEvent2 e) {
390  if (activeElement instanceof KeyPressedHandler && ((KeyPressedHandler)activeElement).keyPressed(e)) {
391  return true;
392  }
393 
394  switch (e.getKeyCode()) {
395  case KeyEvent.VK_ENTER:
396  case KeyEvent.VK_SPACE:
397  final ActivatableGUIElement defaultElement = getDefaultElement();
398  if (defaultElement != null) {
399  defaultElement.execute();
400  return true;
401  }
402  break;
403 
404  case KeyEvent.VK_TAB:
405  if (activeElement != null) {
406  switch (e.getModifiers()&KeyEvent2.MASK) {
407  case KeyEvent2.NONE:
409  return true;
410 
411  case KeyEvent2.SHIFT:
413  return true;
414  }
415  }
416  break;
417  }
418 
419  return keyBindings.handleKeyPress(e);
420  }
421 
428  public boolean deactivateCommandInput() {
429  if (activeElement == null) {
430  return false;
431  }
432 
433  final GUIElement textArea = activeElement;
434  if (!textArea.getName().equals("command")) {
435  return false;
436  }
437 
438  assert activeElement != null;
439  activeElement.setActive(false);
440  return true;
441  }
442 
451  @Nullable
452  public <T extends GUIElement> T getFirstElement(@NotNull final Class<T> class_, @NotNull final String name) {
453  final int count = component.getComponentCount();
454  for (int i = 0; i < count; i++) {
455  final Component component = this.component.getComponent(i);
456  if (component.isVisible() && component instanceof final GUIElement element && class_.isAssignableFrom(element.getClass()) && element.getName().equals(name)) {
457  return class_.cast(element);
458  }
459  }
460  return null;
461  }
462 
467  @NotNull
469  return keyBindings;
470  }
471 
476  public void hideInState(@NotNull final RendererGuiState state) {
477  hideInStates.add(state);
478  }
479 
485  public boolean isHidden(@NotNull final RendererGuiState state) {
486  return hideInStates.contains(state);
487  }
488 
495  this.guiAutoCloseListener = guiAutoCloseListener;
496  }
497 
504  public boolean isWithinDrawingArea(final int x, final int y) {
505  return component.getX() <= x && x < component.getX()+component.getWidth() && component.getY() <= y && y < component.getY()+component.getHeight();
506  }
507 
513  public void setForcedActive(@Nullable final ActivatableGUIElement forcedActive) {
514  this.forcedActive = forcedActive;
515  }
516 
517  @NotNull
518  @Override
519  public String toString() {
520  final String name = component.getName();
521  return (name == null ? "" : name)+"["+component.getWidth()+"x"+component.getHeight()+"]";
522  }
523 
530  public void autoSize(final int screenWidth, final int screenHeight) {
532  final int x;
533  final int y;
534  final int w;
535  final int h;
536  final Extent extent = autoSize;
537  if (extent != null) {
538  final Dimension preferredSize = component.getPreferredSize();
539  x = extent.getX(screenWidth, screenHeight, preferredSize.width, preferredSize.height);
540  y = extent.getY(screenWidth, screenHeight, preferredSize.width, preferredSize.height);
541  w = extent.getW(screenWidth, screenHeight, preferredSize.width, preferredSize.height);
542  h = extent.getH(screenWidth, screenHeight, preferredSize.width, preferredSize.height);
543  } else if (initialPositionSet) {
544  x = component.getX();
545  y = component.getY();
546  w = component.getWidth();
547  h = component.getHeight();
548  } else {
549  final Dimension preferredSize = component.getPreferredSize();
550  //noinspection IfMayBeConditional
551  if (defaultX == null) {
552  x = screenWidth/2-preferredSize.width;
553  } else {
554  x = defaultX.evaluate(screenWidth, screenHeight, preferredSize.width, preferredSize.height)-preferredSize.width/2;
555  }
556  //noinspection IfMayBeConditional
557  if (defaultY == null) {
558  y = screenHeight/2-preferredSize.height;
559  } else {
560  y = defaultY.evaluate(screenWidth, screenHeight, preferredSize.width, preferredSize.height)-preferredSize.height/2;
561  }
562  w = preferredSize.width;
563  h = preferredSize.height;
564  }
565  setBounds(x, y, w, h, screenWidth, screenHeight);
566  });
567  }
568 
574  public void setDefaultPosition(@NotNull final Expression defaultX, @NotNull final Expression defaultY) {
575  this.defaultX = defaultX;
576  this.defaultY = defaultY;
577  }
578 
583  public boolean isSaveDialog() {
584  return saveDialog;
585  }
586 
590  public void setSaveDialog() {
591  saveDialog = true;
592  }
593 
597  public void notifyOpen() {
598  if (help != null) {
599  help.notifyOpen();
600  }
601 
602  final int count = component.getComponentCount();
603  for (int i = 0; i < count; i++) {
604  final Component component = this.component.getComponent(i);
605  if (component.isVisible() && component instanceof final GUIElement element) {
606  element.notifyOpen();
607  }
608  }
609  }
610 
616  @Nullable
617  public GUIPicture getHelp() {
618  return help;
619  }
620 
625  public void setHelp(@NotNull final GUIPicture help) {
626  this.help = help;
627  }
628 
641  public void setBounds(final int x, final int y, final int width, final int height, final int windowWidth, final int windowHeight) {
642  int newWidth = width;
643  int newHeight = height;
644  final Dimension maximumSize = component.getMaximumSize();
645  if (maximumSize != null) {
646  if (newWidth > maximumSize.width) {
647  newWidth = maximumSize.width;
648  }
649  if (newHeight > maximumSize.height) {
650  newHeight = maximumSize.height;
651  }
652  }
653  final Dimension minimumSize = component.getMinimumSize();
654  if (minimumSize != null) {
655  if (newWidth < minimumSize.width) {
656  newWidth = minimumSize.width;
657  }
658  if (newHeight < minimumSize.height) {
659  newHeight = minimumSize.height;
660  }
661  }
662  final int newX = Math.max(Math.min(x, windowWidth-newWidth), 0);
663  final int newY = Math.max(Math.min(y, windowHeight-newHeight), 0);
664  component.setBounds(newX, newY, newWidth, newHeight);
665  initialPositionSet = true;
666  validate();
667  }
668 
672  private void validate() {
673  Container c = component;
674  while (c != null) {
675  c = c.getParent();
676  if (c instanceof JFrame) {
677  c.validate();
678  break;
679  }
680  }
681  }
682 
686  public void repaint() {
687  SwingUtilities2.invokeLater(component::repaint);
688  }
689 
694  public void setOpaqueDialogBackground(final boolean opaque) {
695  final int count = component.getComponentCount();
696  for (int i = 0; i < count; i++) {
697  final Component component = this.component.getComponent(i);
698  if (component.isVisible() && component instanceof final GUIDialogBackground dialogBackground) {
699  dialogBackground.setOpaqueDialogBackground(opaque);
700  }
701  }
702  }
703 
709  public void setShowSentCommands(final boolean showSentCommands) {
710  final int count = component.getComponentCount();
711  for (int i = 0; i < count; i++) {
712  final Component component = this.component.getComponent(i);
713  if (component.isVisible() && component instanceof final GUIMessageLog messageLog) {
714  messageLog.setShowSentCommands(showSentCommands);
715  }
716  }
717  }
718 
723  public void setShowTimestamps(final boolean showTimestamps) {
724  final int count = component.getComponentCount();
725  for (int i = 0; i < count; i++) {
726  final Component component = this.component.getComponent(i);
727  if (component.isVisible() && component instanceof final GUIMessageLog messageLog) {
728  messageLog.setShowTimestamps(showTimestamps);
729  }
730  }
731  }
732 
733 }
com.realtime.crossfire.jxclient.util.SwingUtilities2
Utility class for Swing related functions.
Definition: SwingUtilities2.java:34
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.gui.gui.Gui.isAutoSize
boolean isAutoSize()
Returns whether this dialog is an auto-size dialog.
Definition: Gui.java:179
com.realtime.crossfire.jxclient.gui.gui.Gui.setGuiAutoCloseListener
void setGuiAutoCloseListener(@Nullable final GuiAutoCloseListener guiAutoCloseListener)
Sets the GuiAutoCloseListener to be notified when this dialog becomes inactive.
Definition: Gui.java:494
com.realtime.crossfire.jxclient.gui.gui.Gui
Combines a list of GUIElements to for a gui.
Definition: Gui.java:49
com.realtime.crossfire.jxclient.gui.gui.Gui.setHelp
void setHelp(@NotNull final GUIPicture help)
Sets the help icon of this dialog.
Definition: Gui.java:625
com.realtime.crossfire.jxclient.gui.gui.Gui.setDefaultPosition
void setDefaultPosition(@NotNull final Expression defaultX, @NotNull final Expression defaultY)
Sets the default position for this dialog.
Definition: Gui.java:574
com.realtime.crossfire.jxclient.gui.gui.Gui.isWithinDrawingArea
boolean isWithinDrawingArea(final int x, final int y)
Returns whether a given point is within this dialog's drawing area.
Definition: Gui.java:504
com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement.activeChanged
abstract void activeChanged()
Will be called whenever the active state has changed.
com.realtime.crossfire.jxclient.gui.gui.Gui.defaultX
Expression defaultX
The default x-coordinate for this dialog.
Definition: Gui.java:130
com.realtime.crossfire.jxclient.gui.gui.Gui.autoSize
void autoSize(final int screenWidth, final int screenHeight)
Auto-resizes the dialog.
Definition: Gui.java:530
com.realtime.crossfire.jxclient.gui.keybindings.KeyEvent2.NONE
static final int NONE
The mask for "no modifier".
Definition: KeyEvent2.java:39
com.realtime.crossfire.jxclient.gui.gui.Extent.getW
int getW(final int width, final int height, final int prefWidth, final int prefHeight)
Returns the width.
Definition: Extent.java:104
com.realtime.crossfire.jxclient.gui.gui.GuiAutoCloseListener.autoClosed
void autoClosed()
Called when a dialog has been auto-closed.
com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement.execute
abstract void execute()
Executes the actions associated with this GUI element.
com.realtime.crossfire.jxclient.gui.gui.Gui.handleKeyPress
boolean handleKeyPress(@NotNull final KeyEvent2 e)
Dispatches a key press KeyEvent.
Definition: Gui.java:389
com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement.activateNextElement
void activateNextElement()
Activates the following element.
Definition: ActivatableGUIElement.java:137
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement
Abstract base class for GUI elements to be shown in Guis.
Definition: AbstractGUIElement.java:37
com.realtime.crossfire.jxclient.gui.gui.Gui.isHidden
boolean isHidden(@NotNull final RendererGuiState state)
Returns whether this gui is visible in a state.
Definition: Gui.java:485
com.realtime.crossfire.jxclient.util.SwingUtilities2.invokeLater
static void invokeLater(@NotNull final Runnable runnable)
Calls SwingUtilities#invokeLater(Runnable) if not on the EDT or calls the Runnable directly if on the...
Definition: SwingUtilities2.java:73
com.realtime.crossfire.jxclient.gui.gui.Gui.getHelp
GUIPicture getHelp()
Returns the help icon of this dialog.
Definition: Gui.java:617
com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement
A GUIElement that can be set to active or inactive.
Definition: ActivatableGUIElement.java:33
com.realtime.crossfire.jxclient.gui.keybindings
Definition: InvalidKeyBindingException.java:23
com.realtime.crossfire.jxclient.gui.gui.Gui.hideInState
void hideInState(@NotNull final RendererGuiState state)
Hides the dialog in a state.
Definition: Gui.java:476
com.realtime.crossfire.jxclient.gui.gui.Gui.setActiveElementActive
void setActiveElementActive(final boolean active)
Activates or deactivates the GUI element owning the focus.
Definition: Gui.java:378
com.realtime.crossfire.jxclient.gui.keybindings.KeyEvent2
Represents a pressed or released key.
Definition: KeyEvent2.java:34
com.realtime.crossfire.jxclient.gui.log.GUIMessageLog
A gui element implementing the message window.
Definition: GUIMessageLog.java:40
com.realtime.crossfire.jxclient.gui.gui.Expression
An expression yielding an integer value derived from a screen resolution.
Definition: Expression.java:31
com.realtime.crossfire.jxclient.gui.gui.Gui.setActiveElement
void setActiveElement(@NotNull final ActivatableGUIElement activeElement, final boolean active)
Sets the gui element owning the focus.
Definition: Gui.java:327
com.realtime.crossfire.jxclient.gui.log
Definition: Buffer.java:23
com.realtime.crossfire.jxclient.gui.gui.Gui.isUserResizable
boolean isUserResizable()
Returns whether the dialog is user-resizable.
Definition: Gui.java:211
com.realtime.crossfire.jxclient.gui.keybindings.KeyBindings
Manages a set of key bindings.
Definition: KeyBindings.java:47
com.realtime.crossfire.jxclient.gui.gui.Gui.setShowSentCommands
void setShowSentCommands(final boolean showSentCommands)
Sets whether the commands sent to the server should be shown in the messages dialog.
Definition: Gui.java:709
com.realtime.crossfire.jxclient.gui.gui.Gui.defaultY
Expression defaultY
The default y-coordinate for this dialog.
Definition: Gui.java:137
com.realtime.crossfire.jxclient.gui.gui.Gui.setSaveDialog
void setSaveDialog()
Makes this dialog retain its position across restarts.
Definition: Gui.java:590
com.realtime.crossfire.jxclient.gui.gui.GUIElement
Interface defining an abstract GUI element.
Definition: GUIElement.java:33
com.realtime.crossfire.jxclient.gui.keybindings.KeyBindings.handleKeyPress
boolean handleKeyPress(@NotNull final KeyEvent2 e)
Executes a "key press" event.
Definition: KeyBindings.java:320
com.realtime.crossfire.jxclient.gui.gui.GuiAutoCloseListener
Interface for clients interested in auto-close events of Gui instances.
Definition: GuiAutoCloseListener.java:30
com.realtime.crossfire.jxclient.gui.gui.Gui.validate
void validate()
Calls Container#validate() on the top-level frame.
Definition: Gui.java:672
com.realtime.crossfire.jxclient.gui.gui.Gui.saveDialog
boolean saveDialog
Whether this dialog retains its position across restarts.
Definition: Gui.java:80
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement.isDefault
boolean isDefault
Whether this element is the default element.
Definition: AbstractGUIElement.java:61
com.realtime.crossfire.jxclient.gui.gui.Extent
Encapsulates the extent of a GUI element.
Definition: Extent.java:32
com.realtime.crossfire.jxclient.gui.gui.Gui.getElementFromPoint
AbstractGUIElement getElementFromPoint(final int x, final int y)
Determines the GUIElement for a given coordinate.
Definition: Gui.java:311
com.realtime.crossfire.jxclient.gui.gui.Gui.setOpaqueDialogBackground
void setOpaqueDialogBackground(final boolean opaque)
Sets whether the dialog's background is opaque.
Definition: Gui.java:694
com.realtime.crossfire.jxclient.gui.gui.Gui.activateDefaultElement
void activateDefaultElement()
Activates the first default gui element of this gui.
Definition: Gui.java:235
com.realtime.crossfire.jxclient.gui.gui.Gui.userResizable
boolean userResizable
Whether this dialog is user-resizable.
Definition: Gui.java:91
com.realtime.crossfire.jxclient.gui.gui.Gui.setForcedActive
void setForcedActive(@Nullable final ActivatableGUIElement forcedActive)
Sets an ActivatableGUIElement that is always active.
Definition: Gui.java:513
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.gui.keybindings.KeyEvent2.MASK
static final int MASK
The mask for all used modifiers.
Definition: KeyEvent2.java:69
com.realtime.crossfire.jxclient.gui.gui.Gui.setUserResizable
void setUserResizable(final boolean userResizable)
Sets whether the dialog is user-resizable.
Definition: Gui.java:203
com.realtime.crossfire.jxclient.gui.gui.Gui.setBounds
void setBounds(final int x, final int y, final int width, final int height, final int windowWidth, final int windowHeight)
Sets the position and size of this dialog.
Definition: Gui.java:641
com.realtime.crossfire.jxclient.gui.gui.Gui.guiAutoCloseListener
GuiAutoCloseListener guiAutoCloseListener
If set, the auto-close listener to notify if this dialog looses the active gui element.
Definition: Gui.java:123
com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement.activatePrevElement
void activatePrevElement()
Activates the previous element.
Definition: ActivatableGUIElement.java:145
com.realtime.crossfire.jxclient.gui.keybindings.KeyEvent2.SHIFT
static final int SHIFT
The mask for "shift".
Definition: KeyEvent2.java:64
com.realtime.crossfire.jxclient.gui.gui.Gui.hideInStates
final Collection< RendererGuiState > hideInStates
The gui states that do not show this dialog.
Definition: Gui.java:97
com.realtime.crossfire.jxclient.util
Definition: Codec.java:23
com.realtime.crossfire.jxclient.gui.gui.Gui.setShowTimestamps
void setShowTimestamps(final boolean showTimestamps)
Sets whether timestamps should be shown in the messages dialog.
Definition: Gui.java:723
com.realtime.crossfire.jxclient.gui.gui.Gui.getComponent
JComponent getComponent()
Returns the JComponent for this instance.
Definition: Gui.java:161
com.realtime.crossfire.jxclient.gui.gui.Gui.isModal
boolean isModal()
Returns the modal state.
Definition: Gui.java:195
com.realtime.crossfire.jxclient.gui.gui.Gui.getKeyBindings
KeyBindings getKeyBindings()
Returns the key bindings instance for this gui.
Definition: Gui.java:468
com.realtime.crossfire.jxclient.gui.gui.Expression.evaluate
int evaluate(final int width, final int height, final int prefWidth, final int prefHeight)
Evaluates the expression into a constant.
Definition: Expression.java:98
com.realtime.crossfire.jxclient.gui.gui.GUIElement.getName
String getName()
Returns the internal name of this gui element.
com.realtime.crossfire.jxclient.gui.gui.KeyPressedHandler
Interface for classes that may handle "pressed" key events.
Definition: KeyPressedHandler.java:32
com.realtime.crossfire.jxclient.gui.gui.Gui.keyBindings
final KeyBindings keyBindings
The KeyBindings for this gui.
Definition: Gui.java:68
com.realtime.crossfire
com.realtime
com.realtime.crossfire.jxclient.gui.gui.Extent.getX
int getX(final int width, final int height, final int prefWidth, final int prefHeight)
Returns the x coordinate.
Definition: Extent.java:80
com.realtime.crossfire.jxclient.gui.gui.Gui.isActiveElement
boolean isActiveElement(@Nullable final ActivatableGUIElement activeElement)
Returns whether a given gui element is the active element of this dialog.
Definition: Gui.java:369
com.realtime.crossfire.jxclient.gui.gui.Gui.Gui
Gui(@NotNull final String name, @NotNull final KeyBindings keyBindings)
Creates a new instance.
Definition: Gui.java:151
com
com.realtime.crossfire.jxclient.gui.gui.Gui.getFirstElement
public< T extends GUIElement > T getFirstElement(@NotNull final Class< T > class_)
Returns the first gui element of this gui belonging to the given class.
Definition: Gui.java:291
com.realtime.crossfire.jxclient.gui.misc.GUIDialogBackground
A background image for dialog windows.
Definition: GUIDialogBackground.java:46
com.realtime.crossfire.jxclient.gui.misc.GUIPicture
A AbstractGUIElement that displays a picture.
Definition: GUIPicture.java:42
com.realtime.crossfire.jxclient.gui.gui.Gui.autoSize
Extent autoSize
The extent of the dialog if it is auto-sizing or.
Definition: Gui.java:75
com.realtime.crossfire.jxclient.gui.gui.Gui.modal
boolean modal
Whether this dialog is modal.
Definition: Gui.java:85
com.realtime.crossfire.jxclient.gui.gui.Gui.repaint
void repaint()
Repaints this component.
Definition: Gui.java:686
com.realtime.crossfire.jxclient.gui.gui.Gui.setModal
void setModal(final boolean modal)
Sets the modal state.
Definition: Gui.java:187
com.realtime.crossfire.jxclient.gui.gui.Gui.initialPositionSet
boolean initialPositionSet
Whether an initial position has been set.
Definition: Gui.java:116
com.realtime.crossfire.jxclient.gui.gui.Gui.deactivateCommandInput
boolean deactivateCommandInput()
Deactivates the command text input field of this dialog.
Definition: Gui.java:428
com.realtime.crossfire.jxclient.gui.gui.Gui.getFirstElementEndingWith
public< T extends GUIElement > T getFirstElementEndingWith(@NotNull final Class< T > class_, @NotNull final String ending)
Returns the first gui element of this gui which belongs to the given class and that's name ends with ...
Definition: Gui.java:251
com.realtime.crossfire.jxclient.gui.gui.Gui.component
final JComponent component
The JComponent for this instance.
Definition: Gui.java:55
com.realtime.crossfire.jxclient.gui.gui.Gui.activeElement
ActivatableGUIElement activeElement
The gui element which has the focus.
Definition: Gui.java:111
com.realtime.crossfire.jxclient.gui.gui.Extent.getY
int getY(final int width, final int height, final int prefWidth, final int prefHeight)
Returns the y coordinate.
Definition: Extent.java:92
com.realtime.crossfire.jxclient.gui.gui.Gui.setAutoSize
void setAutoSize(@Nullable final Extent autoSize)
Sets the auto-size state.
Definition: Gui.java:170
com.realtime.crossfire.jxclient.gui.gui.Gui.help
GUIPicture help
The help icon of the dialog.
Definition: Gui.java:144
com.realtime.crossfire.jxclient.gui.misc
Definition: GUICheckBox.java:23
com.realtime.crossfire.jxclient.gui.gui.ActivatableGUIElement.setActive
void setActive(final boolean active)
Sets the active state of a GUI element.
Definition: ActivatableGUIElement.java:115
com.realtime.crossfire.jxclient.util.SwingUtilities2.invokeAndWait
static void invokeAndWait(@NotNull final Runnable runnable)
Calls SwingUtilities#invokeAndWait(Runnable) if not on the EDT or calls the Runnable directly if on t...
Definition: SwingUtilities2.java:47
com.realtime.crossfire.jxclient.gui.gui.Gui.getDefaultElement
ActivatableGUIElement getDefaultElement()
Returns the first default gui element of this gui.
Definition: Gui.java:220
com.realtime.crossfire.jxclient.gui.misc.GUIPicture.notifyOpen
void notifyOpen()
Called each time the enclosing dialog is opened (or raised).
Definition: GUIPicture.java:114
com.realtime.crossfire.jxclient.gui.gui.Gui.notifyOpen
void notifyOpen()
Call GUIElement#notifyOpen() for all GUI elements.
Definition: Gui.java:597
com.realtime.crossfire.jxclient.gui.gui.Extent.getH
int getH(final int width, final int height, final int prefWidth, final int prefHeight)
Returns the height.
Definition: Extent.java:116
com.realtime.crossfire.jxclient.gui.gui.Gui.toString
String toString()
Definition: Gui.java:519
com.realtime.crossfire.jxclient.gui.gui.Gui.forcedActive
ActivatableGUIElement forcedActive
If non-.
Definition: Gui.java:104
com.realtime.crossfire.jxclient.gui.gui.Gui.isSaveDialog
boolean isSaveDialog()
Returns whether this dialog retains its position across restarts.
Definition: Gui.java:583
com.realtime.crossfire.jxclient.gui.gui.Gui.getFirstElement
public< T extends GUIElement > T getFirstElement(@NotNull final Class< T > class_, @NotNull final String name)
Returns the first gui element of this gui belonging to the given class and having the given name.
Definition: Gui.java:452
com.realtime.crossfire.jxclient.gui.gui.Gui.getFirstElementNotEndingWith
public< T extends GUIElement > T getFirstElementNotEndingWith(@NotNull final Class< T > class_, @NotNull final String ending)
Returns the first gui element of this gui which belongs to the given class and that's name does not e...
Definition: Gui.java:272
com.realtime.crossfire.jxclient.gui.gui.RendererGuiState
All gui states of JXCWindowRenderer.
Definition: RendererGuiState.java:31