X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUIPreferences.java;h=062cb49dd2d090156667606275f6bd9e2334550b;hp=485cb582f1cd13f93af714433f459afdbe6b08b7;hb=eaf2ee0f498b519d64e1664a2b8c66c52ac1497c;hpb=65b512c890a3ccf487655b79305ab1cfcf49259c diff --git a/altosuilib/AltosUIPreferences.java b/altosuilib/AltosUIPreferences.java index 485cb582..062cb49d 100644 --- a/altosuilib/AltosUIPreferences.java +++ b/altosuilib/AltosUIPreferences.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 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 @@ -15,13 +16,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib; +package org.altusmetrum.altosuilib_13; import java.io.*; import java.util.*; import java.awt.Component; import javax.swing.*; -import org.altusmetrum.AltosLib.*; +import org.altusmetrum.altoslib_13.*; public class AltosUIPreferences extends AltosPreferences { @@ -31,6 +32,12 @@ public class AltosUIPreferences extends AltosPreferences { /* Look&Feel preference name */ final static String lookAndFeelPreference = "LOOK-AND-FEEL"; + /* Window position preference name */ + final static String positionPreference = "POSITION"; + + /* Maps cache size preference name */ + final static String mapCachePreference = "MAP-CACHE"; + /* UI Component to pop dialogs up */ static Component component; @@ -45,6 +52,10 @@ public class AltosUIPreferences extends AltosPreferences { /* Serial debug */ public static boolean serial_debug; + static LinkedList position_listeners; + + public static int position = AltosUILib.position_top_left; + public static void init() { AltosPreferences.init(new AltosUIPreferencesBackend()); @@ -56,7 +67,11 @@ public class AltosUIPreferences extends AltosPreferences { ui_listeners = new LinkedList(); serial_debug = backend.getBoolean(serialDebugPreference, false); + AltosLink.set_debug(serial_debug); + + position = backend.getInt(positionPreference, AltosUILib.position_top_left); + position_listeners = new LinkedList(); } static { init(); } @@ -177,4 +192,31 @@ public class AltosUIPreferences extends AltosPreferences { } } + public static void register_position_listener(AltosPositionListener l) { + synchronized(backend) { + position_listeners.add(l); + } + } + + public static void unregister_position_listener(AltosPositionListener l) { + synchronized (backend) { + position_listeners.remove(l); + } + } + + public static void set_position(int new_position) { + synchronized (backend) { + position = new_position; + backend.putInt(positionPreference, position); + flush_preferences(); + for (AltosPositionListener l : position_listeners) + l.position_changed(position); + } + } + + public static int position() { + synchronized (backend) { + return position; + } + } }