mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-03 17:59:33 +02:00
git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@113 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
parent
ead7360026
commit
fca386d7df
2 changed files with 134 additions and 31 deletions
|
@ -63,7 +63,7 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
ConfigAutoSavingOption = new ZLBooleanOption(ZLOption.CONFIG_CATEGORY, CONFIG, AUTO_SAVE, true);
|
ConfigAutoSavingOption = new ZLBooleanOption(ZLOption.CONFIG_CATEGORY, CONFIG, AUTO_SAVE, true);
|
||||||
ConfigAutoSaveTimeoutOption = new ZLIntegerRangeOption(ZLOption.CONFIG_CATEGORY, CONFIG, TIMEOUT, 1, 6000, 30);
|
ConfigAutoSaveTimeoutOption = new ZLIntegerRangeOption(ZLOption.CONFIG_CATEGORY, CONFIG, TIMEOUT, 1, 6000, 30);
|
||||||
KeyDelayOption = new ZLIntegerRangeOption(ZLOption.CONFIG_CATEGORY, "Options", "KeyDelay", 0, 5000, 250);
|
KeyDelayOption = new ZLIntegerRangeOption(ZLOption.CONFIG_CATEGORY, "Options", "KeyDelay", 0, 5000, 250);
|
||||||
myViewWidget = null;
|
setMyViewWidget(null);
|
||||||
myWindow = null;
|
myWindow = null;
|
||||||
if (ConfigAutoSavingOption.getValue()) {
|
if (ConfigAutoSavingOption.getValue()) {
|
||||||
//ZLOption.startAutoSave((int)(ConfigAutoSaveTimeoutOption.getValue()));
|
//ZLOption.startAutoSave((int)(ConfigAutoSaveTimeoutOption.getValue()));
|
||||||
|
@ -73,11 +73,11 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
//ZLCommunicationManager.instance().registerHandler("present", myPresentWindowHandler);
|
//ZLCommunicationManager.instance().registerHandler("present", myPresentWindowHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Toolbar toolbar() {
|
public Toolbar getToolbar() {
|
||||||
return this.myToolbar;
|
return this.myToolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Menubar menubar() {
|
public Menubar getMenubar() {
|
||||||
return this.myMenubar;
|
return this.myMenubar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myViewWidget != null) {
|
if (getMyViewWidget() != null) {
|
||||||
myViewWidget.setView(view);
|
getMyViewWidget().setView(view);
|
||||||
resetWindowCaption();
|
resetWindowCaption();
|
||||||
refreshWindow();
|
refreshWindow();
|
||||||
} else {
|
} else {
|
||||||
|
@ -97,7 +97,7 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ZLView getCurrentView() {
|
protected ZLView getCurrentView() {
|
||||||
return (myViewWidget != null) ? myViewWidget.getView() : null;
|
return (getMyViewWidget() != null) ? getMyViewWidget().getView() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void quit() {
|
protected void quit() {
|
||||||
|
@ -111,7 +111,7 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initWindow() {
|
public void initWindow() {
|
||||||
myViewWidget = myWindow.createViewWidget();
|
setMyViewWidget(myWindow.createViewWidget());
|
||||||
myWindow.init();
|
myWindow.init();
|
||||||
setView(myInitialView);
|
setView(myInitialView);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshWindow() {
|
public void refreshWindow() {
|
||||||
if (myViewWidget != null) {
|
if (getMyViewWidget() != null) {
|
||||||
//myViewWidget.repaint();
|
//myViewWidget.repaint();
|
||||||
}
|
}
|
||||||
if (myWindow != null) {
|
if (myWindow != null) {
|
||||||
|
@ -184,8 +184,8 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trackStylus(boolean track) {
|
public void trackStylus(boolean track) {
|
||||||
if (myViewWidget != null) {
|
if (getMyViewWidget() != null) {
|
||||||
myViewWidget.trackStylus(track);
|
getMyViewWidget().trackStylus(track);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,23 +195,23 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action action(int actionId) {
|
public Action getAction(int actionId) {
|
||||||
return myActionMap.get(actionId);
|
return myActionMap.get(actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActionVisible(int actionId) {
|
public boolean isActionVisible(int actionId) {
|
||||||
Action a = action(actionId);
|
Action a = getAction(actionId);
|
||||||
return ((a != null) && a.isVisible());
|
return ((a != null) && a.isVisible());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActionEnabled(int actionId) {
|
public boolean isActionEnabled(int actionId) {
|
||||||
Action action = action(actionId);
|
Action action = getAction(actionId);
|
||||||
return (action != null) && action.isEnabled();
|
return (action != null) && action.isEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doAction(int actionId) {
|
public void doAction(int actionId) {
|
||||||
Action action = action(actionId);
|
Action action = getAction(actionId);
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
action.checkAndRun();
|
action.checkAndRun();
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
abstract public ZLKeyBindings keyBindings();
|
abstract public ZLKeyBindings keyBindings();
|
||||||
|
|
||||||
public void doActionByKey(String key) {
|
public void doActionByKey(String key) {
|
||||||
Action a = action(keyBindings().getBinding(key));
|
Action a = getAction(keyBindings().getBinding(key));
|
||||||
if ((a != null) &&
|
if ((a != null) &&
|
||||||
(!a.useKeyDelay() /*||
|
(!a.useKeyDelay() /*||
|
||||||
(myLastKeyActionTime.millisecondsTo(ZLTime()) >= KeyDelayOption.getValue())*/)) {
|
(myLastKeyActionTime.millisecondsTo(ZLTime()) >= KeyDelayOption.getValue())*/)) {
|
||||||
|
@ -250,5 +250,13 @@ public abstract class ZLApplication extends ZLApplicationBase {
|
||||||
public void resetLastCaller() {
|
public void resetLastCaller() {
|
||||||
//((PresentWindowHandler)myPresentWindowHandler).resetLastCaller();
|
//((PresentWindowHandler)myPresentWindowHandler).resetLastCaller();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMyViewWidget(ZLViewWidget myViewWidget) {
|
||||||
|
this.myViewWidget = myViewWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZLViewWidget getMyViewWidget() {
|
||||||
|
return myViewWidget;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,42 +1,137 @@
|
||||||
package org.zlibrary.core.application;
|
package org.zlibrary.core.application;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.zlibrary.core.application.toolbar.ButtonGroup;
|
||||||
|
import org.zlibrary.core.application.toolbar.ButtonItem;
|
||||||
|
import org.zlibrary.core.application.toolbar.Item;
|
||||||
import org.zlibrary.core.view.ZLViewWidget;
|
import org.zlibrary.core.view.ZLViewWidget;
|
||||||
|
|
||||||
abstract public class ZLApplicationWindow {
|
abstract public class ZLApplicationWindow {
|
||||||
private ZLApplication myApplication;
|
private ZLApplication myApplication;
|
||||||
|
private boolean myToggleButtonLock;
|
||||||
|
|
||||||
protected ZLApplicationWindow(ZLApplication application) {
|
protected ZLApplicationWindow(ZLApplication application) {
|
||||||
myApplication = application;
|
myApplication = application;
|
||||||
myApplication.setWindow(this);
|
myApplication.setWindow(this);
|
||||||
|
myToggleButtonLock = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLApplication application() {
|
public ZLApplication application() {
|
||||||
return myApplication;
|
return myApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public void init();
|
public void init() {
|
||||||
|
myApplication.setMyViewWidget(createViewWidget());
|
||||||
|
|
||||||
|
List<Item> toolbarItems = myApplication.getToolbar().items();
|
||||||
|
for (Item item: toolbarItems) {
|
||||||
|
addToolbarItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
initMenu();
|
||||||
|
}
|
||||||
abstract public void initMenu();
|
abstract public void initMenu();
|
||||||
|
|
||||||
/*
|
|
||||||
void onButtonPress(ZLApplication::Toolbar::ButtonItem &button);
|
public void onButtonPress(ButtonItem button) {
|
||||||
// TODO: change to pure virtual
|
if (myToggleButtonLock) {
|
||||||
virtual void setToggleButtonState(const ZLApplication::Toolbar::ButtonItem&) {}
|
return;
|
||||||
// TODO: change to pure virtual
|
}
|
||||||
virtual void setToolbarItemState(ZLApplication::Toolbar::ItemPtr item, bool visible, bool enabled) {}
|
if (button.isToggleButton()) {
|
||||||
*/
|
myToggleButtonLock = true;
|
||||||
|
if (button.isPressed()) {
|
||||||
|
setToggleButtonState(button);
|
||||||
|
myToggleButtonLock = false;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
button.press();
|
||||||
|
ButtonGroup group = button.buttonGroup();
|
||||||
|
Set<ButtonItem> items = group.Items;
|
||||||
|
for (ButtonItem bitem: items) {
|
||||||
|
setToggleButtonState(bitem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
myToggleButtonLock = false;
|
||||||
|
}
|
||||||
|
application().doAction(button.actionId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void setToggleButtonState(ButtonItem item);
|
||||||
|
|
||||||
|
public abstract void setToolbarItemState(Item item, boolean visible, boolean enabled);
|
||||||
|
|
||||||
abstract protected ZLViewWidget createViewWidget();
|
abstract protected ZLViewWidget createViewWidget();
|
||||||
|
|
||||||
/*
|
abstract public void addToolbarItem(Item item);
|
||||||
virtual void addToolbarItem(ZLApplication::Toolbar::ItemPtr item) = 0;
|
|
||||||
|
|
||||||
// TODO: change to non-virtual (?)
|
// TODO: change to non-virtual (?)
|
||||||
virtual void refresh();
|
public void refresh() {
|
||||||
|
/*
|
||||||
|
List<Item> items = application().getToolbar().items();
|
||||||
|
boolean enableToolbarSpace = false;
|
||||||
|
Item lastSeparator = null;
|
||||||
|
for (Item item: items) {
|
||||||
|
switch (item.type()) {
|
||||||
|
case ItemType.OPTION_ENTRY:
|
||||||
|
{
|
||||||
|
boolean visible = ((Toolbar.OptionEntryItem)**it).entry()->isVisible();
|
||||||
|
if (visible) {
|
||||||
|
if (!lastSeparator.isNull()) {
|
||||||
|
setToolbarItemState(lastSeparator, true, true);
|
||||||
|
lastSeparator = 0;
|
||||||
|
}
|
||||||
|
enableToolbarSpace = true;
|
||||||
|
}
|
||||||
|
setToolbarItemState(*it, visible, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ZLApplication::Toolbar::Item::BUTTON:
|
||||||
|
{
|
||||||
|
const ZLApplication::Toolbar::ButtonItem &button = (const ZLApplication::Toolbar::ButtonItem&)**it;
|
||||||
|
int id = button.actionId();
|
||||||
|
|
||||||
|
const bool visible = application().isActionVisible(id);
|
||||||
|
const bool enabled = application().isActionEnabled(id);
|
||||||
|
|
||||||
|
if (visible) {
|
||||||
|
if (!lastSeparator.isNull()) {
|
||||||
|
setToolbarItemState(lastSeparator, true, true);
|
||||||
|
lastSeparator = 0;
|
||||||
|
}
|
||||||
|
enableToolbarSpace = true;
|
||||||
|
}
|
||||||
|
if (!enabled && button.isPressed()) {
|
||||||
|
shared_ptr<ZLApplication::Toolbar::ButtonGroup> group = button.buttonGroup();
|
||||||
|
group->press(0);
|
||||||
|
application().doAction(group->UnselectAllButtonsActionId);
|
||||||
|
myToggleButtonLock = true;
|
||||||
|
setToggleButtonState(button);
|
||||||
|
myToggleButtonLock = false;
|
||||||
|
}
|
||||||
|
setToolbarItemState(*it, visible, enabled);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ZLApplication::Toolbar::Item::SEPARATOR:
|
||||||
|
if (enableToolbarSpace) {
|
||||||
|
lastSeparator = *it;
|
||||||
|
enableToolbarSpace = false;
|
||||||
|
} else {
|
||||||
|
setToolbarItemState(*it, false, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!lastSeparator.isNull()) {
|
||||||
|
setToolbarItemState(lastSeparator, false, true);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
// TODO: change to pure virtual
|
// TODO: change to pure virtual
|
||||||
virtual void present() {}
|
//virtual void present() {}
|
||||||
|
|
||||||
virtual void close() = 0;
|
//virtual void close() = 0;
|
||||||
*/
|
//*/
|
||||||
|
|
||||||
abstract public void setCaption(String caption);
|
abstract public void setCaption(String caption);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue