thinlet-development Mailing List for Thinlet (Page 6)
Brought to you by:
bajzat
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
(22) |
Apr
(7) |
May
(26) |
Jun
(42) |
Jul
(9) |
Aug
(3) |
Sep
|
Oct
(2) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(6) |
Jun
(12) |
Jul
(2) |
Aug
(9) |
Sep
(1) |
Oct
(8) |
Nov
(1) |
Dec
|
2005 |
Jan
(6) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
(13) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Andrzej B. <ab...@ge...> - 2003-05-09 08:30:45
|
Hi all, First of all, sorry for making so many white-space changes - I noticed it only after commit, since I'm using diff -bB by default... :-( Anyway, the main commit message didn't make it to the list for the reasons explained below. To see the exact changes, you can check out the new version from cvs and then use: cvs diff -bBu -r 1.16 Thinlet.java Best regards, Andrzej. -------- Original Message -------- Subject: Your message to Thinlet-development awaits moderator approval Date: Thu, 08 May 2003 18:43:30 -0700 From: thi...@li... To: ab...@us... Your mail to 'Thinlet-development' with the subject thinlet/src/thinlet AppletLauncher.java,NONE,1.1 FrameLauncher.java,NONE,1.1 Thinlet.java,1.16,1.17 Is being held until the list moderator can review it for approval. The reason it is being held: Message body is too big: 48777 bytes but there's a limit of 40 KB Either the message will get posted to the list, or you will receive notification of the moderator's decision. -- Best regards, Andrzej Bialecki ------------------------------------------------- Software Architect, System Integration Specialist CEN/ISSS EC Workshop, ECIMF project chair EU FP6 E-Commerce Expert/Evaluator ------------------------------------------------- FreeBSD developer (http://www.freebsd.org) |
From: <ab...@us...> - 2003-05-09 02:04:43
|
Update of /cvsroot/thinlet/thinlet/demo In directory sc8-pr-cvs1:/tmp/cvs-serv7682/demo Modified Files: Demo.java demo.xml Log Message: Several improvements and fixes: * internationalization - please see setLangResource javadoc for description. * borderless textarea; suitable for multiline labels * new sidebar and hyperlink widgets * improved spinbox - supports minimum, maximum, value and step * improved support for custom background / foreground and font for individual components * support for menus that open above menubar, not below * popup menus work now for more components * use different gradient for dialog titlebars * a few of NPEs in layout code fixed. * added more javadoc to public methods, and corrected some. Demo has been updated to show the new capabilities. Index: Demo.java =================================================================== RCS file: /cvsroot/thinlet/thinlet/demo/Demo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Demo.java 25 Nov 2002 18:00:49 -0000 1.2 +++ Demo.java 8 May 2003 20:30:56 -0000 1.3 @@ -12,226 +12,256 @@ * */ public class Demo extends Thinlet { - - /** - * - */ - public Demo() { - try { - add(parse("demo.xml")); - } catch (Exception exc) { exc.printStackTrace(); } - } - - /** - * - */ - public static void main(String[] args) { - new FrameLauncher("Demo", new Demo(), 320, 320); - } - - boolean textinit; - boolean valueinit; - - /** - * - */ - public void loadText(Object textarea) { - try { - InputStream inputstream = null; - try { - inputstream = getClass().getResourceAsStream("demodialog.xml"); - } catch (Throwable e) {} - BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream)); - StringBuffer text = new StringBuffer(); - for (int c = reader.read(); c != -1; c = reader.read()) { - if (((c > 0x1f) && (c < 0x7f)) || - ((c > 0x9f) && (c < 0xffff)) || (c == '\n')) { - text.append((char) c); - } - else if (c == '\t') { - text.append(" "); - } - } - reader.close(); - setString(textarea, "text", text.toString()); - textinit = true; - } catch (Exception exc) { getToolkit().beep(); } - } - - /** - * - */ - public void changeEditable(boolean editable, Object textarea) { - setBoolean(textarea, "editable", editable); - } - - /** - * - */ - public void changeEnabled(boolean enabled, Object textarea) { - setBoolean(textarea, "enabled", enabled); - } - - Object dialog; - - /** - * - */ - public void showDialog() { - try { - if (dialog == null) { - dialog = parse("demodialog.xml"); - } - add(dialog); - } catch (Exception exc) { exc.printStackTrace(); } - } - - /** - * - */ - public void findText(Object combobox, String what, - boolean match, boolean down) { - closeDialog(); - if (what.length() == 0) { return; } - - boolean cacheditem = false; - for (int i = getCount(combobox) - 1; i >= 0; i--) { - String choicetext = getString(getItem(combobox, i), "text"); - if (what.equals(choicetext)) { cacheditem = true; break; } - } - if (!cacheditem) { - Object choice = create("choice"); - setString(choice, "text", what); - add(combobox, choice); - } - - Object textarea = find("textarea"); - int end = getInteger(textarea, "end"); - String text = getString(textarea, "text"); - - if (!match) { - what = what.toLowerCase(); - text = text.toLowerCase(); - } - - int index = text.indexOf(what, down ? end : 0); - if (!down && (index != -1) && (index >= end)) { index = -1; } - if (index != -1) { - setInteger(textarea, "start", index); - setInteger(textarea, "end", index + what.length()); - requestFocus(textarea); - } - else { - getToolkit().beep(); - } - } - - /** - * - */ - public void closeDialog() { - remove(dialog); - } - - /** - * - */ - public void insertList(Object list) { - Object item = create("item"); - setString(item, "text", "New item"); - setIcon(item, "icon", getIcon("/icons/bookmarks.gif")); - add(list, item, 0); - } - - /** - * - */ - public void deleteList(Object delete, Object list) { - for (int i = getCount(list) - 1; i >= 0; i--) { - Object item = getItem(list, i); - if (getBoolean(item, "selected")) { - remove(item); - } - } - setBoolean(delete, "enabled", false); - } - - /** - * - */ - public void changeSelection(Object list, Object delete) { - setBoolean(delete, "enabled", getSelectedIndex(list) != -1); - } - - /** - * - */ - public void setSelection(Object list, String selection, Object delete) { - for (int i = getCount(list) - 1; i >= 0; i--) { - setBoolean(getItem(list, i), "selected", false); - } - setChoice(list, "selection", selection); - setBoolean(delete, "enabled", false); - } - - /** - * - */ - public void sliderChanged(int value, Object spinbox) { - setString(spinbox, "text", String.valueOf(value)); - hsbChanged(); - } - - /** - * - */ - public void spinboxChanged(String text, Object slider) { - try { - int value = Integer.parseInt(text); - if ((value >= 0) && (value <= 255)) { - setInteger(slider, "value", value); - hsbChanged(); - } - } catch (NumberFormatException nfe) { getToolkit().beep(); } - } - - private Object sl_red, sl_green, sl_blue; - private Object tf_hue, tf_saturation, tf_brightness; - private Object pb_hue, pb_saturation, pb_brightness; - - /** - * - */ - public void storeWidgets(Object sl_red, Object sl_green, Object sl_blue, - Object tf_hue, Object tf_saturation, Object tf_brightness, - Object pb_hue, Object pb_saturation, Object pb_brightness) { - this.sl_red = sl_red; - this.sl_green = sl_green; - this.sl_blue = sl_blue; - this.tf_hue = tf_hue; - this.tf_saturation = tf_saturation; - this.tf_brightness = tf_brightness; - this.pb_hue = pb_hue; - this.pb_saturation = pb_saturation; - this.pb_brightness = pb_brightness; - } - - /** - * - */ - private void hsbChanged() { - int red = getInteger(sl_red, "value"); - int green = getInteger(sl_green, "value"); - int blue = getInteger(sl_blue, "value"); - - float[] hsb = Color.RGBtoHSB(red, green, blue, null); - - setString(tf_hue, "text", String.valueOf(hsb[0])); - setString(tf_saturation, "text", String.valueOf(hsb[1])); - setString(tf_brightness, "text", String.valueOf(hsb[2])); - - setInteger(pb_hue, "value", (int) (100f * hsb[0])); - setInteger(pb_saturation, "value", (int) (100f * hsb[1])); - setInteger(pb_brightness, "value", (int) (100f * hsb[2])); - } + + /** + * + */ + public Demo() { + try { + add(parse("demo.xml")); + } catch (Exception exc) { exc.printStackTrace(); } + } + + /** + * + */ + public static void main(String[] args) { + new FrameLauncher("Demo", new Demo(), 320, 320); + } + + boolean textinit; + boolean valueinit; + + /** + * + */ + public void loadText(Object textarea) { + try { + InputStream inputstream = null; + try { + inputstream = getClass().getResourceAsStream("demodialog.xml"); + } catch (Throwable e) {} + BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream)); + StringBuffer text = new StringBuffer(); + for (int c = reader.read(); c != -1; c = reader.read()) { + if (((c > 0x1f) && (c < 0x7f)) || + ((c > 0x9f) && (c < 0xffff)) || (c == '\n')) { + text.append((char) c); + } + else if (c == '\t') { + text.append(" "); + } + } + reader.close(); + setString(textarea, "text", text.toString()); + textinit = true; + } catch (Exception exc) { getToolkit().beep(); } + } + + public void actionTheme(String idx) { + int index = idx.charAt(1) - '0'; + switch (index) { + case 0: //xp + setColors(0xece9d8, 0x000000, 0xf5f4f0, + 0x919b9a, 0xb0b0b0, 0xededed, 0xb9b9b9, 0xff899a, 0xc5c5dd); + break; + case 1: //gray + setColors(0xe6e6e6, 0x000000, 0xffffff, + 0x909090, 0xb0b0b0, 0xededed, 0xb9b9b9, 0x89899a, 0xc5c5dd); + break; + case 2: //yellow + setColors(0xeeeecc, 0x000000, 0xffffff, + 0x999966, 0xb0b096, 0xededcb, 0xcccc99, 0xcc6600, 0xffcc66); + break; + case 3: //blue + setColors(0x6375d6, 0xffffff, 0x7f8fdd, + 0xd6dff5, 0x9caae5, 0x666666, 0x003399, 0xff3333, 0x666666); + break; + } + } + /** + * + */ + public void changeEditable(boolean editable, Object textarea) { + setBoolean(textarea, "editable", editable); + } + + /** + * + */ + public void changeEnabled(boolean enabled, Object textarea) { + setBoolean(textarea, "enabled", enabled); + } + + public void changeBorder(boolean enabled, Object textarea) { + setBoolean(textarea, "border", enabled); + } + + Object dialog; + + /** + * + */ + public void showDialog() { + try { + if (dialog == null) { + dialog = parse("demodialog.xml"); + } + add(dialog); + } catch (Exception exc) { exc.printStackTrace(); } + } + + /** + * + */ + public void findText(Object combobox, String what, + boolean match, boolean down) { + closeDialog(); + if (what.length() == 0) { return; } + + boolean cacheditem = false; + for (int i = getCount(combobox) - 1; i >= 0; i--) { + String choicetext = getString(getItem(combobox, i), "text"); + if (what.equals(choicetext)) { cacheditem = true; break; } + } + if (!cacheditem) { + Object choice = create("choice"); + setString(choice, "text", what); + add(combobox, choice); + } + + Object textarea = find("textarea"); + int end = getInteger(textarea, "end"); + String text = getString(textarea, "text"); + + if (!match) { + what = what.toLowerCase(); + text = text.toLowerCase(); + } + + int index = text.indexOf(what, down ? end : 0); + if (!down && (index != -1) && (index >= end)) { index = -1; } + if (index != -1) { + setInteger(textarea, "start", index); + setInteger(textarea, "end", index + what.length()); + requestFocus(textarea); + } + else { + getToolkit().beep(); + } + } + + /** + * + */ + public void closeDialog() { + remove(dialog); + } + + /** + * + */ + public void insertList(Object list) { + Object item = create("item"); + setString(item, "text", "New item"); + setIcon(item, "icon", getIcon("/icons/bookmarks.gif")); + add(list, item, 0); + } + + /** + * + */ + public void deleteList(Object delete, Object list) { + for (int i = getCount(list) - 1; i >= 0; i--) { + Object item = getItem(list, i); + if (getBoolean(item, "selected")) { + remove(item); + } + } + setBoolean(delete, "enabled", false); + } + + /** + * + */ + public void changeSelection(Object list, Object delete) { + setBoolean(delete, "enabled", getSelectedIndex(list) != -1); + } + + /** + * + */ + public void setSelection(Object list, String selection, Object delete) { + for (int i = getCount(list) - 1; i >= 0; i--) { + setBoolean(getItem(list, i), "selected", false); + } + setChoice(list, "selection", selection); + setBoolean(delete, "enabled", false); + } + + /** + * + */ + public void sliderChanged(int value, Object spinbox) { + setString(spinbox, "text", String.valueOf(value)); + hsbChanged(); + } + + /** + * + */ + public void spinboxChanged(String text, Object slider) { + try { + int value = Integer.parseInt(text); + if ((value >= 0) && (value <= 255)) { + setInteger(slider, "value", value); + hsbChanged(); + } + } catch (NumberFormatException nfe) { getToolkit().beep(); } + } + + private Object sl_red, sl_green, sl_blue; + private Object tf_hue, tf_saturation, tf_brightness; + private Object pb_hue, pb_saturation, pb_brightness; + private Object rgb_label; + + /** + * + */ + public void storeWidgets(Object sl_red, Object sl_green, Object sl_blue, + Object tf_hue, Object tf_saturation, Object tf_brightness, + Object pb_hue, Object pb_saturation, Object pb_brightness, + Object rgb_label) { + this.sl_red = sl_red; + this.sl_green = sl_green; + this.sl_blue = sl_blue; + this.tf_hue = tf_hue; + this.tf_saturation = tf_saturation; + this.tf_brightness = tf_brightness; + this.pb_hue = pb_hue; + this.pb_saturation = pb_saturation; + this.pb_brightness = pb_brightness; + this.rgb_label = rgb_label; + actionTheme("t0"); + } + + /** + * + */ + private void hsbChanged() { + int red = getInteger(sl_red, "value"); + int green = getInteger(sl_green, "value"); + int blue = getInteger(sl_blue, "value"); + + float[] hsb = Color.RGBtoHSB(red, green, blue, null); + + setBackground(rgb_label, new Color(red, green, blue)); + setString(tf_hue, "text", String.valueOf(hsb[0])); + setString(tf_saturation, "text", String.valueOf(hsb[1])); + setString(tf_brightness, "text", String.valueOf(hsb[2])); + + setInteger(pb_hue, "value", (int) (100f * hsb[0])); + setInteger(pb_saturation, "value", (int) (100f * hsb[1])); + setInteger(pb_brightness, "value", (int) (100f * hsb[2])); + } } Index: demo.xml =================================================================== RCS file: /cvsroot/thinlet/thinlet/demo/demo.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- demo.xml 29 Apr 2003 17:59:08 -0000 1.3 +++ demo.xml 8 May 2003 20:30:56 -0000 1.4 @@ -26,6 +26,12 @@ <menuitem text="Find..." icon="/icons/find.gif" /> <menuitem text="Find Next" icon="/icons/findagain.gif" /> </menu> + <menu text="Theme"> + <checkboxmenuitem text="XP" name="t0" group="theme" action="actionTheme(this.name)" selected="true"/> + <checkboxmenuitem text="Gray" name="t1" group="theme" action="actionTheme(this.name)"/> + <checkboxmenuitem text="Sandstone" name="t2" group="theme" action="actionTheme(this.name)"/> + <checkboxmenuitem text="Ocean" name="t3" group="theme" action="actionTheme(this.name)"/> + </menu> <menu text="Help"> <menuitem text="Help Topics" icon="/icons/help.gif" /> <separator /> @@ -34,16 +40,21 @@ </menubar> <tabbedpane selected="1" weightx="1" weighty="1"> <tab text="Texts"> - <panel columns="5" top="4" left="4" bottom="4" right="4" gap="4"> - <label text="Find in the text:" mnemonic="10" /> - <button name="b_finddialog" text="Search" tooltip="Search..." + <panel columns="2" top="4" left="4" bottom="4" right="4" gap="4"> + <panel columns="1" gap="2"> + <label text="Find in the text:" mnemonic="10" /> + <button name="b_finddialog" text="Search" tooltip="Search..." icon="/icons/find.gif" mnemonic="1" action="showDialog()" /> - <label weightx="1" /> - <checkbox name="cb_editable" text="Editable" mnemonic="4" + </panel> + <panel columns="2" left="10" gap="4"> + <checkbox name="cb_editable" text="Editable" mnemonic="4" selected="true" action="changeEditable(this.selected, textarea)" /> - <checkbox name="cb_enabled" text="Enabled" selected="true" + <checkbox name="cb_enabled" text="Enabled" selected="true" action="changeEnabled(this.selected, textarea)" /> - <textarea name="textarea" init="loadText(this)" colspan="5" weighty="1" /> + <checkbox name="cb_border" text="Border" selected="true" + action="changeBorder(this.selected, textarea)" /> + </panel> + <textarea name="textarea" init="loadText(this)" colspan="2" halign="fill" weightx="1" weighty="1" /> </panel> </tab> @@ -66,6 +77,12 @@ <splitpane divider="120"> <list name="list" selection="multiple" action="changeSelection(this, delete)" colspan="4" weightx="1" weighty="1"> + <popupmenu> + <menuitem text="one"/> + <menuitem text="two"/> + <separator/> + <menuitem text="three"/> + </popupmenu> <item text="List item A" /> <item text="List item B" icon="/icons/bookmarks.gif" selected="true" /> <item text="List item C" enabled="false" /> @@ -75,6 +92,12 @@ <item text="List item G" /> </list> <tree selection="multiple"> + <popupmenu> + <menuitem text="one"/> + <menuitem text="two"/> + <separator/> + <menuitem text="three"/> + </popupmenu> <node text="Tree node A" icon="/icons/open.gif"> <node text="Tree node" icon="/icons/open.gif" selected="true"> <node text="Tree node" icon="/icons/new.gif" /> @@ -87,6 +110,12 @@ </tree> </splitpane> <table selection="multiple"> + <popupmenu> + <menuitem text="one"/> + <menuitem text="two"/> + <separator/> + <menuitem text="three"/> + </popupmenu> <header> <column text="Column" icon="/icons/bookmarks.gif" width="120" /> <column text="Column" alignment="center" /> @@ -109,29 +138,27 @@ </row> </table> </splitpane> - <separator colspan="5"/> - <button colspan="5" link="true" halign="left" text="www.thinlet.com"/> </panel> </tab> <tab text="Values"> <panel columns="3" top="4" left="4" gap="4" - init="storeWidgets(sl_red, sl_green, sl_blue, tf_hue, tf_saturation, tf_brightness, pb_hue, pb_saturation, pb_brightness)"> + init="storeWidgets(sl_red, sl_green, sl_blue, tf_hue, tf_saturation, tf_brightness, pb_hue, pb_saturation, pb_brightness, rgb_label)"> <label text="Red, green, and blue values" colspan="3" /> <label text="Red:" alignment="right" /> <slider name="sl_red" maximum="255" valign="center" action="sliderChanged(this.value, sb_red)" /> - <spinbox name="sb_red" text="0" columns="3" + <spinbox name="sb_red" maximum="255" text="0" columns="3" action="spinboxChanged(this.text, sl_red)" /> <label text="Green:" alignment="right" /> <slider name="sl_green" maximum="255" valign="center" action="sliderChanged(this.value, sb_green)" /> - <spinbox name="sb_green" text="0" columns="3" + <spinbox name="sb_green" maximum="255" text="0" columns="3" action="spinboxChanged(this.text, sl_green)" /> <label text="Blue:" alignment="right" /> <slider name="sl_blue" maximum="255" valign="center" action="sliderChanged(this.value, sb_blue)" /> - <spinbox name="sb_blue" text="0" columns="3" + <spinbox name="sb_blue" maximum="255" text="0" columns="3" action="spinboxChanged(this.text, sl_blue)" /> <separator colspan="3" /> @@ -146,7 +173,106 @@ <label text="Brightness:" alignment="right" /> <textfield name="tf_brightness" text="0.0" editable="false" /> <progressbar name="pb_brightness" valign="center" /> + <separator colspan="3"/> + <label colspan="3" name="rgb_label" valign="fill" weighty="1" background="#000000"/> + </panel> + </tab> + <tab text="Other"> + <panel halign="fill" weightx="1" valign="fill" weighty="1" gap="4" top="4" columns="3"> + <panel halign="fill" weightx="1" columns="1" gap="2"> + <label text="Sidebar widget:"/> + <tabbedpane placement="stacked" halign="fill" weightx="1" valign="fill" weighty="1"> + <popupmenu> + <menuitem text="one"/> + <menuitem text="two"/> + <separator/> + <menuitem text="three"/> + </popupmenu> + <tab text="One" property="c=123;v=345"> + <panel columns="1" gap="4"> + <textarea valign="fill" weighty="1" weightx="1" halign="fill" border="false" wrap="true" editable="false" text="Popup menus are supported in many components. Try to right-click on the tab name. Try it on lists, trees and tables."/> + </panel> + </tab> + <tab text="Two" font="bold 14"> + <panel scrollable="true" columns="1" gap="4"> + <label text="This is a scrollable panel."/> + <label text="Custom colors/fonts:"/> + <button text="abcdef" font="18" background="#888888"/> + <button text="abcdef" font="Courier 17" background="#882288"/> + <button text="abcdef" font="Serif 16" background="#228888"/> + <button text="abcdef" font="bold 15" background="#888822"/> + <button text="abcdef" font="italic 14" background="#448844"/> + <button text="abcdef" font="bold italic 13" background="#444488"/> + <button text="abcdef" font="12" background="#884444"/> + <button text="abcdef" font="11" background="#2288ff"/> + <button text="abcdef" font="10" background="#ff2288"/> + </panel> + </tab> + <tab text="Three" font="bold" foreground="#0000ff"> + <panel columns="1" gap="4"> + <menubar halign="fill" weightx="1"> + <menu text="File"> + <menuitem text="one"/> + </menu> + </menubar> + <textarea wrap="true" valign="fill" weighty="1" halign="fill" weightx="1" border="false" editable="false" text="Menus can be placed on any panel or dialog."/> + </panel> + </tab> + <tab text="Four" font="Serif bold 14" background="#8888ff" foreground="#ffffff"> + <panel columns="1" gap="4"> + <textarea valign="fill" weighty="1" weightx="1" halign="fill" border="false" wrap="true" editable="false" font="Serif italic bold 14" foreground="#88ff88" background="#446600" text="Most components support custom background / foreground colors and font settings"/> + </panel> + </tab> + </tabbedpane> + </panel> + <separator/> + <panel weighty="1" weightx="1" halign="fill" valign="fill" columns="1" gap="2"> + <textarea halign="fill" weightx="1" border="false" editable="false" text="Border-less textareas can be used as multiline labels." wrap="true"/> + <label text="Link widget:"/> + <button type="link" tooltip="Link widget" halign="left" text="www.thinlet.com"/> + </panel> + <separator colspan="3"/> + <panel colspan="3" halign="fill" weightx="1"> + <menubar placement="top"> + <menu text="Start" font="bold 13" tooltip="Click here to begin"> + <menuitem text="Thinlet Home"/> + <separator/> + <menu text="Programs"> + <menu text="Accessories"> + <menuitem text="Thinlet!"/> + <menuitem text="Thinlet!"/> + <menuitem text="Thinlet!"/> + </menu> + <menuitem text="Amazon Browser"/> + <menuitem text="Calculator"/> + </menu> + <menu text="Documents"> + <menuitem text="one"/> + <menuitem text="two"/> + <menuitem text="three"/> + </menu> + <menu text="Settings"> + <menuitem text="Control Panel"/> + <separator/> + <menu text="Network & Dialup"> + <menuitem text="Thinlet!"/> + </menu> + <menuitem text="Printers"/> + <menuitem text="Taskbar & Start Menu..."/> + </menu> + <menu text="Search"> + <menuitem text="one"/> + </menu> + <menuitem text="Help"/> + <menuitem text="Run..."/> + <separator/> + <menuitem text="Shut Down..."/> + </menu> + </menubar> + <separator/> + <label text=" Unfold-up menus are supported."/> + </panel> </panel> </tab> </tabbedpane> |
From: <ab...@us...> - 2003-05-09 02:03:01
|
Update of /cvsroot/thinlet/thinlet/examples/demo In directory sc8-pr-cvs1:/tmp/cvs-serv27032/demo Log Message: Directory /cvsroot/thinlet/thinlet/examples/demo added to the repository |
From: <ab...@us...> - 2003-05-09 01:54:27
|
Update of /cvsroot/thinlet/thinlet/examples/amazon/browser In directory sc8-pr-cvs1:/tmp/cvs-serv27032/amazon/browser Log Message: Directory /cvsroot/thinlet/thinlet/examples/amazon/browser added to the repository |
From: <ab...@us...> - 2003-05-09 01:41:25
|
Update of /cvsroot/thinlet/thinlet/examples/amazon/explorer In directory sc8-pr-cvs1:/tmp/cvs-serv27032/amazon/explorer Log Message: Directory /cvsroot/thinlet/thinlet/examples/amazon/explorer added to the repository |
From: <ab...@us...> - 2003-05-09 01:41:03
|
Update of /cvsroot/thinlet/thinlet/amazon/explorer In directory sc8-pr-cvs1:/tmp/cvs-serv32680/amazon/explorer Removed Files: AmazonExplorer.java about.xml details.xml error.xml exception.xml exchange.xml explorer.xml linklist.xml listmania.xml manifest.mf market.xml result.xml Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- AmazonExplorer.java DELETED --- --- about.xml DELETED --- --- details.xml DELETED --- --- error.xml DELETED --- --- exception.xml DELETED --- --- exchange.xml DELETED --- --- explorer.xml DELETED --- --- linklist.xml DELETED --- --- listmania.xml DELETED --- --- manifest.mf DELETED --- --- market.xml DELETED --- --- result.xml DELETED --- |
From: <ab...@us...> - 2003-05-09 01:40:57
|
Update of /cvsroot/thinlet/thinlet/examples/common In directory sc8-pr-cvs1:/tmp/cvs-serv32680/examples/common Added Files: ImageChooser.java imagechooser.xml Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- NEW FILE: ImageChooser.java --- package examples.common; import java.awt.*; import java.io.*; import java.util.*; import java.util.zip.*; import thinlet.*; /** * */ public class ImageChooser { /** * */ public void load(Thinlet thinlet, Object tree) throws IOException { String classpath = System.getProperty("java.class.path"); StringTokenizer st = new StringTokenizer(classpath, File.pathSeparator); while (st.hasMoreTokens()) { File file = new File(st.nextToken()); if (!file.exists()) { continue; } String path = file.getCanonicalPath(); if (findNode(thinlet, tree, path) != null) { continue; } // don't add twice if (file.isDirectory()) { Object node = addNode(thinlet, tree, null, path); } else { Object node = addNode(thinlet, tree, null, path); addNode(thinlet, node, null, "loading..."); thinlet.putProperty(node, "loading...", Boolean.TRUE); } } } /** * */ public void expand(Thinlet thinlet, Object node) throws ZipException, IOException{ if (thinlet.getProperty(node, "loading...") == Boolean.TRUE) { System.out.println("> " + thinlet.getString(node, "text")); thinlet.removeAll(node); thinlet.putProperty(node, "loading...", null); ZipFile zipfile = new ZipFile(new File(thinlet.getString(node, "text"))); for (Enumeration entries = zipfile.entries(); entries.hasMoreElements();) { ZipEntry zipentry = (ZipEntry) entries.nextElement(); //if (!zipentry.isDirectory()) { continue; } //System.out.println("> " + zipentry.getName()); StringTokenizer st = new StringTokenizer(zipentry.getName(), "/"); Object parent = node; while (st.hasMoreTokens()) { String text = st.nextToken(); Object current = findNode(thinlet, parent, text); if (current == null) { current = addNode(thinlet, parent, null, text); } parent = current; } /*System.out.println("Name:" + zipentry.getName() + " Directory:" + zipentry.isDirectory() + " Comment:" + zipentry.getComment() + " Extra:" + zipentry.getExtra() + " Method:" + zipentry.getMethod() + " CompressedSize:" + zipentry.getCompressedSize() + " Size:" + zipentry.getSize() + " Crc:" + zipentry.getCrc() + " Time:" + zipentry.getTime());*/ } zipfile.close(); } } /** * */ private Object addNode(Thinlet thinlet, Object parent, Image icon, String text) { Object node = thinlet.create("node"); thinlet.setString(node, "text", text); thinlet.setBoolean(node, "expanded", false); thinlet.add(parent, node); return node; } /** * */ private Object findNode(Thinlet thinlet, Object parent, String text) { Object[] nodes = thinlet.getItems(parent); for (int i = 0; i < nodes.length; i++) { if (text.equals(thinlet.getString(nodes[i], "text"))) { return nodes[i]; } } return null; } /** * */ public static void main(String[] args) throws Exception { Thinlet thinlet = new Thinlet(); thinlet.setFont(new Font("Tahoma", Font.PLAIN, 11)); thinlet.setColors(0xf2f1e4, 0x000000, 0xffffff, 0x909090, 0xb0b0b0, 0xededed, 0xd7d5c2, 0x89899a, 0xc5c5dd); thinlet.add(thinlet.parse("/thinlet/common/imagechooser.xml", new ImageChooser())); new FrameLauncher("Image chooser", thinlet, 240, 320); } } --- NEW FILE: imagechooser.xml --- <?xml version="1.0" encoding="ISO-8859-1"?> <panel gap="4" columns="1"> <tree init="load(thinlet, this)" expand="expand(thinlet, item)" weightx="1" weighty="1" /> </panel> |
From: <ab...@us...> - 2003-05-09 01:34:03
|
Update of /cvsroot/thinlet/thinlet/examples/amazon/explorer In directory sc8-pr-cvs1:/tmp/cvs-serv32680/examples/amazon/explorer Added Files: AmazonExplorer.java about.xml details.xml error.xml exception.xml exchange.xml explorer.xml linklist.xml listmania.xml manifest.mf market.xml result.xml Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- NEW FILE: AmazonExplorer.java --- package examples.amazon.explorer; import java.applet.*; import java.awt.*; import java.io.*; import java.net.*; import java.util.*; import thinlet.*; /** * */ public class AmazonExplorer extends Thinlet { private static final String[] MODES = { "baby", "books", "classical", "dvd", "electronics", "garden", "kitchen", "magazines", "music", "pc-hardware", "photo", "software", "toys", "universal", "vhs", "videogames" }; private static final String[] BOOKS = { "+pmrank", "+salesrank", "+reviewrank", "+pricerank", "+inverse-pricerank", "+daterank", "+titlerank", "-titlerank" }; private static final String[] CLASSICAL_MUSIC = { "+psrank", "+salesrank", "+artistrank", "+orig-rel-date", "+titlerank" }; private static final String[] DVD = { "+salesrank", "+titlerank" }; private static final String[] ELECTRONICS = { "+pmrank", "+salesrank", "+titlerank", "+reviewrank" }; private static final String[] GARDEN_TOOL = { "+psrank", "+salesrank", "+titlerank", "-titlerank", "+manufactrank", "-manufactrank", "+price", "-price" }; private static final String[] KITCHEN = { "+pmrank", "+salesrank", "+titlerank", "-titlerank", "+manufactrank", "-manufactrank", "+price", "-price" }; private static final String[] HARDWARE = { "+psrank", "+salesrank", "+titlerank", "-titlerank" }; private static final String[] PHOTO = { "+pmrank", "+salesrank", "+titlerank", "-titlerank" }; private static final String[] SOFTWARE = { "+pmrank", "+salesrank", "+titlerank", "+price", "-price" }; private static final String[] VHS = { "+psrank", "+salesrank", "+titlerank" }; private static final String[] VIDEOGAMES = { "+pmrank", "+salesrank", "+titlerank", "+price", "-price" }; private static final String[] SORTS = { "Featured Items", "+pmrank", "Bestselling", "+salesrank", "Average Customer Review", "+reviewrank", "Price (Low to High)", "+pricerank", "Price (High to Low)", "+inverse-pricerank", "Publication Date", "+daterank", "Alphabetical (A-Z)", "+titlerank", "Alphabetical (Z-A)", "-titlerank", "Featured Items", "+psrank", "Artist Name", "+artistrank", "Original Release Date", "+orig-rel-date", "Alphabetical", "+titlerank", "Review", "+reviewrank", "Manufacturer (A-Z)", "+manufactrank", "Manufacturer (Z-A)", "-manufactrank", "Price (Low to High)", "+price", "Price (High to Low)", "-price" }; /** * */ public AmazonExplorer() { setFont(new Font("SansSerif", Font.PLAIN, 11)); try { add(parse("explorer.xml")); selectMode(1, find("searchby"), find("keyword"), find("sort")); } catch (Exception exc) { exc.printStackTrace(); } } /** * */ public void selectMode(int selected, Object searchby, Object keyword, Object sort) { String mode = MODES[selected]; removeAll(searchby); addChoice(searchby, "Keyword"); if ((mode == "music") || (mode == "classical")) { addChoice(searchby, "Artist"); } else if (mode == "books") { addChoice(searchby, "Author"); } else if ((mode == "dvd") || (mode == "vhs") || (mode == "video")) { addChoice(searchby, "Actor"); addChoice(searchby, "Director"); } else if ((mode == "electronics") || (mode == "kitchen") || (mode == "videogames") || (mode == "software") || (mode == "photo") || (mode == "pc-hardware")) { addChoice(searchby, "Manufacturer"); } setInteger(searchby, "selected", 0); removeAll(sort); String[] sorts = getSort(mode); if (sorts != null) { for (int i = 0; i < sorts.length; i++) { for (int j = 0; j < SORTS.length; j += 2) { if (SORTS[j + 1] == sorts[i]) { Object choice = create("choice"); setString(choice, "text", SORTS[j]); add(sort, choice); break; } } } } setInteger(sort, "selected", -1); setString(sort, "text", null); setBoolean(sort, "enabled", sorts != null); } /** * */ private void addChoice(Object combobox, String text) { Object choice = create("choice"); setString(choice, "text", text); add(combobox, choice); } /** * */ private static final String[] getSort(String mode) { if (mode == "books") { return BOOKS; } if ((mode == "classical") || (mode == "music")) { return CLASSICAL_MUSIC; } if (mode == "dvd") { return DVD; } if (mode == "electronics") { return ELECTRONICS; } if ((mode == "garden") || (mode == "universal")) { return GARDEN_TOOL; } if (mode == "kitchen") { return KITCHEN; } if (mode == "pc-hardware") { return HARDWARE; } if (mode == "photo") { return PHOTO; } if (mode == "software") { return SOFTWARE; } if (mode == "vhs") { return VHS; } if (mode == "videogames") { return VIDEOGAMES; } // if ((mode == "baby") || (mode == "magazines") || (mode == "toys")) { return null; } /** * */ public void find(int mode, String searchby, Object keyfield, String keyword, int sort) { String searchstring = searchby + "Search=" + convert(keyword) + "&mode=" + MODES[mode] + "&type=lite" + ((sort == -1) ? "" : ("&sort=" + getSort(MODES[mode])[sort])); // add the new keyword to the list boolean cacheditem = false; int n = getCount(keyfield); if (keyword.length() > 0) { for (int i = n - 1; i >= 0; i--) { String choicetext = getString(getItem(keyfield, i), "text"); if (keyword.equals(choicetext)) { cacheditem = true; break; } } if (!cacheditem) { Object choice = create("choice"); setString(choice, "text", keyword); add(keyfield, choice); if (n > 8) { remove(getItem(keyfield, 0)); } } } Object nProductInfo = getResponse(searchstring + "&page=1"); if (!isErrorMessage(nProductInfo)) { try { Object result = parse("result.xml"); Object nextresult = find(result, "nextresult"); putProperty(nextresult, "SearchString", searchstring); loadList(nProductInfo, 1, find(result, "resultlist"), find(result, "total"), nextresult); addPage(result); } catch (Exception exc) { exc.printStackTrace(); } } } /** * */ public void resultSelected(Object resultlist, Object detailsbutton) { setBoolean(detailsbutton, "enabled", getSelectedIndex(resultlist) != -1); } /** * */ public void findNext(Object nextresult, Object total, Object resultlist) { String searchstring = (String) getProperty(nextresult, "SearchString"); int page = ((Integer) getProperty(nextresult, "SearchPage")).intValue() + 1; Object nProductInfo = getResponse(searchstring + "&page=" + page); if (!isErrorMessage(nProductInfo)) { loadList(nProductInfo, page, resultlist, total, nextresult); } } /** * */ private void loadList(Object nProductInfo, int page, Object resultlist, Object total, Object nextresult) { loadDetailsList(nProductInfo, resultlist); String sTotalResults = getDOMText(nProductInfo, "TotalResults"); setString(total, "text", sTotalResults); putProperty(nextresult, "SearchPage", new Integer(page)); setBoolean(nextresult, "enabled", Integer.parseInt(sTotalResults) > getCount(resultlist)); } /** * */ private void loadDetailsList(Object nProductInfo, Object resultlist) { int n = getDOMCount(nProductInfo, "Details"); for (int i = 0; i < n; i++) { Object nDetails = getDOMNode(nProductInfo, "Details", i); Object item = create("item"); setString(item, "text", getDOMText(nDetails, "ProductName")); putProperty(item, "Details", nDetails); add(resultlist, item); } } /** * */ public void showDetails(Object resultlist) { Object item = getSelectedItem(resultlist); Object nDetails = getProperty(item, "Details"); try { Object details = parse("details.xml"); putProperty(details, "Asin", getDOMText(nDetails, "Asin")); //Info Object productname = find(details, "productname"); setString(productname, "text", getDOMText(nDetails, "ProductName")); //setIcon(productname, "icon", loadIcon(getDOMText(nDetails, "ImageUrlSmall"))); Object infoproperties = find(details, "infoproperties"); addLabel(infoproperties, "Name:", nDetails, "ProductName"); addLabel(infoproperties, "Catalog:", nDetails, "Catalog"); addList(infoproperties, "Artist:", nDetails, "Artists", "Artist"); addList(infoproperties, "Author:", nDetails, "Authors", "Author"); addLabel(infoproperties, "Released:", nDetails, "ReleaseDate"); addLabel(infoproperties, "Manufacturer:", nDetails, "Manufacturer"); addLabel(infoproperties, "List price:", nDetails, "ListPrice"); addLabel(infoproperties, "Our price:", nDetails, "OurPrice"); addLabel(infoproperties, "Used price:", nDetails, "UsedPrice"); addPage(details); } catch (Exception exc) { exc.printStackTrace(); } } /** * */ public void checkDetails(Object details, int selectedtab) { if (selectedtab == 0) { return; } // first tab contains lite information String sAsin = (String) getProperty(details, "Asin"); if (sAsin != null) { String searchstring = "AsinSearch=" + sAsin + "&type=heavy"; Object nProductInfo = getResponse(searchstring); if (!isErrorMessage(nProductInfo)) { Object nDetails = getDOMNode(nProductInfo, "Details", 0); if (nDetails == null) { return; } //never putProperty(details, "Asin", null); //More Object moreproperties = find(details, "moreproperties"); addList(moreproperties, "Starring:", nDetails, "Starring", "Actor"); addList(moreproperties, "Director:", nDetails, "Directors", "Director"); addLabel(moreproperties, "Theatrical date:", nDetails, "TheatricalReleaseDate"); addLabel(moreproperties, "Refurbished:", nDetails, "RefurbishedPrice"); addLabel(moreproperties, "Collectible:", nDetails, "CollectiblePrice"); addLabel(moreproperties, "Third-party:", nDetails, "ThirdPartyNewPrice"); addLabel(moreproperties, "Sales rank:", nDetails, "SalesRank"); addLabel(moreproperties, "Media:", nDetails, "Media"); addLabel(moreproperties, "Number:", nDetails, "NumMedia"); addLabel(moreproperties, "Mpaa rating:", nDetails, "MpaaRating"); addLabel(moreproperties, "Availability:", nDetails, "Availability"); //Review Object nReviews = getDOMNode(nDetails, "Reviews", 0); if (nReviews != null) { Object reviewpanel = find(details, "reviewpanel"); String sAvgCustomerRating = getDOMText(nReviews, "AvgCustomerRating"); Object avgrating = find(reviewpanel, "avgrating"); setInteger(avgrating, "value", getNumber(sAvgCustomerRating)); setString(avgrating, "tooltip", sAvgCustomerRating); loadReview(reviewpanel, nReviews, 0); putProperty(reviewpanel, "Reviews", nReviews); } //Detail Object detailpanel = find(details, "detailpanel"); loadList(getDOMNode(nDetails, "Platforms", 0), "Platform", detailpanel, "platformtitle", "platformlist"); loadList(getDOMNode(nDetails, "Features", 0), "Feature", detailpanel, "featuretitle", "featurelist"); //Link Object linkpanel = find(details, "linkpanel"); loadLink(find(linkpanel, "accessories"), nDetails, "Accessories"); loadLink(find(linkpanel, "similars"), nDetails, "SimilarProducts"); loadLink(find(linkpanel, "wishlists"), nDetails, "Lists"); putProperty(find(linkpanel, "marketsearch"), "Asin", sAsin); Object nBrowseList = getDOMNode(nDetails, "BrowseList", 0); if (nBrowseList != null) { int n = getDOMCount(nBrowseList, "BrowseNode"); Object browselist = find(linkpanel, "browselist"); for (int i = 0; i < n; i++) { Object nBrowseNode = getDOMNode(nBrowseList, "BrowseNode", i); Object browseitem = create("item"); setString(browseitem, "text", getDOMText(getDOMNode(nBrowseNode, "BrowseName", 0))); add(browselist, browseitem); } } } } } /** * */ private void loadLink(Object button, Object nDetails, String listname) { Object list = getDOMNode(nDetails, listname, 0); setBoolean(button, "enabled", (list != null)); if (list != null) { putProperty(button, listname, list); } } /** * */ public void previousReview(Object reviewpanel) { int i = ((Integer) getProperty(reviewpanel, "ReviewIndex")).intValue(); loadReview(reviewpanel, getProperty(reviewpanel, "Reviews"), i - 1); } /** * */ public void nextReview(Object reviewpanel) { int i = ((Integer) getProperty(reviewpanel, "ReviewIndex")).intValue(); loadReview(reviewpanel, getProperty(reviewpanel, "Reviews"), i + 1); } /** * */ private void loadReview(Object reviewpanel, Object nReviews, int i) { int n = getDOMCount(nReviews, "CustomerReview"); if ((i >= 0) && (i < n)) { setBoolean(find(reviewpanel, "prevreview"), "enabled", i > 0); setBoolean(find(reviewpanel, "nextreview"), "enabled", i < n - 1); putProperty(reviewpanel, "ReviewIndex", new Integer(i)); Object nCustomerReview = getDOMNode(nReviews, "CustomerReview", i); String sRating = getDOMText(nCustomerReview, "Rating"); Object rating = find(reviewpanel, "rating"); setInteger(rating, "value", getNumber(sRating)); setString(rating, "tooltip", sRating); setString(find(reviewpanel, "summary"), "text", getDOMText(nCustomerReview, "Summary")); setString(find(reviewpanel, "comment"), "text", convertHTML(getDOMText(nCustomerReview, "Comment"))); } } /** * */ private void loadList(Object root, String nodename, Object panel, String titlename, String listname) { Object list = find(panel, listname); if (root != null) { int n = getDOMCount(root, nodename); for (int i = 0; i < n; i++) { Object item = create("item"); setString(item, "text", getDOMText(getDOMNode(root, nodename, i))); add(list, item); } } else { Object title = find(panel, titlename); setBoolean(title, "visible", false); setBoolean(list, "visible", false); } } /** * */ public void showAccessories(Object button) { showLinkList(getProperty(button, "Accessories"), "Accessory", "Accessories:"); } /** * */ public void showSimilars(Object button) { showLinkList(getProperty(button, "SimilarProducts"), "Product", "Similar products:"); } /** * */ private void showLinkList(Object nRoot, String leafname, String title) { StringBuffer asins = new StringBuffer(); int n = getDOMCount(nRoot, leafname); for (int i = 0; i < n; i++) { if (i != 0) asins.append(','); asins.append(getDOMText(getDOMNode(nRoot, leafname, i))); } Object nProductInfo = getResponse("ListManiaSearch=" + asins.toString() + "&type=lite"); if (!isErrorMessage(nProductInfo)) { try { Object linklist = parse("linklist.xml"); setString(find(linklist, "title"), "text", title); loadDetailsList(nProductInfo, find(linklist, "resultlist")); addPage(linklist); } catch (Exception exc) { exc.printStackTrace(); } } } /** * */ public void showWishlists(Object button) { try { Object listmania = parse("listmania.xml"); Object nLists = getProperty(button, "Lists"); putProperty(listmania, "Lists", nLists); loadWishlist(nLists, 0, listmania, find(listmania, "resultlist"), find(listmania, "listname"), find(listmania, "prevlist"), find(listmania, "nextlist")); addPage(listmania); } catch (Exception exc) { exc.printStackTrace(); } } /** * */ public void previousWishlist(Object listmania, Object resultlist, Object listname, Object prevlist, Object nextlist) { int index = ((Integer) getProperty(listmania, "ListsIndex")).intValue(); loadWishlist(getProperty(listmania, "Lists"), index - 1, listmania, resultlist, listname, prevlist, nextlist); } /** * */ public void nextWishlist(Object listmania, Object resultlist, Object listname, Object prevlist, Object nextlist) { int index = ((Integer) getProperty(listmania, "ListsIndex")).intValue(); loadWishlist(getProperty(listmania, "Lists"), index + 1, listmania, resultlist, listname, prevlist, nextlist); } /** * */ private void loadWishlist(Object nLists, int index, Object listmania, Object resultlist, Object listname, Object prevlist, Object nextlist) { int n = getDOMCount(nLists, "ListId"); if ((index >= 0) && (index < n)) { String sListId = getDOMText(getDOMNode(nLists, "ListId", index)); Object nProductInfo = getResponse("ListManiaSearch=" + sListId + "&type=lite"); if (!isErrorMessage(nProductInfo)) { setString(listname, "text", getDOMText(nProductInfo, "ListName")); removeAll(resultlist); loadDetailsList(nProductInfo, resultlist); putProperty(listmania, "ListsIndex", new Integer(index)); setBoolean(prevlist, "enabled", index > 0); setBoolean(nextlist, "enabled", index < n - 1); } } } /** * */ public void searchMarket(Object button, Object offertype) { String asin = (String) getProperty(button, "Asin"); String type = getString(getItem(offertype, getInteger(offertype, "selected")), "text"); String searchstring = "AsinSearch=" + asin + "&type=heavy&offer=" + type; Object nProductInfo = getResponse(searchstring + "&offerpage=1"); if (!isErrorMessage(nProductInfo)) { try { Object market = parse("market.xml"); Object nDetails = getDOMNode(nProductInfo, "Details", 0); if (nDetails == null) { return; } String offerings = getDOMText(nDetails, "NumberOfOfferings"); setString(find(market, "offerings"), "text", offerings); Object nInfo = getDOMNode(nDetails, "ThirdPartyProductInfo", 0); Object detailslist = find(market, "detailslist"); int n = getDOMCount(nInfo, "ThirdPartyProductDetails"); for (int i = 0; i < n; i++) { Object nProduct = getDOMNode(nInfo, "ThirdPartyProductDetails", i); Object row = create("row"); putProperty(row, "ThirdPartyProductDetails", nProduct); Object cellNick = create("cell"); setString(cellNick, "text", getDOMText(nProduct, "SellerNickname")); add(row, cellNick); Object cellPrice = create("cell"); setString(cellPrice, "text", getDOMText(nProduct, "OfferingPrice")); add(row, cellPrice); add(detailslist, row); } addPage(market); } catch (Exception exc) { exc.printStackTrace(); } } } /** * */ public void showMarketDetails(Object detailslist) { Object nProduct = getProperty(getSelectedItem(detailslist), "ThirdPartyProductDetails"); try { Object exchange = parse("exchange.xml"); Object properties = find(exchange, "properties"); addLabel(properties, "Nickname:", nProduct, "SellerNickname"); addLabel(properties, "Price:", nProduct, "OfferingPrice"); addLabel(properties, "Condition:", nProduct, "Condition"); addField(properties, "Condition:", nProduct, "ConditionType"); addLabel(properties, "Availability:", nProduct, "ExchangeAvailability"); addLabel(properties, "Country:", nProduct, "SellerCountry"); addLabel(properties, "State:", nProduct, "SellerState"); addField(properties, "Comments:", nProduct, "ShipComments"); addLabel(properties, "Rating:", nProduct, "SellerRating"); add(exchange); } catch (Exception exc) { exc.printStackTrace(); } } /** * */ private void addLabel(Object panel, String title, Object root, String key) { String value = getDOMText(root, key); if (value != null) { Object label = create("label"); setString(label, "text", title); add(panel, label); Object field = create("label"); setString(field, "text", value); setInteger(field, "weightx", 1); add(panel, field); } } /** * */ private void addField(Object panel, String title, Object root, String key) { String value = getDOMText(root, key); if (value != null) { Object label = create("label"); setString(label, "text", title); add(panel, label); Object field = create("textfield"); setString(field, "text", getDOMText(root, key)); setBoolean(field, "editable", false); setInteger(field, "weightx", 1); add(panel, field); } } /** * */ private void addList(Object panel, String title, Object root, String key, String itemkey) { Object mainnode = getDOMNode(root, key, 0); if (mainnode != null); int n = getDOMCount(mainnode, itemkey); for (int i = 0; i < n; i++) { Object label = create("label"); if (i == 0) { setString(label, "text", title); } add(panel, label); Object field = create("label"); setString(field, "text", getDOMText(getDOMNode(mainnode, itemkey, i))); setInteger(field, "weightx", 1); add(panel, field); } } // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- /** * */ public void exit() { System.exit(0); } /** * */ public void defaultTheme() { setColors(0xe6e6e6, 0x000000, 0xffffff, 0x909090, 0xb0b0b0, 0xededed, 0xb9b9b9, 0x89899a, 0xc5c5dd); } /** * */ public void yellowTheme() { setColors(0xeeeecc, 0x000000, 0xffffff, 0x999966, 0xb0b096, 0xededcb, 0xcccc99, 0xcc6600, 0xffcc66); } /** * */ public void blueTheme() { setColors(0x6375d6, 0xffffff, 0x7f8fdd, 0xd6dff5, 0x9caae5, 0x666666, 0x003399, 0xff3333, 0x666666); } /** * */ public void about() { try { add(parse("about.xml")); } catch (Exception exc) { exc.printStackTrace(); } } // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- /** * */ private Object getResponse(String path) { String associatestag = "thinlet-20"; String developertoken = "D3MAIAYX2Q6JLY"; String url = "http://xml.amazon.com/onca/xml2?t=" + associatestag + "&dev-t=" + developertoken + "&" + path + "&f=xml"; if (getParent() instanceof Applet) { String proxy = ((Applet) getParent()).getParameter("proxy"); if (proxy != null) { url = proxy + convert(url); } } try { return parseDOM(new URL(url).openStream()); } catch (Exception exc) { showException(exc); return null; } } /** * */ private void addPage(Object page) { Object mainpanel = find("mainpanel"); int n = getCount(mainpanel); setBoolean(getItem(mainpanel, n - 1), "visible", false); add(mainpanel, page); } /** * */ public void removePage() { Object mainpanel = find("mainpanel"); int n = getCount(mainpanel); setBoolean(getItem(mainpanel, n - 2), "visible", true); remove(getItem(mainpanel, n - 1)); } /** * */ protected void handleException(Throwable throwable) { showException(throwable); } /** * */ private void showException(Throwable thr) { StringWriter writer = new StringWriter(); thr.printStackTrace(new PrintWriter(writer)); String trace = writer.toString().replace('\r', ' ').replace('\t', ' '); String thrclass = thr.getClass().getName(); thrclass = thrclass.substring(thrclass.lastIndexOf('.') + 1); try { Object exceptiondialog = parse("exception.xml"); setString(exceptiondialog, "text", thrclass); setString(find(exceptiondialog, "message"), "text", thr.getMessage()); setString(find(exceptiondialog, "stacktrace"), "text", trace); add(exceptiondialog); } catch (Exception exc) { exc.printStackTrace(); } } /** * */ private boolean isErrorMessage(Object nProductInfo) { if (nProductInfo == null) { return true; } String sErrorMsg = getDOMText(nProductInfo, "ErrorMsg"); if (sErrorMsg == null) { return false; } try { Object exceptiondialog = parse("error.xml"); setString(find(exceptiondialog, "message"), "text", sErrorMsg); add(exceptiondialog); } catch (Exception exc) { exc.printStackTrace(); } return true; } /** * */ public void closeDialog(Object dialog) { remove(dialog); } // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- /** * */ private String getDOMText(Object node, String key) { Object leaf = getDOMNode(node, key, 0); return (leaf != null) ? getDOMText(leaf) : null; } /** * */ private static int getNumber(String text) { try { if (text.startsWith("$")) { text = text.substring(1); } int dot = text.indexOf('.'); text = text + "00"; if (dot != -1) { text = text.substring(0, dot) + text.substring(dot + 1, Math.min(dot + 3, text.length())); } return Integer.parseInt(text); } catch (Exception exc) { return 0; } } /** * */ private static String convert(String text) { StringBuffer converted = new StringBuffer(text.length()); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9'))) { converted.append(c); } else { converted.append('%'); converted.append(Integer.toHexString((int) c)); } } return converted.toString(); } /** * */ private static String convertHTML(String comment) { StringBuffer sb = new StringBuffer(comment.length()); for (int i = 0; i < comment.length(); i++) { if (comment.startsWith("<P>", i)) { sb.append("\n\n"); i += 5; } else if (comment.startsWith("<BR>", i)) { sb.append("\n"); i += 6; } else sb.append(comment.charAt(i)); } return sb.toString(); } /** * */ public static void main(String[] args) throws Exception { new FrameLauncher("Thinlet Amazon Explorer", new AmazonExplorer(), 208, 256); // 208x235 } } --- NEW FILE: about.xml --- <?xml version="1.0" encoding="UTF-8"?> <dialog name="dialog" icon="/icons/information.gif" text="About" modal="true" columns="1" gap="4" top="4" left="4" bottom="4" right="4" > <label text="Thinlet Amazon Explorer" alignment="center" weightx="1" /> <separator /> <label text="Lajos Szemes" alignment="center" /> <label text="(laj...@th...)" alignment="center" /> <label text="Robert Bajzat" alignment="center" /> <label text="(rob...@th...)" alignment="center" /> <button text="Close" halign="center" action="closeDialog(dialog)" /> </dialog> --- NEW FILE: details.xml --- <?xml version="1.0" encoding="UTF-8"?> <panel name="detailspage" columns="1" weighty="1" gap="4" top="4" left="4" bottom="4" right="4"> <panel columns="2" gap="4"> <textfield name="productname" editable="false" weightx="1" /> <button text="Back" icon="/icons/history.gif" action="removePage" /> </panel> <tabbedpane weightx="1" weighty="1" action="checkDetails(detailspage, this.selected)"> <tab text="Info"> <panel name="infoproperties" columns="2" gap="4" top="4" left="4" bottom="4" right="4" weightx="1" weighty="1" /> </tab> <tab text="More"> <panel name="moreproperties" columns="2" gap="4" top="4" left="4" bottom="4" right="4" weightx="1" weighty="1" /> </tab> <tab text="Reviews"> <panel name="reviewpanel" columns="1" gap="4" top="4" left="4" bottom="4" right="4"> <panel gap="4"> <label text="Average:" /> <progressbar name="avgrating" maximum="500" valign="center" weightx="1" /> </panel> <separator /> <panel columns="4" gap="4"> <textfield name="summary" editable="false" colspan="2" /> <button name="prevreview" icon="/icons/back.gif" tooltip="Previous review" enabled="false" action="previousReview(reviewpanel)" rowspan="2" valign="top" /> <button name="nextreview" icon="/icons/forward.gif" tooltip="Next review" enabled="false" action="nextReview(reviewpanel)" rowspan="2" valign="top" /> <label text="Rating:" /> <progressbar name="rating" maximum="500" valign="center" weightx="1" /> </panel> <textarea name="comment" wrap="true" weightx="1" weighty="1" /> </panel> </tab> <tab text="Details"> <splitpane name="detailpanel" orientation="vertical"> <panel columns="1" gap="4" top="4" left="4" right="4"> <label name="platformtitle" text="Platforms:" /> <list name="platformlist" weightx="1" weighty="1" /> </panel> <panel columns="1" gap="4" left="4" bottom="4" right="4"> <label name="featuretitle" text="Features:" /> <list name="featurelist" weightx="1" weighty="1" /> </panel> </splitpane> </tab> <tab text="Links"> <panel name="linkpanel" columns="1" gap="4" top="4" left="4" bottom="4" right="4"> <panel gap="4" weightx="1"> <button name="accessories" text="Accessories" action="showAccessories(this)" weightx="1" /> <button name="similars" text="Similars" action="showSimilars(this)" weightx="1" /> <button name="wishlists" text="Listmania!" action="showWishlists(this)" weightx="1"/> </panel> <panel gap="4"> <label text="Marketplace:" /> <combobox name="offertype" editable="false" selected="0" weightx="1"> <choice text="All" /> <choice text="ThirdPartyNew" /> <choice text="Used" /> <choice text="Collectible" /> <choice text="Refurbished" /> </combobox> <button name="marketsearch" text="Search" action="searchMarket(this, offertype)" /> </panel> <label text="Browse list:" /> <list name="browselist" weighty="1" /> </panel> </tab> </tabbedpane> </panel> --- NEW FILE: error.xml --- <?xml version="1.0" encoding="UTF-8"?> <dialog name="dialog" icon="/icons/information.gif" text="Error Message" modal="true" columns="1" gap="4" top="4" left="4" bottom="4" right="4" > <label name="message" weightx="1" /> <button text="Close" halign="center" action="closeDialog(dialog)" /> </dialog> --- NEW FILE: exception.xml --- <?xml version="1.0" encoding="UTF-8"?> <dialog name="dialog" icon="/icons/information.gif" modal="true" columns="1" gap="4" top="4" left="4" bottom="4" right="4" > <label name="message" /> <textarea name="stacktrace" editable="false" width="200" height="150" weightx="1" weighty="1" /> <button text="Close" halign="center" action="closeDialog(dialog)" /> </dialog> --- NEW FILE: exchange.xml --- <?xml version="1.0" encoding="UTF-8"?> <dialog text="Third-party Product Details" name="dialog" icon="/icons/information.gif" modal="true" columns="1" gap="4" top="4" left="4" bottom="4" right="4" > <panel name="properties" gap="4" columns="2" weightx="1" /> <separator /> <button text="Close" halign="center" action="closeDialog(dialog)" /> </dialog> --- NEW FILE: explorer.xml --- <?xml version="1.0" encoding="UTF-8"?> <panel name="mainpanel" columns="1"> <menubar weightx="1"> <menu text="File"> <menuitem text="Exit" action="exit" /> </menu> <menu text="Theme"> <checkboxmenuitem text="Default" group="theme" selected="true" action="defaultTheme" /> <checkboxmenuitem text="Sandstone" group="theme" action="yellowTheme" /> <checkboxmenuitem text="Ocean" group="theme" action="blueTheme" /> </menu> <menu text="Help"> <menuitem text="About" action="about" /> </menu> </menubar> <panel columns="2" top="4" left="4" bottom="4" right="4" gap="4"> <label text="Product:" alignment="right" /> <combobox name="modes" editable="false" selected="1" weightx="1" action="selectMode(this.selected, searchby, keyword, sort)"> <choice text="Baby" /> <choice text="Books" /> <choice text="Classical Music" /> <choice text="DVD" /> <choice text="Electronics" /> <choice text="Outdoor Living" /> <choice text="Kitchen & Housewares" /> <choice text="Magazines" /> <choice text="Popular Music" /> <choice text="Computers" /> <choice text="Camera & Photo" /> <choice text="Software" /> <choice text="Toys & Games" /> <choice text="Tools & Hardware" /> <choice text="Video" /> <choice text="Computer & Video Games" /> </combobox> <label text="By:" alignment="right" /> <combobox name="searchby" editable="false" /> <label /> <combobox name="keyword" /> <label text="Sort:" alignment="right" /> <combobox name="sort" editable="false" /> <label /> <button text="Search" icon="/icons/find.gif" halign="left" action="find(modes.selected, searchby.text, keyword, keyword.text, sort.selected)" /> </panel> </panel> --- NEW FILE: linklist.xml --- <?xml version="1.0" encoding="UTF-8"?> <panel columns="1" weighty="1" gap="4" top="4" left="4" bottom="4" right="4"> <label name="title" weightx="1" /> <list name="resultlist" weighty="1" action="resultSelected(resultlist, detailsbutton)" /> <panel gap="4" halign="right"> <button name="detailsbutton" text="Details" enabled="false" action="showDetails(resultlist)" /> <button text="Back" icon="/icons/find.gif" action="removePage" /> </panel> </panel> --- NEW FILE: listmania.xml --- <?xml version="1.0" encoding="UTF-8"?> <panel name="listmania" columns="1" weighty="1" gap="4" top="4" left="4" bottom="4" right="4"> <panel gap="4" weightx="1"> <textfield name="listname" editable="false" weightx="1" /> <button name="prevlist" icon="/icons/back.gif" tooltip="Previous list" enabled="false" action="previousWishlist(listmania, resultlist, listname, this, nextlist)" /> <button name="nextlist" icon="/icons/forward.gif" tooltip="Next list" enabled="false" action="nextWishlist(listmania, resultlist, listname, prevlist, this)" /> </panel> <list name="resultlist" weighty="1" action="resultSelected(resultlist, detailsbutton)" /> <panel gap="4" halign="right"> <button name="detailsbutton" text="Details" enabled="false" action="showDetails(resultlist)" /> <button text="Back" icon="/icons/find.gif" action="removePage" /> </panel> </panel> --- NEW FILE: manifest.mf --- Main-Class: thinlet.amazon.explorer.AmazonExplorer --- NEW FILE: market.xml --- <?xml version="1.0" encoding="UTF-8"?> <panel columns="1" weighty="1" gap="4" top="4" left="4" bottom="4" right="4"> <panel gap="4" weightx="1"> <label text="Number of offerings:" /> <label name="offerings" /> </panel> <table name="detailslist" weighty="1" action="resultSelected(this, detailsbutton)"> <header> <column text="Seller" width="140" /> <column text="Offering Price" /> </header> </table> <panel gap="4" halign="right"> <button name="detailsbutton" text="Details" icon="/icons/history.gif" enabled="false" action="showMarketDetails(detailslist)" /> <button text="Back" icon="/icons/back.gif" action="removePage" /> </panel> </panel> --- NEW FILE: result.xml --- <?xml version="1.0" encoding="UTF-8"?> <panel columns="2" weighty="1" gap="4" top="4" left="4" bottom="4" right="4"> <label text="Total results:" /> <label name="total" weightx="1" /> <list name="resultlist" colspan="2" weighty="1" action="resultSelected(this, detailsbutton)" /> <panel gap="4" colspan="2" halign="right"> <button name="detailsbutton" text="Details" icon="/icons/history.gif" enabled="false" action="showDetails(resultlist)" /> <button text="Back" icon="/icons/find.gif" action="removePage" /> <button name="nextresult" text="Next" icon="/icons/findagain.gif" action="findNext(this, total, resultlist)" /> </panel> </panel> |
From: <ab...@us...> - 2003-05-09 01:33:56
|
Update of /cvsroot/thinlet/thinlet/examples/amazon/browser In directory sc8-pr-cvs1:/tmp/cvs-serv32680/examples/amazon/browser Added Files: AmazonBrowser.java amazonbrowser.xml manifest.mf Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- NEW FILE: AmazonBrowser.java --- package examples.amazon.browser; import java.awt.*; import java.io.*; import java.net.*; import java.util.*; import thinlet.*; /** * */ public class AmazonBrowser extends Thinlet { private final static String[] MODES = { "baby", "books", "classical", "dvd", "electronics", "garden", "kitchen", "magazines", "music", "pc-hardware", "photo", "software", "toys", "universal", "vhs", "videogames" }; private final static String[] SEARCHBY = { "Keyword", "Asin", "Upc", "Author", "Artist", "Actor", "Director", "Manufacturer" }; int level = -1; String name; boolean listmode; Vector details = new Vector(); /** * */ public class Details { String asin; String productName; String catalog; String authors; String artists; String releaseDate; String manufacturer; String imageUrl; String listPrice; String ourPrice; String usedPrice; Image image; public Image getIcon() { if ((image == null) && (imageUrl != null)) { try { image = getToolkit().getImage(new URL(imageUrl)); } catch (Exception exc) { showException(exc); } imageUrl = null; } return image; } } /** * */ public AmazonBrowser() { try { add(parse("amazonbrowser.xml")); productSelected(); } catch (Exception exc) { showException(exc); } } /** * */ public void productSelected() { int productid = getInteger(find("product"), "selected"); boolean music = (productid == 8) || (productid == 2); boolean books = (productid == 1); boolean films = (productid == 3) || (productid == 14); //video? boolean homes = (productid == 4) || (productid == 6) || (productid == 15) || (productid == 11) || (productid == 10) || (productid == 9); Object searchType = find("searchType"); setInteger(searchType, "selected", 0); setString(find("searchText"), "text", ""); setBoolean(getItem(searchType, 2), "enabled", music); setBoolean(getItem(searchType, 3), "enabled", books); setBoolean(getItem(searchType, 4), "enabled", music); setBoolean(getItem(searchType, 5), "enabled", films); setBoolean(getItem(searchType, 6), "enabled", films); setBoolean(getItem(searchType, 7), "enabled", homes); } /** * */ public void search() { String mode = MODES[getInteger(find("product"), "selected")]; String searchby = SEARCHBY[getInteger(find("searchType"), "selected")]; String text = getString(find("searchText"), "text"); StringBuffer converted = new StringBuffer(text.length()); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9'))) { converted.append(c); } else { converted.append('%'); converted.append(Integer.toHexString((int) c)); } } text = converted.toString(); setBoolean(find("errorMessage"), "visible", false); removeAll(find("resultList")); details.removeAllElements(); showProduct(null); try { parseXML(new URL("http://xml.amazon.com/onca/xml?v=1.0&" + "t=webservices-20&dev-t=D3MAIAYX2Q6JLY&" + searchby + "Search=" + text + "&mode=" + mode + "&type=lite&page=1&f=xml").openStream()); //parseXML(getClass().getResourceAsStream("xml.xml")); //parseXML(getClass().getResourceAsStream("err.xml")); } catch (Exception exc) { showException(exc); } } /** * */ public void resultSelected() { int selected = getSelectedIndex(find("resultList")); if (selected != -1) { Details detail = (Details) details.elementAt(selected); showProduct(detail); } } /** * */ private void showProduct(Details detail) { Object detailsPanel = find("detailsPanel"); setIcon(find(detailsPanel, "image"), "icon", (detail != null) ? detail.getIcon() : null); setString(find(detailsPanel, "authors"), "text", (detail != null) ? detail.authors : ""); boolean hasartists = (detail != null) && (detail.artists != null); setBoolean(find(detailsPanel, "artistsLabel"), "visible", hasartists); setBoolean(find(detailsPanel, "artists"), "visible", hasartists); if (hasartists) { setString(find(detailsPanel, "artists"), "text", (detail != null) ? detail.artists : ""); } setString(find(detailsPanel, "productName"), "text", (detail != null) ? detail.productName : ""); setString(find(detailsPanel, "manufactured"), "text", (detail != null) ? detail.manufacturer : ""); setString(find(detailsPanel, "released"), "text", (detail != null) ? detail.releaseDate : ""); setString(find(detailsPanel, "listPrice"), "text", (detail != null) ? detail.listPrice : ""); setString(find(detailsPanel, "ourPrice"), "text", (detail != null) ? detail.ourPrice : ""); setString(find(detailsPanel, "usedPrice"), "text", (detail != null) ? detail.usedPrice : ""); } /** * */ protected void startElement(String name, Hashtable attributelist) { level++; this.name = name; if (level == 1) { if ("Details".equals(name)) { details.addElement(new Details()); listmode = true; } else if ("ErrorMsg".equals(name)) { listmode = false; } } } /** * */ protected void characters(String text) { if ((level == 1) && !listmode) { Object errorMessage = find("errorMessage"); setBoolean(errorMessage, "visible", true); setString(errorMessage, "text", text); } else if (level == 2) { if ("Asin".equals(name)) { getLastDetails().asin = text; } else if ("ProductName".equals(name)) { getLastDetails().productName = text; } else if ("Catalog".equals(name)) { getLastDetails().catalog = text; } else if ("ReleaseDate".equals(name)) { getLastDetails().releaseDate = text; } else if ("Manufacturer".equals(name)) { getLastDetails().manufacturer = text; } else if ("ImageUrlMedium".equals(name)) { getLastDetails().imageUrl = text; } else if ("ListPrice".equals(name)) { getLastDetails().listPrice = text; } else if ("OurPrice".equals(name)) { getLastDetails().ourPrice = text; } else if ("UsedPrice".equals(name)) { getLastDetails().usedPrice = text; } } else if (level == 3) { if ("Author".equals(name)) { Details last = getLastDetails(); last.authors = (last.authors == null) ? text : (last.authors + ", " + text); } else if ("Artist".equals(name)) { Details last = getLastDetails(); last.artists = (last.artists == null) ? text : (last.artists + ", " + text); } } } /** * */ protected void endElement() { if (listmode && (level == 1)) { Details last = getLastDetails(); Object row = create("row"); Object productcell = create("cell"); setString(productcell, "text", last.productName); add(row, productcell); Object catalogcell = create("cell"); setString(catalogcell, "text", last.catalog); add(row, catalogcell); Object pricecell = create("cell"); setString(pricecell, "text", last.ourPrice); add(row, pricecell); add(find("resultList"), row); } level--; } /** * */ private Details getLastDetails() { return (Details) details.elementAt(details.size() - 1); } /** * */ public static void main(String[] args) throws Exception { new FrameLauncher("Amazon Browser", new AmazonBrowser(), 320, 320); } /** * */ private void showException(Throwable exc) { StringWriter writer = new StringWriter(); exc.printStackTrace(new PrintWriter(writer)); String trace = writer.toString().replace('\r', ' ').replace('\t', ' '); Object dialog = create("dialog"); setInteger(dialog, "columns", 1); setInteger(dialog, "gap", 4); setInteger(dialog, "top", 4); setInteger(dialog, "left", 4); setInteger(dialog, "bottom", 4); setInteger(dialog, "right", 4); setString(dialog, "text", exc.getMessage()); setBoolean(dialog, "modal", true); Object textarea = create("textarea"); setString(textarea, "text", trace); setInteger(textarea, "width", 240); setInteger(textarea, "height", 180); add(dialog, textarea); Object button = create("button"); setString(button, "text", "OK"); setChoice(button, "halign", "center"); add(dialog, button); try { setMethod(button, "action", "closeException", dialog, this); } catch (Exception e) {} add(dialog); } /** * */ public void closeException() { remove(getItem(getDesktop(), 0)); } } /*ProductInfo url Details* Asin? ProductName Catalog Authors? Author+ Artists? Artist+ ReleaseDate? Manufacturer? ImageUrlSmall ImageUrlMedium ImageUrlLarge ListPrice? OurPrice? UsedPrice? ShoppingCart? CartId? Items? Item+ ItemId ProductName? Description? Asin Quantity? ListPrice? OurPrice? ErrorMsg? ProductInfo Details* url Asin ProductName Catalog KeyPhrases? KeyPhrase+ Artists? Artist+ Authors? Author+ Mpn? Starring? Actor+ Directors? Director+ TheatricalReleaseDate? ReleaseDate? Manufacturer? Distributor? ImageUrlSmall? ImageUrlMedium? ImageUrlLarge? ListPrice? OurPrice? UsedPrice? RefurbishedPrice? CollectiblePrice? ThirdPartyNewPrice? SalesRank? BrowseList? BrowseNode+ BrowseId? BrowseName? Media? ReadingLevel? Publisher? NumMedia? Isbn? Features? Feature+ Platform? MpaaRating? EsrbRating? AgeGroup? Availability? Upc? Tracks? Track* ByArtist* Accessories? Accessory+ Platforms? Platform* Encoding? Reviews? AvgCustomerRating? CustomerReview* Rating Summary Comment SimilarProducts? Product* Lists? ListId* ShoppingCart? ... ErrorMsg? ...*/ --- NEW FILE: amazonbrowser.xml --- <?xml version="1.0" encoding="ISO-8859-1"?> <panel columns="1" gap="4" top="4" left="4" bottom="4" right="4" > <panel columns="3" gap="4" > <label text="Product:" /> <combobox editable="false" selected="1" colspan="2" name="product" action="productSelected"> <choice text="Baby" /> <choice text="Books" /> <choice text="Classical Music" /> <choice text="DVD" /> <choice text="Electronics" /> <choice text="Outdoor Living" /> <choice text="Kitchen & Housewares" /> <choice text="Magazines" /> <choice text="Popular Music" /> <choice text="Computers" /> <choice text="Camera & Photo" /> <choice text="Software" /> <choice text="Toys & Games" /> <choice text="Tools & Hardware" /> <choice text="Video" /> <choice text="Computer & Video Games" /> </combobox> <combobox editable="false" selected="0" name="searchType"> <choice text="Keyword:" /> <choice text="ASIN/ISBN:" /> <choice text="Upc:" /> <choice text="Author:" /> <choice text="Artist:" /> <choice text="Actor:" /> <choice text="Director:" /> <choice text="Manufacturer:" /> </combobox> <textfield name="searchText" weightx="1" /> <button text="Search" name="search" action="search" /> </panel> <label name="errorMessage" visible="false" /> <table name="resultList" action="resultSelected" weightx="1" weighty="1"> <header> <column text="Name" width="175" /> <column text="Catalog" width="75" /> <column text="OurPrice" width="40" /> </header> </table> <panel name="detailsPanel" columns="2" weightx="1" gap="4"> <label name="image" /> <panel columns="4" weightx="1" gap="4"> <label text="Author:" /> <textfield name="authors" colspan="3" editable="false" /> <label name="artistsLabel" text="Artists:" /> <textfield name="artists" colspan="3" editable="false" /> <label text="Name:" /> <textfield name="productName" colspan="3" editable="false" /> <label text="Manuf.:" /> <textfield name="manufactured" weightx="1" editable="false" /> <label text="Released:" /> <textfield name="released" columns="6" editable="false" /> <separator colspan="4" /> <panel columns="3" colspan="4" gap="4"> <label text="List Price:" /> <label text="Our Price:" /> <label text="Used Price:" /> <textfield name="listPrice" weightx="1" editable="false" /> <textfield name="ourPrice" weightx="1" editable="false" /> <textfield name="usedPrice" weightx="1" editable="false" /> </panel> </panel> </panel> </panel> --- NEW FILE: manifest.mf --- Main-Class: thinlet.amazon.browser.AmazonBrowser |
From: <ab...@us...> - 2003-05-09 01:31:56
|
Update of /cvsroot/thinlet/thinlet/common In directory sc8-pr-cvs1:/tmp/cvs-serv32680/common Removed Files: ImageChooser.java imagechooser.xml Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- ImageChooser.java DELETED --- --- imagechooser.xml DELETED --- |
From: <ab...@us...> - 2003-05-09 01:31:51
|
Update of /cvsroot/thinlet/thinlet/demo In directory sc8-pr-cvs1:/tmp/cvs-serv32680/demo Removed Files: Calculator.java Demo.java calculator.xml demo.xml demodialog.xml manifest.mf Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- Calculator.java DELETED --- --- Demo.java DELETED --- --- calculator.xml DELETED --- --- demo.xml DELETED --- --- demodialog.xml DELETED --- --- manifest.mf DELETED --- |
Update of /cvsroot/thinlet/thinlet/examples/demo In directory sc8-pr-cvs1:/tmp/cvs-serv32680/examples/demo Added Files: Calculator.java Demo.java calculator.xml demo.xml demodialog.xml manifest.mf Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- NEW FILE: Calculator.java --- package examples.demo; import thinlet.*; public class Calculator extends Thinlet { public Calculator() { try { add(parse("calculator.xml")); } catch (Exception exc) { exc.printStackTrace(); } } public void calculate(String number1, String number2, Object result) { // Widget result try { int i1 = Integer.parseInt(number1); int i2 = Integer.parseInt(number2); setString(result, "text", String.valueOf(i1 + i2)); // result.set("text", String.valueOf(i1 + i2)); } catch (NumberFormatException nfe) { getToolkit().beep(); } } public static void main(String[] args) { new FrameLauncher("Calculator", new Calculator(), 320, 240); } } --- NEW FILE: Demo.java --- package examples.demo; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.util.*; import thinlet.*; /** * */ public class Demo extends Thinlet { /** * */ public Demo() { try { add(parse("demo.xml")); } catch (Exception exc) { exc.printStackTrace(); } } /** * */ public static void main(String[] args) { new FrameLauncher("Demo", new Demo(), 320, 320); } boolean textinit; boolean valueinit; /** * */ public void loadText(Object textarea) { try { InputStream inputstream = null; try { inputstream = getClass().getResourceAsStream("demodialog.xml"); } catch (Throwable e) {} BufferedReader reader = new BufferedReader(new InputStreamReader(inputstream)); StringBuffer text = new StringBuffer(); for (int c = reader.read(); c != -1; c = reader.read()) { if (((c > 0x1f) && (c < 0x7f)) || ((c > 0x9f) && (c < 0xffff)) || (c == '\n')) { text.append((char) c); } else if (c == '\t') { text.append(" "); } } reader.close(); setString(textarea, "text", text.toString()); textinit = true; } catch (Exception exc) { getToolkit().beep(); } } public void actionTheme(String idx) { int index = idx.charAt(1) - '0'; switch (index) { case 0: //xp setColors(0xece9d8, 0x000000, 0xf5f4f0, 0x919b9a, 0xb0b0b0, 0xededed, 0xb9b9b9, 0xff899a, 0xc5c5dd); break; case 1: //gray setColors(0xe6e6e6, 0x000000, 0xffffff, 0x909090, 0xb0b0b0, 0xededed, 0xb9b9b9, 0x89899a, 0xc5c5dd); break; case 2: //yellow setColors(0xeeeecc, 0x000000, 0xffffff, 0x999966, 0xb0b096, 0xededcb, 0xcccc99, 0xcc6600, 0xffcc66); break; case 3: //blue setColors(0x6375d6, 0xffffff, 0x7f8fdd, 0xd6dff5, 0x9caae5, 0x666666, 0x003399, 0xff3333, 0x666666); break; } } /** * */ public void changeEditable(boolean editable, Object textarea) { setBoolean(textarea, "editable", editable); } /** * */ public void changeEnabled(boolean enabled, Object textarea) { setBoolean(textarea, "enabled", enabled); } public void changeBorder(boolean enabled, Object textarea) { setBoolean(textarea, "border", enabled); } Object dialog; /** * */ public void showDialog() { try { if (dialog == null) { dialog = parse("demodialog.xml"); } add(dialog); } catch (Exception exc) { exc.printStackTrace(); } } /** * */ public void findText(Object combobox, String what, boolean match, boolean down) { closeDialog(); if (what.length() == 0) { return; } boolean cacheditem = false; for (int i = getCount(combobox) - 1; i >= 0; i--) { String choicetext = getString(getItem(combobox, i), "text"); if (what.equals(choicetext)) { cacheditem = true; break; } } if (!cacheditem) { Object choice = create("choice"); setString(choice, "text", what); add(combobox, choice); } Object textarea = find("textarea"); int end = getInteger(textarea, "end"); String text = getString(textarea, "text"); if (!match) { what = what.toLowerCase(); text = text.toLowerCase(); } int index = text.indexOf(what, down ? end : 0); if (!down && (index != -1) && (index >= end)) { index = -1; } if (index != -1) { setInteger(textarea, "start", index); setInteger(textarea, "end", index + what.length()); requestFocus(textarea); } else { getToolkit().beep(); } } /** * */ public void closeDialog() { remove(dialog); } /** * */ public void insertList(Object list) { Object item = create("item"); setString(item, "text", "New item"); setIcon(item, "icon", getIcon("/icons/bookmarks.gif")); add(list, item, 0); } /** * */ public void deleteList(Object delete, Object list) { for (int i = getCount(list) - 1; i >= 0; i--) { Object item = getItem(list, i); if (getBoolean(item, "selected")) { remove(item); } } setBoolean(delete, "enabled", false); } /** * */ public void changeSelection(Object list, Object delete) { setBoolean(delete, "enabled", getSelectedIndex(list) != -1); } /** * */ public void setSelection(Object list, String selection, Object delete) { for (int i = getCount(list) - 1; i >= 0; i--) { setBoolean(getItem(list, i), "selected", false); } setChoice(list, "selection", selection); setBoolean(delete, "enabled", false); } /** * */ public void sliderChanged(int value, Object spinbox) { setString(spinbox, "text", String.valueOf(value)); hsbChanged(); } /** * */ public void spinboxChanged(String text, Object slider) { try { int value = Integer.parseInt(text); if ((value >= 0) && (value <= 255)) { setInteger(slider, "value", value); hsbChanged(); } } catch (NumberFormatException nfe) { getToolkit().beep(); } } private Object sl_red, sl_green, sl_blue; private Object tf_hue, tf_saturation, tf_brightness; private Object pb_hue, pb_saturation, pb_brightness; private Object rgb_label; /** * */ public void storeWidgets(Object sl_red, Object sl_green, Object sl_blue, Object tf_hue, Object tf_saturation, Object tf_brightness, Object pb_hue, Object pb_saturation, Object pb_brightness, Object rgb_label) { this.sl_red = sl_red; this.sl_green = sl_green; this.sl_blue = sl_blue; this.tf_hue = tf_hue; this.tf_saturation = tf_saturation; this.tf_brightness = tf_brightness; this.pb_hue = pb_hue; this.pb_saturation = pb_saturation; this.pb_brightness = pb_brightness; this.rgb_label = rgb_label; actionTheme("t0"); } /** * */ private void hsbChanged() { int red = getInteger(sl_red, "value"); int green = getInteger(sl_green, "value"); int blue = getInteger(sl_blue, "value"); float[] hsb = Color.RGBtoHSB(red, green, blue, null); setBackground(rgb_label, new Color(red, green, blue)); setString(tf_hue, "text", String.valueOf(hsb[0])); setString(tf_saturation, "text", String.valueOf(hsb[1])); setString(tf_brightness, "text", String.valueOf(hsb[2])); setInteger(pb_hue, "value", (int) (100f * hsb[0])); setInteger(pb_saturation, "value", (int) (100f * hsb[1])); setInteger(pb_brightness, "value", (int) (100f * hsb[2])); } } --- NEW FILE: calculator.xml --- <panel gap="4" top="4" left="4"> <textfield name="number1" columns="4" /> <label text="+" /> <textfield name="number2" columns="4" /> <button text="=" action="calculate(number1.text, number2.text, result)" /> <textfield name="result" editable="false" /> </panel> --- NEW FILE: demo.xml --- <?xml version="1.0" encoding="ISO-8859-1"?> <panel columns="1" gap="4"> <menubar weightx="1"> <menu text="File" mnemonic="0"> <menuitem text="New" icon="/icons/new.gif" mnemonic="0" /> <menuitem text="Open..." icon="/icons/open.gif" /> <menuitem text="Save" icon="/icons/save.gif" /> <menuitem text="Save As..." icon="/icons/saveas.gif" /> <separator /> <menuitem text="Page Setup" icon="/icons/pagesetup.gif" /> <menuitem text="Print" icon="/icons/print.gif" /> <separator /> <menuitem text="Exit" /> </menu> <menu text="Edit"> <menuitem text="Undo" icon="/icons/undo.gif" /> <separator /> <menuitem text="Cut" icon="/icons/cut.gif" /> <menuitem text="Copy" icon="/icons/copy.gif" /> <menuitem text="Paste" icon="/icons/paste.gif" /> <menuitem text="Delete" icon="/icons/delete.gif" /> <separator /> <menuitem text="Select All" /> </menu> <menu text="Search"> <menuitem text="Find..." icon="/icons/find.gif" /> <menuitem text="Find Next" icon="/icons/findagain.gif" /> </menu> <menu text="Theme"> <checkboxmenuitem text="XP" name="t0" group="theme" action="actionTheme(this.name)" selected="true"/> <checkboxmenuitem text="Gray" name="t1" group="theme" action="actionTheme(this.name)"/> <checkboxmenuitem text="Sandstone" name="t2" group="theme" action="actionTheme(this.name)"/> <checkboxmenuitem text="Ocean" name="t3" group="theme" action="actionTheme(this.name)"/> </menu> <menu text="Help"> <menuitem text="Help Topics" icon="/icons/help.gif" /> <separator /> <menuitem text="About" icon="/icons/about.gif" /> </menu> </menubar> <tabbedpane selected="1" weightx="1" weighty="1"> <tab text="Texts"> <panel columns="2" top="4" left="4" bottom="4" right="4" gap="4"> <panel columns="1" gap="2"> <label text="Find in the text:" mnemonic="10" /> <button name="b_finddialog" text="Search" tooltip="Search..." icon="/icons/find.gif" mnemonic="1" action="showDialog()" /> </panel> <panel columns="2" left="10" gap="4"> <checkbox name="cb_editable" text="Editable" mnemonic="4" selected="true" action="changeEditable(this.selected, textarea)" /> <checkbox name="cb_enabled" text="Enabled" selected="true" action="changeEnabled(this.selected, textarea)" /> <checkbox name="cb_border" text="Border" selected="true" action="changeBorder(this.selected, textarea)" /> </panel> <textarea name="textarea" init="loadText(this)" colspan="2" halign="fill" weightx="1" weighty="1" /> </panel> </tab> <tab text="Lists" mnemonic="0"> <panel columns="1" top="4" left="4" bottom="4" right="4" gap="4"> <panel gap="4"> <label text="Update list:" /> <button icon="/icons/new.gif" tooltip="Add new item" action="insertList(list)" /> <button name="delete" icon="/icons/delete.gif" tooltip="Delete selected items" action="deleteList(this, list)" /> <label text=" & selection:" /> <combobox name="selection" selected="2" editable="false" valign="center" action="setSelection(list, this.text, delete)"> <choice text="single" /> <choice text="interval" /> <choice text="multiple" /> </combobox> </panel> <splitpane orientation="vertical" divider="100" weightx="1" weighty="1"> <splitpane divider="120"> <list name="list" selection="multiple" action="changeSelection(this, delete)" colspan="4" weightx="1" weighty="1"> <popupmenu> <menuitem text="one"/> <menuitem text="two"/> <separator/> <menuitem text="three"/> </popupmenu> <item text="List item A" /> <item text="List item B" icon="/icons/bookmarks.gif" selected="true" /> <item text="List item C" enabled="false" /> <item text="List item D" icon="/icons/bookmarks.gif" /> <item text="List item E" /> <item text="List item F" /> <item text="List item G" /> </list> <tree selection="multiple"> <popupmenu> <menuitem text="one"/> <menuitem text="two"/> <separator/> <menuitem text="three"/> </popupmenu> <node text="Tree node A" icon="/icons/open.gif"> <node text="Tree node" icon="/icons/open.gif" selected="true"> <node text="Tree node" icon="/icons/new.gif" /> </node> </node> <node text="Tree node B" enabled="false" icon="/icons/new.gif" /> <node text="Tree node C" icon="/icons/open.gif" expanded="false"> <node text="Tree node C1" icon="/icons/new.gif" /> </node> </tree> </splitpane> <table selection="multiple"> <popupmenu> <menuitem text="one"/> <menuitem text="two"/> <separator/> <menuitem text="three"/> </popupmenu> <header> <column text="Column" icon="/icons/bookmarks.gif" width="120" /> <column text="Column" alignment="center" /> <column text="Column" alignment="center" /> </header> <row> <cell text="Cell" /> <cell text="Cell" /> <cell text="Cell" icon="/icons/bookmarks.gif" /> </row> <row selected="true"> <cell text="Cell" icon="/icons/bookmarks.gif" /> <cell text="Cell" /> <cell text="Cell" /> </row> <row> <cell text="Cell" /> <cell text="Cell" icon="/icons/bookmarks.gif" enabled="false" /> <cell text="Cell" /> </row> </table> </splitpane> </panel> </tab> <tab text="Values"> <panel columns="3" top="4" left="4" gap="4" init="storeWidgets(sl_red, sl_green, sl_blue, tf_hue, tf_saturation, tf_brightness, pb_hue, pb_saturation, pb_brightness, rgb_label)"> <label text="Red, green, and blue values" colspan="3" /> <label text="Red:" alignment="right" /> <slider name="sl_red" maximum="255" valign="center" action="sliderChanged(this.value, sb_red)" /> <spinbox name="sb_red" maximum="255" text="0" columns="3" action="spinboxChanged(this.text, sl_red)" /> <label text="Green:" alignment="right" /> <slider name="sl_green" maximum="255" valign="center" action="sliderChanged(this.value, sb_green)" /> <spinbox name="sb_green" maximum="255" text="0" columns="3" action="spinboxChanged(this.text, sl_green)" /> <label text="Blue:" alignment="right" /> <slider name="sl_blue" maximum="255" valign="center" action="sliderChanged(this.value, sb_blue)" /> <spinbox name="sb_blue" maximum="255" text="0" columns="3" action="spinboxChanged(this.text, sl_blue)" /> <separator colspan="3" /> <label text="Hue, saturation, and brightness values" colspan="3" /> <label text="Hue:" alignment="right" /> <textfield name="tf_hue" text="0.0" editable="false" /> <progressbar name="pb_hue" valign="center" /> <label text="Saturation:" alignment="right" /> <textfield name="tf_saturation" text="0.0" editable="false" /> <progressbar name="pb_saturation" valign="center" /> <label text="Brightness:" alignment="right" /> <textfield name="tf_brightness" text="0.0" editable="false" /> <progressbar name="pb_brightness" valign="center" /> <separator colspan="3"/> <label colspan="3" name="rgb_label" valign="fill" weighty="1" background="#000000"/> </panel> </tab> <tab text="Other"> <panel halign="fill" weightx="1" valign="fill" weighty="1" gap="4" top="4" columns="3"> <panel halign="fill" weightx="1" columns="1" gap="2"> <label text="Sidebar widget:"/> <tabbedpane placement="stacked" halign="fill" weightx="1" valign="fill" weighty="1"> <popupmenu> <menuitem text="one"/> <menuitem text="two"/> <separator/> <menuitem text="three"/> </popupmenu> <tab text="One" property="c=123;v=345"> <panel columns="1" gap="4"> <textarea valign="fill" weighty="1" weightx="1" halign="fill" border="false" wrap="true" editable="false" text="Popup menus are supported in many components. Try to right-click on the tab name. Try it on lists, trees and tables."/> </panel> </tab> <tab text="Two" font="bold 14"> <panel scrollable="true" columns="1" gap="4"> <label text="This is a scrollable panel."/> <label text="Custom colors/fonts:"/> <button text="abcdef" font="18" background="#888888"/> <button text="abcdef" font="Courier 17" background="#882288"/> <button text="abcdef" font="Serif 16" background="#228888"/> <button text="abcdef" font="bold 15" background="#888822"/> <button text="abcdef" font="italic 14" background="#448844"/> <button text="abcdef" font="bold italic 13" background="#444488"/> <button text="abcdef" font="12" background="#884444"/> <button text="abcdef" font="11" background="#2288ff"/> <button text="abcdef" font="10" background="#ff2288"/> </panel> </tab> <tab text="Three" font="bold" foreground="#0000ff"> <panel columns="1" gap="4"> <menubar halign="fill" weightx="1"> <menu text="File"> <menuitem text="one"/> </menu> </menubar> <textarea wrap="true" valign="fill" weighty="1" halign="fill" weightx="1" border="false" editable="false" text="Menus can be placed on any panel or dialog."/> </panel> </tab> <tab text="Four" font="Serif bold 14" background="#8888ff" foreground="#ffffff"> <panel columns="1" gap="4"> <textarea valign="fill" weighty="1" weightx="1" halign="fill" border="false" wrap="true" editable="false" font="Serif italic bold 14" foreground="#88ff88" background="#446600" text="Most components support custom background / foreground colors and font settings"/> </panel> </tab> </tabbedpane> </panel> <separator/> <panel weighty="1" weightx="1" halign="fill" valign="fill" columns="1" gap="2"> <textarea halign="fill" weightx="1" border="false" editable="false" text="Border-less textareas can be used as multiline labels." wrap="true"/> <label text="Link widget:"/> <button type="link" tooltip="Link widget" halign="left" text="www.thinlet.com"/> </panel> <separator colspan="3"/> <panel colspan="3" halign="fill" weightx="1"> <menubar placement="top"> <menu text="Start" font="bold 13" tooltip="Click here to begin"> <menuitem text="Thinlet Home"/> <separator/> <menu text="Programs"> <menu text="Accessories"> <menuitem text="Thinlet!"/> <menuitem text="Thinlet!"/> <menuitem text="Thinlet!"/> </menu> <menuitem text="Amazon Browser"/> <menuitem text="Calculator"/> </menu> <menu text="Documents"> <menuitem text="one"/> <menuitem text="two"/> <menuitem text="three"/> </menu> <menu text="Settings"> <menuitem text="Control Panel"/> <separator/> <menu text="Network & Dialup"> <menuitem text="Thinlet!"/> </menu> <menuitem text="Printers"/> <menuitem text="Taskbar & Start Menu..."/> </menu> <menu text="Search"> <menuitem text="one"/> </menu> <menuitem text="Help"/> <menuitem text="Run..."/> <separator/> <menuitem text="Shut Down..."/> </menu> </menubar> <separator/> <label text=" Unfold-up menus are supported."/> </panel> </panel> </tab> </tabbedpane> </panel> --- NEW FILE: demodialog.xml --- <?xml version="1.0" encoding="ISO-8859-1"?> <dialog text="Find" icon="/icons/find.gif" modal="true" columns="4" top="4" left="4" bottom="4" right="4" gap="4"> <label text="Find what:" /> <combobox name="ch_what" colspan="2" valign="center" /> <button name="b_find" text="Find next" action="findText(ch_what, ch_what.text, cb_match.selected, rb_down.selected)" /> <label text="Direction:" alignment="right" /> <checkbox name="rb_up" text="Up" group="direction" /> <checkbox name="cb_match" text="Match case" selected="true" /> <button name="b_cancel" text="Cancel" action="closeDialog" /> <label /> <checkbox name="rb_down" text="Down" group="direction" selected="true" /> </dialog> --- NEW FILE: manifest.mf --- Main-Class: demo.Demo |
From: <ab...@us...> - 2003-05-09 01:13:18
|
Update of /cvsroot/thinlet/thinlet/examples/demo/icons In directory sc8-pr-cvs1:/tmp/cvs-serv32680/examples/demo/icons Added Files: about.gif bookmarks.gif copy.gif cut.gif delete.gif find.gif findagain.gif help.gif new.gif open.gif pagesetup.gif paste.gif print.gif save.gif saveas.gif undo.gif Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- NEW FILE: about.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: bookmarks.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: copy.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cut.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: delete.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: find.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: findagain.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: help.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: new.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: open.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: pagesetup.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: paste.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: print.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: save.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: saveas.gif --- (This appears to be a binary file; contents omitted.) --- NEW FILE: undo.gif --- (This appears to be a binary file; contents omitted.) |
From: <ab...@us...> - 2003-05-09 01:13:09
|
Update of /cvsroot/thinlet/thinlet In directory sc8-pr-cvs1:/tmp/cvs-serv7682 Removed Files: AppletLauncher.java FrameLauncher.java Log Message: Several improvements and fixes: * internationalization - please see setLangResource javadoc for description. * borderless textarea; suitable for multiline labels * new sidebar and hyperlink widgets * improved spinbox - supports minimum, maximum, value and step * improved support for custom background / foreground and font for individual components * support for menus that open above menubar, not below * popup menus work now for more components * use different gradient for dialog titlebars * a few of NPEs in layout code fixed. * added more javadoc to public methods, and corrected some. Demo has been updated to show the new capabilities. --- AppletLauncher.java DELETED --- --- FrameLauncher.java DELETED --- |
From: <ab...@us...> - 2003-05-09 01:12:00
|
Update of /cvsroot/thinlet/thinlet/examples In directory sc8-pr-cvs1:/tmp/cvs-serv25910/examples Log Message: Directory /cvsroot/thinlet/thinlet/examples added to the repository |
From: <ab...@us...> - 2003-05-09 01:02:51
|
Update of /cvsroot/thinlet/thinlet/examples/demo/icons In directory sc8-pr-cvs1:/tmp/cvs-serv27032/demo/icons Log Message: Directory /cvsroot/thinlet/thinlet/examples/demo/icons added to the repository |
From: <ab...@us...> - 2003-05-09 01:02:45
|
Update of /cvsroot/thinlet/thinlet/examples/common In directory sc8-pr-cvs1:/tmp/cvs-serv27032/common Log Message: Directory /cvsroot/thinlet/thinlet/examples/common added to the repository |
From: <ab...@us...> - 2003-05-09 01:00:07
|
Update of /cvsroot/thinlet/thinlet/src/thinlet In directory sc8-pr-cvs1:/tmp/cvs-serv7682/src/thinlet Modified Files: Thinlet.java Added Files: AppletLauncher.java FrameLauncher.java Log Message: Several improvements and fixes: * internationalization - please see setLangResource javadoc for description. * borderless textarea; suitable for multiline labels * new sidebar and hyperlink widgets * improved spinbox - supports minimum, maximum, value and step * improved support for custom background / foreground and font for individual components * support for menus that open above menubar, not below * popup menus work now for more components * use different gradient for dialog titlebars * a few of NPEs in layout code fixed. * added more javadoc to public methods, and corrected some. Demo has been updated to show the new capabilities. --- 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) {} } Index: Thinlet.java =================================================================== RCS file: /cvsroot/thinlet/thinlet/src/thinlet/Thinlet.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Thinlet.java 6 May 2003 23:19:53 -0000 1.16 +++ Thinlet.java 8 May 2003 20:30:56 -0000 1.17 @@ -47,8 +47,11 @@ private transient Color c_select; private transient Color c_ctrl = null; private transient int block; - private transient Image hgradient, vgradient; + private transient Image hgradient, vgradient, hmodal; //java + private static ResourceBundle langResource = null; + private static ResourceBundle langResourceDefault = null; + private transient boolean allI18n = false; private transient Thread timer; private transient long watchdelay; private transient long watch; @@ -109,7 +112,7 @@ } // button and togglebutton border + padding - private static final Insets BUTTON = new Insets(3, 12, 3, 12); + private static final Insets BUTTON = new Insets(3, 6, 3, 6); // tabbedpane (not selected) tab padding are 1, 3, 1, and 3 pt private static final Insets ITEM = new Insets(1, 3, 1, 3); // list/tree/table item padding @@ -144,7 +147,7 @@ c_disable = new Color(disable); c_hover = new Color(hover); c_press = new Color(press); c_focus = new Color(focus); c_select = new Color(select); - hgradient = vgradient = null; + hgradient = vgradient = hmodal = null; repaint(); } @@ -161,7 +164,7 @@ block = getFontMetrics(font).getHeight(); super.setFont(font); this.font = font; - hgradient = vgradient = null; + hgradient = vgradient = hmodal = null; if (content != null) validate(content); } @@ -176,6 +179,123 @@ } /** + * Set custom foreground color (text color) on a component + * + * @param component component to use the custom foreground + * @param color custom color to use, or null to reset component to use default foreground + */ + public void setForeground(Object component, Color color) { + if (component != null) set(component, "foreground", color); + } + + /** + * Set custom background color on a component. + * <p>Note: on gradient-filled + * components (such as tabs, buttons etc) this will result in a + * component filled with solid background color, and not a new gradient. + * Also, Color.brighter() will be used for highlight, and Color.darker() + * will be used for pressed or not selected. + * + * @param component component to use the custom background + * @param color custom color to use, or null to reset component to use default background + */ + public void setBackground(Object component, Color color) { + if (component != null) set(component, "background", color); + } + + /** + * Set current language resource bundle. This flushes all cached translated values, performs + * lazy loading of new values, and repaints the desktop. This implementation allows applications to switch + * language resources on the fly, without rebuilding/reloading components that use them. + * + * <p>The pseudo-code is as follows: + * <ul> + * <li>if langResource && langResourceDefault are null, don't + * translate anything, no matter what other settings are. This + * behaviour provides compatibility with previous versions.</li> + * <li>if only langResourceDefault is set, use this when translation is required</li> + * <li>if allI18n is set to true: + * <ul> + * <li>if property "i18n" on a component is missing, + * or set to "true", translate</li> + * <li>if property "i18n" is present, and set to "false", + * do not translate</li> + * </ul></li> + * <li>if allI18n is set to false: + * <ul> + * <li>if property "i18n" on a component is missing, + * or set to "false", do not translate</li> + * <li>if property "i18n" is present, and set to "true", + * translate</li> + * </ul></li> + * </ul> + * <p>The "translate" step is applied only to values from "text" + * and "tooltip" properties (for now), and is applied as follows: + * <ul> + * <li>use the value of "text" or "tooltip" as a lookup key</li> + * <li>use langResource to lookup the result value + * <ul> + * <li>if no value is found, use langResourceDefault for lookup + * <ul> + * <li>if no value is found, just return the original value of + * the property. Set a flag on component that prevents + * lookups in the future. This flag is cleared when langResource is changed.</li> + * </ul></li> + * </ul></li> + * <li>cache the result value, if any</li> + * </ul> + * <p>If translated value is found successfully, it is cached in the + * component. This cache is gradually flushed when setLangResource + * is called. Cached value is also flushed when setString() is + * called on a component. + * + * @param res resource bundle containing localized texts for "text" and "tooltip" + */ + public void setLangResource(ResourceBundle res) { + langResource = res; + doLayout(content); + repaint(content); + } + + /** + * Returns language resource bundle currently in use, or default bundle, or null. + */ + public static ResourceBundle getLangResource() { + return langResource; + } + + /** + * Set default language resource bundle. Resources from this bundle will be used if + * they are missing in the current bundle. + * + * @param res resource bundle containing default localized texts for "text" and "tooltip" + */ + public void setLangResourceDefault(ResourceBundle res) { + langResourceDefault = res; + if (langResource == null) setLangResource(res); + } + + /** + * Returns default language resource bundle, or null. + */ + public static ResourceBundle getLangResourceDefault() { + return langResourceDefault; + } + + /** + * Sets the default behaviour of internationalization code. If set to "true", try to translate + * all components' "text" and "tooltip" values, unless explicitly prohibited by setting + * <code>i18n="false"</code> on a specific component. If set to "false", do not translate + * unless explicitly requested by setting <code>i18n="true"</code> on a specific component. + *<p>Default value is "false", to provide backwards compatibility. + * + *@param val if "true", translate by default; if "false", do not translate by default. + */ + public void setAllI18n(boolean val) { + allI18n = val; + } + + /** * */ private void doLayout(Object component) { @@ -241,31 +361,49 @@ Rectangle bounds = getRectangle(component, "bounds"); String placement = getString(component, "placement", "top"); boolean horizontal = ((placement == "top") || (placement == "bottom")); - + boolean stacked = (placement == "stacked"); int selected = getInteger(component, "selected", 0); + int cnt = getItemCountImpl(component, ":comp"); // draw up tabs in row/column int tabd = 0; Rectangle first = null; // x/y location of tab left/top int tabsize = 0; // max height/width of tabs for (Object tab = get(component, ":comp"); tab != null; tab = get(tab, ":next")) { - Dimension d = getSize(tab, horizontal ? 12 : 9, horizontal ? 5 : 8); + Dimension d; + if (stacked) { + d = getSize(tab, 9, 8); + } else d = getSize(tab, horizontal ? 12 : 9, horizontal ? 5 : 8); if ((tabd == 0) && ((first = getRectangle(tab, "bounds")) != null)) { - tabd = horizontal ? first.x : first.y; // restore previous offset + tabd = horizontal && !stacked? first.x : first.y; // restore previous offset } setRectangle(tab, "bounds", - horizontal ? tabd : 0, horizontal ? 0 : tabd, d.width, d.height); + horizontal? tabd : 0, horizontal? 0 : tabd, d.width, d.height); tabd += (horizontal ? d.width : d.height) - 3; - tabsize = Math.max(tabsize, horizontal ? d.height : d.width); + tabsize = Math.max(tabsize, (horizontal || stacked)? d.height : d.width); } - // match tab height/width, set tab content size - int cx = (placement == "left") ? (tabsize + 1) : 2; - int cy = (placement == "top") ? (tabsize + 1) : 2; - int cwidth = bounds.width - (horizontal ? 4 : (tabsize + 3)); - int cheight = bounds.height - (horizontal ? (tabsize + 3) : 4); + int cx = (placement == "left") ? (tabsize + 1) : stacked ? 2 : 2; + int cy = (placement == "top")? (tabsize + 1) : stacked ? (tabsize + 2) : 2; + int cwidth = bounds.width - ((horizontal || stacked)? 4 : (tabsize + 3)); + int cheight = bounds.height - (horizontal ? (tabsize + 3) : stacked? (tabsize + 2)* cnt: 4); + if (cheight < 0) cheight = 0; + tabd = tabsize; + int i = 0; for (Object tab = get(component, ":comp"); tab != null; tab = get(tab, ":next")) { Rectangle r = getRectangle(tab, "bounds"); - if (horizontal) { + if (r == null) { + r = new Rectangle(); + set(tab, "bounds", r); + } + if (horizontal || stacked) { if (placement == "bottom") { r.y = bounds.height - tabsize; } + else if (stacked) { + r.y = tabd; r.x = 2; + //r.width = cwidth - 4; + tabd += tabsize; + if (i == selected) tabd += cheight + 3; + cy += tabsize + 2; + i++; + } r.height = tabsize; } else { if (placement == "right") { r.x = bounds.width - tabsize; } @@ -523,6 +661,7 @@ private void checkOffset(Object component) { String placement = getString(component, "placement", "top"); boolean horizontal = ((placement == "top") || (placement == "bottom")); + boolean stacked = (placement == "stacked"); int selected = getInteger(component, "selected", 0); Rectangle bounds = getRectangle(component, "bounds"); int panesize = horizontal ? bounds.width : bounds.height; @@ -736,10 +875,16 @@ // set :popup bounds String classname = getClass(component); Rectangle menubounds = getRectangle(selected, "bounds"); - if ("menubar" == classname) { // bellow the menubar + if ("menubar" == classname) { // below the menubar + boolean below = getString(component, "placement", "bottom") == "bottom"; popupowner = component; - setRectangle(popup, "bounds", - menux + menubounds.x, menuy + menuheight - 1, pw + 2, ph + 2); + if (below) { + setRectangle(popup, "bounds", + menux + menubounds.x, menuy + menuheight - 1, pw + 2, ph + 2); + } else { + setRectangle(popup, "bounds", + menux + menubounds.x, menuy - ph - 1, pw + 2, ph + 2); + } } else { // right to the previous :popup setRectangle(popup, "bounds", menux + menuwidth - 3, menuy + menubounds.y, pw + 2, ph + 2); @@ -795,6 +940,10 @@ pw = Math.max(pw, d.width); ph += d.height; } + // if popup would fall outside desktop bounds, shift it + Rectangle bounds = getRectangle(content, "bounds"); + if (x + pw + 2 > bounds.x + bounds.width) x -= (pw + 2); + if (y + ph + 2 > bounds.y + bounds.height) y -= (ph + 2); // set :popup bounds setRectangle(popup, "bounds", x, y, pw + 2, ph + 2); repaint(popup); @@ -807,6 +956,7 @@ if ((item != null) && getBoolean(item, "enabled", true)) { String text = getString(item, "text", ""); set(combobox, "text", text); // if editable + putProperty(combobox, "i18n.text", null); setInteger(combobox, "start", text.length(), 0); setInteger(combobox, "end", 0, 0); set(combobox, "icon", get(item, "icon")); @@ -1012,7 +1162,7 @@ return getSize(component, 0, 0); } if (("button" == classname) || ("togglebutton" == classname)) { - if (getChoice(component, "type") == "link") + if ("button" == classname && getChoice(component, "type") == "link") return getSize(component, ITEM.left + ITEM.right, ITEM.top + ITEM.bottom); else @@ -1066,6 +1216,8 @@ if ("tabbedpane" == classname) { String placement = getString(component, "placement", "top"); boolean horizontal = ((placement == "top") || (placement == "bottom")); + boolean stacked = (placement == "stacked"); + int cnt = getItemCountImpl(component, ":comp"); int tabsize = 0; // max tab height/width int contentwidth = 0; int contentheight = 0; // max content size for (Object tab = get(component, ":comp"); @@ -1080,8 +1232,8 @@ contentheight = Math.max(contentheight, dc.height); } } - return new Dimension(contentwidth + (horizontal ? 4 : (tabsize + 3)), - contentheight + (horizontal ? (tabsize + 3) : 4)); + return new Dimension(contentwidth + ((horizontal || stacked)? 4 : (tabsize + 3)), + contentheight + (horizontal? (tabsize + 3) : stacked? (tabsize + 3) * cnt : 4)); } if (("panel" == classname) || (classname == "dialog")) { // title text and icon height @@ -1406,6 +1558,20 @@ } hgradient = createImage(new MemoryImageSource(block, block, pix[0], 0, block)); vgradient = createImage(new MemoryImageSource(block, block, pix[1], 0, block)); + pix = new int[1][block * block]; + r1 = c_select.getRed(); r2 = c_select.getRed(); + g1 = c_select.getGreen(); g2 = c_select.getGreen(); + b1 = c_select.getBlue(); b2 = c_select.getBlue(); + for (int i = 0; i < block; i++) { + int cr = r1 - (r1 - r2) * i / block; + int cg = g1 - (g1 - g2) * i / block; + int cb = b1 - (b1 - b2) * i / block; + int color = (255 << 24) | (cr << 16) | (cg << 8) | cb; + for (int j = 0; j < block; j++) { + pix[0][i * block + j] = color; + } + } + hmodal = createImage(new MemoryImageSource(block, block, pix[0], 0, block)); } //g.setColor(Color.orange); //g.fillRect(0, 0, getSize().width, getSize().height); @@ -1483,6 +1649,11 @@ enabled = getBoolean(component, "enabled", true); //enabled && if ("label" == classname) { + Color bg = (Color) get(component, "background"); + if (bg != null) { + g.setColor(bg); + g.fillRect(0, 0, bounds.width, bounds.height); + } paintContent(component, g, clipx, clipy, clipwidth, clipheight, 0, 0, bounds.width, bounds.height, enabled ? c_text : c_disable, "left", true); @@ -1601,10 +1772,12 @@ g, clipx, clipy, clipwidth, clipheight); } else if ("tabbedpane" == classname) { - int i = 0; Object selectedtab = null; + int i = 0; int idx = 0; Object selectedtab = null; int selected = getInteger(component, "selected", 0); String placement = getString(component, "placement", "top"); boolean horizontal = ((placement == "top") || (placement == "bottom")); + boolean stacked = (placement == "stacked"); + int cnt = getItemCountImpl(component, ":comp"); int bx = horizontal ? 2 : 1, by = horizontal ? 1 : 2, bw = 2 * bx, bh = 2 * by; int dx = horizontal ? 6 : ((placement == "left") ? 5 : 4), dy = horizontal ? ((placement == "top") ? 3 : 2) : 4, @@ -1613,19 +1786,45 @@ g.clipRect(0, 0, bounds.width, bounds.height); //+clip for (Object tab = get(component, ":comp"); tab != null; tab = get(tab, ":next")) { if (selected != i) { - boolean hover = inside && (mousepressed == null) && (insidepart == tab); + boolean hover = inside && (mousepressed == null) && (insidepart == tab); boolean tabenabled = enabled && getBoolean(tab, "enabled", true); Rectangle r = getRectangle(tab, "bounds"); + if (r == null) { + r = new Rectangle(); + set(tab, "bounds", r); + } + Color bg = (Color) get(tab, "background"); + if (bg == null) bg = tabenabled ? (hover ? c_hover : c_ctrl) : c_ctrl; + else bg = tabenabled ? (hover ? bg.brighter() : bg.darker()) : bg.brighter(); paintRect(g, r.x + bx, r.y + by, r.width - bw, r.height - bh, enabled ? c_border : c_disable, - tabenabled ? (hover ? c_hover : c_ctrl) : c_ctrl, + bg, (placement != "bottom"), (placement != "right"), - (placement != "top"), (placement != "left"), true); + stacked ? false : (placement != "top"), (placement != "left"), true); + if (stacked) { + g.setColor(enabled ? c_border : c_disable); + g.drawLine(1, r.y + r.height - 3, bounds.width - 1, r.y + r.height - 3); + g.drawLine(1, r.y + r.height - 3, 1, r.y + r.height ); + g.drawLine(bounds.width - 1, r.y + r.height - 3, bounds.width - 1, r.y + r.height + 2); + /* cut corners ... uncomment if you like them + int x = r.x + bx + r.width - bw - r.height / 3; + int y = r.y + by; + g.drawLine(x, y, x + r.height / 3 - 1, y + r.height / 3 - 1); + g.setColor(c_bg); + g.fillPolygon( + new int[]{x + 1, x + r.height / 3, x + r.height / 3}, + new int[]{y, y, y + r.height / 3 - 1}, + 3); + */ + } paintContent(tab, g, clipx, clipy, clipwidth, clipheight, r.x + dx, r.y + dy, r.width - dw, r.height - dh, tabenabled ? c_text : c_disable, "left", true); } - else { selectedtab = tab; } + else { + selectedtab = tab; + idx = i; + } i++; } @@ -1633,19 +1832,25 @@ if (selectedtab != null) { Rectangle r = getRectangle(selectedtab, "bounds"); // paint tabbedpane border + if (stacked) { + g.setColor(enabled ? c_border : c_disable); + g.drawLine(0, r.y + r.height - 1, bounds.width - 1, r.y + r.height - 1); + } else paintRect(g, (placement == "left") ? r.width - 1 : 0, (placement == "top") ? r.height - 1 : 0, horizontal ? bounds.width : (bounds.width - r.width + 1), horizontal ? (bounds.height - r.height + 1) : bounds.height, enabled ? c_border : c_disable, c_bg, true, true, true, true, true); + Color bg = (Color) get(selectedtab, "background"); + if (bg == null) bg = c_bg; // paint selected tab - paintRect(g, r.x, r.y, r.width, r.height, enabled ? c_border : c_disable, c_bg, + paintRect(g, r.x, r.y, stacked ? r.width: r.width, r.height, enabled ? c_border : c_disable, bg, (placement != "bottom"), (placement != "right"), - (placement != "top"), (placement != "left"), true); + (placement != "top") && !stacked, (placement != "left"), true); if (focus) { g.setColor(c_focus); g.drawRect(r.x + ((placement != "right") ? 2 : 0), r.y + ((placement != "bottom") ? 2 : 0), - r.width - (horizontal ? 5 : 3), r.height - (horizontal ? 3 : 5)); + r.width - ((horizontal || stacked)? 5 : 3), r.height - ((horizontal || stacked) ? 3 : 5)); } paintContent(selectedtab, g, clipx, clipy, clipwidth, clipheight, r.x + dx, r.y + dy, r.width - dw, r.height - dh, @@ -1653,6 +1858,19 @@ Object comp = get(selectedtab, ":comp"); if ((comp != null) && getBoolean(comp, "visible", true)) { + if (stacked) { + Rectangle cr = getRectangle(comp, "bounds"); + if (cr == null) { + cr = new Rectangle(); + set(comp, "bounds", cr); + } + cr.y = r.height + 1; + doLayout(comp); + g.setColor(enabled ? c_border : c_disable); + g.drawLine(0, r.y + r.height - 1, 0, r.y + r.height - 1 + cr.height + 3); + g.drawLine(bounds.width - 1, r.y + r.height - 1, bounds.width - 1, r.y + r.height - 1 + cr.height + 3); + g.drawLine(0, r.y + r.height - 1 + cr.height + 3, bounds.width - 1, r.y + r.height - 1 + cr.height + 3); + } clipx -= r.x; clipy -= r.y; g.translate(r.x, r.y); // relative to tab paint(g, clipx, clipy, clipwidth, clipheight, comp, enabled); clipx += r.x; clipy += r.y; g.translate(-r.x, -r.y); @@ -1699,7 +1917,7 @@ if ((tooltipowner != null) && (component == content)) { Rectangle r = getRectangle(tooltipowner, ":tooltipbounds"); paintRect(g, r.x, r.y, r.width, r.height, - c_border, c_bg, true, true, true, true, true); + c_border, c_textbg, true, true, true, true, true); String text = getString(tooltipowner, "tooltip", null); g.setColor(c_text); g.drawString(text, r.x + 2, r.y + g.getFontMetrics().getAscent() + 2); //+nullpointerexception @@ -1796,6 +2014,7 @@ else if ("menubar" == classname) { Object selected = get(component, "selected"); int lastx = 0; + boolean above = getString(component, "placement", "bottom") == "top"; for (Object menu = get(component, ":comp"); menu != null; menu = get(menu, ":next")) { Rectangle mb = getRectangle(menu, "bounds"); @@ -1803,10 +2022,13 @@ if (clipx >= mb.x + mb.width) { continue; } boolean menuenabled = enabled && getBoolean(menu, "enabled", true); boolean armed = (selected == menu); - boolean hoover = (selected == null) && (insidepart == menu); + boolean hover = (selected == null) && (insidepart == menu); + Color bg = (Color) get(menu, "background"); + if (bg == null) bg = enabled ? (menuenabled ? (armed ? c_select : (hover ? c_hover : c_ctrl)) : c_ctrl) : c_bg; + else bg = enabled ? (menuenabled ? (armed ? c_select : (hover ? c_hover : bg)) : c_ctrl) : bg; paintRect(g, mb.x, 0, mb.width, bounds.height, enabled ? c_border : c_disable, - enabled ? (menuenabled ? (armed ? c_select : (hoover ? c_hover : c_ctrl)) : c_ctrl) : c_bg, - armed, armed, true, armed, true); + bg, + armed || above, armed, armed || !above, armed, true); paintContent(menu, g, clipx, clipy, clipwidth, clipheight, mb.x + 4, 1, mb.width, bounds.height, menuenabled ? c_text : c_disable, "left", true); @@ -1814,7 +2036,9 @@ } paintRect(g, lastx, 0, bounds.width - lastx, bounds.height, enabled ? c_border : c_disable, enabled ? c_ctrl : c_bg, - false, false, true, false, true); + above, false, true, false, true); + //g.setColor(enabled ? c_border : c_disable); + //g.drawLine(bounds.width, 0, bounds.width, bounds.height - 1); } else if (":popup" == classname) { paintRect(g, 0, 0, bounds.width, bounds.height, @@ -1941,8 +2165,9 @@ g.setColor(c_focus); g.fillRect(1 + left - offset + caret, 1, 1 + evm, height - 2 + evm); } - - g.setColor(enabled ? c_text : c_disable); + Color fg = (Color) get(component, "foreground"); + if (fg == null) fg = c_text; + g.setColor(enabled ? fg : c_disable); int fx = 2 + left - offset; int fy = (height + fm.getAscent() - fm.getDescent()) / 2; if (hidden) { @@ -2048,8 +2273,11 @@ boolean hneed = (horizontal != null); boolean vneed = (vertical != null); if (("panel" != classname) && ("dialog" != classname)) { + boolean border = ("textarea" == classname) ? getBoolean(component, "border", true) : true; + Color bg = (Color)get(component, "background"); + if (bg == null) bg = border ? c_textbg : c_bg; paintRect(g, port.x - 1, port.y - 1, port.width + (vneed ? 1 : 2), port.height + (hneed ? 1 : 2), - enabled ? c_border : c_disable, c_textbg, true, true, !hneed, !vneed, true); + enabled ? c_border : c_disable, bg, border, border, !hneed && border, !vneed && border, true); if ("table" == classname) { Object header = get(component, "header"); if (header != null) { @@ -2059,7 +2287,6 @@ if (i != 0) { column = get(column, ":next"); } boolean lastcolumn = (i == columnwidths.length - 1); int width = lastcolumn ? (port.width - x + 2) : columnwidths[i]; - paintRect(g, x - view.x, 0, width, port.y - 1, enabled ? c_border : c_disable, enabled ? c_ctrl : c_bg, true, true, false, lastcolumn, true); @@ -2105,12 +2332,16 @@ char[] chars = (char[]) get(component, ":text"); int start = focus ? getInteger(component, "start", 0) : 0; int end = focus ? getInteger(component, "end", 0) : 0; + boolean border = getBoolean(component, "border", true); + boolean editable = getBoolean(component, "editable", true); int is = Math.min(start, end); int ie = Math.max(start, end); Font currentfont = (Font) get(component, "font"); if (currentfont != null) { g.setFont(currentfont); } FontMetrics fm = g.getFontMetrics(); int fontascent = fm.getAscent(); int fontheight = fm.getHeight(); int ascent = 1; + Color fg = (Color) get(component, "foreground"); + if (fg == null) fg = c_text; for (int i = 0, j = 0; j <= chars.length; j++) { if ((j == chars.length) || (chars[j] == '\n')) { @@ -2124,9 +2355,9 @@ g.setColor(c_select); g.fillRect(1 + xs, ascent, xe - xs + evm, fontheight + evm); } - g.setColor(enabled ? c_text : c_disable); + g.setColor(enabled ? fg : c_disable); g.drawChars(chars, i, j - i, 1, ascent + fontascent); - if (focus && (end >= i) && (end <= j)) { + if (focus && (end >= i) && (end <= j) && editable) { int caret = fm.charsWidth(chars, i, end - i); g.setColor(c_focus); g.fillRect(caret, ascent, 1 + evm, fontheight + evm); @@ -2136,6 +2367,7 @@ i = j + 1; } } + if (currentfont != null) { g.setFont(font); } } else if (":combolist" == classname) { Object lead = get(component, ":lead"); @@ -2785,6 +3017,8 @@ } if (newvalue != selected) { setInteger(component, "selected", newvalue, 0); + String placement = getString(component, "placement", "top"); + if (placement == "stacked") doLayout(component); checkOffset(component); repaint(component); invoke(component, getItem(component, newvalue), "action"); @@ -3411,7 +3645,7 @@ if (id == MouseEvent.MOUSE_ENTERED) { setTimer(750L); } - else if (id == MouseEvent.MOUSE_EXITED) { + else if (id == MouseEvent.MOUSE_EXITED || id == MouseEvent.MOUSE_PRESSED) { hideTip(); } if (!getBoolean(component, "enabled", true)) { return; } @@ -3556,6 +3790,8 @@ } else { setInteger(component, "selected", current, 0); + String placement = getString(component, "placement", "top"); + if (placement == "stacked") doLayout(component); //Object tabcontent = getItem(component, current); //setFocus((tabcontent != null) ? tabcontent : component); setNextFocusable(component, false); @@ -4046,8 +4282,17 @@ String text = getString(component, "text", null); if (text != null) { try { - String value = String.valueOf( - Integer.parseInt(text) + ((part == "up") ? 1 : -1)); + int max = getInteger(component, "maximum"); + int min = getInteger(component, "minimum"); + int step = getInteger(component, "step"); + int val = Integer.parseInt(text); + if (part == "up") { + if (val + step <= max) val += step; + } else { + if (val - step >= min) val -= step; + } + String value = String.valueOf(val); + setInteger(component, "value", val); setString(component, "text", value, null); setInteger(component, "start", value.length(), 0); setInteger(component, "end", 0, 0); @@ -4062,7 +4307,7 @@ /** * */ - private boolean invoke(Object component, Object part, String event) { + protected boolean invoke(Object component, Object part, String event) { Object method = get(component, event); if (method != null) { invokeImpl(method, component, part); @@ -4509,7 +4754,7 @@ (classname == "tabbedpane") || (forced && (classname == "splitpane"))) { for (Object comp = component; comp != null;) { // component and parents are enabled and visible - if (!getBoolean(comp, "enabled", true) || !getBoolean(comp, "visible", true) ) { + if (!getBoolean(comp, "enabled", true) || !getBoolean(comp, "visible", true)) { return false; } Object parent = getParent(comp); @@ -4629,7 +4874,8 @@ } /** - * Gets the index of the first selected item in the given component (list, table, or tree) + * Gets the index of the first selected item in the given component + * (list, table, tree, tabbedpane or combobox) * * @param component a widget * @return the first selected index or -1 @@ -4648,7 +4894,8 @@ } /** - * Gets the first selected item of the given component (list, table, or tree) + * Gets the first selected item of the given component + * (list, table, tree, tabbedpane or combobox) * * @param component a widget * @return the first selected item or null @@ -4709,7 +4956,7 @@ } /** - * Removes all the components from this container's specified list + * Removes all the components from this container * * @param component the specified container */ @@ -4732,7 +4979,7 @@ } /** - * Returns the subcomponent of the given component's specified list at the given index + * Returns the subcomponent of the given component at the given index * * @param component a specified container * @param index the index of the component to get @@ -5029,10 +5276,14 @@ /** * Binds the specified key to the specified value, and stores in this component. - * <i>Null</i> value removes the property. Use the parameter tag in the xml - * resource to bind a string value, the format is: <i>parameter='key=value'</i> + * <i>Null</i> value removes the property. Previously existing value, if any, is + * silently replaced. + * <p>Use the <code>property</code> tag in the XML + * resource to bind a string value, the format is: <i>property='key=value'</i>. + * For multiple key/value pairs use the format: + * <i>property='key1=value1';key2=value2'</i>. * - * @param component the hashtable is binded to this component + * @param component the property is bound to this component * @param key the client property key * @param value the new client property value */ @@ -5052,7 +5303,7 @@ /** * Returns the value of the property with the specified key. * - * @param component searches the hashtable of this component + * @param component use this component * @param key the client property key * @return the value to which the key is mapped or null if the key is not mapped to any value */ @@ -5460,7 +5711,7 @@ ("checkboxmenuitem" == classname) || ("separator" == classname))) || ((("panel" == parentclass) || ("desktop" == parentclass) || ("splitpane" == parentclass) || ("dialog" == parentclass) || - ("tab" == parentclass)) && instance(classname, "component"))) { + ("tab" == parentclass)) && instance(classname, "component") && (classname != "popupmenu"))) { insertItem(parent, ":comp", component, index); set(component, ":parent", parent); } @@ -5631,7 +5882,7 @@ // ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- /** - * Sets the given property pair (key and value) for the component + * Sets the given attribute (String value) for the component */ public void setString(Object component, String key, String value) { Object[] definition = getDefinition(getClass(component), key, "string"); @@ -5642,14 +5893,16 @@ } /** - * Gets the property value of the given component by the property key + * Gets the String attribute value of the given component by the attribute key */ public String getString(Object component, String key) { - return (String) get(component, key, "string"); + Object[] definition = getDefinition(getClass(component), key, "string"); + return getString(component, (String) definition[1], + (String) definition[3]); } /** - * Sets the given property pair (key and value) for the component + * Sets the given attribute (String value selected from available choices) for the component */ public void setChoice(Object component, String key, String value) { Object[] definition = getDefinition(getClass(component), key, "choice"); @@ -5661,7 +5914,8 @@ } /** - * Gets the property value of the given component by the property key + * Gets the String attribute value of the given component by the attribute key. The value + * returned is equal to one of available choices. */ public String getChoice(Object component, String key) { Object[] definition = getDefinition(getClass(component), key, "choice"); @@ -5670,7 +5924,7 @@ } /** - * Sets the given property pair (key and value) for the component + * Sets the given attribute (boolean value) for the component */ public void setBoolean(Object component, String key, boolean value) { Object[] definition = getDefinition(getClass(component), key, "boolean"); @@ -5681,14 +5935,14 @@ } /** - * Gets the property value of the given component by the property key + * Gets the boolean attribute value of the given component by the attribute key */ public boolean getBoolean(Object component, String key) { return get(component, key, "boolean") == Boolean.TRUE; } /** - * Sets the given property pair (key and value) for the component + * Sets the given attribute (int value) for the component */ public void setInteger(Object component, String key, int value) { Object[] definition = getDefinition(getClass(component), key, "integer"); @@ -5699,14 +5953,14 @@ } /** - * Gets the property value of the given component by the property key + * Gets the int attribute value of the given component by the attribute key */ public int getInteger(Object component, String key) { return ((Integer) get(component, key, "integer")).intValue(); } /** - * Sets the given property pair (key and value) for the component + * Sets the given attribute (java.awt.Image value) for the component */ public void setIcon(Object component, String key, Image icon) { Object[] definition = getDefinition(getClass(component), key, "icon"); @@ -5716,7 +5970,7 @@ } /** - * Gets the property value of the given component by the property key + * Gets the java.awt.Image attribute value of the given component by the attribute key */ public Image getIcon(Object component, String key) { return (Image) get(component, key, "icon"); @@ -5881,6 +6135,9 @@ */ private boolean setString(Object component, String key, String value, String defaultvalue) { + if (key.equals("text") || key.equals("tooltip")) { + putProperty(component, "i18n." + key, null); + } return set(component, key, value); } @@ -5889,8 +6146,40 @@ */ private String getString(Object component, String key, String defaultvalue) { - Object value = get(component, key); - return (value == null) ? defaultvalue : (String) value; + String text = (String)get(component, key); + if (text == null) return defaultvalue; + if (!(key.equals("text") || key.equals("tooltip"))) return text; + if (langResource != null) { + boolean i18n = getBoolean(component, "i18n", true) && allI18n; + if (i18n) { + String ikey = (String)getProperty(component, "i18n." + key); + // initialize + if (ikey == null) { + ikey = text; + putProperty(component, "i18n." + key, ikey); + } else if (ikey.equals("__NONE__")) return text; + String itext = null; + try { + itext = langResource.getString(ikey); + if (itext != null) { + text = itext; + } + } catch (Exception e) { + // not found. Try default + if (langResourceDefault != null) { + try { + itext = langResourceDefault.getString(ikey); + if (itext != null) { + text = itext; + }; + } catch (Exception e1) { + putProperty(component, "i18n." + key, "__NONE__"); + } + } + } + } + } + return text; } /** @@ -6065,6 +6354,7 @@ { "string", "name", "", null }, { "boolean", "enabled", "paint", Boolean.TRUE }, { "boolean", "visible", "parent", Boolean.TRUE }, + { "boolean", "i18n", "validate", Boolean.FALSE }, { "string", "tooltip", "", null }, { "font", "font", "validate", null }, { "color", "foreground", "paint", null }, @@ -6088,13 +6378,14 @@ "label", "component", new Object[][] { { "string", "text", "validate", null }, { "icon", "icon", "validate", null }, + { "boolean", "i18n", "validate", Boolean.FALSE }, { "choice", "alignment", "validate", leftcenterright }, { "integer", "mnemonic", "paint", integer_1 }, { "component", "for", "", null } }, "button", "label", new Object[][] { { "choice", "alignment", "validate", new String[] { "center", "left", "right" } }, { "method", "action", "", null }, - { "choice", "type", "", new String[] { "normal", "default", "cancel" , "link"} } + { "choice", "type", "", new String[] { "normal", "default", "cancel", "link" } } }, "checkbox", "label", new Object[][] { { "boolean", "selected", "paint", Boolean.FALSE }, //...group @@ -6107,6 +6398,7 @@ "choice", null, new Object[][] { { "string", "name", "", null }, { "boolean", "enabled", "paint", Boolean.TRUE }, + { "boolean", "i18n", "validate", Boolean.FALSE }, { "string", "text", "", null }, { "icon", "icon", "", null }, { "choice", "alignment", "", leftcenterright }, @@ -6119,6 +6411,7 @@ { "string", "text", "layout", "" }, { "integer", "columns", "validate", integer0 }, { "boolean", "editable", "paint", Boolean.TRUE }, + { "boolean", "i18n", "validate", Boolean.FALSE }, { "integer", "start", "layout", integer0 }, { "integer", "end", "layout", integer0 }, { "method", "action", "", null }, @@ -6129,10 +6422,11 @@ "passwordfield", "textfield", null, "textarea", "textfield", new Object[][] { { "integer", "rows", "validate", integer0 }, + { "boolean", "border", "validate", Boolean.TRUE }, { "boolean", "wrap", "layout", Boolean.FALSE } }, "tabbedpane", "component", new Object[][] { { "choice", "placement", "validate", - new String[] { "top", "left", "bottom", "right" } }, + new String[] { "top", "left", "bottom", "right", "stacked" } }, { "integer", "selected", "paint", integer0 }, { "method", "action", "", null } }, //...focus "tab", "choice", new Object[][] { @@ -6146,6 +6440,7 @@ { "integer", "gap", "validate", integer0 }, { "string", "text", "validate", null }, { "icon", "icon", "validate", null }, + { "boolean", "i18n", "validate", Boolean.FALSE }, { "boolean", "border", "validate", Boolean.FALSE }, { "boolean", "scrollable", "validate", Boolean.FALSE } }, "desktop", "component", null, @@ -6153,7 +6448,11 @@ { "string", "text", "", null }, { "icon", "icon", "", null }, { "boolean", "modal", "", Boolean.FALSE } }, - "spinbox", "textfield", null, //... + "spinbox", "textfield", new Object[][] { + { "integer", "minimum", "paint", integer0 }, //...checkvalue + { "integer", "maximum", "paint", new Integer(100) }, + { "integer", "step", "paint", integer1 }, + { "integer", "value", "paint", integer0 } }, "progressbar", "component", new Object[][] { { "choice", "orientation", "validate", orientation }, { "integer", "minimum", "paint", integer0 }, //...checkvalue @@ -6201,7 +6500,10 @@ { "boolean", "selected", "", Boolean.FALSE }, { "boolean", "expanded", "", Boolean.TRUE } }, "separator", "component", null, - "menubar", "component", null, + "menubar", "component", new Object[][] { + { "choice", "placement", "validate", + new String[] { "top", "bottom"} } + }, "menu", "choice", new Object[][] { { "integer", "mnemonic", "paint", integer_1 } }, "menuitem", "choice", new Object[][] { |
From: <ab...@us...> - 2003-05-09 00:37:40
|
Update of /cvsroot/thinlet/thinlet/examples/amazon In directory sc8-pr-cvs1:/tmp/cvs-serv27032/amazon Log Message: Directory /cvsroot/thinlet/thinlet/examples/amazon added to the repository |
From: <ab...@us...> - 2003-05-09 00:01:44
|
Update of /cvsroot/thinlet/thinlet/amazon/browser In directory sc8-pr-cvs1:/tmp/cvs-serv32680/amazon/browser Removed Files: AmazonBrowser.java amazonbrowser.xml manifest.mf Log Message: Move Demo, Calculator, AmazonBrowser/Explorer, common under /examples. This helps to determine which parts are core sources, and which are example applications. --- AmazonBrowser.java DELETED --- --- amazonbrowser.xml DELETED --- --- manifest.mf DELETED --- |
From: <ab...@us...> - 2003-05-06 23:19:57
|
Update of /cvsroot/thinlet/thinlet/src/thinlet In directory sc8-pr-cvs1:/tmp/cvs-serv22614 Modified Files: Thinlet.java Log Message: Fix getSelectedIndex and getSelectedItem so that it works with tabbedpane and combobox. Index: Thinlet.java =================================================================== RCS file: /cvsroot/thinlet/thinlet/src/thinlet/Thinlet.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- Thinlet.java 1 May 2003 20:38:22 -0000 1.15 +++ Thinlet.java 6 May 2003 23:19:53 -0000 1.16 @@ -4635,6 +4635,10 @@ * @return the first selected index or -1 */ public int getSelectedIndex(Object component) { + String classname = getClass(component); + if (classname == "tabbedpane" || classname == "combobox") { + return getInteger(component, "selected"); + } Object item = get(component, ":comp"); for (int i = 0; item != null; i++) { if (getBoolean(item, "selected", false)) { return i; } @@ -4651,6 +4655,9 @@ */ public Object getSelectedItem(Object component) { String classname = getClass(component); + if (classname == "tabbedpane" || classname == "combobox") { + return getItemImpl(component, ":comp", getInteger(component, "selected")); + } for (Object item = findNextItem(component, classname, null); item != null; item = findNextItem(component, classname, item)) { if (getBoolean(item, "selected", false)) { return item; } |
From: <ab...@us...> - 2003-05-01 20:38:26
|
Update of /cvsroot/thinlet/thinlet/src/thinlet In directory sc8-pr-cvs1:/tmp/cvs-serv7682 Modified Files: Thinlet.java Log Message: Fixes for the "link" widget: * bring back focus-ability * use type="link" instead of link="true" * hand cursor code, contributed by Eugene Klein Fix for the table column clipping bug. Disable angled lines in the tree widget, until they are ready for use. Index: Thinlet.java =================================================================== RCS file: /cvsroot/thinlet/thinlet/src/thinlet/Thinlet.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Thinlet.java 29 Apr 2003 17:58:14 -0000 1.14 +++ Thinlet.java 1 May 2003 20:38:22 -0000 1.15 @@ -1012,7 +1012,7 @@ return getSize(component, 0, 0); } if (("button" == classname) || ("togglebutton" == classname)) { - if (getBoolean(component, "link", false)) + if (getChoice(component, "type") == "link") return getSize(component, ITEM.left + ITEM.right, ITEM.top + ITEM.bottom); else @@ -1489,7 +1489,7 @@ } else if (("button" == classname) || ("togglebutton" == classname)) { boolean toggled = ("togglebutton" == classname) && getBoolean(component, "selected", false); - boolean link = ("button" == classname) && getBoolean(component, "link", false); + boolean link = ("button" == classname) && (getChoice(component, "type") == "link"); if (link) { g.setColor(enabled ? ((inside != pressed) ? c_hover : (pressed ? c_press : c_bg)) : c_bg); g.fillRect(0, 0, bounds.width, bounds.height); @@ -1500,7 +1500,7 @@ enabled ? ((inside != pressed) ? c_hover : ((pressed || toggled) ? c_press : c_ctrl)) : (toggled ? c_press : c_bg), true, true, true, true, true); } - if (focus && !link) { + if (focus) { g.setColor(c_focus); g.drawRect(2, 2, bounds.width - 5, bounds.height - 5); } @@ -2198,7 +2198,7 @@ if ("tree" == classname) { int x = r.x - block / 2; int y = r.y + (r.height - 1) / 2; g.setColor(c_bg); - g.drawLine(x, r.y, x, y); g.drawLine(x, y, r.x, y); + //g.drawLine(x, r.y, x, y); g.drawLine(x, y, r.x, y); if (subnode) { paintRect(g, x - 4, y - 4, 9, 9, itemenabled ? c_border : c_disable, itemenabled ? c_ctrl : c_bg, true, true, true, true, true); @@ -2213,6 +2213,8 @@ for (Object cell = get(item, ":comp"); cell != null; cell = get(cell, ":next")) { if (clipx + clipwidth <= x) { break; } int iwidth = columnwidths[i]; + boolean lastcolumn = (i == columnwidths.length - 1); + if (lastcolumn) { iwidth = Math.max(iwidth, viewwidth - x); } if (clipx < x + iwidth) { boolean cellenabled = enabled && getBoolean(cell, "enabled", true); paintContent(cell, g, clipx, clipy, clipwidth, clipheight, @@ -2344,7 +2346,7 @@ String text = getString(component, "text", null); Image icon = getIcon(component, "icon", null); if ((text == null) && (icon == null)) { return; } - boolean link = getBoolean(component, "link", false); + boolean link = (getClass(component) == "button") && (getChoice(component, "type") == "link"); String alignment = getString(component, "alignment", defaultalignment); Font customfont = (text != null) ? (Font) get(component, "font") : null; if (customfont != null) { g.setFont(customfont); } @@ -3430,6 +3432,16 @@ } else invoke(component, null, "action"); } + // hand cursor for links ... + else if ( "button" == classname && (getChoice(component, "type") == "link") ) { + if ((id == MouseEvent.MOUSE_ENTERED) && (mousepressed == null) ) { + setCursor(Cursor.getPredefinedCursor( Cursor.HAND_CURSOR )); + } + else if (((id == MouseEvent.MOUSE_EXITED) && (mousepressed == null)) || + ((id == MouseEvent.MOUSE_RELEASED) && (mouseinside != component))) { + setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + } repaint(component); } } @@ -4497,7 +4509,7 @@ (classname == "tabbedpane") || (forced && (classname == "splitpane"))) { for (Object comp = component; comp != null;) { // component and parents are enabled and visible - if (!getBoolean(comp, "enabled", true) || !getBoolean(comp, "visible", true) || getBoolean(comp, "link", false)) { + if (!getBoolean(comp, "enabled", true) || !getBoolean(comp, "visible", true) ) { return false; } Object parent = getParent(comp); @@ -6074,9 +6086,8 @@ { "component", "for", "", null } }, "button", "label", new Object[][] { { "choice", "alignment", "validate", new String[] { "center", "left", "right" } }, - { "boolean", "link", "", Boolean.FALSE }, { "method", "action", "", null }, - { "choice", "type", "", new String[] { "normal", "default", "cancel" } } + { "choice", "type", "", new String[] { "normal", "default", "cancel" , "link"} } }, "checkbox", "label", new Object[][] { { "boolean", "selected", "paint", Boolean.FALSE }, //...group |
From: <ab...@us...> - 2003-04-29 17:59:13
|
Update of /cvsroot/thinlet/thinlet/demo In directory sc8-pr-cvs1:/tmp/cvs-serv8625 Modified Files: demo.xml Log Message: Demonstrate link widget. Index: demo.xml =================================================================== RCS file: /cvsroot/thinlet/thinlet/demo/demo.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- demo.xml 25 Nov 2002 18:00:49 -0000 1.2 +++ demo.xml 29 Apr 2003 17:59:08 -0000 1.3 @@ -109,6 +109,8 @@ </row> </table> </splitpane> + <separator colspan="5"/> + <button colspan="5" link="true" halign="left" text="www.thinlet.com"/> </panel> </tab> |
From: <ab...@us...> - 2003-04-29 17:58:21
|
Update of /cvsroot/thinlet/thinlet/src/thinlet In directory sc8-pr-cvs1:/tmp/cvs-serv8022 Modified Files: Thinlet.java Log Message: Implementation of new widget (variant of button), which resembles standard hypertext link. See updated Demo for example. To use, just add boolean attribute "link": <button link="true"/> Index: Thinlet.java =================================================================== RCS file: /cvsroot/thinlet/thinlet/src/thinlet/Thinlet.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Thinlet.java 15 Apr 2003 20:18:07 -0000 1.13 +++ Thinlet.java 29 Apr 2003 17:58:14 -0000 1.14 @@ -1012,8 +1012,12 @@ return getSize(component, 0, 0); } if (("button" == classname) || ("togglebutton" == classname)) { - return getSize(component, BUTTON.left + BUTTON.right, - BUTTON.top + BUTTON.bottom); + if (getBoolean(component, "link", false)) + return getSize(component, ITEM.left + ITEM.right, + ITEM.top + ITEM.bottom); + else + return getSize(component, BUTTON.left + BUTTON.right, + BUTTON.top + BUTTON.bottom); } if ("checkbox" == classname) { Dimension d = getSize(component, 0, 0); @@ -1485,11 +1489,18 @@ } else if (("button" == classname) || ("togglebutton" == classname)) { boolean toggled = ("togglebutton" == classname) && getBoolean(component, "selected", false); - paintRect(g, 0, 0, bounds.width, bounds.height, - enabled ? c_border : c_disable, - enabled ? ((inside != pressed) ? c_hover : ((pressed || toggled) ? c_press : c_ctrl)) : + boolean link = ("button" == classname) && getBoolean(component, "link", false); + if (link) { + g.setColor(enabled ? ((inside != pressed) ? c_hover : (pressed ? c_press : c_bg)) : c_bg); + g.fillRect(0, 0, bounds.width, bounds.height); + } else { + + paintRect(g, 0, 0, bounds.width, bounds.height, + enabled ? c_border : c_disable, + enabled ? ((inside != pressed) ? c_hover : ((pressed || toggled) ? c_press : c_ctrl)) : (toggled ? c_press : c_bg), true, true, true, true, true); - if (focus) { + } + if (focus && !link) { g.setColor(c_focus); g.drawRect(2, 2, bounds.width - 5, bounds.height - 5); } @@ -1497,10 +1508,16 @@ g.setColor(c_border); g.drawRect(1, 1, bounds.width - 3, bounds.height - 3); } - paintContent(component, g, clipx, clipy, clipwidth, clipheight, - BUTTON.left, BUTTON.top, bounds.width - BUTTON.left - BUTTON.right, - bounds.height - BUTTON.top - BUTTON.bottom, - enabled ? c_text : c_disable, "center", true); + if (link) + paintContent(component, g, clipx, clipy, clipwidth, clipheight, + ITEM.left, ITEM.top, bounds.width - ITEM.left - ITEM.right, + bounds.height - ITEM.top - ITEM.bottom, + enabled ? c_text : c_disable, "left", true); + else + paintContent(component, g, clipx, clipy, clipwidth, clipheight, + BUTTON.left, BUTTON.top, bounds.width - BUTTON.left - BUTTON.right, + bounds.height - BUTTON.top - BUTTON.bottom, + enabled ? c_text : c_disable, "center", true); } else if ("checkbox" == classname) { boolean selected = getBoolean(component, "selected", false); @@ -2327,6 +2344,7 @@ String text = getString(component, "text", null); Image icon = getIcon(component, "icon", null); if ((text == null) && (icon == null)) { return; } + boolean link = getBoolean(component, "link", false); String alignment = getString(component, "alignment", defaultalignment); Font customfont = (text != null) ? (Font) get(component, "font") : null; if (customfont != null) { g.setFont(customfont); } @@ -2340,6 +2358,7 @@ ta = fm.getAscent(); th = fm.getDescent() + ta; Color customfg = (Color) get(component, "foreground"); //+no if disabled + if (link && customfg == null) customfg = Color.blue; g.setColor((customfg != null) ? customfg : foreground); } int iw = 0, ih = 0; @@ -2362,6 +2381,7 @@ if (text != null) { int ty = y + (height - th) / 2 + ta; g.drawString(text, cx, ty); + if (link) g.drawLine(cx, ty + 1, cx + tw, ty + 1); if (checkmnemonic) { int mnemonic = getInteger(component, "mnemonic", -1); if ((mnemonic != -1) && (mnemonic < text.length())) { @@ -4477,7 +4497,7 @@ (classname == "tabbedpane") || (forced && (classname == "splitpane"))) { for (Object comp = component; comp != null;) { // component and parents are enabled and visible - if (!getBoolean(comp, "enabled", true) || !getBoolean(comp, "visible", true)) { + if (!getBoolean(comp, "enabled", true) || !getBoolean(comp, "visible", true) || getBoolean(comp, "link", false)) { return false; } Object parent = getParent(comp); @@ -6054,6 +6074,7 @@ { "component", "for", "", null } }, "button", "label", new Object[][] { { "choice", "alignment", "validate", new String[] { "center", "left", "right" } }, + { "boolean", "link", "", Boolean.FALSE }, { "method", "action", "", null }, { "choice", "type", "", new String[] { "normal", "default", "cancel" } } }, |
From: Andrzej B. <ab...@ge...> - 2003-04-25 20:21:57
|
KD...@tw... wrote: > Is there documentation on the latest version of Thinlets 1.13. Something > that will tell me easily all the attributes for each widgets. The one that > I downloaded is way out of date. > > Please have a look at the end of Thinlet.java. There is a "private static Object[] dtd" there. As far as I understand it, it shows you the following: * component name * component parent * attributes: - attribute type - attribute name - mode for updating the contents - a bit mysterious to me... - default value (or enumeration of allowed choices) So, based on this structure, it is easy to figure out the proper DTD, and proper XML to use. If you take for example "button". The dtd section defines it as follows: ... "button", "label", new Object[][] { { "choice", "alignment", "validate", new String[] { "center", "left", "right" } }, { "method", "action", "", null }, { "choice", "type", "", new String[] { "normal", "default", "cancel" } } }, ... From this you can see that the formal DTD can be defined as follows: <!ELEMENT button EMPTY> <!ATTLIST button &label-attributes; alignment (center | left | right) "left" action CDATA #IMPLIED type (normal | default | cancel) "normal" > where &label-attributes; means to include all attributes defined for "label". Based on this DTD, it is now easy to construct proper XML: <button alignment="center" action="myAction" type="default"/> Now, a separate problem is to understand the semantics of the above example. For now I'm afraid you have to consult the source code... but as soon as the documentation is in CVS (Robert?), there are people willing to bring it up-to-date... BTW: in this case, the type="default" means that the button will be selected by default, and if you press Enter, the action="myAction" will be invoked. Pretty much what you would expect, but the default implementation doesn't handle it... -- Best regards, Andrzej Bialecki ------------------------------------------------- Software Architect, System Integration Specialist CEN/ISSS EC Workshop, ECIMF project chair EU FP6 E-Commerce Expert/Evaluator ------------------------------------------------- FreeBSD developer (http://www.freebsd.org) |