mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.2.1
This commit is contained in:
31
150_gfui/src_300_gxw/gplx/gfui/GxwBoxListener.java
Normal file
31
150_gfui/src_300_gxw/gplx/gfui/GxwBoxListener.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
public class GxwBoxListener implements ComponentListener, FocusListener {
|
||||
@Override public void componentShown(ComponentEvent e) {host.Host().VisibleChangedCbk();}
|
||||
@Override public void componentHidden(ComponentEvent e) {host.Host().VisibleChangedCbk();}
|
||||
@Override public void componentMoved(ComponentEvent e) {}
|
||||
@Override public void componentResized(ComponentEvent e) {host.Host().SizeChangedCbk();}
|
||||
@Override public void focusGained(FocusEvent e) {host.Host().FocusGotCbk();}
|
||||
@Override public void focusLost(FocusEvent e) {host.Host().FocusLostCbk();}
|
||||
public GxwBoxListener(GxwElem host) {this.host = host;} GxwElem host;
|
||||
}
|
||||
35
150_gfui/src_300_gxw/gplx/gfui/GxwCbkHost.java
Normal file
35
150_gfui/src_300_gxw/gplx/gfui/GxwCbkHost.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface GxwCbkHost {
|
||||
boolean KeyDownCbk(IptEvtDataKey data);
|
||||
boolean KeyHeldCbk(IptEvtDataKeyHeld data);
|
||||
boolean KeyUpCbk(IptEvtDataKey data);
|
||||
boolean MouseDownCbk(IptEvtDataMouse data);
|
||||
boolean MouseUpCbk(IptEvtDataMouse data);
|
||||
boolean MouseMoveCbk(IptEvtDataMouse data);
|
||||
boolean MouseWheelCbk(IptEvtDataMouse data);
|
||||
boolean PaintCbk(PaintArgs paint);
|
||||
boolean PaintBackgroundCbk(PaintArgs paint);
|
||||
boolean DisposeCbk();
|
||||
boolean SizeChangedCbk();
|
||||
boolean FocusGotCbk();
|
||||
boolean FocusLostCbk();
|
||||
boolean VisibleChangedCbk();
|
||||
//boolean WndProcCbk(WindowMessage windowMessage);
|
||||
}
|
||||
86
150_gfui/src_300_gxw/gplx/gfui/GxwCbkHost_.java
Normal file
86
150_gfui/src_300_gxw/gplx/gfui/GxwCbkHost_.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
class GxwCbkHost_ {
|
||||
public static final GxwCbkHost Null = new GfuiHost_cls_null();
|
||||
public static final boolean ExecKeyEvent(GxwCbkHost host, KeyEvent e) {
|
||||
boolean rv = true; int id = e.getID(), val = e.getKeyCode();
|
||||
boolean isAltF4 = false;
|
||||
if (e.isAltDown() && val == IptKey_.F4.Val() ) {
|
||||
isAltF4 = true;
|
||||
}
|
||||
if (id == KeyEvent.KEY_TYPED) {
|
||||
IptEvtDataKeyHeld keyHeldData = IptEvtDataKeyHeld.char_(e.getKeyChar());
|
||||
rv = host.KeyHeldCbk(keyHeldData);
|
||||
if (keyHeldData.Handled()) rv = false;
|
||||
}
|
||||
else {
|
||||
if (e.isShiftDown()) val |= IptKey_.Shift.Val();
|
||||
if (e.isControlDown()) val |= IptKey_.Ctrl.Val();
|
||||
if (e.isAltDown()) val |= IptKey_.Alt.Val();
|
||||
IptEvtDataKey keyData = IptEvtDataKey.int_(val);
|
||||
// Tfds.Write(e.getKeyChar(), e.getKeyCode(), val, id);
|
||||
if (id == KeyEvent.KEY_PRESSED) rv = host.KeyDownCbk(keyData);
|
||||
else if (id == KeyEvent.KEY_RELEASED) rv = host.KeyUpCbk(keyData);
|
||||
if (keyData.Handled()) rv = false; // was false
|
||||
}
|
||||
if (isAltF4) {
|
||||
e.consume();
|
||||
}
|
||||
if (e.getKeyCode() == KeyEvent.VK_ALT) e.consume(); // force consume of alt-keys; occurs when alt-f4ing out of video app (though not audio app)
|
||||
return rv;
|
||||
}
|
||||
public static final boolean ExecMouseEvent(GxwCbkHost host, MouseEvent e) {
|
||||
int button = e.getButton(), val = 0;
|
||||
if (button == MouseEvent.BUTTON1)
|
||||
val = IptMouseBtn_.Left.Val();
|
||||
if (button == MouseEvent.BUTTON2) val |= IptMouseBtn_.Middle.Val();
|
||||
if (button == MouseEvent.BUTTON3) val |= IptMouseBtn_.Right.Val();
|
||||
IptEvtDataMouse data = IptEvtDataMouse.new_(IptMouseBtn_.api_(val), IptMouseWheel_.None, e.getX(), e.getY());
|
||||
boolean rv = true;
|
||||
int id = e.getID();
|
||||
if (id == MouseEvent.MOUSE_PRESSED) rv = host.MouseDownCbk(data);
|
||||
else if (id == MouseEvent.MOUSE_RELEASED) rv = host.MouseUpCbk(data);
|
||||
return rv;
|
||||
}
|
||||
public static final boolean ExecMouseWheel(GxwCbkHost host, MouseWheelEvent e) {
|
||||
IptMouseWheel wheel = e.getWheelRotation() < 0 ? IptMouseWheel_.Up : IptMouseWheel_.Down;
|
||||
return host.MouseWheelCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, wheel, e.getX(), e.getY()));
|
||||
}
|
||||
}
|
||||
class GfuiHost_cls_null implements GxwCbkHost { // NOTE: return true by default so that super.proc() is always called; ex: SizeChangedCbk should return true so that super.OnResize will be called
|
||||
public boolean KeyDownCbk(IptEvtDataKey data) {return true;}
|
||||
public boolean KeyHeldCbk(IptEvtDataKeyHeld data) {return true;}
|
||||
public boolean KeyUpCbk(IptEvtDataKey data) {return true;}
|
||||
public boolean MouseDownCbk(IptEvtDataMouse data) {return true;}
|
||||
public boolean MouseUpCbk(IptEvtDataMouse data) {return true;}
|
||||
public boolean MouseMoveCbk(IptEvtDataMouse data) {return true;}
|
||||
public boolean MouseWheelCbk(IptEvtDataMouse data) {return true;}
|
||||
public boolean PaintCbk(PaintArgs paint) {return true;}
|
||||
public boolean PaintBackgroundCbk(PaintArgs paint) {return true;}
|
||||
public boolean DisposeCbk() {return true;}
|
||||
public boolean SizeChangedCbk() {return true;}
|
||||
public boolean FocusGotCbk() {return true;}
|
||||
public boolean FocusLostCbk() {return true;}
|
||||
public boolean VisibleChangedCbk() {return true;}
|
||||
// public boolean WndProcCbk(WindowMessage windowMessage) {return true;}
|
||||
}
|
||||
31
150_gfui/src_300_gxw/gplx/gfui/GxwCheckListBox.java
Normal file
31
150_gfui/src_300_gxw/gplx/gfui/GxwCheckListBox.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface GxwCheckListBox extends GxwElem {
|
||||
int Items_count();
|
||||
List_adp Items_getAll();
|
||||
List_adp Items_getChecked();
|
||||
|
||||
void Items_add(Object obj, boolean v);
|
||||
void Items_reverse();
|
||||
boolean Items_getCheckedAt(int i);
|
||||
void Items_setCheckedAt(int i, boolean v);
|
||||
void Items_setAll(boolean v);
|
||||
|
||||
void Items_clear();
|
||||
}
|
||||
201
150_gfui/src_300_gxw/gplx/gfui/GxwCheckListBox_lang.java
Normal file
201
150_gfui/src_300_gxw/gplx/gfui/GxwCheckListBox_lang.java
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.util.Vector;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import gplx.gfui.*;
|
||||
public class GxwCheckListBox_lang extends JScrollPane implements GxwCheckListBox, GxwElem {
|
||||
Vector<CheckListItem> internalItems;
|
||||
GxwListBox_lang listBox;
|
||||
public GxwCheckListBox_lang() {
|
||||
initComponents();
|
||||
}
|
||||
private void initComponents() {
|
||||
listBox = GxwListBox_lang.new_();
|
||||
this.setViewportView(listBox);
|
||||
|
||||
internalItems = new Vector<CheckListItem>();
|
||||
this.listBox.setListData(internalItems);
|
||||
|
||||
CheckListCellRenderer renderer = new CheckListCellRenderer();
|
||||
listBox.setCellRenderer(renderer);
|
||||
listBox.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
CheckListListener lst = new CheckListListener(this); listBox.addMouseListener(lst); listBox.addKeyListener(lst);
|
||||
ctrlMgr = new GxwCore_host(GxwCore_lang.new_(this), listBox.ctrlMgr);
|
||||
|
||||
// ctrlMgr = GxwCore_lang.new_(this);
|
||||
this.enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
|
||||
GxwBoxListener_checkListBox lnr = new GxwBoxListener_checkListBox(this, this);
|
||||
// this.setFocusTraversalKeysEnabled(false);
|
||||
this.addComponentListener(lnr);
|
||||
this.addFocusListener(lnr);
|
||||
}
|
||||
public GxwCbkHost Host() {return host;}
|
||||
public void Host_set(GxwCbkHost host) {
|
||||
this.host = host;
|
||||
listBox.Host_set(host);
|
||||
} private GxwCbkHost host = GxwCbkHost_.Null;
|
||||
// @Override public boolean requestFocusInWindow() {
|
||||
// return listBox.requestFocusInWindow();
|
||||
//// return super.requestFocusInWindow();
|
||||
// }
|
||||
public List_adp Items_getAll() {return Items_get(Mode_All);}
|
||||
public int Items_count() {return internalItems.size();}
|
||||
public boolean Items_getCheckedAt(int i) {return internalItems.get(i).selected;}
|
||||
public void Items_setCheckedAt(int i, boolean v) {internalItems.get(i).selected = v;}
|
||||
public List_adp Items_getChecked() {return Items_get(Mode_Selected);}
|
||||
static final int Mode_All = 1, Mode_Selected = 2;
|
||||
List_adp Items_get(int mode) {
|
||||
List_adp list = List_adp_.new_();
|
||||
for (CheckListItem data: internalItems) {
|
||||
boolean add = (mode == Mode_All) || (mode == Mode_Selected) && data.Selected();
|
||||
if (add)
|
||||
list.Add(data.Data());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public void Items_add(Object data, boolean selected) {
|
||||
internalItems.add(new CheckListItem(data, selected));
|
||||
this.listBox.setListData(internalItems);
|
||||
this.listBox.updateUI();
|
||||
}
|
||||
public void Items_setAll(boolean v) {
|
||||
for (CheckListItem data: internalItems) {
|
||||
data.Selected_set(v);
|
||||
}
|
||||
this.listBox.updateUI();
|
||||
}
|
||||
public void Items_reverse() {
|
||||
for (CheckListItem data: internalItems) {
|
||||
data.Selected_set(!data.Selected());
|
||||
}
|
||||
this.listBox.updateUI();
|
||||
}
|
||||
public void Items_clear() {
|
||||
internalItems.clear();
|
||||
this.listBox.updateUI();
|
||||
}
|
||||
@Override public void setBounds(Rectangle r) {super.setBounds(r); this.validate();}
|
||||
@Override public void setSize(int w, int h) {super.setSize(w, h); this.validate();}
|
||||
@Override public void setSize(Dimension d) {super.setSize(d); this.validate();}
|
||||
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public String TextVal() {return "GxwCheckListBox_lang";} public void TextVal_set(String v) {}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return this;
|
||||
}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void SendMouseWheel(IptMouseWheel direction) {}
|
||||
@Override public void processKeyEvent(KeyEvent e) {
|
||||
if (GxwCbkHost_.ExecKeyEvent(host, e))
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go before PaintCbk (had issues with drawing text on images)
|
||||
}
|
||||
public void EnableDoubleBuffering() { // eliminates flickering during OnPaint
|
||||
}
|
||||
public void CreateControlIfNeeded() {
|
||||
}
|
||||
}
|
||||
class GxwBoxListener_checkListBox extends GxwBoxListener {
|
||||
@Override public void focusGained(FocusEvent e) {
|
||||
host.Host().FocusGotCbk();
|
||||
clb.listBox.requestFocusInWindow();
|
||||
if (clb.listBox.getSelectedIndex() < 0)
|
||||
clb.listBox.setSelectedIndex(0);
|
||||
}
|
||||
@Override public void focusLost(FocusEvent e) {host.Host().FocusLostCbk();}
|
||||
public GxwBoxListener_checkListBox(GxwElem host, GxwCheckListBox_lang clb) {super(host); this.clb = clb;}
|
||||
GxwCheckListBox_lang clb;
|
||||
}
|
||||
class CheckListListener implements MouseListener, KeyListener {
|
||||
GxwCheckListBox_lang m_parent; JList m_list;
|
||||
public CheckListListener(GxwCheckListBox_lang parent) {
|
||||
m_parent = parent;
|
||||
m_list = parent.listBox;
|
||||
}
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getX() < 20) doCheck();
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {}
|
||||
public void mouseReleased(MouseEvent e) {}
|
||||
public void mouseEntered(MouseEvent e) {}
|
||||
public void mouseExited(MouseEvent e) {}
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyChar() == ' ') doCheck();
|
||||
}
|
||||
public void keyTyped(KeyEvent e) {
|
||||
}
|
||||
public void keyReleased(KeyEvent e) {
|
||||
}
|
||||
protected void doCheck() {
|
||||
int index = m_list.getSelectedIndex();
|
||||
if (index < 0) return;
|
||||
CheckListItem data = (CheckListItem)m_list.getModel().getElementAt(index);
|
||||
data.Selected_toggle();
|
||||
m_list.repaint();
|
||||
}
|
||||
}
|
||||
class CheckListCellRenderer extends JCheckBox implements ListCellRenderer{
|
||||
public CheckListCellRenderer() {
|
||||
setOpaque(true);
|
||||
setBorder(GxwBorderFactory.Empty);
|
||||
}
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
if (value != null) setText(value.toString());
|
||||
setBackground(isSelected ? list.getSelectionBackground() : list.getBackground());
|
||||
setForeground(isSelected ? list.getSelectionForeground() : list.getForeground());
|
||||
|
||||
CheckListItem data = (CheckListItem)value;
|
||||
setSelected(data.Selected());
|
||||
|
||||
setFont(list.getFont());
|
||||
setBorder((cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : GxwBorderFactory.Empty);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class CheckListItem {
|
||||
public CheckListItem(Object data, Boolean selected) {this.data = data; this.selected = selected;}
|
||||
public Object Data() {return data;} Object data;
|
||||
public boolean Selected() {return selected;} public void Selected_set(boolean selected) {this.selected = selected;} protected boolean selected;
|
||||
public void Selected_toggle() {selected = !selected;}
|
||||
public String toString() {return Object_.Xto_str_strict_or_null_mark(data);}
|
||||
}
|
||||
22
150_gfui/src_300_gxw/gplx/gfui/GxwComboBox.java
Normal file
22
150_gfui/src_300_gxw/gplx/gfui/GxwComboBox.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface GxwComboBox extends GxwElem {
|
||||
void DataSource_set(Object... ary);
|
||||
Object SelectedItm(); void SelectedItm_set(Object v);
|
||||
}
|
||||
108
150_gfui/src_300_gxw/gplx/gfui/GxwComboBox_lang.java
Normal file
108
150_gfui/src_300_gxw/gplx/gfui/GxwComboBox_lang.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.*;
|
||||
public class GxwComboBox_lang extends JComboBox implements GxwComboBox, GxwElem, ActionListener {
|
||||
public void DataSource_set(Object... ary) {
|
||||
for (Object o : ary)
|
||||
this.insertItemAt(o, this.getItemCount());
|
||||
/*
|
||||
Get current value
|
||||
Object obj = cb.getSelectedItem();
|
||||
|
||||
Set a new valu
|
||||
cb.setSelectedItem("item2");
|
||||
obj = cb.getSelectedItem();
|
||||
*/
|
||||
}
|
||||
public Object SelectedItm() {return this.getEditor().getItem();} public void SelectedItm_set(Object v) {
|
||||
this.getEditor().setItem(v);
|
||||
}
|
||||
void ctor_() {
|
||||
ctrlMgr = GxwCore_lang.new_(this);
|
||||
this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
|
||||
GxwBoxListener lnr = new GxwBoxListener(this);
|
||||
// this.setFocusTraversalKeysEnabled(false);
|
||||
// this.addKeyListener(this);
|
||||
this.addComponentListener(lnr);
|
||||
this.addFocusListener(lnr);
|
||||
this.setEditable(true);
|
||||
// this.addActionListener(this);
|
||||
this.setFocusable(true);
|
||||
this.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
Component jc = this.getEditor().getEditorComponent(); // WORKAROUND:SWING:JComboBox does not reroute events from editor; will not handle canceling key
|
||||
jc.addKeyListener(new ComboBox_keylistener(this));
|
||||
}
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
// need to validate, else dropDownArrow will not get redrawn in correct pos
|
||||
@Override public void setBounds(Rectangle r) {super.setBounds(r); this.validate();}
|
||||
@Override public void setSize(int w, int h) {super.setSize(w, h); this.validate();}
|
||||
@Override public void setSize(Dimension d) {super.setSize(d); this.validate();}
|
||||
public String TextVal() {return Object_.Xto_str_strict_or_empty(this.SelectedItm());} public void TextVal_set(String v) {this.SelectedItm_set(v);}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return this;
|
||||
}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void SendMouseWheel(IptMouseWheel direction) {}
|
||||
// @Override public void keyPressed(KeyEvent arg0) {this.processKeyEvent(arg0);}
|
||||
// @Override public void keyReleased(KeyEvent arg0) {this.processKeyEvent(arg0);}
|
||||
// @Override public void keyTyped(KeyEvent arg0) {this.processKeyEvent(arg0);}
|
||||
@Override public void processKeyEvent(KeyEvent e) {
|
||||
if (GxwCbkHost_.ExecKeyEvent(host, e))
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
// @Override public void actionPerformed(ActionEvent e) {
|
||||
// }
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go before PaintCbk (had issues with drawing text on images)
|
||||
}
|
||||
public void EnableDoubleBuffering() { // eliminates flickering during OnPaint
|
||||
}
|
||||
public void CreateControlIfNeeded() {
|
||||
}
|
||||
public static GxwComboBox_lang new_() {
|
||||
GxwComboBox_lang rv = new GxwComboBox_lang();
|
||||
rv.ctor_();
|
||||
return rv;
|
||||
} GxwComboBox_lang() {}
|
||||
}
|
||||
class ComboBox_keylistener implements KeyListener {
|
||||
public ComboBox_keylistener(GxwComboBox_lang host) {this.host = host;} GxwComboBox_lang host;
|
||||
@Override public void keyPressed(KeyEvent arg0) {
|
||||
// if (arg0.getKeyChar() == 'f')
|
||||
// System.out.println('h');
|
||||
host.processKeyEvent(arg0);
|
||||
}
|
||||
@Override public void keyReleased(KeyEvent arg0) {
|
||||
//host.processKeyEvent(arg0);
|
||||
}
|
||||
@Override public void keyTyped(KeyEvent arg0) {
|
||||
//host.processKeyEvent(arg0);
|
||||
}
|
||||
}
|
||||
|
||||
43
150_gfui/src_300_gxw/gplx/gfui/GxwCore_base.java
Normal file
43
150_gfui/src_300_gxw/gplx/gfui/GxwCore_base.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public abstract class GxwCore_base {
|
||||
public abstract void Controls_add(GxwElem sub);
|
||||
public abstract void Controls_del(GxwElem sub);
|
||||
public abstract int Width(); public abstract void Width_set(int v);
|
||||
public abstract int Height(); public abstract void Height_set(int v);
|
||||
public abstract int X(); public abstract void X_set(int v);
|
||||
public abstract int Y(); public abstract void Y_set(int v);
|
||||
public abstract SizeAdp Size(); public abstract void Size_set(SizeAdp v);
|
||||
public abstract PointAdp Pos(); public abstract void Pos_set(PointAdp v);
|
||||
public abstract RectAdp Rect(); public abstract void Rect_set(RectAdp v);
|
||||
public abstract boolean Visible(); public abstract void Visible_set(boolean v);
|
||||
public abstract ColorAdp BackColor(); public abstract void BackColor_set(ColorAdp v);
|
||||
public abstract ColorAdp ForeColor(); public abstract void ForeColor_set(ColorAdp v);
|
||||
public abstract FontAdp TextFont(); public abstract void TextFont_set(FontAdp v);
|
||||
public abstract String TipText(); public abstract void TipText_set(String v);
|
||||
|
||||
public abstract int Focus_index(); public abstract void Focus_index_set(int v);
|
||||
public abstract boolean Focus_able(); public abstract void Focus_able_(boolean v);
|
||||
public abstract boolean Focus_has();
|
||||
public abstract void Focus();
|
||||
public abstract void Select_exec();
|
||||
public abstract void Zorder_front(); public abstract void Zorder_back();
|
||||
public abstract void Invalidate();
|
||||
public abstract void Dispose();
|
||||
}
|
||||
159
150_gfui/src_300_gxw/gplx/gfui/GxwCore_lang.java
Normal file
159
150_gfui/src_300_gxw/gplx/gfui/GxwCore_lang.java
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JWindow;
|
||||
import javax.swing.RootPaneContainer;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.ToolTipManager;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
public class GxwCore_lang extends GxwCore_base {
|
||||
@Override public int Width() {return control.getWidth();} @Override public void Width_set(int v) {control.setSize(v, control.getHeight());}
|
||||
@Override public int Height() {return control.getHeight();} @Override public void Height_set(int v) {control.setSize(control.getWidth(), v);}
|
||||
@Override public int X() {return control.getX();} @Override public void X_set(int v) {control.setLocation(v, control.getY());}
|
||||
@Override public int Y() {return control.getY();} @Override public void Y_set(int v) {control.setLocation(control.getX(), v);}
|
||||
@Override public SizeAdp Size() {return GxwCore_lang.XtoSizeAdp(control.getSize());} @Override public void Size_set(SizeAdp v) {control.setSize(GxwCore_lang.Xto_size(v));}
|
||||
@Override public PointAdp Pos() {return GxwCore_lang.XtoPointAdp(control.getLocation());} @Override public void Pos_set(PointAdp v) {control.setLocation(GxwCore_lang.XtoPoint(v));}
|
||||
@Override public RectAdp Rect() {return GxwCore_lang.XtoRectAdp(control.getBounds());} @Override public void Rect_set(RectAdp v) {
|
||||
control.setBounds(GxwCore_lang.XtoRect(v));
|
||||
// control.setLocation(v.Pos().XtoPoint());
|
||||
// control.setSize(v.Size().XtoDimension());
|
||||
}
|
||||
@Override public boolean Visible() {
|
||||
Container owner = control.getParent();
|
||||
// WORKAROUND:JAVA: .NET automatically propagates .Visible down ElementTree; .Visible needs to propagate else sub.Visible can be true though owner.Visible will be false
|
||||
while (owner != null) {
|
||||
if (!owner.isVisible())
|
||||
return false; // handles case wherein sub is visible but owner is not -> sub should be marked not visible
|
||||
owner = owner.getParent();
|
||||
}
|
||||
return control.isVisible();
|
||||
}
|
||||
@Override public void Visible_set(boolean v) {
|
||||
control.setVisible(v);
|
||||
}
|
||||
@Override public ColorAdp BackColor() {return XtoColorAdp(control.getBackground());}
|
||||
@Override public void BackColor_set(ColorAdp v) {
|
||||
if (control instanceof JComponent) {
|
||||
((JComponent)control).setBackground(ColorAdpCache._.GetNativeColor(v));
|
||||
}
|
||||
else if (control instanceof RootPaneContainer) {
|
||||
RootPaneContainer container = (RootPaneContainer)control;
|
||||
container.getContentPane().setBackground(ColorAdpCache._.GetNativeColor(v));
|
||||
}
|
||||
}
|
||||
@Override public ColorAdp ForeColor() {return XtoColorAdp(control.getForeground());} @Override public void ForeColor_set(ColorAdp v) {control.setForeground(ColorAdpCache._.GetNativeColor(v));}
|
||||
@Override public FontAdp TextFont() {
|
||||
if (prvFont != null) return prvFont;
|
||||
Font f = control.getFont();
|
||||
FontAdp curFont = FontAdp.new_(f.getFontName(), FontAdpCache.XtoOsDpi(f.getSize2D()), FontStyleAdp_.lang_(f.getStyle()));
|
||||
curFont.OwnerGxwCore_(this);
|
||||
prvFont = curFont;
|
||||
return prvFont;
|
||||
} FontAdp prvFont;
|
||||
@Override public void TextFont_set(FontAdp v) {
|
||||
control.setFont(v.UnderFont());
|
||||
v.OwnerGxwCore_(this);
|
||||
prvFont = v;
|
||||
}
|
||||
@Override public String TipText() {return tipText;} @Override public void TipText_set(String v) {tipText = v;} String tipText;
|
||||
@Override public void Controls_add(GxwElem sub) {
|
||||
try {
|
||||
JComponent component = (JComponent)sub;
|
||||
Container container = (Container)control;
|
||||
container.add(component);
|
||||
}catch (Exception e) {}
|
||||
}
|
||||
@Override public void Controls_del(GxwElem sub) {
|
||||
JComponent component = (JComponent)sub;
|
||||
// clear out painted area, or residue will remain (see opal when navigating to empty grid)
|
||||
Graphics2D g2 = (Graphics2D) component.getGraphics();
|
||||
g2.setColor(component.getBackground());
|
||||
g2.fillRect(0, 0, component.getWidth(), component.getHeight());
|
||||
g2.dispose();
|
||||
Container container = (Container)control;
|
||||
container.remove(component);
|
||||
}
|
||||
@Override public boolean Focus_has() {return control.hasFocus();}
|
||||
// @Override public boolean Focus_able() {return control.isFocusable();}
|
||||
// @Override public void Focus_able_(boolean v) {control.setFocusable(v);}
|
||||
@Override public boolean Focus_able() {return focus_able;} boolean focus_able;
|
||||
@Override public void Focus_able_(boolean v) {focus_able = v;}
|
||||
// @Override public void Focus_able_force_(boolean v){control.setFocusable(v);}
|
||||
@Override public int Focus_index() {return focusIndex;} @Override public void Focus_index_set(int v) {focusIndex = v;} int focusIndex;
|
||||
@Override public void Focus() {
|
||||
if (Focus_able()) { // NOTE: .Focus() only works if TabStop = true; otherwise, must call .Select()
|
||||
// FocusableThread t = new FocusableThread(control);
|
||||
// SwingUtilities.invokeLater(t);
|
||||
// control.requestFocus();
|
||||
if (!control.requestFocusInWindow()) { // will fail when switching to imgApp with gallery open from opalMain
|
||||
// control.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
class FocusableThread implements Runnable {
|
||||
public void run() {
|
||||
// comp.requestFocusInWindow();
|
||||
comp.requestFocus();
|
||||
comp.repaint();
|
||||
}
|
||||
public FocusableThread(Component comp) {this.comp = comp;} Component comp;
|
||||
}
|
||||
@Override public void Select_exec() {
|
||||
control.requestFocus();
|
||||
}
|
||||
@Override public void Zorder_front() {
|
||||
Container owner = control.getParent();
|
||||
if (owner == null)return;
|
||||
owner.setComponentZOrder(control, 0); // NOTE: last component gets drawn last, so will be first visually
|
||||
}
|
||||
@Override public void Zorder_back() {
|
||||
Container owner = control.getParent();
|
||||
owner.setComponentZOrder(control, owner.getComponentCount() - 1);
|
||||
}
|
||||
@Override public void Invalidate() {control.repaint();
|
||||
|
||||
}
|
||||
@Override public void Dispose() {} // JAVA: no Dispose for component? only for form
|
||||
protected Component control;
|
||||
public static GxwCore_lang new_(Component control) {
|
||||
GxwCore_lang rv = new GxwCore_lang();
|
||||
rv.control = control;
|
||||
return rv;
|
||||
} GxwCore_lang() {}
|
||||
public static ColorAdp XtoColorAdp(java.awt.Color v) {return ColorAdp.new_((int)v.getAlpha(), (int)v.getRed(), (int)v.getGreen(), (int)v.getBlue());}
|
||||
public static java.awt.Dimension Xto_size(SizeAdp v) {return new java.awt.Dimension(v.Width(), v.Height());}
|
||||
public static SizeAdp XtoSizeAdp(java.awt.Dimension val) {
|
||||
return new SizeAdp(val.width, val.height);
|
||||
}
|
||||
public static java.awt.Point XtoPoint(PointAdp v) {return new java.awt.Point(v.X(), v.Y());}
|
||||
public static PointAdp XtoPointAdp(java.awt.Point v) {
|
||||
return new PointAdp(v.x, v.y);
|
||||
}
|
||||
public static RectAdp XtoRectAdp(java.awt.Rectangle rect) {
|
||||
return new RectAdp(GxwCore_lang.XtoPointAdp(rect.getLocation())
|
||||
, GxwCore_lang.XtoSizeAdp(rect.getSize()));
|
||||
}
|
||||
public static java.awt.Rectangle XtoRect(RectAdp rect) {return new java.awt.Rectangle(rect.X(), rect.Y(), rect.Width(), rect.Height());}
|
||||
public static java.awt.Rectangle XtoRect(int x, int y, int w, int h) {return new java.awt.Rectangle(x, y, w, h);}
|
||||
}
|
||||
45
150_gfui/src_300_gxw/gplx/gfui/GxwCore_mock.java
Normal file
45
150_gfui/src_300_gxw/gplx/gfui/GxwCore_mock.java
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public class GxwCore_mock extends GxwCore_base {
|
||||
@Override public int Width() {return size.Width();} @Override public void Width_set(int v) {size = SizeAdp_.new_(v, size.Height());}
|
||||
@Override public int Height() {return size.Height();} @Override public void Height_set(int v) {size = SizeAdp_.new_(size.Width(), v);}
|
||||
@Override public int X() {return pos.X();} @Override public void X_set(int v) {pos = PointAdp_.new_(v, pos.Y());}
|
||||
@Override public int Y() {return pos.Y();} @Override public void Y_set(int v) {pos = PointAdp_.new_(pos.X(), v);}
|
||||
@Override public SizeAdp Size() {return size;} @Override public void Size_set(SizeAdp v) {size = v;} SizeAdp size = SizeAdp_.Zero;
|
||||
@Override public PointAdp Pos() {return pos;} @Override public void Pos_set(PointAdp v) {pos = v;} PointAdp pos = PointAdp_.Zero;
|
||||
@Override public RectAdp Rect() {return RectAdp_.vector_(pos, size);} @Override public void Rect_set(RectAdp v) {size = v.Size(); pos = v.Pos();}
|
||||
@Override public boolean Visible() {return visible;} @Override public void Visible_set(boolean v) {visible = v;} private boolean visible = true; // HACK: default all controls to visible (should be set to visible only when form is loaded); will cause FocusKeyMgrTst.SubWidget test to fail
|
||||
@Override public ColorAdp BackColor() {return backColor;} @Override public void BackColor_set(ColorAdp v) {backColor = v;} ColorAdp backColor = ColorAdp_.Null;
|
||||
@Override public ColorAdp ForeColor() {return textColor;} @Override public void ForeColor_set(ColorAdp v) {textColor = v;} ColorAdp textColor = ColorAdp_.Null;
|
||||
@Override public FontAdp TextFont() {return font;} @Override public void TextFont_set(FontAdp v) {font = v;} FontAdp font;
|
||||
@Override public String TipText() {return tipText;} @Override public void TipText_set(String v) {tipText = v;} private String tipText;
|
||||
|
||||
@Override public void Controls_add(GxwElem sub) {list.Add(sub);}
|
||||
@Override public void Controls_del(GxwElem sub) {list.Del(sub);}
|
||||
@Override public int Focus_index() {return focusKeyIndex;} @Override public void Focus_index_set(int v) {focusKeyIndex = v;} int focusKeyIndex;
|
||||
@Override public boolean Focus_able() {return canFocus;} @Override public void Focus_able_(boolean v) {canFocus = v;} private boolean canFocus = true;
|
||||
@Override public boolean Focus_has() {return false;}
|
||||
@Override public void Focus() {}
|
||||
@Override public void Select_exec() {}
|
||||
@Override public void Zorder_front() {} @Override public void Zorder_back() {}
|
||||
@Override public void Invalidate() {} @Override public void Dispose() {}
|
||||
|
||||
public void SendKey(IptKey key) {}
|
||||
List_adp list = List_adp_.new_();
|
||||
}
|
||||
26
150_gfui/src_300_gxw/gplx/gfui/GxwElem.java
Normal file
26
150_gfui/src_300_gxw/gplx/gfui/GxwElem.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface GxwElem extends GfoInvkAble {
|
||||
GxwCore_base Core();
|
||||
GxwCbkHost Host(); void Host_set(GxwCbkHost host);
|
||||
String TextVal(); void TextVal_set(String v);
|
||||
|
||||
|
||||
void EnableDoubleBuffering();
|
||||
}
|
||||
74
150_gfui/src_300_gxw/gplx/gfui/GxwElemFactory_base.java
Normal file
74
150_gfui/src_300_gxw/gplx/gfui/GxwElemFactory_base.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public abstract class GxwElemFactory_base {
|
||||
@gplx.Internal protected abstract GxwElem control_();
|
||||
@gplx.Internal protected abstract GxwWin win_app_();
|
||||
@gplx.Internal protected abstract GxwWin win_tool_(KeyValHash ctorArgs);
|
||||
@gplx.Internal protected abstract GxwWin win_toaster_(KeyValHash ctorArgs);
|
||||
@gplx.Internal protected abstract GxwElem lbl_();
|
||||
@gplx.Internal protected abstract GxwTextFld text_fld_();
|
||||
@gplx.Internal protected abstract GxwTextFld text_memo_();
|
||||
@gplx.Internal protected abstract GxwTextHtml text_html_();
|
||||
@gplx.Internal protected abstract GxwCheckListBox checkListBox_(KeyValHash ctorArgs);
|
||||
@gplx.Internal protected abstract GxwComboBox comboBox_();
|
||||
@gplx.Internal protected abstract GxwListBox listBox_();
|
||||
// @gplx.Internal protected GxwElem spacer_() {return MockControl.new_();}
|
||||
}
|
||||
class GxwElemFactory_ {
|
||||
public static GxwElemFactory_base _ = new GxwElemFactory_cls_mock();
|
||||
public static void winForms_() {_ = new GxwElemFactory_cls_lang();}
|
||||
public static void swt_(org.eclipse.swt.widgets.Display display) {_ = new GxwElemFactory_swt(display);}
|
||||
}
|
||||
class GxwElemFactory_cls_lang extends GxwElemFactory_base {
|
||||
@gplx.Internal @Override protected GxwElem control_() {return new GxwElem_lang();}
|
||||
@gplx.Internal @Override protected GxwWin win_tool_(KeyValHash ctorArgs) {
|
||||
GfuiWin ownerForm = (GfuiWin)ctorArgs.FetchValOr(GfuiElem_.InitKey_ownerWin, null);
|
||||
GxwWin ownerElem = ownerForm == null ? null : (GxwWin)ownerForm.UnderElem();
|
||||
return GxwWin_jdialog.new_(ownerElem);
|
||||
// return GxwWin_lang.new_();
|
||||
}
|
||||
@gplx.Internal @Override protected GxwWin win_toaster_(KeyValHash ctorArgs) {
|
||||
GfsCtx ctx = GfsCtx.new_(); ctx.Match("", "");
|
||||
GfuiWin ownerForm = (GfuiWin)ctorArgs.FetchValOr(GfuiElem_.InitKey_ownerWin, null);
|
||||
GxwWin ownerElem = ownerForm == null ? null : (GxwWin)ownerForm.UnderElem();
|
||||
return GxwWin_jwindow.new_(ownerElem);
|
||||
// return GxwWin_lang.new_();
|
||||
}
|
||||
@gplx.Internal @Override protected GxwWin win_app_() {return GxwWin_lang.new_();}
|
||||
@gplx.Internal @Override protected GxwElem lbl_() {return new GxwElem_lang();}
|
||||
@gplx.Internal @Override protected GxwTextFld text_fld_() {return GxwTextBox_lang_.fld_();}
|
||||
@gplx.Internal @Override protected GxwTextFld text_memo_() {return GxwTextBox_lang_.memo_();}
|
||||
@gplx.Internal @Override protected GxwTextHtml text_html_() {return new GxwTextHtml_lang().ctor();}
|
||||
@gplx.Internal @Override protected GxwCheckListBox checkListBox_(KeyValHash ctorArgs) {return new GxwCheckListBox_lang();}
|
||||
@gplx.Internal @Override protected GxwComboBox comboBox_() {return GxwComboBox_lang.new_();}
|
||||
@gplx.Internal @Override protected GxwListBox listBox_() {return GxwListBox_lang.new_();}
|
||||
}
|
||||
class GxwElemFactory_cls_mock extends GxwElemFactory_base {
|
||||
@gplx.Internal @Override protected GxwElem control_() {return GxwElem_mock_base.new_();}
|
||||
@gplx.Internal @Override protected GxwWin win_app_() {return MockForm._;}
|
||||
@gplx.Internal @Override protected GxwWin win_tool_(KeyValHash ctorArgs) {return MockForm._;}
|
||||
@gplx.Internal @Override protected GxwWin win_toaster_(KeyValHash ctorArgs) {return MockForm._;}
|
||||
@gplx.Internal @Override protected GxwElem lbl_() {return GxwElem_mock_base.new_();}
|
||||
@gplx.Internal @Override protected GxwTextFld text_fld_() {return new MockTextBox();}
|
||||
@gplx.Internal @Override protected GxwTextFld text_memo_() {return new MockTextBoxMulti();}
|
||||
@gplx.Internal @Override protected GxwTextHtml text_html_() {return new MockTextBoxMulti();}
|
||||
@gplx.Internal @Override protected GxwCheckListBox checkListBox_(KeyValHash ctorArgs) {throw Exc_.new_unimplemented();}
|
||||
@gplx.Internal @Override protected GxwComboBox comboBox_() {return new MockComboBox();}
|
||||
@gplx.Internal @Override protected GxwListBox listBox_() {return new MockListBox();}
|
||||
}
|
||||
67
150_gfui/src_300_gxw/gplx/gfui/GxwElem_lang.java
Normal file
67
150_gfui/src_300_gxw/gplx/gfui/GxwElem_lang.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import javax.swing.JComponent;
|
||||
public class GxwElem_lang extends JComponent implements GxwElem {
|
||||
public static final String AlignH_cmd = "AlignH";
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public String TextVal() {return text;} public void TextVal_set(String v) {text = v;} String text; // JAVA: JComponent does not support Text (.NET Control does)
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;} // noop: intended for AlignH
|
||||
@Override public void processKeyEvent(KeyEvent e) {if (GxwCbkHost_.ExecKeyEvent(host, e)) super.processKeyEvent(e);}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {
|
||||
if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
// always paint background color; must happen before any controlPaint; extract to separate method if override needed
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
g2.setBackground(this.getBackground());
|
||||
RectAdp clipRect = GxwCore_lang.XtoRectAdp(g2.getClipBounds());
|
||||
g2.clearRect(clipRect.X(), clipRect.Y(), clipRect.Width(), clipRect.Height());
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_(g2), clipRect))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go before PaintCbk (had issues with drawing text on images)
|
||||
}
|
||||
// todo: call Dispose when ownerForm is disposed
|
||||
// @Override protected void Dispose(boolean disposing) {if (host.DisposeCbk()) super.Dispose(disposing);}
|
||||
public void ctor_GxwElem() {
|
||||
ctrlMgr = GxwCore_lang.new_(this);
|
||||
GxwBoxListener lnr = new GxwBoxListener(this);
|
||||
//this.setFocusTraversalKeysEnabled(false);
|
||||
this.addComponentListener(lnr);
|
||||
this.addFocusListener(lnr);
|
||||
this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
|
||||
}
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {
|
||||
}
|
||||
public void EnableDoubleBuffering() {} // eliminates flickering during OnPaint
|
||||
JComponent comp = null;
|
||||
public GxwElem_lang() {this.ctor_GxwElem();}
|
||||
}
|
||||
74
150_gfui/src_300_gxw/gplx/gfui/GxwElem_mock_base.java
Normal file
74
150_gfui/src_300_gxw/gplx/gfui/GxwElem_mock_base.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public class GxwElem_mock_base implements GxwElem {
|
||||
public GxwCore_base Core() {return ctrlMgr;} final GxwCore_mock ctrlMgr = new GxwCore_mock();
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public String TextVal() {return text;} public void TextVal_set(String v) {text = v;} private String text = "";
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void EnableDoubleBuffering() {}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return this;
|
||||
}
|
||||
|
||||
List_adp list = List_adp_.new_();
|
||||
public static GxwElem_mock_base new_() {return new GxwElem_mock_base();} protected GxwElem_mock_base() {}
|
||||
}
|
||||
class MockTextBox extends GxwElem_mock_base implements GxwTextFld {
|
||||
public boolean Border_on() {return borderOn;} public void Border_on_(boolean v) {borderOn = v;} private boolean borderOn = true;
|
||||
public boolean OverrideTabKey() {return false;} public void OverrideTabKey_(boolean v) {}
|
||||
public int SelBgn() {return selectionStart;} public void SelBgn_set(int v) {selectionStart = v;} int selectionStart;
|
||||
public int SelLen() {return selectionLength;} public void SelLen_set(int v) {selectionLength = v;} int selectionLength;
|
||||
public void AlignH_(GfuiAlign val) {}
|
||||
public void CreateControlIfNeeded() {}
|
||||
public void Margins_set(int left, int top, int right, int bot) {}
|
||||
}
|
||||
class MockTextBoxMulti extends MockTextBox implements GxwTextMemo, GxwTextHtml { public KeyVal[] Html_sel_atrs() {return KeyVal_.Ary_empty;}
|
||||
public void Html_enabled(boolean v) {}
|
||||
public String Html_doc_html() {return "";}
|
||||
public void Html_css_set(String s) {}
|
||||
public int LinesPerScreen() {return linesPerScreen;} int linesPerScreen = 1;
|
||||
public int LinesTotal() {return linesTotal;} int linesTotal = 1;
|
||||
public int ScreenCount() {return screenCount;} int screenCount = 1;
|
||||
public int LineLength(int lineIndex) {return -1;}
|
||||
public int CharIndexOf(int lineIndex) {return -1;}
|
||||
public int CharIndexOfFirst() {return -1;}
|
||||
public int LineIndexOfFirst() {return -1;}
|
||||
public int LineIndexOf(int charIndex) {return -1;}
|
||||
public PointAdp PosOf(int charIndex) {return PointAdp_.Null;}
|
||||
public void ScrollLineUp() {}
|
||||
public void ScrollLineDown() {}
|
||||
public void ExtendLineUp() {}
|
||||
public void ExtendLineDown() {}
|
||||
public void ScrollScreenUp() {}
|
||||
public void ScrollScreenDown() {}
|
||||
public void SelectionStart_toFirstChar() {}
|
||||
public void ScrollTillSelectionStartIsFirstLine() {}
|
||||
public void ScrollTillCaretIsVisible() {}
|
||||
}
|
||||
class MockComboBox extends GxwElem_mock_base implements GxwComboBox {
|
||||
public void DataSource_set(Object... ary) {}
|
||||
public Object SelectedItm() {return selectedItm;} public void SelectedItm_set(Object v) {this.selectedItm = v;} Object selectedItm;
|
||||
}
|
||||
class MockListBox extends GxwElem_mock_base implements GxwListBox {
|
||||
public void Items_Add(Object item) {}
|
||||
public void Items_Clear() {}
|
||||
public Object Items_SelObj() {return null;}
|
||||
public int Items_Count() {return -1;}
|
||||
public int Items_SelIdx() {return -1;} public void Items_SelIdx_set(int v) {}
|
||||
}
|
||||
25
150_gfui/src_300_gxw/gplx/gfui/GxwListBox.java
Normal file
25
150_gfui/src_300_gxw/gplx/gfui/GxwListBox.java
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface GxwListBox extends GxwElem {
|
||||
void Items_Add(Object item);
|
||||
void Items_Clear();
|
||||
int Items_Count();
|
||||
int Items_SelIdx(); void Items_SelIdx_set(int v);
|
||||
Object Items_SelObj();
|
||||
}
|
||||
82
150_gfui/src_300_gxw/gplx/gfui/GxwListBox_lang.java
Normal file
82
150_gfui/src_300_gxw/gplx/gfui/GxwListBox_lang.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.*;
|
||||
class GxwListBox_lang extends JList implements GxwListBox {
|
||||
void ctor_() {
|
||||
ctrlMgr = GxwCore_lang.new_(this);
|
||||
this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
|
||||
GxwBoxListener lnr = new GxwBoxListener(this);
|
||||
// this.setFocusTraversalKeysEnabled(false);
|
||||
this.addComponentListener(lnr);
|
||||
this.addFocusListener(lnr);
|
||||
this.setFocusable(true);
|
||||
this.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
}
|
||||
Vector<String> internalItems = new Vector<String>();
|
||||
public void Items_Add(Object item) {
|
||||
internalItems.add((String)item);
|
||||
this.setListData(internalItems);
|
||||
this.updateUI();
|
||||
}
|
||||
public void Items_Clear() {internalItems.clear();}
|
||||
public int Items_Count() {return internalItems.size();}
|
||||
public int Items_SelIdx() {return this.getSelectedIndex();} public void Items_SelIdx_set(int v) {this.setSelectedIndex(v);}
|
||||
public Object Items_SelObj() {return this.getSelectedValue();}
|
||||
|
||||
public Object SelectedItm() {return this.getSelectedValue();} public void SelectedItm_set(Object v) {this.setSelectedValue(v, true);}
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
// need to validate, else dropDownArrow will not get redrawn in correct pos
|
||||
@Override public void setBounds(Rectangle r) {super.setBounds(r); this.validate();}
|
||||
@Override public void setSize(int w, int h) {super.setSize(w, h); this.validate();}
|
||||
@Override public void setSize(Dimension d) {super.setSize(d); this.validate();}
|
||||
public String TextVal() {return Object_.Xto_str_strict_or_empty(this.SelectedItm());} public void TextVal_set(String v) {this.SelectedItm_set(v);}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return this;
|
||||
}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void SendMouseWheel(IptMouseWheel direction) {}
|
||||
@Override public void processKeyEvent(KeyEvent e) {
|
||||
if (GxwCbkHost_.ExecKeyEvent(host, e)){
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go before PaintCbk (had issues with drawing text on images)
|
||||
}
|
||||
public void EnableDoubleBuffering() { // eliminates flickering during OnPaint
|
||||
}
|
||||
public void CreateControlIfNeeded() {
|
||||
}
|
||||
public static GxwListBox_lang new_() {
|
||||
GxwListBox_lang rv = new GxwListBox_lang();
|
||||
rv.ctor_();
|
||||
return rv;
|
||||
} GxwListBox_lang() {}
|
||||
}
|
||||
216
150_gfui/src_300_gxw/gplx/gfui/GxwTextBox_lang.java
Normal file
216
150_gfui/src_300_gxw/gplx/gfui/GxwTextBox_lang.java
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.text.JTextComponent;
|
||||
public class GxwTextBox_lang extends JTextArea implements GxwTextFld {
|
||||
public Object UnderElem() {return this;}
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public int SelBgn() {return this.getSelectionStart();} public void SelBgn_set(int v) {this.setSelectionStart(v); this.setCaretPosition(v);}
|
||||
public int SelLen() {return this.getSelectionEnd() - this.getSelectionStart();} public void SelLen_set(int v) {this.setSelectionEnd(this.SelBgn() + v);}
|
||||
public String TextVal() {return this.getText();} public void TextVal_set(String v) {this.setText(v);}
|
||||
public void AlignH_(GfuiAlign val) {} // TODO
|
||||
//@#if !plat_wce
|
||||
public int BorderWidth() {return borderOn ? 2 : 0;}
|
||||
public boolean Border_on() {return borderOn;} boolean borderOn = true;
|
||||
public void Border_on_(boolean v) {
|
||||
borderOn = v;
|
||||
Border border = v ? BorderFactory.createLineBorder(Color.BLACK, 1) : null;
|
||||
this.setBorder(border);
|
||||
}
|
||||
public void Margins_set(int left, int top, int right, int bot) {}
|
||||
public boolean OverrideTabKey() {return overrideTabKey;} boolean overrideTabKey;
|
||||
public void OverrideTabKey_(boolean val) {
|
||||
overrideTabKey = val;
|
||||
if (val)
|
||||
GxwTextBox_overrideKeyCmd.new_((GfuiElem)host, this, "TAB", "\t", false);
|
||||
else
|
||||
GxwTextBox_overrideKeyCmd.focus_((GfuiElem)host, this, "TAB");
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
return this;
|
||||
}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void SendMouseWheel(IptMouseWheel direction) {}
|
||||
@Override public void processKeyEvent(KeyEvent e) {
|
||||
if (overrideTabKey && e.getKeyCode() == KeyEvent.VK_TAB) {
|
||||
super.processKeyEvent(e); return;}
|
||||
if (GxwCbkHost_.ExecKeyEvent(host, e))
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go before PaintCbk (had issues with drawing text on images)
|
||||
}
|
||||
public GxwTextBox_lang(){ctor_();}
|
||||
void ctor_() {
|
||||
ctrlMgr = GxwCore_lang.new_(this);
|
||||
this.setTabSize(4);
|
||||
}
|
||||
public void EnableDoubleBuffering() {} // eliminates flickering during OnPaint
|
||||
public void CreateControlIfNeeded() {}
|
||||
@gplx.Virtual public void ctor_MsTextBox_() {
|
||||
ctor_();
|
||||
}
|
||||
}
|
||||
class GxwTextFld_cls_lang extends JTextField implements GxwTextFld {
|
||||
public Object UnderElem() {return this;}
|
||||
public void AlignH_(GfuiAlign val) {
|
||||
int align = JTextField.LEFT;
|
||||
if (val.Val() == GfuiAlign_.Mid.Val()) align = JTextField.CENTER;
|
||||
else if (val.Val() == GfuiAlign_.Right.Val()) align = JTextField.RIGHT;
|
||||
this.setHorizontalAlignment(align);
|
||||
}
|
||||
public int SelBgn() {return this.getSelectionStart();}
|
||||
public void SelBgn_set(int v) {
|
||||
// if (v >= this.getSelectionStart() && v < this.getSelectionEnd())
|
||||
try {
|
||||
this.setSelectionStart(v);
|
||||
} catch (Exception e) {
|
||||
Exc_.Noop(e);
|
||||
} // NOTE: sometimes fails when skipping ahead in dvd player; v = 0, and start/end = 0
|
||||
}
|
||||
public int SelLen() {return this.getSelectionEnd() - this.getSelectionStart();} public void SelLen_set(int v) {this.setSelectionEnd(this.SelBgn() + v);}
|
||||
@gplx.Virtual public void ctor_MsTextBox_() {
|
||||
ctor_();
|
||||
}
|
||||
//@#if !plat_wce
|
||||
public int BorderWidth() {return borderOn ? 2 : 0;}
|
||||
public boolean Border_on() {return borderOn;}
|
||||
// @Override public void setBorder(Border border) {
|
||||
// if (borderOn) super.setBorder(border);
|
||||
// else {
|
||||
// super.setBorder(null);
|
||||
// }
|
||||
// // NO!
|
||||
// }
|
||||
public void Border_on_(boolean v) {
|
||||
borderOn = v;
|
||||
Border border = v ? BorderFactory.createLineBorder(Color.BLACK) : null;
|
||||
this.setBorder(border);
|
||||
} boolean borderOn = true;
|
||||
public void Margins_set(int left, int top, int right, int bot) {}
|
||||
public boolean OverrideTabKey() {return overrideTabKey;}
|
||||
public void OverrideTabKey_(boolean val) {
|
||||
overrideTabKey = val;
|
||||
GxwTextBox_overrideKeyCmd.new_((GfuiElem)host, this, "TAB", "\t", false);
|
||||
} boolean overrideTabKey;
|
||||
void ctor_() {
|
||||
ctrlMgr = GxwCore_lang.new_(this);
|
||||
this.enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
|
||||
this.Border_on_(true);
|
||||
GxwBoxListener lnr = new GxwBoxListener(this);
|
||||
// this.setFocusTraversalKeysEnabled(false);
|
||||
this.addComponentListener(lnr);
|
||||
this.addFocusListener(lnr);
|
||||
}
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public String TextVal() {return this.getText();} public void TextVal_set(String v) {
|
||||
this.setText(v);
|
||||
this.SelBgn_set(0); this.SelLen_set(0); // otherwise will set cursor to end; want to see text start
|
||||
}
|
||||
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 this;
|
||||
}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void SendMouseWheel(IptMouseWheel direction) {}
|
||||
@Override public void processKeyEvent(KeyEvent e) {
|
||||
if (overrideTabKey && e.getKeyCode() == KeyEvent.VK_TAB) {
|
||||
super.processKeyEvent(e); return;}
|
||||
if (GxwCbkHost_.ExecKeyEvent(host, e))
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {
|
||||
if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go before PaintCbk (had issues with drawing text on images)
|
||||
}
|
||||
public void EnableDoubleBuffering() { // eliminates flickering during OnPaint
|
||||
}
|
||||
public void CreateControlIfNeeded() {
|
||||
}
|
||||
}
|
||||
class GxwTextBox_overrideKeyCmd extends AbstractAction {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (focus) {
|
||||
int z = owner.OwnerWin().FocusMgr().SubElems().Idx_of(owner);
|
||||
owner.OwnerWin().FocusMgr().Focus(focusDir, z);
|
||||
return;
|
||||
}
|
||||
if (overrideText == null) return;
|
||||
textBox.replaceSelection(overrideText);
|
||||
}
|
||||
public GxwTextBox_overrideKeyCmd(JTextComponent textBox, String overrideText) {this.textBox = textBox; this.overrideText = overrideText;}
|
||||
public static GxwTextBox_overrideKeyCmd focus_(GfuiElem owner, JTextComponent textBox, String keyName) {return GxwTextBox_overrideKeyCmd.new_(owner, textBox, keyName, null, true);}
|
||||
public static GxwTextBox_overrideKeyCmd focusPrv_(GfuiElem owner, JTextComponent textBox, String keyName) {
|
||||
GxwTextBox_overrideKeyCmd rv = GxwTextBox_overrideKeyCmd.new_(owner, textBox, keyName, null, true);
|
||||
rv.focusDir = false;
|
||||
return rv;
|
||||
}
|
||||
public static GxwTextBox_overrideKeyCmd noop_(GfuiElem owner, JTextComponent textBox, String keyName) {return GxwTextBox_overrideKeyCmd.new_(owner, textBox, keyName, null, false);}
|
||||
public static GxwTextBox_overrideKeyCmd new_(GfuiElem owner, JTextComponent textBox, String keyName, String overrideText, boolean focus) {
|
||||
KeyStroke tabKey = KeyStroke.getKeyStroke(keyName);
|
||||
GxwTextBox_overrideKeyCmd action = new GxwTextBox_overrideKeyCmd(textBox, overrideText);
|
||||
action.focus = focus;
|
||||
action.owner = owner;
|
||||
textBox.getInputMap().remove(tabKey);
|
||||
textBox.getInputMap().put(tabKey, action);
|
||||
return action;
|
||||
}
|
||||
JTextComponent textBox; String overrideText; GfuiElem owner; boolean focus; boolean focusDir = true;
|
||||
}
|
||||
class GxwTextBox_lang_ {
|
||||
public static GxwTextFld fld_() {
|
||||
GxwTextFld_cls_lang rv = new GxwTextFld_cls_lang();
|
||||
rv.ctor_MsTextBox_();
|
||||
return rv;
|
||||
}
|
||||
public static GxwTextMemo_lang memo_() {
|
||||
GxwTextMemo_lang rv = new GxwTextMemo_lang();
|
||||
rv.ctor_MsTextBoxMultiline_();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
43
150_gfui/src_300_gxw/gplx/gfui/GxwTextFld.java
Normal file
43
150_gfui/src_300_gxw/gplx/gfui/GxwTextFld.java
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface GxwTextFld extends GxwElem {
|
||||
boolean Border_on(); void Border_on_(boolean v);
|
||||
int SelBgn(); void SelBgn_set(int v);
|
||||
int SelLen(); void SelLen_set(int v);
|
||||
void CreateControlIfNeeded();
|
||||
boolean OverrideTabKey(); void OverrideTabKey_(boolean v);
|
||||
void Margins_set(int left, int top, int right, int bot);
|
||||
}
|
||||
interface GxwTextMemo extends GxwTextFld {
|
||||
int LinesPerScreen();
|
||||
int LinesTotal();
|
||||
int ScreenCount();
|
||||
int CharIndexOf(int lineIndex);
|
||||
int CharIndexOfFirst();
|
||||
int LineIndexOfFirst();
|
||||
int LineIndexOf(int charIndex);
|
||||
PointAdp PosOf(int charIndex);
|
||||
void ScrollLineUp();
|
||||
void ScrollLineDown();
|
||||
void ScrollScreenUp();
|
||||
void ScrollScreenDown();
|
||||
void SelectionStart_toFirstChar();
|
||||
void ScrollTillSelectionStartIsFirstLine();
|
||||
void ScrollTillCaretIsVisible();
|
||||
}
|
||||
24
150_gfui/src_300_gxw/gplx/gfui/GxwTextHtml.java
Normal file
24
150_gfui/src_300_gxw/gplx/gfui/GxwTextHtml.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
interface GxwTextHtml extends GxwTextMemo {
|
||||
KeyVal[] Html_sel_atrs();
|
||||
void Html_enabled(boolean v);
|
||||
String Html_doc_html();
|
||||
void Html_css_set(String s);
|
||||
}
|
||||
253
150_gfui/src_300_gxw/gplx/gfui/GxwTextHtml_lang.java
Normal file
253
150_gfui/src_300_gxw/gplx/gfui/GxwTextHtml_lang.java
Normal file
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.text.AbstractDocument;
|
||||
import javax.swing.text.AttributeSet;
|
||||
import javax.swing.text.BoxView;
|
||||
import javax.swing.text.ComponentView;
|
||||
import javax.swing.text.DefaultEditorKit;
|
||||
import javax.swing.text.DefaultStyledDocument;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.text.EditorKit;
|
||||
import javax.swing.text.Element;
|
||||
import javax.swing.text.IconView;
|
||||
import javax.swing.text.LabelView;
|
||||
import javax.swing.text.MutableAttributeSet;
|
||||
import javax.swing.text.ParagraphView;
|
||||
import javax.swing.text.PlainDocument;
|
||||
import javax.swing.text.Segment;
|
||||
import javax.swing.text.SimpleAttributeSet;
|
||||
import javax.swing.text.StyleConstants;
|
||||
import javax.swing.text.StyledDocument;
|
||||
import javax.swing.text.StyledEditorKit;
|
||||
import javax.swing.text.View;
|
||||
import javax.swing.text.ViewFactory;
|
||||
import javax.swing.text.html.HTML;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import javax.swing.text.html.HTMLEditorKit.HTMLFactory;
|
||||
import javax.swing.text.html.InlineView;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
public class GxwTextHtml_lang extends JScrollPane implements GxwTextHtml {
|
||||
@Override public GxwCore_base Core() {return core;} GxwCore_host core;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host; editor.Host_set(host);} GxwCbkHost host;
|
||||
@Override public int SelBgn() {return editor.SelBgn();} @Override public void SelBgn_set(int v) {editor.SelBgn_set(v);}
|
||||
@Override public int SelLen() {return editor.SelLen();} @Override public void SelLen_set(int v) {editor.SelLen_set(v);}
|
||||
@Override public String TextVal() {return editor.TextVal();} @Override public void TextVal_set(String v) {editor.TextVal_set(v);}
|
||||
@Override public boolean Border_on() {return false;} //boolean borderOn = true;
|
||||
@Override public void Border_on_(boolean v) {
|
||||
// borderOn = v;
|
||||
// Border border = v ? BorderFactory.createLineBorder(Color.BLACK) : null;
|
||||
// this.setBorder(border);
|
||||
}
|
||||
@Override public boolean OverrideTabKey() {return false;}
|
||||
@Override public void OverrideTabKey_(boolean v) {}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return null;}
|
||||
public void Html_enabled(boolean v) {
|
||||
// String newContentType = v ? "text/html" : "text/plain";
|
||||
// if (!String_.Eq(editor.getContentType(), newContentType)) {
|
||||
// editor = new GxwTextHtml_editor().ctor();
|
||||
// core.Inner_set(editor.core);
|
||||
// this.setViewportView(editor);
|
||||
// }
|
||||
editor.Html_enabled(v);
|
||||
}
|
||||
public GxwTextHtml_editor Editor() {return editor;} GxwTextHtml_editor editor;
|
||||
public void ScrollTillCaretIsVisible() {throw Exc_.new_unimplemented();}
|
||||
public GxwTextHtml_lang ctor() {
|
||||
editor = new GxwTextHtml_editor().ctor();
|
||||
core = new GxwCore_host(GxwCore_lang.new_(this), editor.core);
|
||||
this.setViewportView(editor);
|
||||
// this.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
// this.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
this.setBorder(null);
|
||||
return this;
|
||||
}
|
||||
public KeyVal[] Html_sel_atrs() {return editor.Html_sel_atrs();}
|
||||
public String Html_doc_html() {return editor.Html_doc_html();}
|
||||
public void Html_css_set(String s) {editor.Html_css_set(s);}
|
||||
@Override public void Margins_set(int left, int top, int right, int bot) {}
|
||||
@Override public void EnableDoubleBuffering() {}
|
||||
@Override public void CreateControlIfNeeded() {}
|
||||
@Override public int LinesPerScreen() {return 0;}
|
||||
@Override public int LinesTotal() {return 0;}
|
||||
@Override public int ScreenCount() {return 0;}
|
||||
@Override public int CharIndexOf(int lineIndex) {return 0;}
|
||||
@Override public int CharIndexOfFirst() {return 0;}
|
||||
@Override public int LineIndexOfFirst() {return 0;}
|
||||
@Override public int LineIndexOf(int charIndex) {return 0;}
|
||||
@Override public PointAdp PosOf(int charIndex) {return null;}
|
||||
@Override public void ScrollLineUp() {}
|
||||
@Override public void ScrollLineDown() {}
|
||||
@Override public void ScrollScreenUp() {}
|
||||
@Override public void ScrollScreenDown() {}
|
||||
@Override public void SelectionStart_toFirstChar() {}
|
||||
@Override public void ScrollTillSelectionStartIsFirstLine() {}
|
||||
}
|
||||
|
||||
class GxwTextHtml_editor extends JEditorPane implements GxwTextHtml {
|
||||
public GxwTextHtml_editor ctor() {
|
||||
styledKit = new StyledEditorKit();
|
||||
htmlKit = new HTMLEditorKit();
|
||||
this.setEditorKit(htmlKit);
|
||||
// this.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE); this.setFont(new Font("Courier New", 6, Font.PLAIN)); // force jeditorpane to take font
|
||||
core = GxwCore_lang.new_(this);
|
||||
this.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
|
||||
return this;
|
||||
}
|
||||
// public HTMLEditorKit HtmlKit() {return htmlKit;} HTMLEditorKit htmlKit;
|
||||
@Override public GxwCore_base Core() {return core;} GxwCore_base core;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host;
|
||||
@Override public int SelBgn() {return this.getSelectionStart();} @Override public void SelBgn_set(int v) {this.setSelectionStart(v); this.setCaretPosition(v);}
|
||||
@Override public int SelLen() {return this.getSelectionEnd() - this.getSelectionStart();} @Override public void SelLen_set(int v) {this.setSelectionEnd(this.getSelectionStart() + v);}
|
||||
@Override public String TextVal() {return this.getText();}
|
||||
@Override public void TextVal_set(String v) {this.setText(v);}
|
||||
@Override public boolean Border_on() {return borderOn;} boolean borderOn = true;
|
||||
@Override public void Border_on_(boolean v) {
|
||||
borderOn = v;
|
||||
Border border = v ? BorderFactory.createLineBorder(Color.BLACK) : null;
|
||||
this.setBorder(border);
|
||||
}
|
||||
@Override public boolean OverrideTabKey() {return false;}
|
||||
@Override public void OverrideTabKey_(boolean v) {}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return null;}
|
||||
StyledEditorKit styledKit; HTMLEditorKit htmlKit;
|
||||
|
||||
public void Html_enabled(boolean v) {
|
||||
// String contentType = v ? "text/html" : "text/rtf";
|
||||
// this.setEditorKit(v ? new StyledEditorKit() : new DefaultEditorKit());
|
||||
this.setEditorKit(v ? htmlKit : styledKit);
|
||||
}
|
||||
public void ScrollTillCaretIsVisible() {throw Exc_.new_unimplemented();}
|
||||
public void Html_css_set(String s) {
|
||||
StyleSheet styleSheet = htmlKit.getStyleSheet();
|
||||
styleSheet.addRule(s);
|
||||
}
|
||||
public String Html_print() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
sb.Add("selBgn=").Add(Int_.Xto_str(Html_sel_bgn())).Add_char_crlf();
|
||||
sb.Add("selEnd=").Add(Int_.Xto_str(Html_sel_end())).Add_char_crlf();
|
||||
sb.Add("selTxt=").Add(Html_sel_text()).Add_char_crlf();
|
||||
KeyVal[] atrs = Html_sel_atrs();
|
||||
for (int i = 0; i < atrs.length; i++) {
|
||||
KeyVal atr = atrs[i];
|
||||
sb.Add(atr.Key() + "=").Add(atr.Val_to_str_or_null()).Add_char_crlf();
|
||||
}
|
||||
return sb.XtoStr();
|
||||
}
|
||||
Element Html_sel_elm() {
|
||||
HTMLDocument doc = (HTMLDocument)this.getDocument();
|
||||
int pos = this.getCaretPosition();
|
||||
return doc.getCharacterElement(pos);
|
||||
}
|
||||
public int Html_sel_bgn() {return Html_sel_elm().getStartOffset();}
|
||||
public int Html_sel_end() {return Html_sel_elm().getEndOffset();}
|
||||
// public String Html_doc_html() {
|
||||
// HTMLEditorKit kit = (HTMLEditorKit)this.getEditorKit();
|
||||
// HTMLDocument doc = (HTMLDocument)this.getDocument();
|
||||
// StringWriter sw = new StringWriter();
|
||||
// try {kit.write(sw, doc, 0, doc.getLength());}
|
||||
// catch (Exception exc) {throw Err_.err_(exc, "Html_doc_html");}
|
||||
// return sw.toString();
|
||||
// }
|
||||
public String Html_doc_html() {
|
||||
Document doc = this.getDocument();
|
||||
try {return this.getDocument().getText(0, doc.getLength());}
|
||||
catch (Exception e) {throw Exc_.new_exc(e, "ui", "Html_doc_html");}
|
||||
}
|
||||
public String Html_sel_text() {
|
||||
Element elm = Html_sel_elm();
|
||||
int sel_bgn = elm.getStartOffset();
|
||||
int sel_end = elm.getEndOffset();
|
||||
try {return this.getDocument().getText(sel_bgn, sel_end - sel_bgn);}
|
||||
catch (Exception e) {throw Exc_.new_exc(e, "ui", "Html_sel_text");}
|
||||
}
|
||||
static void Html_sel_atrs(AttributeSet atrs, List_adp list, String ownerKey, String dlm) {
|
||||
if (atrs == null) return;
|
||||
Enumeration<?> keys = atrs.getAttributeNames();
|
||||
while (true) {
|
||||
if (!keys.hasMoreElements()) break;
|
||||
Object atr_key = keys.nextElement(); if (atr_key == null) break;
|
||||
Object atr_val = atrs.getAttribute(atr_key);
|
||||
String atr_key_str = atr_key.toString();
|
||||
String itm_key = ownerKey == null ? atr_key_str : ownerKey + dlm + atr_key_str;
|
||||
if (atr_val instanceof javax.swing.text.AttributeSet)
|
||||
Html_sel_atrs((AttributeSet)atr_val, list, itm_key, dlm);
|
||||
else
|
||||
list.Add(KeyVal_.new_(itm_key, atr_val));
|
||||
}
|
||||
}
|
||||
public KeyVal[] Html_sel_atrs() {
|
||||
if (String_.Eq(this.getContentType(), "text/plain")) return KeyVal_.Ary_empty;
|
||||
Element elm = Html_sel_elm(); if (elm == null) return KeyVal_.Ary_empty;
|
||||
List_adp sel_atrs_list = List_adp_.new_();
|
||||
Html_sel_atrs(elm.getAttributes(), sel_atrs_list, null, ".");
|
||||
return (KeyVal[])sel_atrs_list.To_ary(KeyVal.class);
|
||||
}
|
||||
|
||||
@Override public void processKeyEvent(KeyEvent e) {
|
||||
// if (overrideTabKey && e.getKeyCode() == KeyEvent.VK_TAB) {
|
||||
// super.processKeyEvent(e); return;}
|
||||
if (GxwCbkHost_.ExecKeyEvent(host, e))
|
||||
super.processKeyEvent(e);
|
||||
}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g); // Reevaluate if necessary: super.paint might need to (a) always happen and (b) go before PaintCbk (had issues with drawing text on images)
|
||||
}
|
||||
|
||||
@Override public void Margins_set(int left, int top, int right, int bot) {}
|
||||
@Override public void EnableDoubleBuffering() {}
|
||||
@Override public void CreateControlIfNeeded() {}
|
||||
@Override public int LinesPerScreen() {return 0;}
|
||||
@Override public int LinesTotal() {return 0;}
|
||||
@Override public int ScreenCount() {return 0;}
|
||||
@Override public int CharIndexOf(int lineIndex) {return 0;}
|
||||
@Override public int CharIndexOfFirst() {return 0;}
|
||||
@Override public int LineIndexOfFirst() {return 0;}
|
||||
@Override public int LineIndexOf(int charIndex) {return 0;}
|
||||
@Override public PointAdp PosOf(int charIndex) {return null;}
|
||||
@Override public void ScrollLineUp() {}
|
||||
@Override public void ScrollLineDown() {}
|
||||
@Override public void ScrollScreenUp() {}
|
||||
@Override public void ScrollScreenDown() {}
|
||||
@Override public void SelectionStart_toFirstChar() {}
|
||||
@Override public void ScrollTillSelectionStartIsFirstLine() {}
|
||||
}
|
||||
335
150_gfui/src_300_gxw/gplx/gfui/GxwTextMemo_lang.java
Normal file
335
150_gfui/src_300_gxw/gplx/gfui/GxwTextMemo_lang.java
Normal file
@@ -0,0 +1,335 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import java.awt.AWTKeyStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.event.UndoableEditEvent;
|
||||
import javax.swing.event.UndoableEditListener;
|
||||
import javax.swing.text.Document;
|
||||
import javax.swing.undo.CannotRedoException;
|
||||
import javax.swing.undo.CannotUndoException;
|
||||
import javax.swing.undo.UndoManager;
|
||||
public class GxwTextMemo_lang extends JScrollPane implements GxwTextMemo {
|
||||
public JTextArea Inner() {return txt_box;} GxwTextBox_lang txt_box;
|
||||
public GxwCore_base Core() {return core;} GxwCore_base core;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host; txt_box.Host_set(host);} GxwCbkHost host;
|
||||
@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);
|
||||
}
|
||||
public void ScrollTillCaretIsVisible() {throw Exc_.new_unimplemented();}
|
||||
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)));
|
||||
}
|
||||
}
|
||||
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);
|
||||
// }
|
||||
// }
|
||||
} @gplx.Internal protected GxwTextMemo_lang() {}
|
||||
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");
|
||||
}
|
||||
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
|
||||
}
|
||||
public void AlignH_(GfuiAlign val) {
|
||||
// can't work with jtextArea
|
||||
// if (val.Val() == GfuiAlign_.Mid.Val())
|
||||
// txt_box.setAlignmentY(JTextArea.CENTER_ALIGNMENT);
|
||||
}
|
||||
public int LinesPerScreen() {return LinesPerScreen(this);}
|
||||
public int LinesTotal() {
|
||||
return 40;
|
||||
// return this.getStyledDocument(). .getLineCount();
|
||||
}
|
||||
public int ScreenCount() {return Int_.DivAndRoundUp(this.LinesTotal(), this.LinesPerScreen());}
|
||||
public int LineLength(int lineIndex) {return LineLength(this, lineIndex);}
|
||||
public int CharIndexOfFirst() {
|
||||
int firstLineIndex = LineIndexOfFirst();
|
||||
return CharIndexOf(firstLineIndex);
|
||||
}
|
||||
public int CharIndexOf(int lineIndex) {
|
||||
return lineIndex;
|
||||
// try {return this.getLineStartOffset(lineIndex);}
|
||||
// catch (BadLocationException e) {return -1;}
|
||||
}
|
||||
public int LineIndexOfFirst() {
|
||||
// this.getl
|
||||
|
||||
return 0; //todo
|
||||
// return TextBoxNpi.LineIndexFirst(ControlNpi.Hwnd(this));
|
||||
}
|
||||
public int LineIndexOf(int charIndex) {
|
||||
return charIndex;
|
||||
// try {return this.getLineOfOffset(charIndex);}
|
||||
// catch (BadLocationException e) {return -1;}
|
||||
}
|
||||
public PointAdp PosOf(int charIndex) {
|
||||
// Document d = this.getDocument();
|
||||
// Element e = d.getDefaultRootElement();
|
||||
// e.
|
||||
return PointAdp_.Zero; //todo
|
||||
// PointAdp point = TextBoxNpi.PosOf(ControlNpi.Hwnd(this), charIndex);
|
||||
// return (point.Eq(TextBoxNpi.InvalidPoint))
|
||||
// ? TextBoxNpi.InvalidPoint
|
||||
// : PointAdp_.XtoPointAdp(this.PointToScreen(point.XtoPoint()));
|
||||
}
|
||||
public void SelectionStart_toFirstChar() {
|
||||
// scrollPane.s
|
||||
// JScrollPane scrollingResult = new JScrollPane(this);
|
||||
// scrollingResult.
|
||||
//todo
|
||||
// this.SelectionStart = this.CharIndexOfFirst();
|
||||
}
|
||||
public void ScrollLineUp() {
|
||||
// ScrollWindow(TextBoxScrollTypes.LineUp);
|
||||
}
|
||||
public void ScrollLineDown() {
|
||||
// ScrollWindow(TextBoxScrollTypes.LineDown);
|
||||
}
|
||||
// public void ExtendLineUp() {int l = this.SelectionStart; ScrollWindow(TextBoxScrollTypes.LineUp); int m = this.SelectionStart; this.SelectionStart = l; this.SelectionLength = m - l;}
|
||||
// public void ExtendLineDown() {int l = this.SelectionStart; ScrollWindow(TextBoxScrollTypes.LineDown); int m = this.SelectionStart; this.SelectionStart = l; this.SelectionLength = m - l;}
|
||||
public void ScrollScreenUp() {
|
||||
// ScrollWindow(TextBoxScrollTypes.PageUp);
|
||||
}
|
||||
public void ScrollScreenDown() {
|
||||
// ScrollWindow(TextBoxScrollTypes.PageDown);
|
||||
}
|
||||
public void ScrollTillSelectionStartIsFirstLine() {
|
||||
// this.Visible = false;
|
||||
// this.ScrollToCaret();
|
||||
// int currentLine = TextBoxNpi.LineIndex(ControlNpi.Hwnd(this), this.SelectionStart);
|
||||
// int lineCount = this.LinesPerScreen();
|
||||
// int previousFirstLine = -1;
|
||||
// do {
|
||||
// int firstLine = TextBoxNpi.LineIndexFirst(ControlNpi.Hwnd(this));
|
||||
// if (firstLine == previousFirstLine) break; // NOTE: avoid infinite loop
|
||||
//
|
||||
// if (firstLine - currentLine > lineCount)
|
||||
// this.ScrollScreenUp();
|
||||
// else if (currentLine - firstLine > lineCount)
|
||||
// this.ScrollScreenDown();
|
||||
// else if (currentLine < firstLine)
|
||||
// this.ScrollLineUp();
|
||||
// else if (currentLine > firstLine)
|
||||
// this.ScrollLineDown();
|
||||
// else
|
||||
// break;
|
||||
// previousFirstLine = firstLine;
|
||||
// } while (true);
|
||||
// this.Visible = true;
|
||||
// GfuiEnv_.DoEvents(); // WORKAROUND (WCE): needed to repaint screen
|
||||
// this.Parent.Focus();
|
||||
}
|
||||
// void ScrollWindow(TextBoxScrollTypes scrollType) {TextBoxNpi.ScrollWindow(ControlNpi.Hwnd(this), scrollType);}
|
||||
public static int LinesPerScreen(GxwTextMemo_lang textBox) {
|
||||
return 50;
|
||||
// int lineIndexLine0 = textBox.LineIndexOfFirst();
|
||||
// int charIndexLine0 = textBox.CharIndexOf(lineIndexLine0);
|
||||
// PointAdp posLine0 = textBox.PosOf(charIndexLine0);
|
||||
// int charIndexLine1 = textBox.CharIndexOf(lineIndexLine0 + 1);
|
||||
// PointAdp posLine1 = textBox.PosOf(charIndexLine1);
|
||||
//
|
||||
// int availHeight = textBox.Height - (2 * textBox.BorderWidth());
|
||||
// int lineHeight = (posLine1.Eq(TextBoxNpi.InvalidPoint)) // TextBox is sized for one line, or textBox.Text = ""
|
||||
// ? availHeight
|
||||
// : posLine1.Y() - posLine0.Y();
|
||||
// int rv = availHeight / lineHeight;
|
||||
// return rv == 0 ? 1 : rv; // always return at least 1 line
|
||||
}
|
||||
public static int LineLength(GxwTextMemo_lang textBox, int lineIndex) {
|
||||
return -1;
|
||||
// int lineLength = TextBoxNpi.LineLength(ControlNpi.Hwnd(textBox), lineIndex);
|
||||
//
|
||||
// // WORKAROUND (TextBox): TextBoxNpi.LineLength ignores String_.NewLine; manually check for NewLine
|
||||
// int newLineLength = String_.NewLine.length;
|
||||
// String text = textBox.Text;
|
||||
// int charIndexFirst = textBox.CharIndexOf(lineIndex);
|
||||
// int charIndexLastAccordingToApi = charIndexFirst + lineLength;
|
||||
// if (charIndexLastAccordingToApi + newLineLength > text.length) return lineLength; // last line of text; no ignored line possible
|
||||
// String charactersPastEndOfLine = text.Substring(charIndexLastAccordingToApi, newLineLength);
|
||||
// return charactersPastEndOfLine == String_.NewLine ? lineLength + newLineLength : lineLength;
|
||||
}
|
||||
public boolean Border_on() {return txt_box.Border_on();} public void Border_on_(boolean v) {txt_box.Border_on_(v);}
|
||||
public void CreateControlIfNeeded() {txt_box.CreateControlIfNeeded();}
|
||||
public boolean OverrideTabKey() {return txt_box.OverrideTabKey();}
|
||||
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);
|
||||
}
|
||||
}
|
||||
public int SelBgn() {return txt_box.SelBgn();} public void SelBgn_set(int v) {txt_box.SelBgn_set(v);}
|
||||
public int SelLen() {return txt_box.SelLen();} public void SelLen_set(int v) {txt_box.SelLen_set(v);}
|
||||
public void EnableDoubleBuffering() {txt_box.EnableDoubleBuffering();}
|
||||
|
||||
public void SendKeyDown(IptKey key) {txt_box.SendKeyDown(key);}
|
||||
public String TextVal() {return txt_box.TextVal();}
|
||||
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
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
class GxwCore_host extends GxwCore_base {
|
||||
@Override public void Controls_add(GxwElem sub){outer.Controls_add(sub);}
|
||||
@Override public void Controls_del(GxwElem sub){outer.Controls_del(sub);}
|
||||
@Override public int Width(){return outer.Width();} @Override public void Width_set(int v){outer.Width_set(v); inner.Width_set(v);}
|
||||
@Override public int Height(){return outer.Height();} @Override public void Height_set(int v){outer.Height_set(v); inner.Height_set(v);}
|
||||
@Override public int X(){return outer.X();} @Override public void X_set(int v){outer.X_set(v);} // NOTE: noop inner.x
|
||||
@Override public int Y(){return outer.Y();} @Override public void Y_set(int v){outer.Y_set(v);} // NOTE: noop inner.y
|
||||
@Override public SizeAdp Size(){return outer.Size();} @Override public void Size_set(SizeAdp v){outer.Size_set(v); inner.Size_set(v);}
|
||||
@Override public PointAdp Pos(){return outer.Pos();} @Override public void Pos_set(PointAdp v){outer.Pos_set(v);} // NOTE: noop inner.pos
|
||||
@Override public RectAdp Rect(){return outer.Rect();} @Override public void Rect_set(RectAdp v){outer.Rect_set(v); inner.Size_set(v.Size());} // NOTE: noop inner.pos
|
||||
@Override public boolean Visible(){return outer.Visible();} @Override public void Visible_set(boolean v){outer.Visible_set(v); inner.Visible_set(v);}
|
||||
@Override public ColorAdp BackColor(){return outer.BackColor();} @Override public void BackColor_set(ColorAdp v){outer.BackColor_set(v); inner.BackColor_set(v);}
|
||||
@Override public ColorAdp ForeColor(){return outer.ForeColor();} @Override public void ForeColor_set(ColorAdp v){outer.ForeColor_set(v); inner.ForeColor_set(v);}
|
||||
@Override public FontAdp TextFont(){return outer.TextFont();} @Override public void TextFont_set(FontAdp v){outer.TextFont_set(v); inner.TextFont_set(v);}
|
||||
@Override public String TipText() {return tipText;} @Override public void TipText_set(String v) {tipText = v;} String tipText;
|
||||
public Object Reapply() {
|
||||
TextFont_set(outer.TextFont()); return this;} // HACK:
|
||||
|
||||
@Override public int Focus_index(){return inner.Focus_index();} @Override public void Focus_index_set(int v){outer.Focus_index_set(v); inner.Focus_index_set(v);}
|
||||
@Override public boolean Focus_able(){return inner.Focus_able();} @Override public void Focus_able_(boolean v){outer.Focus_able_(v); inner.Focus_able_(v);}
|
||||
// @Override public void Focus_able_force_(boolean v){outer.Focus_able_force_(v); inner.Focus_able_force_(v);}
|
||||
@Override public boolean Focus_has(){return inner.Focus_has();}
|
||||
@Override public void Focus(){
|
||||
inner.Focus();
|
||||
}
|
||||
@Override public void Select_exec(){
|
||||
inner.Select_exec();
|
||||
}
|
||||
@Override public void Zorder_front(){outer.Zorder_front();} @Override public void Zorder_back(){outer.Zorder_back();}
|
||||
@Override public void Invalidate(){outer.Invalidate();
|
||||
inner.Invalidate();}
|
||||
@Override public void Dispose(){outer.Dispose();}
|
||||
GxwCore_base outer; GxwCore_base inner;
|
||||
public void Inner_set(GxwCore_base v) {inner = v;}
|
||||
public GxwCore_host(GxwCore_base outer, GxwCore_base inner) {this.outer = outer; this.inner = inner;}
|
||||
}
|
||||
32
150_gfui/src_300_gxw/gplx/gfui/GxwWin.java
Normal file
32
150_gfui/src_300_gxw/gplx/gfui/GxwWin.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface GxwWin extends GxwElem {
|
||||
IconAdp IconWin(); void IconWin_set(IconAdp v);
|
||||
|
||||
void ShowWin();
|
||||
void HideWin();
|
||||
boolean Maximized(); void Maximized_(boolean v);
|
||||
boolean Minimized(); void Minimized_(boolean v);
|
||||
void CloseWin();
|
||||
boolean Pin(); void Pin_set(boolean val);
|
||||
|
||||
void OpenedCmd_set(GfoInvkAbleCmd v);
|
||||
void TaskbarVisible_set(boolean val);
|
||||
void TaskbarParkingWindowFix(GxwElem form);
|
||||
}
|
||||
271
150_gfui/src_300_gxw/gplx/gfui/GxwWin_lang.java
Normal file
271
150_gfui/src_300_gxw/gplx/gfui/GxwWin_lang.java
Normal file
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
import javax.swing.JDesktopPane;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JWindow;
|
||||
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
public class GxwWin_lang extends JFrame implements GxwWin, WindowListener {
|
||||
public void ShowWin() {this.setVisible(true);}
|
||||
public void HideWin() {this.setVisible(false);}
|
||||
public boolean Minimized() {return this.getState() == Frame.ICONIFIED;} public void Minimized_(boolean v) {this.setState(v ? Frame.ICONIFIED : Frame.NORMAL);}
|
||||
public boolean Maximized() {return this.getState() == Frame.MAXIMIZED_BOTH;} public void Maximized_(boolean v) {this.setState(v ? Frame.MAXIMIZED_BOTH : Frame.NORMAL);}
|
||||
public void CloseWin() {this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.dispose();}
|
||||
public boolean Pin() {return pin;}
|
||||
public void Pin_set(boolean val) {
|
||||
this.setAlwaysOnTop(val); pin = val;} boolean pin = false;
|
||||
public IconAdp IconWin() {return icon;} IconAdp icon;
|
||||
public void IconWin_set(IconAdp i) {
|
||||
if (i == null) return;
|
||||
icon = i;
|
||||
this.setIconImage(i.XtoImage());
|
||||
}
|
||||
public void OpenedCmd_set(GfoInvkAbleCmd v) {whenLoadedCmd = v;} GfoInvkAbleCmd whenLoadedCmd = GfoInvkAbleCmd.Null;
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public String TextVal() {return this.getTitle();} public void TextVal_set(String v) {this.setTitle(v);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void windowActivated(WindowEvent e) {}
|
||||
public void windowClosed(WindowEvent e) {}
|
||||
public void windowClosing(WindowEvent e) {host.DisposeCbk();}
|
||||
public void windowDeactivated(WindowEvent e) {}
|
||||
public void windowDeiconified(WindowEvent e) {host.SizeChangedCbk();}
|
||||
public void windowIconified(WindowEvent e) {host.SizeChangedCbk();}
|
||||
public void windowOpened(WindowEvent e) {whenLoadedCmd.Invk();}
|
||||
@Override public void processKeyEvent(KeyEvent e) {if (GxwCbkHost_.ExecKeyEvent(host, e)) super.processKeyEvent(e);}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g);
|
||||
}
|
||||
public void EnableDoubleBuffering() {}
|
||||
public void TaskbarVisible_set(boolean val) {} public void TaskbarParkingWindowFix(GxwElem form) {}
|
||||
public static GxwWin_lang new_() {
|
||||
GxwWin_lang rv = new GxwWin_lang();
|
||||
rv.ctor_GxwForm();
|
||||
return rv;
|
||||
} GxwWin_lang() {}
|
||||
void ctor_GxwForm() {
|
||||
ctrlMgr = GxwCore_form.new_(this);
|
||||
this.setLayout(null); // use gfui layout
|
||||
this.ctrlMgr.BackColor_set(ColorAdp_.White); // default form backColor to white
|
||||
this.setUndecorated(true); // remove icon, titleBar, minimize, maximize, close, border
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // JAVA: cannot cancel alt+f4; set Close to noop, and manually control closing by calling this.CloseForm
|
||||
enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
|
||||
this.addWindowListener(this);
|
||||
GxwBoxListener lnr = new GxwBoxListener(this);
|
||||
this.addComponentListener(lnr);
|
||||
this.addFocusListener(lnr);
|
||||
}
|
||||
}
|
||||
class GxwWin_jdialog extends JDialog implements GxwWin, WindowListener {
|
||||
public void ShowWin() {this.setVisible(true);}
|
||||
public void HideWin() {this.setVisible(false);}
|
||||
public void CloseWin() {this.dispose();}//this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.dispose();
|
||||
public boolean Maximized() {return false;} public void Maximized_(boolean v) {}
|
||||
public boolean Minimized() {return false;} public void Minimized_(boolean v) {} //this.setState(Frame.ICONIFIED);
|
||||
public boolean Pin() {return pin;} public void Pin_set(boolean val) {
|
||||
this.setAlwaysOnTop(val); pin = val;} boolean pin = false;
|
||||
public IconAdp IconWin() {return icon;} IconAdp icon;
|
||||
public void IconWin_set(IconAdp i) {
|
||||
if (i == null) return;
|
||||
icon = i;
|
||||
this.setIconImage(i.XtoImage());
|
||||
}
|
||||
public void OpenedCmd_set(GfoInvkAbleCmd v) {whenLoadedCmd = v;} GfoInvkAbleCmd whenLoadedCmd = GfoInvkAbleCmd.Null;
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public String TextVal() {return "";} public void TextVal_set(String v) {}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void windowActivated(WindowEvent e) {}
|
||||
public void windowClosed(WindowEvent e) {}
|
||||
public void windowClosing(WindowEvent e) {host.DisposeCbk();}
|
||||
public void windowDeactivated(WindowEvent e) {}
|
||||
public void windowDeiconified(WindowEvent e) {host.SizeChangedCbk();}
|
||||
public void windowIconified(WindowEvent e) {host.SizeChangedCbk();}
|
||||
public void windowOpened(WindowEvent e) {whenLoadedCmd.Invk();}
|
||||
@Override public void processKeyEvent(KeyEvent e) {if (GxwCbkHost_.ExecKeyEvent(host, e)) super.processKeyEvent(e);}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g);
|
||||
}
|
||||
public void EnableDoubleBuffering() {}
|
||||
public void TaskbarVisible_set(boolean val) {} public void TaskbarParkingWindowFix(GxwElem form) {}
|
||||
public static GxwWin new_(GxwWin owner) {
|
||||
Window ownerWindow = owner instanceof Window ? (Window)owner : null;
|
||||
GxwWin_jdialog rv = new GxwWin_jdialog(ownerWindow);
|
||||
rv.ctor_GxwForm();
|
||||
return rv;
|
||||
} GxwWin_jdialog(Window owner) {super(owner);}
|
||||
void ctor_GxwForm() {
|
||||
ctrlMgr = GxwCore_form.new_(this);
|
||||
this.setLayout(null); // use gfui layout
|
||||
this.ctrlMgr.BackColor_set(ColorAdp_.White); // default form backColor to white
|
||||
this.setUndecorated(true); // remove icon, titleBar, minimize, maximize, close, border
|
||||
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // JAVA: cannot cancel alt+f4; set CloseOp to noop, and manually control closing by calling this.CloseForm
|
||||
enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
|
||||
this.addWindowListener(this);
|
||||
GxwBoxListener lnr = new GxwBoxListener(this);
|
||||
this.addComponentListener(lnr);
|
||||
this.addFocusListener(lnr);
|
||||
}
|
||||
}
|
||||
class GxwWin_jwindow extends JWindow implements GxwWin, WindowListener {
|
||||
public void ShowWin() {this.setVisible(true);}
|
||||
public void HideWin() {this.setVisible(false);}
|
||||
public void CloseWin() {} //this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.dispose();
|
||||
public boolean Maximized() {return false;} public void Maximized_(boolean v) {}
|
||||
public boolean Minimized() {return false;} public void Minimized_(boolean v) {}
|
||||
public boolean Pin() {return pin;} public void Pin_set(boolean val) {this.setAlwaysOnTop(val); pin = val;} boolean pin = false;
|
||||
public IconAdp IconWin() {return icon;} IconAdp icon;
|
||||
public void IconWin_set(IconAdp i) {
|
||||
if (i == null) return;
|
||||
icon = i;
|
||||
this.setIconImage(i.XtoImage());
|
||||
}
|
||||
public void OpenedCmd_set(GfoInvkAbleCmd v) {whenLoadedCmd = v;} GfoInvkAbleCmd whenLoadedCmd = GfoInvkAbleCmd.Null;
|
||||
public GxwCore_base Core() {return ctrlMgr;} GxwCore_base ctrlMgr;
|
||||
public GxwCbkHost Host() {return host;} public void Host_set(GxwCbkHost host) {this.host = host;} GxwCbkHost host = GxwCbkHost_.Null;
|
||||
public String TextVal() {return "";} public void TextVal_set(String v) {}// this.setTitle(v);
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {return this;}
|
||||
public void SendKeyDown(IptKey key) {}
|
||||
public void SendMouseMove(int x, int y) {}
|
||||
public void SendMouseDown(IptMouseBtn btn) {}
|
||||
public void windowActivated(WindowEvent e) {}
|
||||
public void windowClosed(WindowEvent e) {}
|
||||
public void windowClosing(WindowEvent e) {host.DisposeCbk();}
|
||||
public void windowDeactivated(WindowEvent e) {}
|
||||
public void windowDeiconified(WindowEvent e) {host.SizeChangedCbk();}
|
||||
public void windowIconified(WindowEvent e) {host.SizeChangedCbk();}
|
||||
public void windowOpened(WindowEvent e) {whenLoadedCmd.Invk();}
|
||||
@Override public void processKeyEvent(KeyEvent e) {if (GxwCbkHost_.ExecKeyEvent(host, e)) super.processKeyEvent(e);}
|
||||
@Override public void processMouseEvent(MouseEvent e) {if (GxwCbkHost_.ExecMouseEvent(host, e)) super.processMouseEvent(e);}
|
||||
@Override public void processMouseWheelEvent(MouseWheelEvent e) {if (GxwCbkHost_.ExecMouseWheel(host, e)) super.processMouseWheelEvent(e);}
|
||||
@Override public void processMouseMotionEvent(MouseEvent e) {if (host.MouseMoveCbk(IptEvtDataMouse.new_(IptMouseBtn_.None, IptMouseWheel_.None, e.getX(), e.getY()))) super.processMouseMotionEvent(e);}
|
||||
@Override public void paint(Graphics g) {
|
||||
if (host.PaintCbk(PaintArgs.new_(GfxAdpBase.new_((Graphics2D)g), RectAdp_.Zero))) // ClipRect not used by any clients; implement when necessary
|
||||
super.paint(g);
|
||||
}
|
||||
public void EnableDoubleBuffering() {}
|
||||
public void TaskbarVisible_set(boolean val) {} public void TaskbarParkingWindowFix(GxwElem form) {}
|
||||
public static GxwWin new_(GxwWin owner) {
|
||||
// Window ownerWindow = owner instanceof Window ? (Window)owner : null;
|
||||
// GxwWin_jwindow rv = new GxwWin_jwindow((Window)owner);
|
||||
GxwWin_jwindow rv = new GxwWin_jwindow();
|
||||
rv.ctor_GxwForm();
|
||||
// rv.setUndecorated(true);
|
||||
return rv;
|
||||
} GxwWin_jwindow(Window owner) {super(owner);}
|
||||
GxwWin_jwindow() {}
|
||||
public static GxwWin owner_(GxwWin owner) {
|
||||
GxwWin_jwindow rv = new GxwWin_jwindow((Window)owner);
|
||||
rv.setFocusable(true);
|
||||
rv.setFocusableWindowState(true);
|
||||
rv.ctor_GxwForm();
|
||||
return rv;
|
||||
}
|
||||
public void ctor_GxwForm() {
|
||||
ctrlMgr = GxwCore_form.new_(this);
|
||||
this.setLayout(null); // use gfui layout
|
||||
this.ctrlMgr.BackColor_set(ColorAdp_.White); // default form backColor to white
|
||||
// this.setUndecorated(true); // remove icon, titleBar, minimize, maximize, close, border
|
||||
// this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // JAVA: cannot cancel alt+f4; set CloseOp to noop, and manually control closing by calling this.CloseForm
|
||||
enableEvents(AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK);
|
||||
this.addWindowListener(this);
|
||||
GxwBoxListener lnr = new GxwBoxListener(this);
|
||||
this.addComponentListener(lnr);
|
||||
this.addFocusListener(lnr);
|
||||
}
|
||||
}
|
||||
class GxwCore_form extends GxwCore_lang {
|
||||
@Override public void Zorder_front() {
|
||||
Window frame = (Window)this.control;
|
||||
frame.toFront();
|
||||
}
|
||||
@Override public void Zorder_back() {
|
||||
Window frame = (Window)this.control;
|
||||
frame.toBack();
|
||||
}
|
||||
public static GxwCore_form new_(Component control) {
|
||||
GxwCore_form rv = new GxwCore_form();
|
||||
rv.control = control;
|
||||
return rv;
|
||||
} GxwCore_form() {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class GxwElemFactory_swt extends GxwElemFactory_base {
|
||||
public GxwElemFactory_swt(org.eclipse.swt.widgets.Display display) {
|
||||
this.display = display;
|
||||
} Display display;
|
||||
@gplx.Internal @Override protected GxwElem control_() {return null;}
|
||||
@gplx.Internal @Override protected GxwWin win_app_() {
|
||||
return new Swt_win(display);
|
||||
}
|
||||
@gplx.Internal @Override protected GxwWin win_tool_(KeyValHash ctorArgs) {
|
||||
return null;
|
||||
}
|
||||
@gplx.Internal @Override protected GxwWin win_toaster_(KeyValHash ctorArgs) {
|
||||
return null;
|
||||
}
|
||||
@gplx.Internal @Override protected GxwElem lbl_() {return null;}
|
||||
@gplx.Internal @Override protected GxwTextFld text_fld_() {return null;}
|
||||
@gplx.Internal @Override protected GxwTextFld text_memo_() {return null;}
|
||||
@gplx.Internal @Override protected GxwTextHtml text_html_() {return null;}
|
||||
@gplx.Internal @Override protected GxwCheckListBox checkListBox_(KeyValHash ctorArgs) {throw Exc_.new_unimplemented();}
|
||||
@gplx.Internal @Override protected GxwComboBox comboBox_() {return null;}
|
||||
@gplx.Internal @Override protected GxwListBox listBox_() {return null;}
|
||||
}
|
||||
|
||||
|
||||
//#}
|
||||
30
150_gfui/src_300_gxw/gplx/gfui/Gxw_html.java
Normal file
30
150_gfui/src_300_gxw/gplx/gfui/Gxw_html.java
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface Gxw_html extends GxwElem {
|
||||
void Html_doc_html_load_by_mem(String html);
|
||||
void Html_doc_html_load_by_url(String path, String html);
|
||||
byte Html_doc_html_load_tid(); void Html_doc_html_load_tid_(byte v);
|
||||
void Html_js_enabled_(boolean v);
|
||||
String Html_js_eval_proc_as_str (String name, Object... args);
|
||||
boolean Html_js_eval_proc_as_bool (String name, Object... args);
|
||||
String Html_js_eval_script (String script);
|
||||
void Html_js_cbks_add (String js_func_name, GfoInvkAble invk);
|
||||
void Html_invk_src_(GfoEvObj v);
|
||||
void Html_dispose();
|
||||
}
|
||||
35
150_gfui/src_300_gxw/gplx/gfui/Gxw_html_load_tid_.java
Normal file
35
150_gfui/src_300_gxw/gplx/gfui/Gxw_html_load_tid_.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public class Gxw_html_load_tid_ {
|
||||
public static final byte Tid_mem = 0, Tid_url = 1;
|
||||
public static final String Key_mem = "mem", Key_url = "url";
|
||||
public static String Xto_key(byte v) {
|
||||
switch (v) {
|
||||
case Tid_mem: return Key_mem;
|
||||
case Tid_url: return Key_url;
|
||||
default: throw Exc_.new_unimplemented();
|
||||
}
|
||||
}
|
||||
public static byte Xto_tid(String s) {
|
||||
if (String_.Eq(s, Key_mem)) return Tid_mem;
|
||||
else if (String_.Eq(s, Key_url)) return Tid_url;
|
||||
else throw Exc_.new_unimplemented();
|
||||
}
|
||||
public static KeyVal[] Options__list = KeyVal_.Ary(KeyVal_.new_(Key_mem), KeyVal_.new_(Key_url));
|
||||
}
|
||||
24
150_gfui/src_300_gxw/gplx/gfui/Gxw_tab_itm.java
Normal file
24
150_gfui/src_300_gxw/gplx/gfui/Gxw_tab_itm.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface Gxw_tab_itm extends GxwElem {
|
||||
void Subs_add(GfuiElem sub);
|
||||
Gfui_tab_itm_data Tab_data();
|
||||
String Tab_name(); void Tab_name_(String v);
|
||||
String Tab_tip_text(); void Tab_tip_text_(String v);
|
||||
}
|
||||
31
150_gfui/src_300_gxw/gplx/gfui/Gxw_tab_mgr.java
Normal file
31
150_gfui/src_300_gxw/gplx/gfui/Gxw_tab_mgr.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public interface Gxw_tab_mgr extends GxwElem {
|
||||
ColorAdp Btns_selected_color(); void Btns_selected_color_(ColorAdp v);
|
||||
ColorAdp Btns_unselected_color(); void Btns_unselected_color_(ColorAdp v);
|
||||
int Btns_height(); void Btns_height_(int v);
|
||||
boolean Btns_place_on_top(); void Btns_place_on_top_(boolean v);
|
||||
boolean Btns_curved(); void Btns_curved_(boolean v);
|
||||
boolean Btns_close_visible(); void Btns_close_visible_(boolean v);
|
||||
boolean Btns_unselected_close_visible(); void Btns_unselected_close_visible_(boolean v);
|
||||
Gxw_tab_itm Tabs_add(Gfui_tab_itm_data tab_data);
|
||||
void Tabs_select_by_idx(int i);
|
||||
void Tabs_close_by_idx(int i);
|
||||
void Tabs_switch(int src, int trg);
|
||||
}
|
||||
31
150_gfui/src_300_gxw/gplx/gfui/MockForm.java
Normal file
31
150_gfui/src_300_gxw/gplx/gfui/MockForm.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfui; import gplx.*;
|
||||
public class MockForm extends GxwElem_mock_base implements GxwWin {
|
||||
public IconAdp IconWin() {return null;} public void IconWin_set(IconAdp v) {}
|
||||
public void ShowWin() {}
|
||||
public void CloseWin() {}
|
||||
public void HideWin() {}
|
||||
public boolean Maximized() {return false;} public void Maximized_(boolean v) {}
|
||||
public boolean Minimized() {return false;} public void Minimized_(boolean v) {}
|
||||
public boolean Pin() {return pin;} public void Pin_set(boolean val) {pin = val;} private boolean pin;
|
||||
public void OpenedCmd_set(GfoInvkAbleCmd v) {}
|
||||
public void TaskbarVisible_set(boolean val) {}
|
||||
public void TaskbarParkingWindowFix(GxwElem form) {}
|
||||
public static final MockForm _ = new MockForm(); MockForm() {}
|
||||
}
|
||||
Reference in New Issue
Block a user