View Javadoc

1   /*
2    * TextAreaDefaults.java - Encapsulates default values for various settings
3    * Copyright (C) 1999 Slava Pestov
4    *
5    * You may use and modify this package for any purpose. Redistribution is
6    * permitted, in both source and binary form, provided that this notice
7    * remains intact in all source distributions of this package.
8    */
9   package com.ochafik.swing.syntaxcoloring;
10  
11  import java.awt.Color;
12  
13  import javax.swing.JPopupMenu;
14  
15  /**
16   * Encapsulates default settings for a text area. This can be passed
17   * to the constructor once the necessary fields have been filled out.
18   * The advantage of doing this over calling lots of set() methods after
19   * creating the text area is that this method is faster.
20   */
21  public class TextAreaDefaults
22  {
23  	//private static TextAreaDefaults DEFAULTS;
24  
25  	public InputHandler inputHandler;
26  	public SyntaxDocument document;
27  	public boolean editable;
28  
29  	public boolean caretVisible;
30  	public boolean caretBlinks;
31  	public boolean blockCaret;
32  	public int electricScroll;
33  
34  	public int cols;
35  	public int rows;
36  	public SyntaxStyle[] styles;
37  	public Color caretColor;
38  	public Color selectionColor;
39  	public Color lineHighlightColor;
40  	public boolean lineHighlight;
41  	public Color bracketHighlightColor;
42  	public boolean bracketHighlight;
43  	public Color eolMarkerColor;
44  	public boolean eolMarkers;
45  	public boolean paintInvalid;
46  
47  	public JPopupMenu popup;
48  
49  	/**
50  	 * Returns a new TextAreaDefaults object with the default values filled
51  	 * in.
52  	 */
53  	public static TextAreaDefaults getDefaults()
54  	{
55  		/*if(DEFAULTS == null)
56  		{*/ // we have to create a new object each time
57  			TextAreaDefaults DEFAULTS;
58  			DEFAULTS = new TextAreaDefaults();
59  
60  			DEFAULTS.inputHandler = new DefaultInputHandler();
61  			DEFAULTS.inputHandler.addDefaultKeyBindings();
62  			DEFAULTS.document = new SyntaxDocument();
63  			DEFAULTS.editable = true;
64  
65  			DEFAULTS.caretVisible = true;
66  			DEFAULTS.caretBlinks = true;
67  			DEFAULTS.electricScroll = 3;
68  
69  			DEFAULTS.cols = 80;
70  			DEFAULTS.rows = 25;
71  			DEFAULTS.styles = SyntaxUtilities.getDefaultSyntaxStyles();
72  			DEFAULTS.caretColor = Color.red;
73  			DEFAULTS.selectionColor = new Color(0xccccff);
74  			DEFAULTS.lineHighlightColor = new Color(0xe0e0e0);
75  			DEFAULTS.lineHighlight = true;
76  			DEFAULTS.bracketHighlightColor = Color.black;
77  			DEFAULTS.bracketHighlight = true;
78  			DEFAULTS.eolMarkerColor = new Color(0x009999);
79  			DEFAULTS.eolMarkers = true;
80  			DEFAULTS.paintInvalid = true;
81  		//}
82  
83  		return DEFAULTS;
84  	}
85  }