[Thinlet-development] thinlet/src/java/thinlet AppletLauncher.java,NONE,1.1 FrameLauncher.java,NONE,
Brought to you by:
bajzat
|
From: <ab...@us...> - 2003-06-26 15:21:59
|
Update of /cvsroot/thinlet/thinlet/src/java/thinlet
In directory sc8-pr-cvs1:/tmp/cvs-serv29772/src/java/thinlet
Added Files:
AppletLauncher.java FrameLauncher.java Thinlet.java
Widget.java
Log Message:
New CVS layout and build infrastructure. Contributed by Campbell Boucher-Burnet. Many thanks\!
--- NEW FILE: AppletLauncher.java ---
package thinlet;
import java.applet.*;
import java.awt.*;
/**
*
*/
public class AppletLauncher extends Applet implements Runnable {
private transient Thinlet content;
private transient Image doublebuffer;
/**
*
*/
public void init() {
setBackground(Color.white); setForeground(Color.darkGray);
setLayout(new BorderLayout());
add(new Label("Loading...", Label.CENTER), BorderLayout.CENTER);
new Thread(this).start();
}
/**
*
*/
public void run() {
try {
content = (Thinlet) Class.forName(getParameter("class")).newInstance();
removeAll();
add(content, BorderLayout.CENTER);
} catch (Throwable exc) {
removeAll();
add(new Label(exc.getMessage()), BorderLayout.CENTER);
}
doLayout(); repaint();
}
/**
*
*/
public void doLayout() {
super.doLayout();
if (doublebuffer != null) {
doublebuffer.flush();
doublebuffer = null;
}
}
/**
*
*/
public void stop() {
if (doublebuffer != null) {
doublebuffer.flush();
doublebuffer = null;
}
}
/**
*
*/
public void update(Graphics g) {
paint(g);
}
/**
*
*/
public void paint(Graphics g) {
if (doublebuffer == null) {
Dimension d = getSize();
doublebuffer = createImage(d.width, d.height);
}
Graphics dg = doublebuffer.getGraphics();
dg.setClip(g.getClipBounds());
super.paint(dg);
dg.dispose();
g.drawImage(doublebuffer, 0, 0, this);
}
/**
*
*/
public void destroy() {
content.destroy();
}
}
--- NEW FILE: FrameLauncher.java ---
package thinlet;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
/**
*
*/
public class FrameLauncher extends Frame implements WindowListener {
private transient Thinlet content;
private transient Image doublebuffer;
/**
* @param title
* @param content
* @param width
* @param height
*/
public FrameLauncher(String title, Thinlet content, int width, int height) {
super(title);
this.content = content;
add(content, BorderLayout.CENTER);
addWindowListener(this);
pack();
Insets is = getInsets();
width += is.left + is.right;
height += is.top + is.bottom;
Dimension ss = getToolkit().getScreenSize();
width = Math.min(width, ss.width);
height = Math.min(height, ss.height);
setBounds((ss.width - width) / 2, (ss.height - height) / 2, width, height);
setVisible(true);
//maximize: setBounds(-is.left, -is.top, ss.width + is.left + is.right, ss.height + is.top + is.bottom);
int[] pix = new int[16 * 16];
for (int x = 0; x < 16; x++) {
int sx = ((x >= 1) && (x <= 9)) ? 1 : (((x >= 11) && (x <= 14)) ? 2 : 0);
for (int y = 0; y < 16; y++) {
int sy = ((y >= 1) && (y <= 9)) ? 1 : (((y >= 11) && (y <= 14)) ? 2 : 0);
pix[y * 16 + x] = ((sx == 0) || (sy == 0)) ? 0xffffffff :
((sx == 1) ? ((sy == 1) ? (((y == 2) && (x >= 2) && (x <= 8)) ? 0xffffffff :
(((y >= 3) && (y <= 8)) ? ((x == 5) ? 0xffffffff : (((x == 4) || (x == 6)) ?
0xffe8bcbd : 0xffb01416)) : 0xffb01416)) : 0xff377ca4) :
((sy == 1) ? 0xff3a831d : 0xfff2cc9c));
}
}
setIconImage(createImage(new MemoryImageSource(16, 16, pix, 0, 16)));
}
/**
*
*/
public void update(Graphics g) {
paint(g);
}
/**
*
*/
public void paint(Graphics g) {
if (doublebuffer == null) {
Dimension d = getSize();
doublebuffer = createImage(d.width, d.height);
}
Graphics dg = doublebuffer.getGraphics();
dg.setClip(g.getClipBounds());
super.paint(dg);
dg.dispose();
g.drawImage(doublebuffer, 0, 0, this);
}
/**
*
*/
public void doLayout() {
if (doublebuffer != null) {
doublebuffer.flush();
doublebuffer = null;
}
super.doLayout();
}
/**
*
*/
public void windowClosing(WindowEvent e) {
if (content.destroy()) {
System.exit(0);
}
setVisible(true);
}
public void windowOpened(WindowEvent e) {}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
}
--- NEW FILE: Thinlet.java ---
/*
Thinlet GUI toolkit - www.thinlet.com
Copyright (C) 2002 Robert Bajzat (rob...@th...)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
[...6490 lines suppressed...]
new String[] { "top", "bottom"} }
},
"menu", "choice", new Object[][] {
{ "integer", "mnemonic", "paint", integer_1 } },
"menuitem", "choice", new Object[][] {
{ "keystroke", "accelerator", "", null },
{ "method", "action", "", null },
{ "integer", "mnemonic", "paint", integer_1 }
//... KeyStroke=keyCode+modifiers(SHIFT CTRL META ALT_MASK)
},
"checkboxmenuitem", "menuitem", new Object[][] {
{ "boolean", "selected", "paint", Boolean.FALSE }, //...group
{ "string", "group", "paint", null } }, //...group
"popupmenu", "component", null, // Post menu: Shift+F10
"bean", "component", new Object[][] {
{ "bean", "bean", "", null }
}
};
}
}
--- NEW FILE: Widget.java ---
package thinlet;
import java.awt.*;
/**
*
*/
public class Widget {
private transient Thinlet thinlet;
private transient Object widget;
/**
*
*/
public Widget(String classname) {
widget = Thinlet.create(classname);
}
/**
*
*/
public String getClassName() {
return null;
}
/**
*
*/
public void set(String key, String value) {
thinlet.setString(widget, key, value);
}
public boolean requestFocus(Object component) {
return true;
}
}
|