/cwxeditor_src/cwx/editor/gui/dwt/messageutils.d
D | 2683 lines | 2500 code | 135 blank | 48 comment | 359 complexity | c7da1b3e317cf6cd1cc458f9f702851d MD5 | raw file
Possible License(s): LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- module cwx.editor.gui.dwt.messageutils;
- import cwx.utils;
- import cwx.types;
- import cwx.event;
- import cwx.summary;
- import cwx.skin;
- import cwx.xml;
- import cwx.flag;
- import cwx.path;
- import cwx.structs;
- import cwx.msgutils;
- import cwx.menu;
- import cwx.types;
- import cwx.imagesize;
- import cwx.system;
- import cwx.editor.gui.dwt.dprops;
- import cwx.editor.gui.dwt.dskin;
- import cwx.editor.gui.dwt.dutils;
- import cwx.editor.gui.dwt.commons;
- import cwx.editor.gui.dwt.centerlayout;
- import cwx.editor.gui.dwt.customtext;
- import cwx.editor.gui.dwt.customtable;
- import cwx.editor.gui.dwt.imageselect;
- import cwx.editor.gui.dwt.materialselect;
- import cwx.editor.gui.dwt.absdialog;
- import cwx.editor.gui.dwt.eventdialog;
- import cwx.editor.gui.dwt.xmlbytestransfer;
- import cwx.editor.gui.dwt.undo;
- import cwx.editor.gui.dwt.splitpane;
- import cwx.editor.gui.dwt.properties;
- import cwx.editor.gui.dwt.absdialog;
- import cwx.editor.gui.dwt.dmenu;
- import cwx.editor.gui.dwt.couponview;
- import cwx.editor.gui.dwt.chooser;
- import std.array;
- import std.utf;
- import std.string;
- import std.datetime;
- import std.conv;
- import std.exception;
- import org.eclipse.swt.all;
- import java.lang.all;
- /// ??????????????????????????????
- class AbstractMessageDialog : EventDialog {
- private KeyDownFilter _kdFilter;
- private MsgPreviewWindow _previewWin = null;
- private MsgPreview _preview = null;
- private UndoManager _undo;
- private class SelPrev : SelectionAdapter {
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- auto btn = cast(Button) e.widget;
- if (btn.getSelection()) { mixin(S_TRACE);
- auto s = wrapReturnCode(text);
- if (_previewWin) { mixin(S_TRACE);
- if (_previewWin.isVisible()) return;
- _previewWin.text(selectedTalker, "", s);
- _previewWin.open();
- } else { mixin(S_TRACE);
- if (rightGroup.isVisible()) return;
- _preview.text(selectedTalker, imgPath, s);
- setPreviewLData(true);
- }
- } else { mixin(S_TRACE);
- if (_previewWin) { mixin(S_TRACE);
- if (!_previewWin.isVisible()) return;
- _previewWin.close();
- } else { mixin(S_TRACE);
- if (!rightGroup.isVisible()) return;
- setPreviewLData(false);
- }
- }
- }
- }
- private void setPreviewLData(bool visible, bool regWin = true) { mixin(S_TRACE);
- bool oVisible = rightGroup.isVisible();
- assert (_preview);
- rightGroup.setVisible(visible);
- int pvw;
- if (!visible) { mixin(S_TRACE);
- pvw = rightGroup.getSize().x;
- }
- int w = visible ? prop.looks.messageBounds.width : 0;
- int h = 0;
- rightGroupSize(w, h);
- if (getShell().isVisible()) getShell().setRedraw(false);
- scope (exit) {
- if (getShell().isVisible()) getShell().setRedraw(true);
- }
- if (regWin && oVisible != visible) { mixin(S_TRACE);
- auto ws = getShell().getSize();
- if (visible) { mixin(S_TRACE);
- pvw = rightGroup.getSize().x;
- }
- if (visible) { mixin(S_TRACE);
- ws.x += pvw;
- } else { mixin(S_TRACE);
- ws.x -= pvw;
- }
- getShell().setSize(ws);
- }
- }
- private class Dispose : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- comm.refMenu.remove(&refMenu);
- comm.refUndoMax.remove(&refUndoMax);
- getShell().getDisplay().removeFilter(SWT.KeyDown, _kdFilter);
- if (_preview) { mixin(S_TRACE);
- if (type is CType.TALK_MESSAGE) { mixin(S_TRACE);
- prop.var.etc.showMessagePreview = _preview.isVisible();
- } else if (type is CType.TALK_DIALOG) { mixin(S_TRACE);
- prop.var.etc.showDialogPreview = _preview.isVisible();
- } else assert (0);
- }
- }
- }
- private class KeyDownFilter : Listener {
- this () { mixin(S_TRACE);
- refMenu(MenuID.Undo);
- refMenu(MenuID.Redo);
- }
- override void handleEvent(Event e) { mixin(S_TRACE);
- auto c = cast(Control) e.widget;
- if (!c || c.getShell() !is getShell()) return;
- if (!canHookKeyDown(c)) return;
- if (cast(Text) c) return;
- if (eqAcc(_undoAcc, e.keyCode, e.character, e.stateMask)) { mixin(S_TRACE);
- _undo.undo();
- e.doit = false;
- } else if (eqAcc(_redoAcc, e.keyCode, e.character, e.stateMask)) { mixin(S_TRACE);
- _undo.redo();
- e.doit = false;
- }
- }
- }
- protected bool canHookKeyDown(Control fc) { mixin(S_TRACE);
- return !_preview || !_preview.focusInValues;
- }
- private int _undoAcc;
- private int _redoAcc;
- private void refMenu(MenuID id) { mixin(S_TRACE);
- if (id == MenuID.Undo) _undoAcc = convertAccelerator(prop.buildMenu(MenuID.Undo));
- if (id == MenuID.Redo) _redoAcc = convertAccelerator(prop.buildMenu(MenuID.Redo));
- }
- private void refUndoMax() { mixin(S_TRACE);
- _undo.max = prop.var.etc.undoMaxEtc;
- }
- protected void initPreview(Composite area, WSize size) { mixin(S_TRACE);
- auto aComp = addition();
- aComp.setLayout(new GridLayout(1, true));
- auto prev = new Button(aComp, SWT.TOGGLE);
- prev.setText(prop.msgs.messagePreview);
- bool show;
- if (type is CType.TALK_MESSAGE) { mixin(S_TRACE);
- show = prop.var.etc.showMessagePreview;
- } else if (type is CType.TALK_DIALOG) { mixin(S_TRACE);
- show = prop.var.etc.showDialogPreview;
- } else assert (0);
- prev.setSelection(show);
- prev.addSelectionListener(new SelPrev);
- if (prop.var.etc.floatMessagePreview) { mixin(S_TRACE);
- _previewWin = new MsgPreviewWindow(getShell(), comm, prop, summ, prev, size);
- } else { mixin(S_TRACE);
- _preview = new MsgPreview(rightGroup, comm, prop, summ);
- rightGroup.setLayout(zeroGridLayout(1, false));
- _preview.setLayoutData(new GridData(GridData.FILL_BOTH));
- setPreviewLData(show, false);
- }
- refreshPreview();
- }
- this (Commons comm, Props prop, Shell shell, Summary summ, CType type, Content parent, Content evt, DSize size) { mixin(S_TRACE);
- super (comm, prop, shell, summ, type, parent, evt, true, size, false, !prop.var.etc.floatMessagePreview);
- _undo = new UndoManager(prop.var.etc.undoMaxEtc);
- }
- override
- protected void opened() { mixin(S_TRACE);
- if (!_previewWin) return;
- if (type is CType.TALK_MESSAGE) { mixin(S_TRACE);
- if (prop.var.etc.showMessagePreview) _previewWin.open();
- closeEvent ~= { mixin(S_TRACE);
- prop.var.etc.showMessagePreview = _previewWin.isVisible();
- };
- } else if (type is CType.TALK_DIALOG) { mixin(S_TRACE);
- if (prop.var.etc.showDialogPreview) _previewWin.open();
- closeEvent ~= { mixin(S_TRACE);
- prop.var.etc.showDialogPreview = _previewWin.isVisible();
- };
- } else assert (0);
- }
- protected override void setup(Composite area) { mixin(S_TRACE);
- area.addDisposeListener(new Dispose);
- _kdFilter = new KeyDownFilter;
- area.getDisplay().addFilter(SWT.KeyDown, _kdFilter);
- comm.refMenu.add(&refMenu);
- comm.refUndoMax.add(&refUndoMax);
- }
- void refreshPreview() { mixin(S_TRACE);
- if (!_previewWin && !_preview) return;
- auto s = wrapReturnCode(text);
- if (_previewWin) { mixin(S_TRACE);
- _previewWin.text(selectedTalker, imgPath, s);
- _previewWin.refresh();
- } else { mixin(S_TRACE);
- _preview.text(selectedTalker, imgPath, s);
- _preview.refresh();
- }
- }
- @property
- abstract string text();
- @property
- abstract Talker selectedTalker();
- @property
- abstract string imgPath();
- }
- /// ????????????????
- class SpeakDialog : AbstractMessageDialog {
- private:
- class APData {
- int selDlg;
- SDialog[] dlgs;
- }
- Object readAPD(Object old) { mixin(S_TRACE);
- auto o = new APData;
- o.selDlg = _dlgsL.getSelectionIndex();
- foreach (d; _dlgs) { mixin(S_TRACE);
- o.dlgs ~= new SDialog(d);
- }
- return o;
- }
- void writeAPD(Object o) { mixin(S_TRACE);
- bool oldIgnoreMod = ignoreMod;
- ignoreMod = true;
- scope (exit) ignoreMod = oldIgnoreMod;
- auto apd = cast(APData)o;
- assert (apd);
- foreach (i, d; apd.dlgs) { mixin(S_TRACE);
- _dlgs[i] = new SDialog(d);
- }
- refreshDlgList();
- _dlgsL.select(apd.selDlg);
- selectChanged();
- }
- class SUndo : Undo {
- private SDialog[] _dlgs;
- private int _selDlg;
- this () { mixin(S_TRACE);
- save();
- }
- private void save() { mixin(S_TRACE);
- _dlgs = [];
- foreach (d; this.outer._dlgs) { mixin(S_TRACE);
- _dlgs ~= new SDialog(d);
- }
- _selDlg = _dlgsL.getSelectionIndex();
- }
- private void impl() { mixin(S_TRACE);
- auto dlgs = _dlgs;
- int selDlg = _selDlg;
- save();
- this.outer._dlgs = [];
- foreach (dlg; dlgs) { mixin(S_TRACE);
- this.outer._dlgs ~= new SDialog(dlg);
- }
- refreshDlgList();
- _dlgsL.select(selDlg);
- selectChanged();
- }
- override void undo() {impl();}
- override void redo() {impl();}
- override void dispose() { mixin(S_TRACE);
- // Nothing
- }
- }
- void storeEdit() { mixin(S_TRACE);
- _undo ~= new SUndo;
- }
- void updateValue() { mixin(S_TRACE);
- int max = _initValue.getSelection();
- int min = max;
- foreach (cp; _couponView.coupons) { mixin(S_TRACE);
- if (cp.value < 0) { mixin(S_TRACE);
- min -= cp.value;
- } else { mixin(S_TRACE);
- max += cp.value;
- }
- }
- if (0 >= min) { mixin(S_TRACE);
- _couponView.toolTip = .tryFormat(prop.msgs.valuedTalkerMaxMinLess0, max, min);
- } else { mixin(S_TRACE);
- _couponView.toolTip = .tryFormat(prop.msgs.valuedTalkerMaxMin, max, min);
- }
- }
- override
- protected void refreshWarning() { mixin(S_TRACE);
- string[] ws;
- if (prop.targetVersion("1.50")) { mixin(S_TRACE);
- if (Talker.VALUED is selectedTalker) { mixin(S_TRACE);
- ws ~= prop.msgs.warningValuedTalker;
- }
- }
- warning = ws;
- }
- string _id;
- Combo _talkers;
- SDialog[] _dlgs;
- Table _dlgsL;
- Text _rCoupons;
- Combo _rCouponsList;
- FixedWidthText _text;
- TextMenuModify _textTM, _rCouponsTM;
- CouponView!(CVType.Valued) _couponView;
- Spinner _initValue;
- protected override bool canHookKeyDown(Control fc) { mixin(S_TRACE);
- return super.canHookKeyDown(fc) && !isDescendant(_couponView, fc);
- }
- void selectChanged() { mixin(S_TRACE);
- bool oldIgnoreMod = ignoreMod;
- ignoreMod = true;
- scope (exit) ignoreMod = oldIgnoreMod;
- auto dlg = _dlgs[_dlgsL.getSelectionIndex()];
- string rcs;
- foreach (rc; dlg.rCoupons) { mixin(S_TRACE);
- rcs ~= rc;
- rcs ~= '\n';
- }
- _rCoupons.setText(rcs);
- _text.setText(dlg.text);
- auto len = dlg.text.length;
- _text.widget.setSelection(len, len);
- refreshPreview();
- comm.refreshToolBar();
- }
- void createDialog(SDialog dlg) { mixin(S_TRACE);
- insertDialog(dlg, _dlgsL.getSelectionIndex());
- }
- void createDialog() { mixin(S_TRACE);
- createDialog(new SDialog);
- }
- void insertDialog(SDialog dlg, int index, bool store = true) { mixin(S_TRACE);
- if (store) storeEdit();
- if (index < 0) index = _dlgs.length;
- _dlgs = _dlgs[0 .. index] ~ dlg ~ _dlgs[index .. $];
- auto itm = new TableItem(_dlgsL, SWT.NONE, index);
- itm.setImage(prop.images.content(CType.TALK_DIALOG));
- _dlgsL.setSelection([itm]);
- _dlgsL.showSelection();
- selectChanged();
- applyEnabled();
- }
- void deleteDialog(int index, bool store = true) { mixin(S_TRACE);
- if (index < 0 || _dlgs.length <= 1) return;
- if (store) storeEdit();
- bool sel = _dlgsL.getSelectionIndex() == index;
- _dlgs = _dlgs[0 .. index] ~ _dlgs[index + 1 .. $];
- _dlgsL.remove(index);
- if (sel) { mixin(S_TRACE);
- _dlgsL.select(index < _dlgs.length ? index : _dlgs.length - 1);
- selectChanged();
- } else { mixin(S_TRACE);
- comm.refreshToolBar();
- }
- applyEnabled();
- }
- void deleteDialogSel() { mixin(S_TRACE);
- deleteDialog(_dlgsL.getSelectionIndex());
- }
- void overDialog() { mixin(S_TRACE);
- int index = _dlgsL.getSelectionIndex();
- if (index > 0) { mixin(S_TRACE);
- _dlgsL.select(index - 1);
- selectChanged();
- }
- }
- void underDialog() { mixin(S_TRACE);
- int index = _dlgsL.getSelectionIndex();
- if (index + 1 < _dlgs.length) { mixin(S_TRACE);
- _dlgsL.select(index + 1);
- selectChanged();
- }
- }
- void up() { mixin(S_TRACE);
- int index = _dlgsL.getSelectionIndex();
- if (index > 0) { mixin(S_TRACE);
- storeEdit();
- auto temp = _dlgs[index - 1];
- _dlgs[index - 1] = _dlgs[index];
- _dlgs[index] = temp;
- auto tempL = _dlgsL.getItem(index - 1).getText();
- _dlgsL.getItem(index - 1).setText(_dlgsL.getItem(index).getText());
- _dlgsL.getItem(index).setText(tempL);
- _dlgsL.select(index - 1);
- applyEnabled();
- comm.refreshToolBar();
- }
- }
- void down() { mixin(S_TRACE);
- int index = _dlgsL.getSelectionIndex();
- if (index + 1 < _dlgs.length) { mixin(S_TRACE);
- storeEdit();
- auto temp = _dlgs[index + 1];
- _dlgs[index + 1] = _dlgs[index];
- _dlgs[index] = temp;
- auto tempL = _dlgsL.getItem(index + 1).getText();
- _dlgsL.getItem(index + 1).setText(_dlgsL.getItem(index).getText());
- _dlgsL.getItem(index).setText(tempL);
- _dlgsL.select(index + 1);
- applyEnabled();
- comm.refreshToolBar();
- }
- }
- void copyToUpper() { mixin(S_TRACE);
- storeEdit();
- int index = _dlgsL.getSelectionIndex();
- string textL = _dlgsL.getItem(index).getText();
- string text = lastRet(wrapReturnCode(_text.getText()));
- for (int i = 0; i < index; i++) { mixin(S_TRACE);
- _dlgsL.getItem(i).setText(textL);
- _dlgs[i].text = text;
- }
- applyEnabled();
- comm.refreshToolBar();
- }
- void copyToLower() { mixin(S_TRACE);
- storeEdit();
- int index = _dlgsL.getSelectionIndex();
- string textL = _dlgsL.getItem(index).getText();
- string text = lastRet(wrapReturnCode(_text.getText()));
- for (int i = index + 1; i < _dlgs.length; i++) { mixin(S_TRACE);
- _dlgsL.getItem(i).setText(textL);
- _dlgs[i].text = text;
- }
- applyEnabled();
- comm.refreshToolBar();
- }
- void copyToDialogs() { mixin(S_TRACE);
- storeEdit();
- int index = _dlgsL.getSelectionIndex();
- string textL = _dlgsL.getItem(index).getText();
- string text = lastRet(wrapReturnCode(_text.getText()));
- foreach (i, dlg; _dlgs) { mixin(S_TRACE);
- if (i != index) { mixin(S_TRACE);
- _dlgsL.getItem(i).setText(textL);
- dlg.text = text;
- }
- }
- applyEnabled();
- comm.refreshToolBar();
- }
- void put(dchar put) { mixin(S_TRACE);
- putColor(_text, put);
- }
- void insert(string put) { mixin(S_TRACE);
- _text.insert(put);
- }
- void putText(SDialog dlg) { mixin(S_TRACE);
- dlg.text = lastRet(wrapReturnCode(_text.getText()));
- }
- void putRCoupons(SDialog dlg) { mixin(S_TRACE);
- string[] rcs;
- foreach (rc; splitLines!string(_rCoupons.getText())) { mixin(S_TRACE);
- if (rc.length > 0) { mixin(S_TRACE);
- rcs ~= rc;
- }
- }
- dlg.rCoupons = rcs;
- }
- void updateTalker() { mixin(S_TRACE);
- _couponView.enabled = (Talker.VALUED is selectedTalker);
- _initValue.setEnabled(_couponView.enabled);
- comm.refreshToolBar();
- }
- class SelL : SelectionAdapter {
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- selectChanged();
- }
- }
- class SelectTalker : SelectionAdapter {
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- refreshPreview();
- refreshWarning();
- updateTalker();
- }
- }
- private void refreshDlgList(int index) { mixin(S_TRACE);
- string text = wrapReturnCode(_dlgs[index].text).singleLine;
- // FIXME: ""?setText???Argument cannot be null
- if (text == "") text = " ";
- _dlgsL.getItem(index).setText(0, text);
- }
- class ModL : ModifyListener {
- override void modifyText(ModifyEvent e) { mixin(S_TRACE);
- if (_textTM && _rCouponsTM && !_textTM.inProc() && !_rCouponsTM.inProc()) { mixin(S_TRACE);
- putText(_dlgs[_dlgsL.getSelectionIndex()]);
- }
- refreshDlgList(_dlgsL.getSelectionIndex());
- refreshPreview();
- }
- }
- class ModRC : ModifyListener {
- override void modifyText(ModifyEvent e) { mixin(S_TRACE);
- if (_textTM && _rCouponsTM && !_textTM.inProc() && !_rCouponsTM.inProc()) { mixin(S_TRACE);
- putRCoupons(_dlgs[_dlgsL.getSelectionIndex()]);
- }
- }
- }
- @property
- SDialog selection() { mixin(S_TRACE);
- int index = _dlgsL.getSelectionIndex();
- return index >= 0 ? _dlgs[index] : null;
- }
- class DialogsTCPD : TCPD {
- void cut(SelectionEvent se) { mixin(S_TRACE);
- if (_dlgsL.getItemCount() > 1 && selection) { mixin(S_TRACE);
- copy(se);
- del(se);
- }
- }
- void copy(SelectionEvent se) { mixin(S_TRACE);
- auto d = selection;
- if (d) { mixin(S_TRACE);
- XMLtoCB(prop, comm.clipboard, d.toNode().text);
- comm.refreshToolBar();
- }
- }
- void paste(SelectionEvent se) { mixin(S_TRACE);
- auto xml = CBtoXML(comm.clipboard);
- if (xml) { mixin(S_TRACE);
- try { mixin(S_TRACE);
- auto node = XNode.parse(xml);
- if (node.name == SDialog.XML_NAME) { mixin(S_TRACE);
- auto ver = new XMLInfo(prop.sys, LATEST_VERSION);
- createDialog(SDialog.createFromNode(node, ver));
- }
- } catch (Exception e) {
- debugln(e);
- }
- }
- }
- void del(SelectionEvent se) {deleteDialogSel();}
- void clone(SelectionEvent se) { mixin(S_TRACE);
- comm.clipboard.memoryMode = true;
- scope (exit) comm.clipboard.memoryMode = false;
- copy(se);
- paste(se);
- }
- @property bool canDoTCPD() {return _dlgsL.isFocusControl();}
- @property bool canDoT() {return _dlgsL.getSelectionIndex() > 0;}
- @property bool canDoC() {return canDoT;}
- @property bool canDoP() {return CBisXML(comm.clipboard);}
- @property bool canDoD() {return canDoT;}
- @property bool canDoClone() {return canDoC;}
- }
- class DDropListener : DropTargetAdapter {
- override void dragEnter(DropTargetEvent e){ mixin(S_TRACE);
- e.detail = DND.DROP_MOVE;
- }
- override void dragOver(DropTargetEvent e){ mixin(S_TRACE);
- e.detail = DND.DROP_MOVE;
- }
- override void drop(DropTargetEvent e){ mixin(S_TRACE);
- if (!isXMLBytes(e.data)) return;
- e.detail = DND.DROP_NONE;
- string xml = bytesToXML(e.data);
- try { mixin(S_TRACE);
- auto node = XNode.parse(xml);
- if (node.name != SDialog.XML_NAME) return;
- storeEdit();
- scope p = (cast(DropTarget) e.getSource()).getControl().toControl(e.x, e.y);
- auto t = _dlgsL.getItem(p);
- int index = t ? _dlgsL.indexOf(t) : _dlgsL.getItemCount();
- auto ver = new XMLInfo(prop.sys, LATEST_VERSION);
- insertDialog(SDialog.createFromNode(node, ver), index, false);
- if (_id == node.attr("paneId", false)) { mixin(S_TRACE);
- e.detail = DND.DROP_MOVE;
- }
- } catch {}
- }
- }
- class DDragListener : DragSourceAdapter {
- private TableItem _itm;
- override void dragStart(DragSourceEvent e) { mixin(S_TRACE);
- e.doit = (cast(DragSource) e.getSource()).getControl().isFocusControl();
- }
- override void dragSetData(DragSourceEvent e){ mixin(S_TRACE);
- if (XMLBytesTransfer.getInstance().isSupportedType(e.dataType)) { mixin(S_TRACE);
- auto c = cast(Table) (cast(DragSource) e.getSource()).getControl();
- int index = c.getSelectionIndex();
- if (index >= 0) { mixin(S_TRACE);
- auto d = _dlgs[index];
- auto node = d.toNode();
- node.newAttr("paneId", _id);
- e.data = bytesFromXML(node.text);
- _itm = c.getItem(index);
- }
- }
- }
- override void dragFinished(DragSourceEvent e) { mixin(S_TRACE);
- if (e.detail == DND.DROP_MOVE) { mixin(S_TRACE);
- deleteDialog(_dlgsL.indexOf(_itm), false);
- }
- }
- }
- protected override void refSkin() { mixin(S_TRACE);
- _text.font = dwtData(prop.looks.messageFont(summ.legacy));
- }
- void refreshDlgList() { mixin(S_TRACE);
- bool oldIgnoreMod = ignoreMod;
- ignoreMod = true;
- scope (exit) ignoreMod = oldIgnoreMod;
- int selIndex = _dlgsL.getSelectionIndex();
- int topIndex = _dlgsL.getTopIndex();
- _dlgsL.removeAll();
- foreach (dlg; _dlgs) { mixin(S_TRACE);
- auto itm = new TableItem(_dlgsL, SWT.NONE);
- itm.setImage(prop.images.content(CType.TALK_DIALOG));
- string text = dlg.text.singleLine;
- // FIXME: ""?setText???Argument cannot be null
- itm.setText(text.length > 0 ? text : " ");
- }
- if (selIndex < 0 || _dlgs.length <= selIndex) { mixin(S_TRACE);
- _dlgsL.select(0);
- } else { mixin(S_TRACE);
- _dlgsL.select(selIndex);
- _dlgsL.setTopIndex(topIndex);
- }
- if (selIndex != _dlgsL.getSelectionIndex()) { mixin(S_TRACE);
- selectChanged();
- } else { mixin(S_TRACE);
- comm.refreshToolBar();
- }
- }
- class DisposeLeftSash : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- auto sash = cast(SplitPane) e.widget;
- auto ws = sash.getWeights();
- prop.var.etc.talkLeftSashL = ws[0];
- prop.var.etc.talkLeftSashR = ws[1];
- }
- }
- class DisposeMainSash : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- auto sash = cast(SplitPane) e.widget;
- auto ws = sash.getWeights();
- prop.var.etc.talkMainSashL = ws[0];
- prop.var.etc.talkMainSashR = ws[1];
- }
- }
- private class KeyDownFilter : Listener {
- this () { mixin(S_TRACE);
- refMenu(MenuID.OverDialog);
- refMenu(MenuID.UnderDialog);
- }
- override void handleEvent(Event e) { mixin(S_TRACE);
- auto c = cast(Control) e.widget;
- if (!c || c.getShell() !is getShell()) return;
- if (_dlgsL is c) return;
- if (eqAcc(_overAcc, e.keyCode, e.character, e.stateMask)) { mixin(S_TRACE);
- overDialog();
- e.doit = false;
- } else if (eqAcc(_underAcc, e.keyCode, e.character, e.stateMask)) { mixin(S_TRACE);
- underDialog();
- e.doit = false;
- }
- }
- }
- private int _overAcc;
- private int _underAcc;
- private void refMenu(MenuID id) { mixin(S_TRACE);
- if (id == MenuID.OverDialog) _overAcc = convertAccelerator(prop.buildMenu(MenuID.OverDialog));
- if (id == MenuID.UnderDialog) _underAcc = convertAccelerator(prop.buildMenu(MenuID.UnderDialog));
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- _id = format("%08X", &this) ~ "-" ~ to!(string)(Clock.currTime());
- super(comm, prop, shell, summ, CType.TALK_DIALOG, parent, evt, prop.var.speakDlg);
- }
- override
- bool openCWXPath(string path, bool shellActivate) { mixin(S_TRACE);
- auto cate = cpcategory(path);
- if ("dialog" == cate) { mixin(S_TRACE);
- auto index = cpindex(path);
- if (index >= _dlgsL.getItemCount()) return false;
- _dlgsL.select(index);
- selectChanged();
- .forceFocus(_dlgsL, shellActivate);
- path = cpbottom(path);
- return cpempty(path);
- }
- return super.openCWXPath(path, shellActivate);
- }
- @property
- override
- string text() { mixin(S_TRACE);
- return wrapReturnCode(_text.getText());
- }
- @property
- override
- Talker selectedTalker() { mixin(S_TRACE);
- switch (_talkers.getSelectionIndex()) {
- case 0: return Talker.SELECTED;
- case 1: return Talker.UNSELECTED;
- case 2: return Talker.RANDOM;
- case 3: return Talker.VALUED;
- default: assert (0);
- }
- }
- @property
- override
- string imgPath() { mixin(S_TRACE);
- return "";
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- super.setup(area);
- area.setLayout(windowGridLayout(1, true));
- auto sash = new SplitPane(area, SWT.HORIZONTAL);
- sash.setLayoutData(new GridData(GridData.FILL_BOTH));
- auto left = new Composite(sash, SWT.NONE);
- left.setLayout(zeroMarginGridLayout(1, true));
- { mixin(S_TRACE);
- auto grp = new Group(left, SWT.NONE);
- grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- grp.setText(prop.msgs.talker);
- grp.setLayout(new GridLayout(1, true));
- _talkers = new Combo(grp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
- mod(_talkers);
- _talkers.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- _talkers.add(prop.msgs.talkerName(Talker.SELECTED));
- _talkers.add(prop.msgs.talkerName(Talker.UNSELECTED));
- _talkers.add(prop.msgs.talkerName(Talker.RANDOM));
- _talkers.add(prop.msgs.talkerName(Talker.VALUED));
- _talkers.addSelectionListener(new SelectTalker);
- }
- auto leftSash = new SplitPane(left, SWT.VERTICAL);
- leftSash.setLayoutData(new GridData(GridData.FILL_BOTH));
- auto skin = comm.skin;
- { mixin(S_TRACE);
- auto grp = new Group(leftSash, SWT.NONE);
- grp.setText(prop.msgs.toneCoupons);
- grp.setLayout(new GridLayout(1, true));
- Control tp;
- if (evt) { mixin(S_TRACE);
- tp = createTalkerPane2(grp, comm, prop, summ, evt.dialogs[0].rCoupons, _rCoupons, _rCouponsList);
- } else { mixin(S_TRACE);
- tp = createTalkerPane2(grp, comm, prop, summ, [], _rCoupons, _rCouponsList);
- }
- mod(_rCoupons);
- _rCoupons.addModifyListener(new ModRC);
- tp.setLayoutData(new GridData(GridData.FILL_BOTH));
- }
- { mixin(S_TRACE);
- auto grp = new Group(leftSash, SWT.NONE);
- grp.setText(prop.msgs.valued);
- grp.setLayout(new GridLayout(2, false));
- auto lbl = new Label(grp, SWT.NONE);
- lbl.setText(prop.msgs.initValue);
- _initValue = new Spinner(grp, SWT.BORDER);
- initSpinner(_initValue);
- mod(_initValue);
- _initValue.setMinimum(cast(int) prop.var.etc.couponValueMax * -1);
- _initValue.setMaximum(prop.var.etc.couponValueMax);
- _initValue.setSelection(1);
- _initValue.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- .listener(_initValue, SWT.Selection, &updateValue);
- _couponView = new CouponView!(CVType.Valued)(comm, summ, grp, SWT.NONE, &catchMod);
- mod(_couponView);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 2;
- _couponView.setLayoutData(gd);
- _couponView.modEvent ~= &updateValue;
- }
- auto right = new Composite(sash, SWT.NONE);
- right.setLayout(zeroMarginGridLayout(2, false));
- { mixin(S_TRACE);
- _dlgsL = new Table(right, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
- new FullTableColumn(_dlgsL, SWT.NONE);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.widthHint = 0;
- gd.heightHint = 0;
- _dlgsL.setLayoutData(gd);
- _dlgsL.addSelectionListener(new SelL);
- auto drag = new DragSource(_dlgsL, DND.DROP_MOVE | DND.DROP_COPY);
- drag.setTransfer([XMLBytesTransfer.getInstance()]);
- drag.addDragListener(new DDragListener);
- auto drop = new DropTarget(_dlgsL, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY);
- drop.setTransfer([XMLBytesTransfer.getInstance()]);
- drop.addDropListener(new DDropListener);
- auto menu = new Menu(_dlgsL);
- createMenuItem(comm, menu, MenuID.Undo, {_undo.undo();}, &_undo.canUndo);
- createMenuItem(comm, menu, MenuID.Redo, {_undo.redo();}, &_undo.canRedo);
- new MenuItem(menu, SWT.SEPARATOR);
- createMenuItem(comm, menu, MenuID.Up, &up, () => _dlgsL.getSelectionIndex() != -1 && 0 < _dlgsL.getSelectionIndex());
- createMenuItem(comm, menu, MenuID.Down, &down, () => _dlgsL.getSelectionIndex() != -1 && _dlgsL.getSelectionIndex() + 1 < _dlgsL.getItemCount());
- new MenuItem(menu, SWT.SEPARATOR);
- createMenuItem(comm, menu, MenuID.OverDialog, &overDialog, () => _dlgsL.getSelectionIndex() != -1 && 0 < _dlgsL.getSelectionIndex());
- createMenuItem(comm, menu, MenuID.UnderDialog, &underDialog, () => _dlgsL.getSelectionIndex() != -1 && _dlgsL.getSelectionIndex() + 1 < _dlgsL.getItemCount());
- new MenuItem(menu, SWT.SEPARATOR);
- appendMenuTCPD(comm, menu, new DialogsTCPD, true, true, true, true, true);
- _dlgsL.setMenu(menu);
- auto bar = new ToolBar(right, SWT.FLAT | SWT.VERTICAL);
- comm.put(bar);
- bar.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- bar.addListener(SWT.Traverse, new class Listener {
- override void handleEvent(Event e) {e.doit = true;}
- });
- bar.addListener(SWT.KeyDown, new class Listener {
- override void handleEvent(Event e) {e.doit = true;}
- });
- createToolItem2(comm, bar, prop.msgs.createDialog, prop.images.createDialog, &createDialog, null);
- createToolItem2(comm, bar, prop.msgs.deleteDialog, prop.images.deleteDialog, &deleteDialogSel, () => _dlgsL.getItemCount() > 1 && _dlgsL.getSelectionIndex() != -1);
- new ToolItem(bar, SWT.SEPARATOR);
- createToolItem(comm, bar, MenuID.Up, &up, () => _dlgsL.getSelectionIndex() != -1 && 0 < _dlgsL.getSelectionIndex());
- createToolItem(comm, bar, MenuID.Down, &down, () => _dlgsL.getSelectionIndex() != -1 && _dlgsL.getSelectionIndex() + 1 < _dlgsL.getItemCount());
- new ToolItem(bar, SWT.SEPARATOR);
- createToolItem2(comm, bar, prop.msgs.copyToDialogs, prop.images.copyToDialogs, ©ToDialogs, () => _dlgsL.getSelectionIndex() != -1 && _dlgsL.getItemCount() > 1);
- createToolItem2(comm, bar, prop.msgs.copyToUpper, prop.images.copyToUpper, ©ToUpper, () => _dlgsL.getSelectionIndex() != -1 && 0 < _dlgsL.getSelectionIndex());
- createToolItem2(comm, bar, prop.msgs.copyToLower, prop.images.copyToLower, ©ToLower, () => _dlgsL.getSelectionIndex() != -1 && _dlgsL.getSelectionIndex() + 1 < _dlgsL.getItemCount());
- }
- { mixin(S_TRACE);
- auto msgComp = new Composite(right, SWT.NONE);
- auto gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- msgComp.setLayoutData(gd);
- msgComp.setLayout(new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0));
- _text = createMessagePane(comm, prop, true, msgComp, summ);
- mod(_text.widget);
- _text.widget.setLayoutData(_text.computeTextBaseSize(prop.looks.messageLine));
- _text.widget.addModifyListener(new ModL);
- }
- { mixin(S_TRACE);
- auto bar = createSCharBar(comm, area, &insert, &put, prop, skin);
- bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- { mixin(S_TRACE);
- auto bar = createSkinSCharBar(comm, area, &insert, prop, skin);
- bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- { mixin(S_TRACE);
- auto bar = createFlagStepBar(area, &insert, comm, prop);
- bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- leftSash.setWeights([prop.var.etc.talkLeftSashL, prop.var.etc.talkLeftSashR]);
- leftSash.addDisposeListener(new DisposeLeftSash);
- sash.setWeights([prop.var.etc.talkMainSashL, prop.var.etc.talkMainSashR]);
- sash.addDisposeListener(new DisposeMainSash);
- auto kdFilter = new KeyDownFilter;
- area.getDisplay().addFilter(SWT.KeyDown, kdFilter);
- comm.refMenu.add(&refMenu);
- .listener(area, SWT.Dispose, { mixin(S_TRACE);
- area.getDisplay().removeFilter(SWT.KeyDown, kdFilter);
- comm.refMenu.remove(&refMenu);
- });
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- if (evt) { mixin(S_TRACE);
- switch (evt.talkerNC) {
- case Talker.SELECTED:
- _talkers.select(0);
- break;
- case Talker.UNSELECTED:
- _talkers.select(1);
- break;
- case Talker.RANDOM:
- _talkers.select(2);
- break;
- case Talker.VALUED:
- _talkers.select(3);
- break;
- default:
- _talkers.select(0);
- }
- foreach (dlg; evt.dialogs) { mixin(S_TRACE);
- _dlgs ~= new SDialog(dlg.text, dlg.rCoupons);
- }
- _couponView.coupons = evt.coupons;
- _initValue.setSelection(evt.initValue);
- } else { mixin(S_TRACE);
- _talkers.select(0);
- _dlgs = [new SDialog];
- }
- refreshDlgList();
- _textTM = createTextMenu!Text(comm, prop, _rCoupons, &catchMod, _undo, TMAppendData(&readAPD, &writeAPD));
- _rCouponsTM = createTextMenu!Text(comm, prop, _text.widget, &catchMod, _undo, TMAppendData(&readAPD, &writeAPD));
- initPreview(area, prop.var.dlgPrev);
- updateValue();
- updateTalker();
- refreshWarning();
- }
- override bool apply() { mixin(S_TRACE);
- if (!evt) evt = new Content(CType.TALK_DIALOG, "");
- evt.dialogs = _dlgs;
- evt.talkerNC = selectedTalker;
- if (Talker.VALUED is evt.talkerNC) { mixin(S_TRACE);
- evt.coupons = _couponView.coupons;
- evt.initValue = _initValue.getSelection();
- } else { mixin(S_TRACE);
- evt.coupons = [];
- evt.initValue = 0;
- }
- comm.refCoupons.call();
- return true;
- }
- }
- /// ???????????????????
- class MessageDialog : AbstractMessageDialog {
- private:
- CTabFolder _tabf;
- Composite _msgCompA, _msgCompB;
- FixedWidthText _text;
- ImageSelect!(MtType.CARD, Combo) _msel;
- override
- protected void refreshWarning() { mixin(S_TRACE);
- string[] ws;
- ws ~= _msel.warnings;
- warning = ws;
- }
- void tabChanged() { mixin(S_TRACE);
- switch (_tabf.getSelectionIndex()) {
- case 0:
- _text.num = prop.looks.messageImageLen;
- _text.widget.setParent(_msgCompA);
- break;
- case 1:
- _text.num = prop.looks.messageLen;
- _text.widget.setParent(_msgCompB);
- break;
- default: return;
- }
- _text.widget.setLayoutData(_text.computeTextBaseSize(prop.looks.messageLine));
- _text.widget.getParent().layout();
- if (0 == _tabf.getSelectionIndex()) { mixin(S_TRACE);
- _text.widget.getParent().getParent().layout();
- }
- refreshPreview();
- }
- class SL : SelectionAdapter {
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- tabChanged();
- }
- }
- class ModText : ModifyListener {
- override void modifyText(ModifyEvent e) { mixin(S_TRACE);
- refreshPreview();
- }
- }
- void put(dchar put) { mixin(S_TRACE);
- putColor(_text, put);
- }
- void insert(string put) { mixin(S_TRACE);
- _text.insert(put);
- }
- protected override void refSkin() { mixin(S_TRACE);
- _text.font = dwtData(prop.looks.messageFont(summ.legacy));
- }
- public:
- this (Commons comm, Props prop, Shell shell, Summary summ, Content parent, Content evt) { mixin(S_TRACE);
- super(comm, prop, shell, summ, CType.TALK_MESSAGE, parent, evt, prop.var.msgDlg);
- }
- void selectedTalkerParam(out Talker talker, out string imgPath) { mixin(S_TRACE);
- imgPath = "";
- switch (_tabf.getSelectionIndex()) {
- case 0:
- switch (_msel.dirsCombo.getSelectionIndex()) {
- case 0:
- talker = Talker.SELECTED;
- break;
- case 1:
- talker = Talker.UNSELECTED;
- break;
- case 2:
- talker = Talker.RANDOM;
- break;
- case 3:
- talker = Talker.CARD;
- break;
- default:
- talker = Talker.IMAGE;
- imgPath = _msel.image;
- }
- break;
- case 1:
- talker = Talker.NARRATION;
- break;
- default: assert (0);
- }
- }
- @property
- override Talker selectedTalker() { mixin(S_TRACE);
- Talker talker;
- string imgPath;
- selectedTalkerParam(talker, imgPath);
- return talker;
- }
- @property
- override string imgPath() { mixin(S_TRACE);
- Talker talker;
- string imgPath;
- selectedTalkerParam(talker, imgPath);
- return imgPath;
- }
- @property
- override string text() { mixin(S_TRACE);
- return wrapReturnCode(_text.getText());
- }
- protected:
- override void setup(Composite area) { mixin(S_TRACE);
- super.setup(area);
- area.setLayout(new GridLayout(1, true));
- _tabf = new CTabFolder(area, SWT.BORDER);
- mod(_tabf);
- _tabf.setLayoutData(new GridData(GridData.FILL_BOTH));
- auto skin = comm.skin;
- { mixin(S_TRACE);
- auto comp = new Composite(_tabf, SWT.NONE);
- comp.setLayout(new GridLayout(2, false));
- Control tp;
- if (evt) { mixin(S_TRACE);
- tp = createTalkerPane(comp, comm, prop, summ, evt.talkerC, evt.cardPath, _msel);
- } else { mixin(S_TRACE);
- tp = createTalkerPane(comp, comm, prop, summ, Talker.SELECTED, "", _msel);
- }
- mod(_msel);
- _msel.modEvent ~= &refreshWarning;
- _msel.cardMode = CardMode.Message;
- tp.setLayoutData(new GridData(GridData.FILL_BOTH));
- _msgCompA = new Composite(comp, SWT.NONE);
- _msgCompA.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- _msgCompA.setLayout(new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0));
- _text = createMessagePane(comm, prop, true, _msgCompA, summ);
- mod(_text.widget);
- _text.widget.addModifyListener(new ModText);
- createTextMenu!Text(comm, prop, _text.widget, &catchMod, _undo);
- auto tab = new CTabItem(_tabf, SWT.NONE);
- tab.setText(prop.msgs.imageMessage);
- tab.setControl(comp);
- }
- { mixin(S_TRACE);
- _msgCompB = new Composite(_tabf, SWT.NONE);
- _msgCompB.setLayout(new CenterLayout);
- auto tab = new CTabItem(_tabf, SWT.NONE);
- tab.setText(prop.msgs.noImageMessage);
- tab.setControl(_msgCompB);
- }
- { mixin(S_TRACE);
- auto bar = createSCharBar(comm, area, &insert, &put, prop, skin);
- bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- { mixin(S_TRACE);
- auto bar = createSkinSCharBar(comm, area, &insert, prop, skin);
- bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- { mixin(S_TRACE);
- auto bar = createFlagStepBar(area, &insert, comm, prop);
- bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
- _tabf.addSelectionListener(new SL);
- ignoreMod = true;
- scope (exit) ignoreMod = false;
- _tabf.setSelection(0);
- if (evt) { mixin(S_TRACE);
- _text.setText(evt.text);
- if (evt.talkerC == Talker.NARRATION) { mixin(S_TRACE);
- _tabf.setSelection(1);
- }
- } else { mixin(S_TRACE);
- _tabf.setSelection(1);
- }
- tabChanged();
- initPreview(area, prop.var.msgPrev);
- _msel.modEvent ~= &refreshPreview;
- _msel.updateImageEvent ~= &refreshPreview;
- }
- override bool apply() { mixin(S_TRACE);
- string text;
- string path = "";
- Talker talker;
- selectedTalkerParam(talker, path);
- text = lastRet(wrapReturnCode(_text.getText()));
- if (!evt) evt = new Content(CType.TALK_MESSAGE, "");
- evt.text = text;
- evt.talkerC = talker;
- evt.cardPath = path;
- return true;
- }
- }
- private Composite createTalkerPane2(Composite parent, Commons comm, Props prop, Summary summ,
- string[] coupons, out Text couponList, out Combo couponCombo) { mixin(S_TRACE);
- auto comp = new Composite(parent, SWT.NONE);
- comp.setLayout(zeroMarginGridLayout(2, false));
- couponCombo = createCouponCombo(comm, summ, comp, null, CouponComboType.Talker, "");
- auto push = new Button(comp, SWT.PUSH);
- auto skin = comm.skin;
- { mixin(S_TRACE);
- auto gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = prop.var.etc.talkersWidth;
- couponCombo.setLayoutData(gd);
- push.setToolTipText(prop.msgs.setTalkerCoupon);
- push.setImage(prop.images.setTalkerCoupon);
- }
- { mixin(S_TRACE);
- couponList = new Text(comp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
- auto gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 2;
- couponList.setLayoutData(gd);
- string buf;
- foreach (coupon; coupons) { mixin(S_TRACE);
- buf ~= coupon ~ "\n";
- }
- couponList.setText(buf);
- push.addSelectionListener(new class SelectionAdapter {
- private Combo _combo;
- private Text _list;
- this() { mixin(S_TRACE);
- _combo = couponCombo;
- _list = couponList;
- }
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- if (_combo.getText().length > 0) { mixin(S_TRACE);
- _list.setSelection(_list.getText().length, _list.getText().length);
- string[] lines = splitLines!string(_list.getText());
- if (lines.length > 0 && lines[$ - 1].length > 0) { mixin(S_TRACE);
- _list.insert("\n");
- }
- _list.insert(_combo.getText() ~ "\n");
- }
- }
- });
- }
- return comp;
- }
- private Composite createTalkerPane
- (Composite parent, Commons comm, Props prop, Summary summ, Talker talker, string path,
- out ImageSelect!(MtType.CARD, Combo) msel) { mixin(S_TRACE);
- auto comp = new Composite(parent, SWT.NONE);
- { mixin(S_TRACE);
- comp.setLayout(zeroMarginGridLayout(1, true));
- }
- auto selected = prop.images.talker(Talker.SELECTED).getImageData();
- auto unselected = prop.images.talker(Talker.UNSELECTED).getImageData();
- auto random = prop.images.talker(Talker.RANDOM).getImageData();
- ImageData createDefImage(size_t index) { mixin(S_TRACE);
- switch (index) {
- case 0:
- // ???
- return selected;
- case 1:
- // ?????
- return unselected;
- case 2:
- // ????
- return random;
- case 3:
- // ???
- return menuCard(comm.skin);
- default: assert (0);
- }
- }
- string[] defs = [
- prop.msgs.talkerName(Talker.SELECTED),
- prop.msgs.talkerName(Talker.UNSELECTED),
- prop.msgs.talkerName(Talker.RANDOM),
- prop.msgs.talkerName(Talker.CARD)
- ];
- auto s = prop.looks.cardSize;
- msel = new ImageSelect!(MtType.CARD, Combo)(comp, SWT.NONE, comm, prop, summ, s.width, s.height,
- false, false, () => "", null, defs, &createDefImage);
- auto gd = new GridData(GridData.FILL_BOTH);
- msel.widget.setLayoutData(gd);
- msel.image = path;
- if (msel.image.length == 0) { mixin(S_TRACE);
- switch (talker) {
- case Talker.SELECTED:
- msel.dirsCombo.select(0);
- break;
- case Talker.UNSELECTED:
- msel.dirsCombo.select(1);
- break;
- case Talker.RANDOM:
- msel.dirsCombo.select(2);
- break;
- case Talker.CARD:
- msel.dirsCombo.select(3);
- break;
- default:
- msel.dirsCombo.select(0);
- }
- }
- return comp;
- }
- private class DisposeText : DisposeListener {
- private Color _back, _fore;
- this (Color back, Color fore) { mixin(S_TRACE);
- _back = back;
- _fore = fore;
- }
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- _back.dispose();
- _fore.dispose();
- }
- }
- private FixedWidthText createMessagePane(Commons comm, Props prop, bool image, Composite parent, Summary summ) { mixin(S_TRACE);
- int len = image ? prop.looks.messageImageLen : prop.looks.messageLen;
- auto r = new FixedWidthText(dwtData(prop.looks.messageFont(summ.legacy)), len, parent, SWT.BORDER, true);
- auto d = r.widget.getDisplay();
- auto back = new Color(d, new RGB(prop.var.etc.msgBackR, prop.var.etc.msgBackG, prop.var.etc.msgBackB));
- auto fore = new Color(d, new RGB(prop.var.etc.msgForeR, prop.var.etc.msgForeG, prop.var.etc.msgForeB));
- r.widget.setBackground(back);
- r.widget.setForeground(fore);
- r.widget.addDisposeListener(new DisposeText(back, fore));
- return r;
- }
- private class PutC {
- private void delegate(string) _insert;
- private string _put;
- this(void delegate(string) insert, string put) { mixin(S_TRACE);
- _insert = insert;
- _put = put;
- }
- void put() { mixin(S_TRACE);
- _insert(_put);
- }
- }
- private class PutColor {
- private void delegate(dchar) _put;
- private dchar _color;
- this(void delegate(dchar) put, dchar color) { mixin(S_TRACE);
- _put = put;
- _color = color;
- }
- void put() { mixin(S_TRACE);
- _put(_color);
- }
- }
- private ToolBar createSCharBar(Commons comm, Composite parent,
- void delegate(string) insert, void delegate(dchar) putColor, Props prop, Skin skin) { mixin(S_TRACE);
- auto bar = new ToolBar(parent, SWT.FLAT);
- comm.put(bar);
- bar.addListener(SWT.Traverse, new class Listener {
- override void handleEvent(Event e) {e.doit = true;}
- });
- bar.addListener(SWT.KeyDown, new class Listener {
- override void handleEvent(Event e) {e.doit = true;}
- });
- foreach (c; [
- 'W', 'R', 'B', 'G', 'Y'
- ] ~ [
- 'O', 'P', 'L', 'D' // CardWirth 1.50
- ]) { mixin(S_TRACE);
- string t;
- final switch (c) {
- case 'W': t = prop.msgs.colorW; break;
- case 'R': t = prop.msgs.colorR; break;
- case 'B': t = prop.msgs.colorB; break;
- case 'G': t = prop.msgs.colorG; break;
- case 'Y': t = prop.msgs.colorY; break;
- case 'O': t = prop.msgs.colorO; break; // CardWirth 1.50
- case 'P': t = prop.msgs.colorP; break; // CardWirth 1.50
- case 'L': t = prop.msgs.colorL; break; // CardWirth 1.50
- case 'D': t = prop.msgs.colorD; break; // CardWirth 1.50
- }
- createToolItem2(comm, bar, t, prop.images.color(c), &(new PutColor(putColor, c)).put, null);
- }
- new ToolItem(bar, SWT.SEPARATOR);
- createToolItem2(comm, bar, prop.msgs.scRef, prop.images.scRef, &(new PutC(insert, "#I")).put, null);
- createToolItem2(comm, bar, prop.msgs.scTalkerName(Talker.SELECTED), prop.images.scTalker(Talker.SELECTED),
- &(new PutC(insert, "#M")).put, null);
- createToolItem2(comm, bar, prop.msgs.scTalkerName(Talker.UNSELECTED), prop.images.scTalker(Talker.UNSELECTED),
- &(new PutC(insert, "#U")).put, null);
- createToolItem2(comm, bar, prop.msgs.scTalkerName(Talker.RANDOM), prop.images.scTalker(Talker.RANDOM),
- &(new PutC(insert, "#R")).put, null);
- createToolItem2(comm, bar, prop.msgs.scTalkerName(Talker.CARD), prop.images.scTalker(Talker.CARD),
- &(new PutC(insert, "#C")).put, null);
- createToolItem2(comm, bar, prop.msgs.scTeam, prop.images.scTeam, &(new PutC(insert, "#T")).put, null);
- createToolItem2(comm, bar, prop.msgs.scYado, prop.images.scYado, &(new PutC(insert, "#Y")).put, null);
- return bar;
- }
- private ToolBar createSkinSCharBar(Commons comm, Composite parent, void delegate(string) insert, Props prop, Skin skin) { mixin(S_TRACE);
- auto bar = new ToolBar(parent, SWT.FLAT);
- comm.put(bar);
- bar.addListener(SWT.Traverse, new class Listener {
- override void handleEvent(Event e) {e.doit = true;}
- });
- bar.addListener(SWT.KeyDown, new class Listener {
- override void handleEvent(Event e) {e.doit = true;}
- });
- Image[] imgs;
- foreach (spc; skin.spChars.keys) { mixin(S_TRACE);
- auto img = new Image(Display.getCurrent(), spChar(skin, spc));
- string name = toUTF8("#"d ~ spc);
- auto scp = new PutC(insert, name);
- createToolItem2(comm, bar, name, img, &scp.put, null);
- imgs ~= img;
- }
- bar.addDisposeListener(new class DisposeListener {
- private Image[] _imgs;
- this() {_imgs = imgs;}
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- foreach (img; _imgs) { mixin(S_TRACE);
- img.dispose();
- }
- }
- });
- return bar;
- }
- private Composite createFlagStepBar(Composite parent, void delegate(string) insert, Commons comm, Props prop) { mixin(S_TRACE);
- auto bar = new Composite(parent, SWT.NONE);
- bar.setLayout(zeroMarginGridLayout(2, true));
- void create(out Combo list, out Button put, string puts, Image image, string lc) { mixin(S_TRACE);
- auto comp = new Composite(bar, SWT.NONE);
- comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- comp.setLayout(zeroMarginGridLayout(2, false));
- list = new Combo(comp, SWT.READ_ONLY | SWT.DROP_DOWN | SWT.BORDER);
- list.setVisibleItemCount(prop.var.etc.comboVisibleItemCount);
- list.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- put = new Button(comp, SWT.PUSH);
- put.setToolTipText(puts);
- put.setImage(image);
- put.addSelectionListener(new class SelectionAdapter {
- override void widgetSelected(SelectionEvent e) { mixin(S_TRACE);
- insert(lc ~ list.getText() ~ lc);
- }
- });
- }
- Combo flags, steps;
- Button putFlag, putStep;
- create(flags, putFlag, prop.msgs.addMsgRefFlag, prop.images.flag, "%");
- create(steps, putStep, prop.msgs.addMsgRefStep, prop.images.step, "$");
- void refList() { mixin(S_TRACE);
- auto root = comm.summary.flagDirRoot;
- auto fSel = flags.getText();
- auto sSel = steps.getText();
- flags.removeAll();
- foreach (i, flag; root.allFlags) { mixin(S_TRACE);
- auto p = flag.path;
- flags.add(p);
- if (0 == i || 0 == icmp(p, fSel)) flags.select(i);
- }
- steps.removeAll();
- foreach (i, step; root.allSteps) { mixin(S_TRACE);
- auto p = step.path;
- steps.add(p);
- if (0 == i || 0 == icmp(p, sSel)) steps.select(i);
- }
- flags.setEnabled(flags.getItemCount() > 0);
- putFlag.setEnabled(flags.getEnabled());
- steps.setEnabled(steps.getItemCount() > 0);
- putStep.setEnabled(steps.getEnabled());
- }
- refList();
- void refFlagAndStep(Flag[] flags, Step[] steps) { mixin(S_TRACE);
- refList();
- }
- comm.refFlagAndStep.add(&refFlagAndStep);
- comm.delFlagAndStep.add(&refFlagAndStep);
- bar.addDisposeListener(new class DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- comm.refFlagAndStep.remove(&refFlagAndStep);
- comm.delFlagAndStep.remove(&refFlagAndStep);
- }
- });
- return bar;
- }
- private void putColor(FixedWidthText text, dchar put) { mixin(S_TRACE);
- auto sel = text.widget.getSelection();
- auto old = toUTF32(text.getText());
- auto newt = cwx.msgutils.putColor(old, put, sel.x, sel.y);
- text.setText(toUTF8(newt));
- int nSel = sel.y + (newt.length - old.length);
- text.widget.setSelection(nSel);
- }
- class MsgPreviewWindow {
- private MsgPreview _preview;
- private Button _toggle;
- private WSize _size;
- private Shell _win;
- private ControlListener _winL;
- private int _parX, _parY;
- private class Dispose : DisposeListener {
- override void widgetDisposed(DisposeEvent e) { mixin(S_TRACE);
- _win.getParent().removeControlListener(_winL);
- saveWin();
- }
- }
- private class PShellL : ControlAdapter {
- override void controlMoved(ControlEvent e) { mixin(S_TRACE);
- auto pb = _win.getParent().getBounds();
- auto tb = _win.getBounds();
- _win.setBounds(tb.x + pb.x - _parX, tb.y + pb.y - _parY, tb.width, tb.height);
- _parX = pb.x;
- _parY = pb.y;
- }
- }
- private class ShellL : ShellAdapter {
- override void shellClosed(ShellEvent e) { mixin(S_TRACE);
- close();
- e.doit = false;
- }
- }
- this (Shell parent, Commons comm, Props prop, Summary summ, Button toggle, WSize size) { mixin(S_TRACE);
- _size = size;
- _toggle = toggle;
- _winL = new PShellL;
- parent.addControlListener(_winL);
- _win = new Shell(parent, SWT.TITLE | SWT.RESIZE | SWT.TOOL | SWT.CLOSE);
- _win.setText(prop.msgs.dlgTitMessagePreview);
- auto cl = new CenterLayout(SWT.HORIZONTAL | SWT.VERTICAL, 0);
- cl.fillHorizontal = true;
- cl.fillVertical = true;
- _win.setLayout(cl);
- _win.addShellListener(new ShellL);
- _win.addDisposeListener(new Dispose);
- _preview = new MsgPreview(_win, comm, prop, summ);
- }
- private void saveWin() { mixin(S_TRACE);
- auto winProps = _size;
- winProps.width = _win.getSize().x;
- winProps.height = _win.getSize().y;
- winProps.x = _win.getBounds().x - _win.getParent().getBounds().x;
- winProps.y = _win.getBounds().y - _win.getParent().getBounds().y;
- }
- bool isVisible() {return _win.isVisible();}
- void open() { mixin(S_TRACE);
- if (_win.isVisible()) return;
- auto pb = _win.getParent().getBounds();
- _parX = pb.x;
- _parY = pb.y;
- auto winProps = _size;
- scope wp = _win.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- int width = winProps.width == SWT.DEFAULT ? wp.x : winProps.width;
- int height = winProps.height == SWT.DEFAULT ? wp.y : winProps.height;
- int x = winProps.x == SWT.DEFAULT ? pb.x + pb.width : winProps.x + pb.x;
- int y = winProps.y == SWT.DEFAULT ? pb.y : winProps.y + pb.y;
- intoDisplay(x, y, width, height);
- _win.setBounds(x, y, width, height);
- refresh();
- _win.setVisible(true);
- _toggle.setSelection(true);
- }
- void close() { mixin(S_TRACE);
- if (!_win.isVisible()) return;
- saveWin();
- _win.setVisible(false);
- _toggle.setSelection(false);
- }
- void text(Talker talker, string imgPath, string message) { mixin(S_TRACE);
- _preview.text(talker, imgPath, message);
- }
- private void refresh() { mixin(S_TRACE);
- _preview.refresh();
- }
- }
- enum SPChar {
- M = 0, /// ???
- U = 1, /// ???
- R = 2, /// ????
- C = 3, /// ???
- I = 4, /// ??
- T = 5, /// ???
- Y = 6 /// ?
- }
- immutable SPCHAR_ALL = [
- SPChar.M,
- SPChar.U,
- SPChar.R,
- SPChar.C,
- SPChar.I,
- SPChar.T,
- SPChar.Y,
- ];
- immutable SPCHAR_TEXT = [
- SPChar.M,
- SPChar.U,
- SPChar.R,
- SPChar.T,
- SPChar.Y,
- ];
- private immutable C_TBL = [
- 'M',
- 'U',
- 'R',
- 'C',
- 'I',
- 'T',
- 'Y',
- ];
- class PreviewValues : Composite {
- void delegate()[] modEvent;
- private static class FlagData {
- Flag flag;
- bool onOff;
- }
- private static class StepData {
- Step step;
- int select;
- }
- private Commons _comm;
- private Props _prop;
- private Summary _summ;
- private bool _isMessage;
- private const(SPChar)[] _targetChars;
- private Table _values;
- private int[SPChar] _indexTable;
- private UndoManager _undo;
- private bool _changedText = false;
- private class UndoPV : Undo {
- private string[char] _names;
- private bool[string] _flags;
- private int[string] _steps;
- this () { mixin(S_TRACE);
- getValues2(_names, _flags, _steps);
- …
Large files files are truncated, but you can click here to view the full file