Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/gui
In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11173/src/games/stendhal/client/gui
Modified Files:
KHtmlEdit.java KTextEdit.java
Log Message:
Made the chat log obey user defined text size
Index: KHtmlEdit.java
===================================================================
RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/KHtmlEdit.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** KHtmlEdit.java 6 Aug 2011 12:25:05 -0000 1.22
--- KHtmlEdit.java 2 Dec 2012 17:53:11 -0000 1.23
***************
*** 381,392 ****
}
- /**
- * Initialize style information for a text pane.
- *
- * @param textPane
- * The text pane.
- */
@Override
! protected void initStylesForTextPane(final JTextPane textPane) {
textPane.setContentType("text/html");
--- 381,386 ----
}
@Override
! protected void initStylesForTextPane(final JTextPane textPane, int mainTextSize) {
textPane.setContentType("text/html");
***************
*** 397,406 ****
* Configure standard styles
*/
! css.addRule("body { font-family: Dialog; font-size: " + (TEXT_SIZE + 1)
+ "pt }");
css.addRule("a { color: blue; font-style: italic }");
css.addRule("._timestamp { color: " + colorToRGB(HEADER_COLOR)
! + "; font-size: " + (TEXT_SIZE - 1)
+ "pt; font-style: italic }");
css.addRule("._header { color: " + colorToRGB(HEADER_COLOR) + " }");
--- 391,400 ----
* Configure standard styles
*/
! css.addRule("body { font-family: Dialog; font-size: " + (mainTextSize + 1)
+ "pt }");
css.addRule("a { color: blue; font-style: italic }");
css.addRule("._timestamp { color: " + colorToRGB(HEADER_COLOR)
! + "; font-size: " + (mainTextSize - 1)
+ "pt; font-style: italic }");
css.addRule("._header { color: " + colorToRGB(HEADER_COLOR) + " }");
***************
*** 479,482 ****
--- 473,477 ----
*/
protected class ActivateLinkCB implements HyperlinkListener {
+ @Override
public void hyperlinkUpdate(final HyperlinkEvent ev) {
if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
Index: KTextEdit.java
===================================================================
RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/KTextEdit.java,v
retrieving revision 1.80
retrieving revision 1.81
diff -C2 -d -r1.80 -r1.81
*** KTextEdit.java 17 Nov 2012 19:06:08 -0000 1.80
--- KTextEdit.java 2 Dec 2012 17:53:11 -0000 1.81
***************
*** 19,22 ****
--- 19,23 ----
import java.awt.BorderLayout;
import java.awt.Color;
+ import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
***************
*** 50,55 ****
*/
public class KTextEdit extends JComponent {
- /** Point size of the text. */
- protected static final int TEXT_SIZE = 11;
/** Color of the time stamp written before the lines. */
protected static final Color HEADER_COLOR = Color.gray;
--- 51,54 ----
***************
*** 95,98 ****
--- 94,107 ----
}
+ @Override
+ public void setFont(Font font) {
+ /*
+ * Dynamic font size changing tries to set the default font for
+ * KTextEdit. We don't use it, but we can signal the change of font
+ * sizes to textPane. Traditionally the chat log has used one point
+ * smaller font than the rest of the UI, so we keep that practice.
+ */
+ initStylesForTextPane(textPane, font.getSize() - 1);
+ }
/**
***************
*** 121,125 ****
textPane.addMouseListener(new TextPaneMouseListener());
! initStylesForTextPane(textPane);
setLayout(new BorderLayout());
--- 130,134 ----
textPane.addMouseListener(new TextPaneMouseListener());
! initStylesForTextPane(textPane, textPane.getFont().getSize());
setLayout(new BorderLayout());
***************
*** 151,185 ****
/**
* Initializes the basic styles.
* @param textPane
* the active text component
*/
! protected void initStylesForTextPane(final JTextPane textPane) {
!
! final Style def = StyleContext.getDefaultStyleContext().getStyle(
! StyleContext.DEFAULT_STYLE);
!
! final Style regular = textPane.addStyle("regular", def);
! StyleConstants.setFontFamily(def, "Dialog");
! StyleConstants.setFontSize(regular, TEXT_SIZE);
! Style s = textPane.addStyle("normal", regular);
! StyleConstants.setBold(s, true);
! StyleConstants.setForeground(s, HEADER_COLOR);
! s = textPane.addStyle("bold", regular);
! StyleConstants.setFontSize(regular, TEXT_SIZE + 1);
! StyleConstants.setItalic(s, true);
! StyleConstants.setBold(s, true);
! StyleConstants.setForeground(s, Color.blue);
! s = textPane.addStyle("header", regular);
! StyleConstants.setItalic(s, true);
! StyleConstants.setFontSize(s, TEXT_SIZE);
! StyleConstants.setForeground(s, HEADER_COLOR);
! s = textPane.addStyle("timestamp", regular);
! StyleConstants.setItalic(s, true);
! StyleConstants.setFontSize(s, TEXT_SIZE - 1);
! StyleConstants.setForeground(s, HEADER_COLOR);
}
--- 160,209 ----
/**
* Initializes the basic styles.
+ *
* @param textPane
* the active text component
+ * @param mainTextSize size of regular text
*/
! protected void initStylesForTextPane(final JTextPane textPane, int mainTextSize) {
! Style regular = textPane.getStyle("regular");
! if (regular == null) {
! final Style def = StyleContext.getDefaultStyleContext().getStyle(
! StyleContext.DEFAULT_STYLE);
! regular = textPane.addStyle("regular", def);
! StyleConstants.setFontFamily(def, "Dialog");
! }
! StyleConstants.setFontSize(regular, mainTextSize);
! Style s = textPane.getStyle("normal");
! if (s == null) {
! s = textPane.addStyle("normal", regular);
! StyleConstants.setBold(s, true);
! StyleConstants.setForeground(s, HEADER_COLOR);
! }
! s = textPane.getStyle("bold");
! if (s == null) {
! s = textPane.addStyle("bold", regular);
! StyleConstants.setItalic(s, true);
! StyleConstants.setBold(s, true);
! StyleConstants.setForeground(s, Color.blue);
! }
! StyleConstants.setFontSize(regular, mainTextSize + 1);
! s = textPane.getStyle("header");
! if (s == null) {
! s = textPane.addStyle("header", regular);
! StyleConstants.setItalic(s, true);
! StyleConstants.setForeground(s, HEADER_COLOR);
! }
! StyleConstants.setFontSize(s, mainTextSize);
! s = textPane.getStyle("timestamp");
! if (s == null) {
! s = textPane.addStyle("timestamp", regular);
! StyleConstants.setItalic(s, true);
! StyleConstants.setForeground(s, HEADER_COLOR);
! }
! StyleConstants.setFontSize(s, mainTextSize - 1);
}
|