package nxm.sys.libg;

import java.awt.Container;

import nxm.sys.inc.InternalUseOnly;
import nxm.sys.inc.MessageHandler;
import nxm.sys.lib.Shell;
import nxm.sys.libg.Theme;

/** A class to handle a MJText area in its own MWindow
    @author  Jeff Schoen
*/
public class MWText extends MWindow {

  /** MJText for this MJText area in its own MWindow */
  @InternalUseOnly
  public MJText mtext;

  /** Creates a new instance.
      @param name     The name of the window.
      @param lines    The number of text lines to setup for.
      @param rows     The number of rows to initially display.
      @param cols     The number of columns to initially display.
      @param fontsize The font size in pixels to use
      @param flags    The options to enable
      @param parent   The window's message handler.
   */
  public MWText (String name, int lines, int rows, int cols, int fontsize,
      int flags, MessageHandler parent) {
    super(name,parent);
    if (!Shell.isHeadless()) { // Since NeXtMidas 3.5.0. Skip if in Headless state. BUG 2817
      setupText(lines,rows,cols,fontsize,flags);
    }
  }

  /** Setup the MJText */
  private void setupText (int lines, int rows, int cols, int fontsize,
      int flags) {
    mtext = new MJText(lines,rows,cols,fontsize,(Theme) Theme.global(),flags);
    panel = (Container)mtext;
    setSize (mtext.getWidth(),mtext.getHeight());
    mtext.setMWindow(this);
  }

  @Override
  public void setTheme (Theme theme) {
    super.setTheme(theme);
    if (mtext!=null) mtext.setTheme(theme);
  }

}

