Debian Codegraph @

src/af/xap/cocoa/xap_CocoaDlg_DocComparison.cpp

raw
1 /* AbiWord
2 * Copyright (C) 2000 AbiSource, Inc.
3 * Copyright (C) 2004 Hubert Figuiere
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301 USA.
19 */
20
21 #import <Cocoa/Cocoa.h>
22
23 #include "ut_string.h"
24
25 #include "ut_string.h"
26 #include "ut_assert.h"
27 #include "ut_debugmsg.h"
28
29 #include "xap_CocoaDialog_Utilities.h"
30
31
32 #include "xap_App.h"
33 #include "xap_CocoaApp.h"
34 #include "xap_Frame.h"
35 #include "xap_Dialog.h"
36 #include "xap_Strings.h"
37 #include "xap_Dialog_Id.h"
38 #include "xap_CocoaDlg_DocComparison.h"
39 #include "xap_CocoaDialogFactory.h"
40
41 /*****************************************************************/
42
43
44 XAP_Dialog * XAP_CocoaDialog_DocComparison::static_constructor(XAP_DialogFactory * pFactory, XAP_Dialog_Id dlgid)
45 {
46 XAP_CocoaDialog_DocComparison * p = new XAP_CocoaDialog_DocComparison(pFactory,dlgid);
47 return p;
48 }
49
50 XAP_CocoaDialog_DocComparison::XAP_CocoaDialog_DocComparison(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id dlgid)
51 : XAP_Dialog_DocComparison(pDlgFactory,dlgid)
52 {
53 }
54
55
56 XAP_CocoaDialog_DocComparison::~XAP_CocoaDialog_DocComparison(void)
57 {
58 }
59
60 void XAP_CocoaDialog_DocComparison::runModal(XAP_Frame * /*pFrame*/)
61 {
62 m_dlg = [[XAP_CocoaDialog_DocComparisonController alloc] initFromNib];
63
64 // used similarly to convert between text and numeric arguments
65 [m_dlg setXAPOwner:this];
66
67 // build the dialog
68 NSWindow * window = [m_dlg window];
69 UT_ASSERT(window);
70
71 _populateWindowData();
72
73 [NSApp runModalForWindow:window];
74 [m_dlg close];
75 [m_dlg release];
76 m_dlg = nil;
77 }
78
79
80 void XAP_CocoaDialog_DocComparison::_populateWindowData(void)
81 {
82 [m_dlg populate];
83 }
84
85
86 @implementation XAP_CocoaDialog_DocComparisonController
87 - (id)initFromNib
88 {
89 return [super initWithWindowNibName:@"xap_CocoaDlg_DocComparison"];
90 }
91
92 -(void)discardXAP
93 {
94 _xap = NULL;
95 }
96
97 -(void)dealloc
98 {
99 [super dealloc];
100 }
101
102 - (void)setXAPOwner:(XAP_Dialog *)owner
103 {
104 _xap = dynamic_cast<XAP_CocoaDialog_DocComparison*>(owner);
105 }
106
107 -(void)windowDidLoad
108 {
109 if (_xap) {
110 const XAP_StringSet *pSS = XAP_App::getApp()->getStringSet();
111 LocalizeControl([self window], pSS, XAP_STRING_ID_DLG_DocComparison_WindowLabel);
112 LocalizeControl(_okBtn, pSS, XAP_STRING_ID_DLG_OK);
113
114 LocalizeControl(_docCmpBox, pSS, XAP_STRING_ID_DLG_DocComparison_DocsCompared);
115 LocalizeControl(_resultsBox, pSS, XAP_STRING_ID_DLG_DocComparison_Results);
116 LocalizeControl(_relationshipLabel, pSS, XAP_STRING_ID_DLG_DocComparison_Relationship);
117 LocalizeControl(_contentLabel, pSS, XAP_STRING_ID_DLG_DocComparison_Content);
118 LocalizeControl(_formatLabel, pSS, XAP_STRING_ID_DLG_DocComparison_Fmt);
119 LocalizeControl(_stylesLabel, pSS, XAP_STRING_ID_DLG_DocComparison_Styles);
120 }
121 }
122
123
124 - (IBAction)okAction:(id)sender
125 {
126 UT_UNUSED(sender);
127 [NSApp stopModal];
128 }
129
130 - (void)populate
131 {
132 const char * path = _xap->getPath1();
133 if(path) {
134 [_doc1 setStringValue:[NSString stringWithUTF8String:path]];
135 }
136 path = _xap->getPath2();
137 if(path) {
138 [_doc2 setStringValue:[NSString stringWithUTF8String:path]];
139 }
140 [_relationshipData setStringValue:[NSString stringWithUTF8String:_xap->getResultValue(0)]];
141 [_contentData setStringValue:[NSString stringWithUTF8String:_xap->getResultValue(1)]];
142 [_formatData setStringValue:[NSString stringWithUTF8String:_xap->getResultValue(2)]];
143 [_stylesData setStringValue:[NSString stringWithUTF8String:_xap->getResultValue(3)]];
144 }
145
146
147 @end