00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 00002 00003 /* AbiSource Application Framework 00004 * Copyright (C) 2004 AbiSource, Inc. 00005 * Copyright (C) 2004 Francis James Franklin <fjf@alinameridon.com> 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00020 * 02110-1301 USA. 00021 */ 00022 00023 00024 #ifndef XAP_COCOATOOLPALETTE_H 00025 #define XAP_COCOATOOLPALETTE_H 00026 00027 #import <Cocoa/Cocoa.h> 00028 00029 #include "ap_Strings.h" 00030 #include "ap_Toolbar_Id.h" 00031 00032 #include "xav_Listener.h" 00033 00034 class XAP_Frame; 00035 class EV_Menu_ActionSet; 00036 class EV_Toolbar_ActionSet; 00037 class FV_View; 00038 00039 @class XAP_CocoaToolPalette; 00040 00041 struct XAP_CocoaPaletteRef 00042 { 00043 NSString * Name; // used internally to identify palette 00044 NSButton * Title; 00045 NSBox * Box; 00046 }; 00047 00048 struct XAP_CocoaToolRef 00049 { 00050 NSButton * button; 00051 XAP_Toolbar_Id tlbrid; 00052 AP_String_Id_Enum ttipid; 00053 }; 00054 00055 class XAP_CocoaToolPaletteListener : public AV_Listener 00056 { 00057 public: 00058 XAP_CocoaToolPaletteListener(XAP_CocoaToolPalette * pPalette); 00059 00060 virtual ~XAP_CocoaToolPaletteListener(); 00061 00062 virtual bool notify(AV_View * pView, const AV_ChangeMask mask); 00063 virtual AV_ListenerType getType(void); 00064 00065 void setCurrentView(AV_View * view); 00066 00067 private: 00068 XAP_CocoaToolPalette * m_pPalette; 00069 00070 AV_View * m_pView; 00071 AV_ListenerId m_lid; 00072 }; 00073 00074 @interface XAP_CocoaPaletteView : NSView 00075 { 00076 NSMutableArray * m_Palette; 00077 } 00078 - (id)init; 00079 - (void)dealloc; 00080 00081 - (void)addPalette:(const struct XAP_CocoaPaletteRef *)palette; 00082 00083 - (void)sync; 00084 @end 00085 00086 @interface XAP_PaletteProperties_DataSource 00087 : NSObject<NSOutlineViewDataSource, NSOutlineViewDelegate> 00088 { 00089 NSOutlineView * m_OutlineView; 00090 NSMutableArray * m_PropertyLevels; 00091 } 00092 - (id)initWithOutlineView:(NSOutlineView *)outlineView; 00093 - (void)dealloc; 00094 00095 - (void)syncWithView:(FV_View *)pView; 00096 00097 /* NSOutlineViewDataSource 00098 */ 00099 - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item; 00100 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item; 00101 - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item; 00102 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item; 00103 00104 /* NSOutlineView delegate method 00105 */ 00106 - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item; 00107 - (void)outlineView:(NSOutlineView *)outlineView willDisplayOutlineCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item; 00108 @end 00109 00110 @interface XAP_CocoaPreviewPanel : NSWindowController 00111 { 00112 IBOutlet NSTextField *oPreview; 00113 } 00114 - (id)init; 00115 - (void)dealloc; 00116 - (void)windowDidLoad; 00117 - (void)toggleVisibility:(id)sender; 00118 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem; 00119 - (void)setPreviewString:(NSString *)previewString; 00120 @end 00121 00122 @interface XAP_CocoaToolPalette : NSWindowController<NSWindowDelegate> 00123 { 00124 struct XAP_CocoaToolRef * m_ToolChest; 00125 00126 XAP_CocoaPaletteView * m_PaletteView; 00127 00128 XAP_PaletteProperties_DataSource * m_Properties_DataSource; 00129 00130 IBOutlet XAP_CocoaPreviewPanel * oPreviewPanel; 00131 00132 IBOutlet NSButton * oTitle_Standard; 00133 IBOutlet NSButton * oTitle_Format; 00134 IBOutlet NSButton * oTitle_Table; 00135 IBOutlet NSButton * oTitle_Extra; 00136 IBOutlet NSButton * oTitle_Properties; 00137 00138 IBOutlet NSBox * oBox_Standard; 00139 IBOutlet NSBox * oBox_Format; 00140 IBOutlet NSBox * oBox_Table; 00141 IBOutlet NSBox * oBox_Extra; 00142 IBOutlet NSBox * oBox_Properties; 00143 00144 IBOutlet NSPopUpButton * oDocumentStyle; 00145 IBOutlet NSPopUpButton * oFontName; 00146 IBOutlet NSPopUpButton * oFontMemberName; 00147 00148 IBOutlet NSComboBox * oFontSize; 00149 IBOutlet NSComboBox * oZoom; 00150 00151 IBOutlet NSColorWell * oColor_BG; 00152 IBOutlet NSColorWell * oColor_FG; 00153 00154 IBOutlet NSButton * oSwitch_BG; 00155 IBOutlet NSButton * oSwitch_FG; 00156 00157 IBOutlet NSTextField * oPreview; 00158 00159 IBOutlet NSOutlineView * oProperties; 00160 00161 IBOutlet NSPanel * oPanel; 00162 00163 #ifdef defn 00164 #undef defn 00165 #endif 00166 #define defn(T,X,Y) IBOutlet NSButton * T; 00167 #include "xap_CocoaTools.h" 00168 #undef defn 00169 00170 NSMutableArray * m_pFontFamilies; 00171 00172 NSString * m_pCurrentFontFamily; 00173 00174 const EV_Menu_ActionSet * m_pMenuActionSet; 00175 const EV_Toolbar_ActionSet * m_pToolbarActionSet; 00176 const EV_EditMethodContainer * m_pEditMethodContainer; 00177 00178 XAP_CocoaToolPaletteListener * m_Listener; 00179 00180 AV_View * m_pViewCurrent; 00181 AV_View * m_pViewPrevious; 00182 00183 XAP_Frame * m_pFrameCurrent; 00184 XAP_Frame * m_pFramePrevious; 00185 } 00186 + (XAP_CocoaToolPalette *)instance:(id)sender; 00187 + (BOOL)instantiated; 00188 00189 - (id)init; 00190 - (void)dealloc; 00191 00192 - (void)windowDidLoad; 00193 - (void)close; 00194 - (void)windowWillClose:(NSNotification *)aNotification; 00195 00196 - (void)toggleVisibility:(id)sender; 00197 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem; 00198 00199 + (void)setPreviewText:(id)previewText; 00200 - (void)setPreviewString:(NSString *)previewString; 00201 00202 - (NSWindow *)previewPanel; 00203 00204 - (void)setColor:(XAP_Toolbar_Id)tlbrid; 00205 00206 - (IBAction)aColor_FG:(id)sender; 00207 - (IBAction)aColor_BG:(id)sender; 00208 - (IBAction)aSwitch_FG:(id)sender; 00209 - (IBAction)aSwitch_BG:(id)sender; 00210 - (IBAction)aDocumentStyle:(id)sender; 00211 - (IBAction)aFontName:(id)sender; 00212 - (IBAction)aFontMemberName:(id)sender; 00213 - (IBAction)aFontSize:(id)sender; 00214 - (IBAction)aTitle_click:(id)sender; 00215 - (IBAction)aTB_click:(id)sender; 00216 - (IBAction)aZoom:(id)sender; 00217 00218 - (void)sync; 00219 00220 - (void)setCurrentView:(AV_View *)view inFrame:(XAP_Frame *)frame; 00221 00222 - (void)rebuildFontFamilyPopUp; 00223 - (void)syncPopUpsForFont:(NSString *)requestedFontFamilyName; 00224 @end 00225 00226 #endif /* ! XAP_COCOATOOLPALETTE_H */