1 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
2 
3 /* AbiSource Application Framework
4  * Copyright (C) 2004 AbiSource, Inc.
5  * Copyright (C) 2004 Francis James Franklin <fjf@alinameridon.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301 USA.
21  */
22 
23 
24 #ifndef XAP_COCOATOOLPALETTE_H
25 #define XAP_COCOATOOLPALETTE_H
26 
27 #import <Cocoa/Cocoa.h>
28 
29 #include "ap_Strings.h"
30 #include "ap_Toolbar_Id.h"
31 
32 #include "xav_Listener.h"
33 
34 class XAP_Frame;
35 class EV_Menu_ActionSet;
36 class EV_Toolbar_ActionSet;
37 class FV_View;
38 
39 @class XAP_CocoaToolPalette;
40 
41 struct XAP_CocoaPaletteRef
42 {
43 	NSString *		Name; // used internally to identify palette
44 	NSButton *		Title;
45 	NSBox *			Box;
46 };
47 
48 struct XAP_CocoaToolRef
49 {
50 	NSButton *			button;
51 	XAP_Toolbar_Id		tlbrid;
52 	AP_String_Id_Enum	ttipid;
53 };
54 
55 class XAP_CocoaToolPaletteListener : public AV_Listener
56 {
57 public:
58 	XAP_CocoaToolPaletteListener(XAP_CocoaToolPalette * pPalette);
59 
60 	virtual ~XAP_CocoaToolPaletteListener();
61 
62 	virtual bool				notify(AV_View * pView, const AV_ChangeMask mask);
63     virtual AV_ListenerType		getType(void);
64 
65 	void						setCurrentView(AV_View * view);
66 
67 private:
68 	XAP_CocoaToolPalette *	m_pPalette;
69 
70 	AV_View *				m_pView;
71 	AV_ListenerId			m_lid;
72 };
73 
74 @interface XAP_CocoaPaletteView : NSView
75 {
76 	NSMutableArray *	m_Palette;
77 }
78 - (id)init;
79 - (void)dealloc;
80 
81 - (void)addPalette:(const struct XAP_CocoaPaletteRef *)palette;
82 
83 - (void)sync;
84 @end
85 
86 @interface XAP_PaletteProperties_DataSource : NSObject
87 {
88 	NSOutlineView *		m_OutlineView;
89 	NSMutableArray *	m_PropertyLevels;
90 }
91 - (id)initWithOutlineView:(NSOutlineView *)outlineView;
92 - (void)dealloc;
93 
94 - (void)syncWithView:(FV_View *)pView;
95 
96 /* NSOutlineViewDataSource
97  */
98 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
99 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
100 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
101 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
102 
103 /* NSOutlineView delegate method
104  */
105 - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
106 - (void)outlineView:(NSOutlineView *)outlineView willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item;
107 @end
108 
109 @interface XAP_CocoaPreviewPanel : NSWindowController
110 {
111 	IBOutlet NSTextField *oPreview;
112 }
113 - (id)init;
114 - (void)dealloc;
115 - (void)windowDidLoad;
116 - (void)toggleVisibility:(id)sender;
117 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
118 - (void)setPreviewString:(NSString *)previewString;
119 @end
120 
121 @interface XAP_CocoaToolPalette : NSWindowController
122 {
123 	struct XAP_CocoaToolRef *			m_ToolChest;
124 
125 	XAP_CocoaPaletteView *				m_PaletteView;
126 
127 	XAP_PaletteProperties_DataSource *	m_Properties_DataSource;
128 
129 	IBOutlet XAP_CocoaPreviewPanel *	oPreviewPanel;
130 
131 	IBOutlet NSButton *			oTitle_Standard;
132 	IBOutlet NSButton *			oTitle_Format;
133 	IBOutlet NSButton *			oTitle_Table;
134 	IBOutlet NSButton *			oTitle_Extra;
135 	IBOutlet NSButton *			oTitle_Properties;
136 
137 	IBOutlet NSBox *			oBox_Standard;
138 	IBOutlet NSBox *			oBox_Format;
139 	IBOutlet NSBox *			oBox_Table;
140 	IBOutlet NSBox *			oBox_Extra;
141 	IBOutlet NSBox *			oBox_Properties;
142 
143 	IBOutlet NSPopUpButton *	oDocumentStyle;
144 	IBOutlet NSPopUpButton *	oFontName;
145 	IBOutlet NSPopUpButton *	oFontMemberName;
146 
147 	IBOutlet NSComboBox *		oFontSize;
148 	IBOutlet NSComboBox *		oZoom;
149 
150 	IBOutlet NSColorWell *		oColor_BG;
151 	IBOutlet NSColorWell *		oColor_FG;
152 
153 	IBOutlet NSButton *			oSwitch_BG;
154 	IBOutlet NSButton *			oSwitch_FG;
155 
156 	IBOutlet NSTextField *		oPreview;
157 
158 	IBOutlet NSOutlineView *	oProperties;
159 
160 	IBOutlet NSPanel *			oPanel;
161 
162 #ifdef defn
163 #undef defn
164 #endif
165 #define defn(T,X,Y)	IBOutlet NSButton * T;
166 #include "xap_CocoaTools.h"
167 #undef defn
168 
169 	NSMutableArray *				m_pFontFamilies;
170 
171 	NSString *						m_pCurrentFontFamily;
172 
173 	const EV_Menu_ActionSet *		m_pMenuActionSet;
174 	const EV_Toolbar_ActionSet *	m_pToolbarActionSet;
175 	const EV_EditMethodContainer *	m_pEditMethodContainer;
176 
177 	XAP_CocoaToolPaletteListener *	m_Listener;
178 
179 	AV_View *		m_pViewCurrent;
180 	AV_View *		m_pViewPrevious;
181 
182 	XAP_Frame *		m_pFrameCurrent;
183 	XAP_Frame *		m_pFramePrevious;
184 }
185 + (XAP_CocoaToolPalette *)instance:(id)sender;
186 + (BOOL)instantiated;
187 
188 - (id)init;
189 - (void)dealloc;
190 
191 - (void)windowDidLoad;
192 - (void)close;
193 - (void)windowWillClose:(NSNotification *)aNotification;
194 
195 - (void)toggleVisibility:(id)sender;
196 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
197 
198 + (void)setPreviewText:(id)previewText;
199 - (void)setPreviewString:(NSString *)previewString;
200 
201 - (NSWindow *)previewPanel;
202 
203 - (void)setColor:(XAP_Toolbar_Id)tlbrid;
204 
205 - (IBAction)aColor_FG:(id)sender;
206 - (IBAction)aColor_BG:(id)sender;
207 - (IBAction)aSwitch_FG:(id)sender;
208 - (IBAction)aSwitch_BG:(id)sender;
209 - (IBAction)aDocumentStyle:(id)sender;
210 - (IBAction)aFontName:(id)sender;
211 - (IBAction)aFontMemberName:(id)sender;
212 - (IBAction)aFontSize:(id)sender;
213 - (IBAction)aTitle_click:(id)sender;
214 - (IBAction)aTB_click:(id)sender;
215 - (IBAction)aZoom:(id)sender;
216 
217 - (void)sync;
218 
219 - (void)setCurrentView:(AV_View *)view inFrame:(XAP_Frame *)frame;
220 
221 - (void)rebuildFontFamilyPopUp;
222 - (void)syncPopUpsForFont:(NSString *)requestedFontFamilyName;
223 @end
224 
225 #endif /* ! XAP_COCOATOOLPALETTE_H */
226