예제 #1
0
 @Override
 public void setBackground(Color c) {
   if (txt_box == null)
     return; // WORKAROUND.OSX: OSX LookAndFeel calls setBackground during ctor of Mem_html;
   // DATE:2015-05-11
   if (c.getRGB() == Color.BLACK.getRGB()) txt_box.setCaretColor(Color.WHITE);
   else if (c.getRGB() == Color.WHITE.getRGB()) txt_box.setCaretColor(Color.BLACK);
   super.setBackground(c);
 }
예제 #2
0
  void OverrideKeyBindings() {
    Set<AWTKeyStroke> forTraSet = new HashSet<AWTKeyStroke>();
    txt_box.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forTraSet);
    txt_box.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, forTraSet);

    GxwTextBox_overrideKeyCmd.noop_(
        (GfuiElem) host, txt_box, "control H"); // else ctrl+h deletes current char
    //		GxwTextBox_overrideKeyCmd.new_(txt_box, "ENTER", Env_.NewLine); // else enter will always
    // use \n on window; jtextBox allows separation of \r from \n
  }
예제 #3
0
  public void ctor_MsTextBoxMultiline_() {
    txt_box = new GxwTextBox_lang();
    txt_box.ctor_MsTextBox_();
    core = new GxwCore_host(GxwCore_lang.new_(this), txt_box.ctrlMgr);
    this.setViewportView(txt_box);
    txt_box.setLineWrap(true);
    txt_box.setWrapStyleWord(true); // else text will wrap in middle of words
    this.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
    this.setBorder(null);
    txt_box.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    txt_box.setCaretColor(Color.BLACK);
    txt_box.getCaret().setBlinkRate(0);
    txt_box.setMargin(new Insets(0, 200, 200, 0));
    OverrideKeyBindings();
    InitUndoMgr();
    txt_box.setCaret(
        new javax.swing.text.DefaultCaret() {
          public void setSelectionVisible(boolean vis) {
            super.setSelectionVisible(true);
          }
        }); // else highlighted selection will not be visible when text box loses focus
    //		this.setLayout(null);

    //		Object fontDefinition = new UIDefaults.ProxyLazyValue("javax.swing.plaf.FontUIResource",
    // null, new Object[] { "dialog", new Integer(Font.PLAIN), new Integer(12) });
    //		java.util.Enumeration keys = UIManager.getDefaults().keys();
    //		while (keys.hasMoreElements()) {
    //		    Object key = keys.nextElement();
    //		    Object value = UIManager.get(key);
    //		    if (value instanceof javax.swing.plaf.FontUIResource) {
    //		        UIManager.put(key, fontDefinition);
    //		    }
    //		}
  }
예제 #4
0
  void InitUndoMgr() {
    final UndoManager undo = new UndoManager();
    Document doc = txt_box.getDocument();

    // Listen for undo and redo events
    doc.addUndoableEditListener(
        new UndoableEditListener() {
          public void undoableEditHappened(UndoableEditEvent evt) {
            undo.addEdit(evt.getEdit());
          }
        });

    // Create an undo action and add it to the text component
    txt_box
        .getActionMap()
        .put(
            "Undo",
            new AbstractAction("Undo") {
              public void actionPerformed(ActionEvent evt) {
                try {
                  if (undo.canUndo()) {
                    undo.undo();
                  }
                } catch (CannotUndoException e) {
                }
              }
            });

    // Bind the undo action to ctl-Z
    txt_box.getInputMap().put(KeyStroke.getKeyStroke("control Z"), "Undo");

    // Create a redo action and add it to the text component
    txt_box
        .getActionMap()
        .put(
            "Redo",
            new AbstractAction("Redo") {
              public void actionPerformed(ActionEvent evt) {
                try {
                  if (undo.canRedo()) {
                    undo.redo();
                  }
                } catch (CannotRedoException e) {
                }
              }
            });

    // Bind the redo action to ctl-Y
    txt_box.getInputMap().put(KeyStroke.getKeyStroke("control Y"), "Redo");
  }
