PageRenderTime 166ms CodeModel.GetById 150ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre14/org/gjt/sp/jedit/options/TextAreaOptionPane.java

#
Java | 220 lines | 156 code | 23 blank | 41 comment | 0 complexity | 7c3a187e759543f6a783b02d7f7d89ad MD5 | raw file
  1/*
  2 * TextAreaOptionPane.java - Text area options panel
  3 * :tabSize=8:indentSize=8:noTabs=false:
  4 * :folding=explicit:collapseFolds=1:
  5 *
  6 * Copyright (C) 1998, 1999, 2000 Slava Pestov
  7 *
  8 * This program is free software; you can redistribute it and/or
  9 * modify it under the terms of the GNU General Public License
 10 * as published by the Free Software Foundation; either version 2
 11 * of the License, or any later version.
 12 *
 13 * This program is distributed in the hope that it will be useful,
 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 16 * GNU General Public License for more details.
 17 *
 18 * You should have received a copy of the GNU General Public License
 19 * along with this program; if not, write to the Free Software
 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 21 */
 22
 23package org.gjt.sp.jedit.options;
 24
 25//{{{ Imports
 26import javax.swing.*;
 27import java.awt.event.ActionEvent;
 28import java.awt.event.ActionListener;
 29import java.awt.*;
 30import org.gjt.sp.jedit.gui.*;
 31import org.gjt.sp.jedit.*;
 32//}}}
 33
 34public class TextAreaOptionPane extends AbstractOptionPane
 35{
 36	//{{{ TextAreaOptionPane constructor
 37	public TextAreaOptionPane()
 38	{
 39		super("textarea");
 40	} //}}}
 41
 42	//{{{ _init() method
 43	public void _init()
 44	{
 45		/* Font */
 46		font = new FontSelector(jEdit.getFontProperty("view.font"));
 47
 48		addComponent(jEdit.getProperty("options.textarea.font"),font);
 49
 50		/* Text color */
 51		addComponent(jEdit.getProperty("options.textarea.foreground"),
 52			foregroundColor = new ColorWellButton(
 53			jEdit.getColorProperty("view.fgColor")),
 54			GridBagConstraints.VERTICAL);
 55
 56		/* Background color */
 57		addComponent(jEdit.getProperty("options.textarea.background"),
 58			backgroundColor = new ColorWellButton(
 59			jEdit.getColorProperty("view.bgColor")),
 60			GridBagConstraints.VERTICAL);
 61
 62		/* Caret color, caret blink, block caret */
 63		blinkCaret = new JCheckBox(jEdit.getProperty("options.textarea"
 64			+ ".blinkCaret"));
 65		blinkCaret.setSelected(jEdit.getBooleanProperty("view.caretBlink"));
 66
 67		blockCaret = new JCheckBox(jEdit.getProperty("options.textarea"
 68			+ ".blockCaret"));
 69		blockCaret.setSelected(jEdit.getBooleanProperty("view.blockCaret"));
 70
 71		Box caretSettings = new Box(BoxLayout.X_AXIS);
 72		caretSettings.add(new JLabel(jEdit.getProperty(
 73			"options.textarea.caret")));
 74		caretSettings.add(Box.createHorizontalStrut(6));
 75		caretSettings.add(blinkCaret);
 76		caretSettings.add(blockCaret);
 77
 78		addComponent(caretSettings,caretColor = new ColorWellButton(
 79			jEdit.getColorProperty("view.caretColor")),
 80			GridBagConstraints.VERTICAL);
 81
 82		/* Selection color */
 83		addComponent(jEdit.getProperty("options.textarea.selection"),
 84			selectionColor = new ColorWellButton(
 85			jEdit.getColorProperty("view.selectionColor")),
 86			GridBagConstraints.VERTICAL);
 87
 88		/* Multiple selection color */
 89		addComponent(jEdit.getProperty("options.textarea.multipleSelection"),
 90			multipleSelectionColor = new ColorWellButton(
 91			jEdit.getColorProperty("view.multipleSelectionColor")),
 92			GridBagConstraints.VERTICAL);
 93
 94		/* Line highlight */
 95		lineHighlight = new JCheckBox(jEdit.getProperty("options.textarea"
 96			+ ".lineHighlight"));
 97		lineHighlight.setSelected(jEdit.getBooleanProperty("view.lineHighlight"));
 98		addComponent(lineHighlight,lineHighlightColor = new ColorWellButton(
 99			jEdit.getColorProperty("view.lineHighlightColor")),
100			GridBagConstraints.VERTICAL);
101
102		/* Structure highlight */
103		structureHighlight = new JCheckBox(jEdit.getProperty("options.textarea"
104			+ ".structureHighlight"));
105		structureHighlight.setSelected(jEdit.getBooleanProperty(
106			"view.structureHighlight"));
107		addComponent(structureHighlight,structureHighlightColor = new ColorWellButton(
108			jEdit.getColorProperty("view.structureHighlightColor")),
109			GridBagConstraints.VERTICAL);
110
111		/* EOL markers */
112		eolMarkers = new JCheckBox(jEdit.getProperty("options.textarea"
113			+ ".eolMarkers"));
114		eolMarkers.setSelected(jEdit.getBooleanProperty("view.eolMarkers"));
115		addComponent(eolMarkers,eolMarkerColor =new ColorWellButton(
116			jEdit.getColorProperty("view.eolMarkerColor")),
117			GridBagConstraints.VERTICAL);
118
119		/* Wrap guide */
120		wrapGuide = new JCheckBox(jEdit.getProperty("options.textarea"
121			+ ".wrapGuide"));
122		wrapGuide.setSelected(jEdit.getBooleanProperty("view.wrapGuide"));
123		addComponent(wrapGuide,wrapGuideColor = new ColorWellButton(
124			jEdit.getColorProperty("view.wrapGuideColor")),
125			GridBagConstraints.VERTICAL);
126
127		/* Electric borders */
128		electricBorders = new JCheckBox(jEdit.getProperty("options.textarea"
129			+ ".electricBorders"));
130		electricBorders.setSelected(!"0".equals(jEdit.getProperty(
131			"view.electricBorders")));
132		addComponent(electricBorders);
133
134		/* Anti-aliasing */
135		antiAlias = new JCheckBox(jEdit.getProperty("options.textarea"
136			+ ".antiAlias"));
137		boolean antiAliasEnabled = jEdit.getBooleanProperty(
138			"view.antiAlias");
139		font.setAntiAliasEnabled(antiAliasEnabled);
140		antiAlias.addActionListener(new ActionListener()
141		{
142			public void actionPerformed(ActionEvent evt)
143			{
144				font.setAntiAliasEnabled(
145					antiAlias.isSelected());
146				font.repaint();
147			}
148		});
149		antiAlias.setSelected(antiAliasEnabled);
150		addComponent(antiAlias);
151
152		/* Fractional font metrics */
153		fracFontMetrics = new JCheckBox(jEdit.getProperty("options.textarea"
154			+ ".fracFontMetrics"));
155		fracFontMetrics.setSelected(jEdit.getBooleanProperty(
156			"view.fracFontMetrics"));
157		addComponent(fracFontMetrics);
158	} //}}}
159
160	//{{{ _save() method
161	public void _save()
162	{
163		jEdit.setFontProperty("view.font",font.getFont());
164
165		jEdit.setColorProperty("view.fgColor",foregroundColor
166			.getSelectedColor());
167		jEdit.setColorProperty("view.bgColor",backgroundColor
168			.getSelectedColor());
169		jEdit.setBooleanProperty("view.caretBlink",blinkCaret.isSelected());
170		jEdit.setBooleanProperty("view.blockCaret",blockCaret.isSelected());
171		jEdit.setColorProperty("view.caretColor",caretColor
172			.getSelectedColor());
173		jEdit.setColorProperty("view.selectionColor",selectionColor
174			.getSelectedColor());
175		jEdit.setColorProperty("view.multipleSelectionColor",multipleSelectionColor
176			.getSelectedColor());
177		jEdit.setBooleanProperty("view.lineHighlight",lineHighlight
178			.isSelected());
179		jEdit.setColorProperty("view.lineHighlightColor",
180			lineHighlightColor.getSelectedColor());
181		jEdit.setBooleanProperty("view.structureHighlight",structureHighlight
182			.isSelected());
183		jEdit.setColorProperty("view.structureHighlightColor",
184			structureHighlightColor.getSelectedColor());
185		jEdit.setBooleanProperty("view.eolMarkers",eolMarkers
186			.isSelected());
187		jEdit.setColorProperty("view.eolMarkerColor",
188			eolMarkerColor.getSelectedColor());
189		jEdit.setBooleanProperty("view.wrapGuide",wrapGuide
190			.isSelected());
191		jEdit.setColorProperty("view.wrapGuideColor",
192			wrapGuideColor.getSelectedColor());
193		jEdit.setIntegerProperty("view.electricBorders",electricBorders
194			.isSelected() ? 3 : 0);
195		jEdit.setBooleanProperty("view.antiAlias",antiAlias.isSelected());
196		jEdit.setBooleanProperty("view.fracFontMetrics",fracFontMetrics.isSelected());
197	} //}}}
198
199	//{{{ Private members
200	private FontSelector font;
201	private ColorWellButton foregroundColor;
202	private ColorWellButton backgroundColor;
203	private JCheckBox blinkCaret;
204	private JCheckBox blockCaret;
205	private ColorWellButton caretColor;
206	private ColorWellButton selectionColor;
207	private ColorWellButton multipleSelectionColor;
208	private JCheckBox lineHighlight;
209	private ColorWellButton lineHighlightColor;
210	private JCheckBox structureHighlight;
211	private ColorWellButton structureHighlightColor;
212	private JCheckBox eolMarkers;
213	private ColorWellButton eolMarkerColor;
214	private JCheckBox wrapGuide;
215	private ColorWellButton wrapGuideColor;
216	private JCheckBox electricBorders;
217	private JCheckBox antiAlias;
218	private JCheckBox fracFontMetrics;
219	//}}}
220}