00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */ 00002 00003 /* AbiSource Application Framework 00004 * Copyright (C) 1998 AbiSource, Inc. 00005 * Copyright (C) 2001-2003, 2009 Hubert Figuiere 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 #ifndef XAP_COCOADIALOG_FONTCHOOSER_H 00024 #define XAP_COCOADIALOG_FONTCHOOSER_H 00025 00026 #import <Cocoa/Cocoa.h> 00027 #include "xap_App.h" 00028 #include "xap_Dlg_FontChooser.h" 00029 #include "ut_misc.h" 00030 00031 #import "xap_CocoaDialog_Utilities.h" 00032 #import "xap_Cocoa_NSTableUtils.h" 00033 #import "xap_CocoaFrame.h" 00034 00035 class GR_CocoaGraphics; 00036 class XAP_CocoaDialog_FontChooser; 00037 00038 @interface XAP_CocoaDialog_FontChooserController 00039 : NSWindowController <XAP_CocoaDialogProtocol, NSTableViewDelegate> 00040 { 00041 IBOutlet NSTableView * _fontList; 00042 IBOutlet NSTableView * _styleList; 00043 IBOutlet NSTableView * _sizeList; 00044 00045 IBOutlet NSTextField * _fontLabel; 00046 IBOutlet NSTextField * _styleLabel; 00047 IBOutlet NSTextField * _sizeLabel; 00048 IBOutlet NSBox * _effectLabel; 00049 IBOutlet NSBox * _textColorLabel; 00050 IBOutlet NSBox * _textHighlightColorLabel; 00051 00052 IBOutlet NSButton * _okBtn; 00053 IBOutlet NSButton * _cancelBtn; 00054 IBOutlet NSButton * _strikeButton; 00055 IBOutlet NSButton * _underlineButton; 00056 IBOutlet NSButton * _overlineButton; 00057 IBOutlet NSButton * _hiddenButton; 00058 IBOutlet NSButton * _superscriptButton; 00059 IBOutlet NSButton * _subscriptButton; 00060 IBOutlet NSButton * _noHighlightColorButton; 00061 00062 IBOutlet NSColorWell * _textColorWell; 00063 IBOutlet NSColorWell * _textHighlightColorWell; 00064 00065 IBOutlet XAP_CocoaNSView * _preview; 00066 00067 IBOutlet NSBox * _previewBox; 00068 00069 XAP_StringListDataSource * m_fontDataSource; 00070 XAP_StringListDataSource * m_sizeDataSource; 00071 XAP_StringListDataSource * m_stylesDataSource; 00072 00073 XAP_CocoaDialog_FontChooser * _xap; 00074 } 00075 00076 -(IBAction)okAction:(id)sender; 00077 -(IBAction)cancelAction:(id)sender; 00078 -(IBAction)colorWellAction:(id)sender; 00079 -(IBAction)underlineAction:(id)sender; 00080 -(IBAction)overlineAction:(id)sender; 00081 -(IBAction)strikeoutAction:(id)sender; 00082 -(IBAction)superscriptAction:(id)sender; 00083 -(IBAction)subscriptAction:(id)sender; 00084 -(IBAction)transparentAction:(id)sender; // = no higlight color ? 00085 00086 - (void)tableViewSelectionDidChange:(NSNotification *)aNotification; 00087 00088 - (XAP_CocoaNSView*)preview; 00089 /* accessors */ 00090 -(void)setStrikeout:(bool)value; 00091 -(void)setUnderline:(bool)value; 00092 -(void)setOverline:(bool)value; 00093 -(void)setSuperscript:(bool)value; 00094 -(void)setSubscript:(bool)value; 00095 00096 -(void)selectFont:(char*)value; 00097 -(NSString*)selectedFont; 00098 -(void)selectSize:(char*)value; 00099 -(NSString*)selectedSize; 00100 -(void)selectStyle:(char*)style withWeight:(char*)weight; 00101 00102 -(NSColor*)textColor; 00103 -(void)setTextColor:(NSColor*)color; 00104 -(NSColor*)bgColor; 00105 -(void)setBgColor:(NSColor*)color; 00106 00107 @end 00108 00109 /*****************************************************************/ 00110 00111 class XAP_CocoaDialog_FontChooser : public XAP_Dialog_FontChooser 00112 { 00113 public: 00114 XAP_CocoaDialog_FontChooser(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id); 00115 virtual ~XAP_CocoaDialog_FontChooser(void); 00116 00117 virtual void runModal(XAP_Frame * pFrame); 00118 00119 static XAP_Dialog * static_constructor(XAP_DialogFactory *, XAP_Dialog_Id id); 00120 void underlineChanged(bool); 00121 void overlineChanged(bool); 00122 void strikeoutChanged(bool); 00123 void superscriptChanged(bool); 00124 void subscriptChanged(bool); 00125 void transparencyChanged(bool); 00126 void updatePreview(void); 00127 void fontRowChanged(void); 00128 void styleRowChanged(int); 00129 void sizeRowChanged(void); 00130 void fgColorChanged(void); 00131 void bgColorChanged(void); 00132 00133 // the state of what data is hidden and what is public is 00134 // pretty grave here. 00135 bool getEntryString(const char ** string); 00136 00137 /* GUI actions */ 00138 void _okAction(void); 00139 void _cancelAction(void); 00140 00141 /* GUI creation */ 00142 void _createGC(XAP_CocoaNSView* owner); 00143 void _deleteGC(void); 00144 00145 private: 00146 bool m_bSuperScriptInitialValue; 00147 bool m_bSubScriptInitialValue; 00148 00149 void _colorChanged(NSColor* color, const gchar* attr, char* buf); 00150 00151 gchar * m_currentFamily; 00152 XAP_CocoaDialog_FontChooserController* m_dlg; 00153 }; 00154 00155 00156 #endif /* XAP_COCOADIALOG_FONTCHOOSER_H */