void setState(boolean maximized) {
    maxBackground.setVisible(maximized);
    maxBackground.setEnabled(maximized);
    minimize.setVisible(maximized);
    minimize.setEnabled(maximized);

    minBackground.setVisible(!maximized);
    minBackground.setEnabled(!maximized);
    maximize.setVisible(!maximized);
    maximize.setEnabled(!maximized);

    maxLinesCount = maximized ? maxLinesCountMaximized : maxLinesCountMinimized;
    startDisplayIndex = Math.max(0, messages.size() - maxLinesCount);
    refreshOutput();
  }
  public LogControl(GUIContext container, Font font) {
    super(container);

    this.font = font;
    output = new TextOutput(container, font, "");
    maxLinesCountMinimized = textAreaHeightMinimized / font.getLineHeight();
    maxLinesCountMaximized = textAreaHeightMaximized / font.getLineHeight();

    Image arrowImage = ResourceManager.getInstance().getImage("LOG_ARROW");
    arrowUp = new Picture(container, arrowImage);
    arrowDown = new Picture(container, arrowImage.getFlippedCopy(false, true));

    arrowUp.onMouseClickedAdd(
        new MouseClickedAction() {
          @Override
          public void execute(AbstractControl sender, MouseClickedEventArgs e) {
            LogControl log = ((LogControl) sender.getParent());
            if (log.startDisplayIndex > 0) {
              log.startDisplayIndex--;
              refreshOutput();
            }
          }
        });

    arrowDown.onMouseClickedAdd(
        new MouseClickedAction() {
          @Override
          public void execute(AbstractControl sender, MouseClickedEventArgs e) {
            LogControl log = ((LogControl) sender.getParent());
            if (messages.size() > maxLinesCount
                && log.startDisplayIndex < messages.size() - maxLinesCount) {
              log.startDisplayIndex++;
              refreshOutput();
            }
          }
        });

    minBackground =
        new Picture(container, ResourceManager.getInstance().getImage("LOG_BACKGROUND_MIN"));
    maxBackground =
        new Picture(container, ResourceManager.getInstance().getImage("LOG_BACKGROUND_MAX"));

    minimize =
        new Picture(container, ResourceManager.getInstance().getImage("LOG_BUTTON_MINIMIZE"));
    maximize =
        new Picture(container, ResourceManager.getInstance().getImage("LOG_BUTTON_MAXIMIZE"));

    minimize.onMouseClickedAdd(
        new MouseClickedAction() {
          @Override
          public void execute(AbstractControl sender, MouseClickedEventArgs e) {
            ((LogControl) sender.getParent()).setState(false);
          }
        });

    maximize.onMouseClickedAdd(
        new MouseClickedAction() {
          @Override
          public void execute(AbstractControl sender, MouseClickedEventArgs e) {
            ((LogControl) sender.getParent()).setState(true);
          }
        });

    this.addChild(minBackground);
    this.addChild(maxBackground);
    this.addChild(maximize, new Size(428, 64));
    this.addChild(minimize, new Size(428, 220));
    this.addChild(arrowUp, new Size(410, 15));
    this.addChild(arrowDown, new Size(410, 40));
    this.addChild(output, new Size(12, 12));

    setState(false);
  }