Debian Codegraph @

src/af/xap/cocoa/xap_CocoaDlg_About.cpp

raw
1 /* AbiSource Application Framework
2 * Copyright (C) 1998 AbiSource, Inc.
3 * Copyright (C) 2001-2002 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 #include <stdlib.h>
23 #include <string.h>
24 #include "ut_string.h"
25 #include "ut_assert.h"
26 #include "ut_debugmsg.h"
27
28 #include "xap_App.h"
29 #include "xap_Dialog_Id.h"
30 #include "xap_CocoaApp.h"
31 #include "xap_CocoaFrame.h"
32
33 #include "xap_Dialog_Id.h"
34 #include "xap_Dlg_About.h"
35 #include "xap_CocoaDialog_Utilities.h"
36 #include "xap_CocoaDlg_About.h"
37
38 #import "xap_Cocoa_ResourceIDs.h"
39
40
41 /*****************************************************************/
42
43
44 XAP_Dialog * XAP_CocoaDialog_About::static_constructor(XAP_DialogFactory * pFactory,
45 XAP_Dialog_Id dlgid)
46 {
47 XAP_CocoaDialog_About * p = new XAP_CocoaDialog_About(pFactory,dlgid);
48 return p;
49 }
50
51 XAP_CocoaDialog_About::XAP_CocoaDialog_About(XAP_DialogFactory * pDlgFactory,
52 XAP_Dialog_Id dlgid)
53 : XAP_Dialog_About(pDlgFactory,dlgid)
54 {
55 }
56
57 XAP_CocoaDialog_About::~XAP_CocoaDialog_About(void)
58 {
59 }
60
61 /*****************************************************************/
62
63 void XAP_CocoaDialog_About::runModal(XAP_Frame * )
64 {
65 m_dlg = [[XAP_CocoaDlg_AboutController alloc] initFromNib];
66 [m_dlg setXAPOwner:this];
67 NSWindow *win = [m_dlg window]; // force the window to be loaded.
68
69 [NSApp runModalForWindow:win];
70
71 [m_dlg discardXAP];
72 [m_dlg close];
73 [m_dlg release];
74 }
75
76 void XAP_CocoaDialog_About::event_OK(void)
77 {
78 [NSApp stopModal];
79 }
80
81 void XAP_CocoaDialog_About::event_URL(void)
82 {
83 XAP_App::getApp()->openURL("http://www.abisource.com/");
84 }
85
86 /*****************************************************************/
87
88
89 @implementation XAP_CocoaDlg_AboutController
90
91
92 - (id)initFromNib
93 {
94 return [super initWithWindowNibName:@"xap_CocoaDlg_About"];
95 }
96
97 -(void)discardXAP
98 {
99 m_xap = NULL;
100 }
101
102 - (void)setXAPOwner:(XAP_Dialog *)owner
103 {
104 m_xap = dynamic_cast<XAP_CocoaDialog_About*>(owner);
105 }
106
107 - (void)windowDidLoad
108 {
109 XAP_App * app = XAP_App::getApp();
110 // we get all our strings from the application string set
111 const XAP_StringSet * pSS = app->getStringSet();
112 std::string s;
113 pSS->getValueUTF8(XAP_STRING_ID_DLG_ABOUT_Title, s);
114 [[self window] setTitle:[NSString stringWithFormat:[NSString stringWithUTF8String:s.c_str()], app->getApplicationName()]];
115 [m_okBtn setTitle:[NSString stringWithUTF8String:pSS->getValue(XAP_STRING_ID_DLG_OK)]];
116 [m_appName setStringValue:[NSString stringWithUTF8String:app->getApplicationName()]];
117 pSS->getValueUTF8(XAP_STRING_ID_DLG_ABOUT_Version, s);
118 [m_versionLabel setStringValue:[NSString stringWithFormat:[NSString stringWithUTF8String:s.c_str()], XAP_App::s_szBuild_Version]];
119 [m_licenseText insertText:[NSString stringWithFormat:@"%s\n\n%@", XAP_ABOUT_COPYRIGHT,
120 [NSString stringWithFormat:@XAP_ABOUT_GPL_LONG_LF, app->getApplicationName()]]];
121 [m_licenseText setEditable:NO];
122
123 NSClipView * clipView = (NSClipView *) [m_licenseText superview];
124 [clipView scrollToPoint:NSZeroPoint];
125
126 NSScrollView * scrollView = (NSScrollView *) [clipView superview]; // Not sure why this is necessary...
127 [scrollView reflectScrolledClipView:clipView];
128
129 NSImage* image = [NSImage imageNamed:XAP_COCOA_ABOUT_SIDEBAR_RESOURCE_NAME];
130 [m_imageView setImage:image];
131 }
132
133 - (IBAction)okBtnAction:(id)sender
134 {
135 UT_UNUSED(sender);
136 m_xap->event_OK();
137 }
138
139 - (IBAction)webBtnAction:(id)sender
140 {
141 UT_UNUSED(sender);
142 m_xap->event_URL();
143 }
144
145 @end
146