00001 /* AbiWord 00002 * Copyright (C) 1998 AbiSource, Inc. 00003 * Copyright (C) 2001, 2003 Hubert Figuiere 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00018 * 02110-1301 USA. 00019 */ 00020 00021 #ifndef AP_COCOADIALOG_TAB_H 00022 #define AP_COCOADIALOG_TAB_H 00023 00024 #include "ut_types.h" 00025 #include "ap_Dialog_Tab.h" 00026 #include "xap_CocoaDialog_Utilities.h" 00027 #import "xap_Cocoa_NSTableUtils.h" 00028 00029 class XAP_CocoaFrame; 00030 class AP_CocoaDialog_Tab; 00031 class AP_CocoaDialog_Tab_Proxy; 00032 00033 00034 @interface AP_CocoaDialog_TabController : NSWindowController <XAP_CocoaDialogProtocol> 00035 { 00036 IBOutlet NSBox *_alignmentBox; 00037 IBOutlet NSCell *_barCell; 00038 IBOutlet NSButton *_cancelBtn; 00039 IBOutlet NSCell *_centerCell; 00040 IBOutlet NSButton *_clearAllBtn; 00041 IBOutlet NSButton *_clearBtn; 00042 IBOutlet NSCell *_decimalCell; 00043 IBOutlet NSTextField *_defaultTabData; 00044 IBOutlet NSTextField *_defaultTabLabel; 00045 IBOutlet NSStepper *_defaultTabStepper; 00046 IBOutlet NSCell *_leaderNoneCell; 00047 IBOutlet NSCell *_leaderDotCell; 00048 IBOutlet NSCell *_leaderDashCell; 00049 IBOutlet NSCell *_leaderUnderlineCell; 00050 IBOutlet NSBox *_leaderBox; 00051 IBOutlet NSCell *_leftCell; 00052 IBOutlet NSButton *_okBtn; 00053 IBOutlet NSCell *_rightCell; 00054 IBOutlet NSButton *_setBtn; 00055 IBOutlet NSTextField *_tabClearLabel; 00056 IBOutlet NSTableView *_tabList; 00057 IBOutlet NSTextField *_tabPositionData; 00058 IBOutlet NSTextField *_tabPositionLabel; 00059 AP_CocoaDialog_Tab* _xap; 00060 AP_CocoaDialog_Tab_Proxy* _proxy; 00061 } 00062 - (IBAction)cancelAction:(id)sender; 00063 - (IBAction)clearAction:(id)sender; 00064 - (IBAction)clearAllAction:(id)sender; 00065 - (IBAction)defaultTabAction:(id)sender; 00066 - (IBAction)defaultTabStepperAction:(id)sender; 00067 - (IBAction)okAction:(id)sender; 00068 - (IBAction)setAction:(id)sender; 00069 - (IBAction)alignmentAction:(id)sender; 00070 - (IBAction)leaderAction:(id)sender; 00071 - (IBAction)positionEditAction:(id)sender; 00072 - (void)tabListAction:(id)sender; 00073 - (id)_lookupWidget:(AP_Dialog_Tab::tControl)ctlid; 00074 @end 00075 00076 /*****************************************************************/ 00077 class AP_CocoaDialog_Tab: public AP_Dialog_Tab 00078 { 00079 public: 00080 AP_CocoaDialog_Tab(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id dlgid); 00081 virtual ~AP_CocoaDialog_Tab(void); 00082 00083 virtual void runModal(XAP_Frame * pFrame); 00084 00085 static XAP_Dialog * static_constructor(XAP_DialogFactory *, XAP_Dialog_Id dlgid); 00086 friend class AP_CocoaDialog_Tab_Proxy; 00087 protected: 00088 virtual void _controlEnable( tControl ctlid, bool value ); 00089 // we implement these so the XP dialog can set/grab our data 00090 #define SET_GATHER(a,t) virtual t _gather##a(void); \ 00091 virtual void _set##a( t ) 00092 SET_GATHER (Alignment, eTabType); 00093 SET_GATHER (Leader, eTabLeader); 00094 SET_GATHER (DefaultTabStop, const gchar*); 00095 00096 00097 // to populate the whole list 00098 virtual void _setTabList(UT_uint32 count); 00099 00100 // get/set the selected tab 00101 // the list of n tabs are index 0..(n-1) 00102 // -1 deselects everything 00103 SET_GATHER (SelectTab, UT_sint32); 00104 00105 // a pointer to the text in the edit box, MUST BE FREEd on get 00106 SET_GATHER (TabEdit, const char *); 00107 #undef SET_GATHER 00108 00109 virtual void _clearList(); 00110 00111 // private construction functions 00112 void event_OK(void); 00113 void event_Cancel(void); 00114 void event_Leader(id sender); 00115 void event_Alignment(id sender); 00116 00117 eTabType m_current_alignment; 00118 eTabLeader m_current_leader; 00119 // callbacks can fire these events 00120 private: 00121 AP_CocoaDialog_TabController* m_dlg; 00122 XAP_StringListDataSource* m_dataSource; 00123 }; 00124 00125 class AP_CocoaDialog_Tab_Proxy 00126 { 00127 public: 00128 AP_CocoaDialog_Tab_Proxy (AP_CocoaDialog_Tab* dialog) 00129 : m_dlg(dialog) { }; 00130 void cancelAction(void) 00131 { m_dlg->event_Cancel(); }; 00132 void clearAction(void) 00133 { m_dlg->_event_Clear(); }; 00134 void clearAllAction(void) 00135 { m_dlg->_event_ClearAll(); }; 00136 void okAction(void) 00137 { m_dlg->event_OK(); }; 00138 void setAction(void) 00139 { m_dlg->_event_Set(); }; 00140 void alignmentAction(id sender) 00141 { m_dlg->event_Alignment(sender); }; 00142 void leaderAction(id sender) 00143 { m_dlg->event_Leader(sender); }; 00144 void positionEditAction(void) 00145 { m_dlg->_event_TabChange(); }; 00146 void tabListAction(UT_sint32 index) 00147 { m_dlg->_event_TabSelected(index); }; 00148 private: 00149 AP_CocoaDialog_Tab* m_dlg; 00150 }; 00151 00152 #endif /* AP_COCOADIALOG_TAB_H */ 00153 00154 00155