001: /*
002: * TextAreaOptionPane.java - Text area options panel
003: * :tabSize=8:indentSize=8:noTabs=false:
004: * :folding=explicit:collapseFolds=1:
005: *
006: * Copyright (C) 1998, 1999, 2000 Slava Pestov
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022:
023: package org.gjt.sp.jedit.options;
024:
025: //{{{ Imports
026: import javax.swing.*;
027: import java.awt.event.ActionEvent;
028: import java.awt.event.ActionListener;
029: import java.awt.*;
030: import org.gjt.sp.jedit.textarea.AntiAlias;
031: import org.gjt.sp.jedit.jEdit;
032: import org.gjt.sp.jedit.AbstractOptionPane;
033: import org.gjt.sp.jedit.gui.FontSelector;
034: import org.gjt.sp.jedit.gui.ColorWellButton;
035:
036: //}}}
037:
038: /**
039: * @author Slava Pestov
040: * @version $Id: TextAreaOptionPane.java 7143 2006-09-29 09:08:24Z kpouer $
041: */
042: public class TextAreaOptionPane extends AbstractOptionPane {
043: //{{{ TextAreaOptionPane constructor
044: public TextAreaOptionPane() {
045: super ("textarea");
046: } //}}}
047:
048: //{{{ _init() method
049: public void _init() {
050: /* Font */
051: font = new FontSelector(jEdit.getFontProperty("view.font"));
052:
053: addComponent(jEdit.getProperty("options.textarea.font"), font);
054:
055: /* Text color */
056: addComponent(jEdit.getProperty("options.textarea.foreground"),
057: foregroundColor = new ColorWellButton(jEdit
058: .getColorProperty("view.fgColor")),
059: GridBagConstraints.VERTICAL);
060:
061: /* Background color */
062: addComponent(jEdit.getProperty("options.textarea.background"),
063: backgroundColor = new ColorWellButton(jEdit
064: .getColorProperty("view.bgColor")),
065: GridBagConstraints.VERTICAL);
066:
067: /* Caret color, caret blink, block caret */
068: blinkCaret = new JCheckBox(jEdit.getProperty("options.textarea"
069: + ".blinkCaret"));
070: blinkCaret.setSelected(jEdit
071: .getBooleanProperty("view.caretBlink"));
072:
073: blockCaret = new JCheckBox(jEdit.getProperty("options.textarea"
074: + ".blockCaret"));
075: blockCaret.setSelected(jEdit
076: .getBooleanProperty("view.blockCaret"));
077:
078: Box caretSettings = new Box(BoxLayout.X_AXIS);
079: caretSettings.add(new JLabel(jEdit
080: .getProperty("options.textarea.caret")));
081: caretSettings.add(Box.createHorizontalStrut(6));
082: caretSettings.add(blinkCaret);
083: caretSettings.add(blockCaret);
084:
085: addComponent(caretSettings, caretColor = new ColorWellButton(
086: jEdit.getColorProperty("view.caretColor")),
087: GridBagConstraints.VERTICAL);
088:
089: /* Selection color */
090: addComponent(jEdit.getProperty("options.textarea.selection"),
091: selectionColor = new ColorWellButton(jEdit
092: .getColorProperty("view.selectionColor")),
093: GridBagConstraints.VERTICAL);
094:
095: /* Multiple selection color */
096: addComponent(
097: jEdit.getProperty("options.textarea.multipleSelection"),
098: multipleSelectionColor = new ColorWellButton(
099: jEdit
100: .getColorProperty("view.multipleSelectionColor")),
101: GridBagConstraints.VERTICAL);
102:
103: /* Line highlight */
104: lineHighlight = new JCheckBox(jEdit
105: .getProperty("options.textarea" + ".lineHighlight"));
106: lineHighlight.setSelected(jEdit
107: .getBooleanProperty("view.lineHighlight"));
108: addComponent(lineHighlight,
109: lineHighlightColor = new ColorWellButton(jEdit
110: .getColorProperty("view.lineHighlightColor")),
111: GridBagConstraints.VERTICAL);
112:
113: /* Structure highlight */
114: structureHighlight = new JCheckBox(
115: jEdit.getProperty("options.textarea"
116: + ".structureHighlight"));
117: structureHighlight.setSelected(jEdit
118: .getBooleanProperty("view.structureHighlight"));
119: addComponent(
120: structureHighlight,
121: structureHighlightColor = new ColorWellButton(
122: jEdit
123: .getColorProperty("view.structureHighlightColor")),
124: GridBagConstraints.VERTICAL);
125:
126: /* EOL markers */
127: eolMarkers = new JCheckBox(jEdit.getProperty("options.textarea"
128: + ".eolMarkers"));
129: eolMarkers.setSelected(jEdit
130: .getBooleanProperty("view.eolMarkers"));
131: addComponent(eolMarkers, eolMarkerColor = new ColorWellButton(
132: jEdit.getColorProperty("view.eolMarkerColor")),
133: GridBagConstraints.VERTICAL);
134:
135: /* Wrap guide */
136: wrapGuide = new JCheckBox(jEdit.getProperty("options.textarea"
137: + ".wrapGuide"));
138: wrapGuide.setSelected(jEdit
139: .getBooleanProperty("view.wrapGuide"));
140: addComponent(wrapGuide, wrapGuideColor = new ColorWellButton(
141: jEdit.getColorProperty("view.wrapGuideColor")),
142: GridBagConstraints.VERTICAL);
143:
144: /* Electric borders */
145: electricBorders = new JCheckBox(jEdit
146: .getProperty("options.textarea" + ".electricBorders"));
147: electricBorders.setSelected(!"0".equals(jEdit
148: .getProperty("view.electricBorders")));
149: addComponent(electricBorders);
150:
151: /* Anti-aliasing */
152:
153: antiAlias = new JComboBox(AntiAlias.comboChoices);
154: antiAlias.setToolTipText(jEdit
155: .getProperty("options.textarea.antiAlias.tooltip"));
156: AntiAlias antiAliasValue = new AntiAlias(jEdit
157: .getProperty("view.antiAlias"));
158: font.setAntiAliasEnabled(antiAliasValue.val() > 0);
159: antiAlias.addActionListener(new ActionListener() {
160: public void actionPerformed(ActionEvent evt) {
161: int idx = antiAlias.getSelectedIndex();
162: font.setAntiAliasEnabled(idx > 0);
163: font.repaint();
164: }
165: });
166: antiAlias.setSelectedIndex(antiAliasValue.val());
167: addComponent(jEdit.getProperty("options.textarea"
168: + ".antiAlias"), antiAlias);
169:
170: /* Fractional font metrics */
171: fracFontMetrics = new JCheckBox(jEdit
172: .getProperty("options.textarea" + ".fracFontMetrics"));
173: fracFontMetrics.setSelected(jEdit
174: .getBooleanProperty("view.fracFontMetrics"));
175: addComponent(fracFontMetrics);
176:
177: /* Strip trailing EOL */
178: stripTrailingEOL = new JCheckBox(jEdit
179: .getProperty("options.textArea.stripTrailingEOL"));
180: stripTrailingEOL.setSelected(jEdit
181: .getBooleanProperty("stripTrailingEOL"));
182: addComponent(stripTrailingEOL);
183:
184: } //}}}
185:
186: //{{{ _save() method
187: public void _save() {
188: jEdit.setFontProperty("view.font", font.getFont());
189:
190: jEdit.setColorProperty("view.fgColor", foregroundColor
191: .getSelectedColor());
192: jEdit.setColorProperty("view.bgColor", backgroundColor
193: .getSelectedColor());
194: jEdit.setBooleanProperty("view.caretBlink", blinkCaret
195: .isSelected());
196: jEdit.setBooleanProperty("view.blockCaret", blockCaret
197: .isSelected());
198: jEdit.setColorProperty("view.caretColor", caretColor
199: .getSelectedColor());
200: jEdit.setColorProperty("view.selectionColor", selectionColor
201: .getSelectedColor());
202: jEdit.setColorProperty("view.multipleSelectionColor",
203: multipleSelectionColor.getSelectedColor());
204: jEdit.setBooleanProperty("view.lineHighlight", lineHighlight
205: .isSelected());
206: jEdit.setColorProperty("view.lineHighlightColor",
207: lineHighlightColor.getSelectedColor());
208: jEdit.setBooleanProperty("view.structureHighlight",
209: structureHighlight.isSelected());
210: jEdit.setColorProperty("view.structureHighlightColor",
211: structureHighlightColor.getSelectedColor());
212: jEdit.setBooleanProperty("view.eolMarkers", eolMarkers
213: .isSelected());
214: jEdit.setColorProperty("view.eolMarkerColor", eolMarkerColor
215: .getSelectedColor());
216: jEdit.setBooleanProperty("view.wrapGuide", wrapGuide
217: .isSelected());
218: jEdit.setColorProperty("view.wrapGuideColor", wrapGuideColor
219: .getSelectedColor());
220: jEdit.setIntegerProperty("view.electricBorders",
221: electricBorders.isSelected() ? 3 : 0);
222: AntiAlias nv = new AntiAlias(jEdit
223: .getProperty("view.antiAlias"));
224: nv.set(antiAlias.getSelectedIndex());
225: jEdit.setProperty("view.antiAlias", nv.toString());
226: jEdit.setBooleanProperty("view.fracFontMetrics",
227: fracFontMetrics.isSelected());
228: jEdit.setBooleanProperty("stripTrailingEOL", stripTrailingEOL
229: .isSelected());
230: } //}}}
231:
232: //{{{ Private members
233: private FontSelector font;
234: private ColorWellButton foregroundColor;
235: private ColorWellButton backgroundColor;
236: private JCheckBox blinkCaret;
237: private JCheckBox blockCaret;
238: private ColorWellButton caretColor;
239: private ColorWellButton selectionColor;
240: private ColorWellButton multipleSelectionColor;
241: private JCheckBox lineHighlight;
242: private ColorWellButton lineHighlightColor;
243: private JCheckBox structureHighlight;
244: private ColorWellButton structureHighlightColor;
245: private JCheckBox eolMarkers;
246: private ColorWellButton eolMarkerColor;
247: private JCheckBox wrapGuide;
248: private ColorWellButton wrapGuideColor;
249: private JCheckBox electricBorders;
250: // private JCheckBox antiAlias;
251: private JComboBox antiAlias;
252: private JCheckBox fracFontMetrics;
253: private JCheckBox stripTrailingEOL;
254: //}}}
255: }
|