예제 #5
0
 public void Margins_set(int left, int top, int right, int bot) {
   if (left == 0 && right == 0) {
     txt_box.setBorder(BorderFactory.createLineBorder(Color.BLACK));
     txt_box.setMargin(new Insets(0, 0, 0, 0));
   } else {
     //			txt_box.setBorder(BasicBorders.getTextFieldBorder());
     //			txt_box.setMargin(new Insets(0, l, 0, r));
     txt_box.setFont(new Font("Courier New", FontStyleAdp_.Plain.Val(), 12));
     txt_box.setBorder(
         BorderFactory.createCompoundBorder(
             BorderFactory.createLineBorder(Color.BLACK),
             BorderFactory.createEmptyBorder(top, left, bot, right)));
   }
 }
예제 #6
0
 public void OverrideTabKey_(boolean v) {
   txt_box.OverrideTabKey_(v);
   if (v) {
     Set<AWTKeyStroke> forTraSet = new HashSet<AWTKeyStroke>();
     txt_box.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forTraSet);
     txt_box.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, forTraSet);
   } else {
     Set<AWTKeyStroke> forTraSet = new HashSet<AWTKeyStroke>();
     txt_box.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forTraSet);
     txt_box.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, forTraSet);
     GxwTextBox_overrideKeyCmd.focus_(
         (GfuiElem) host, txt_box, "TAB"); // else ctrl+h deletes current char
     GxwTextBox_overrideKeyCmd.focusPrv_(
         (GfuiElem) host, txt_box, "shift TAB"); // else ctrl+h deletes current char
     //			Set<AWTKeyStroke> forTraSet = new HashSet<AWTKeyStroke> ();
     //			forTraSet.add(AWTKeyStroke.getAWTKeyStroke("TAB"));
     //			Set<AWTKeyStroke> bwdTraSet = new HashSet<AWTKeyStroke> ();
     //			bwdTraSet.add(AWTKeyStroke.getAWTKeyStroke("control TAB"));
     //			txt_box.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forTraSet);
     //			txt_box.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, bwdTraSet);
     //			txt_box.OverrideTabKey_(false);
   }
 }
예제 #7
0
 public void SelLen_set(int v) {
   txt_box.SelLen_set(v);
 }
예제 #8
0
 public boolean Border_on() {
   return txt_box.Border_on();
 }
예제 #9
0
 public void Host_set(GxwCbkHost host) {
   this.host = host;
   txt_box.Host_set(host);
 }
예제 #10
0
 public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
   if (ctx.Match(k, GxwElem_lang.AlignH_cmd)) AlignH_(GfuiAlign_.cast(m.CastObj("v")));
   return txt_box.Invk(ctx, ikey, k, m);
 }
예제 #11
0
 public void TextVal_set(String v) {
   txt_box.TextVal_set(v);
   txt_box.setSelectionStart(0);
   txt_box.setSelectionEnd(0); // else selects whole text and scrolls to end of selection
 }
예제 #12
0
 public String TextVal() {
   return txt_box.TextVal();
 }
예제 #13
0
 public void SendKeyDown(IptKey key) {
   txt_box.SendKeyDown(key);
 }
예제 #14
0
 public void EnableDoubleBuffering() {
   txt_box.EnableDoubleBuffering();
 }
예제 #15
0
 public void Border_on_(boolean v) {
   txt_box.Border_on_(v);
 }
예제 #16
0
 public int SelLen() {
   return txt_box.SelLen();
 }
예제 #17
0
 public int SelBgn() {
   return txt_box.SelBgn();
 }
예제 #18
0
 public boolean OverrideTabKey() {
   return txt_box.OverrideTabKey();
 }
예제 #19
0
 public void CreateControlIfNeeded() {
   txt_box.CreateControlIfNeeded();
 }