]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/prtview/AboutDialog.cpp
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / contrib / prtview / AboutDialog.cpp
1 /*\r
2 PrtView plugin for GtkRadiant\r
3 Copyright (C) 2001 Geoffrey Dewan, Loki software and qeradiant.com\r
4 \r
5 This library is free software; you can redistribute it and/or\r
6 modify it under the terms of the GNU Lesser General Public\r
7 License as published by the Free Software Foundation; either\r
8 version 2.1 of the License, or (at your option) any later version.\r
9 \r
10 This library is distributed in the hope that it will be useful,\r
11 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
13 Lesser General Public License for more details.\r
14 \r
15 You should have received a copy of the GNU Lesser General Public\r
16 License along with this library; if not, write to the Free Software\r
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
18 */\r
19 \r
20 // AboutDialog.cpp : implementation file\r
21 //\r
22 \r
23 #include "stdafx.h"\r
24 \r
25 #ifdef _DEBUG\r
26 #define new DEBUG_NEW\r
27 #undef THIS_FILE\r
28 //static char THIS_FILE[] = __FILE__;\r
29 #endif\r
30 \r
31 /////////////////////////////////////////////////////////////////////////////\r
32 // CAboutDialog dialog\r
33 \r
34 #ifdef GTK_PLUGIN\r
35 \r
36 static void dialog_button_callback (GtkWidget *widget, gpointer data)\r
37 {\r
38   GtkWidget *parent;\r
39   int *loop, *ret;\r
40 \r
41   parent = gtk_widget_get_toplevel (widget);\r
42   loop = (int*)g_object_get_data (G_OBJECT (parent), "loop");\r
43   ret = (int*)g_object_get_data (G_OBJECT (parent), "ret");\r
44 \r
45   *loop = 0;\r
46   *ret = (int)data;\r
47 }\r
48 \r
49 static gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data)\r
50 {\r
51   int *loop;\r
52 \r
53   gtk_widget_hide (widget);\r
54   loop = (int*)g_object_get_data (G_OBJECT (widget), "loop");\r
55   *loop = 0;\r
56 \r
57   return TRUE;\r
58 }\r
59 \r
60 void DoAboutDlg ()\r
61 {\r
62   GtkWidget *dlg, *hbox, *vbox, *button, *label;\r
63   int loop = 1, ret = IDCANCEL;\r
64 \r
65   dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);\r
66   gtk_window_set_title (GTK_WINDOW (dlg), "About Portal Viewer");\r
67   gtk_signal_connect (GTK_OBJECT (dlg), "delete_event",\r
68                       GTK_SIGNAL_FUNC (dialog_delete_callback), NULL);\r
69   gtk_signal_connect (GTK_OBJECT (dlg), "destroy",\r
70                       GTK_SIGNAL_FUNC (gtk_widget_destroy), NULL);\r
71   g_object_set_data (G_OBJECT (dlg), "loop", &loop);\r
72   g_object_set_data (G_OBJECT (dlg), "ret", &ret);\r
73 \r
74   hbox = gtk_hbox_new (FALSE, 10);\r
75   gtk_widget_show (hbox);\r
76   gtk_container_add (GTK_CONTAINER (dlg), hbox);\r
77   gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);\r
78 \r
79   label = gtk_label_new ("Version 1.000\n\n"\r
80                          "Gtk port by Leonardo Zide\nleo@lokigames.com\n\n"\r
81                          "Written by Geoffrey DeWan\ngdewan@prairienet.org\n\n"\r
82        "Built against GtkRadiant " RADIANT_VERSION "\n"\r
83        __DATE__\r
84        );\r
85   gtk_widget_show (label);\r
86   gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);\r
87   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);\r
88 \r
89   vbox = gtk_vbox_new (FALSE, 0);\r
90   gtk_widget_show (vbox);\r
91   gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);\r
92 \r
93   button = gtk_button_new_with_label ("OK");\r
94   gtk_widget_show (button);\r
95   gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);\r
96   gtk_signal_connect (GTK_OBJECT (button), "clicked",\r
97                       GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));\r
98   gtk_widget_set_usize (button, 60, -2);\r
99 \r
100   gtk_grab_add (dlg);\r
101   gtk_widget_show (dlg);\r
102 \r
103   while (loop)\r
104     gtk_main_iteration ();\r
105 \r
106   gtk_grab_remove (dlg);\r
107   gtk_widget_destroy (dlg);\r
108 }\r
109 \r
110 #else // GTK_PLUGIN\r
111 \r
112 CAboutDialog::CAboutDialog(CWnd* pParent /*=NULL*/)\r
113         : CDialog(CAboutDialog::IDD, pParent)\r
114 {\r
115         //{{AFX_DATA_INIT(CAboutDialog)\r
116                 // NOTE: the ClassWizard will add member initialization here\r
117         //}}AFX_DATA_INIT\r
118 }\r
119 \r
120 \r
121 void CAboutDialog::DoDataExchange(CDataExchange* pDX)\r
122 {\r
123         CDialog::DoDataExchange(pDX);\r
124         //{{AFX_DATA_MAP(CAboutDialog)\r
125                 // NOTE: the ClassWizard will add DDX and DDV calls here\r
126         //}}AFX_DATA_MAP\r
127 }\r
128 \r
129 \r
130 BEGIN_MESSAGE_MAP(CAboutDialog, CDialog)\r
131         //{{AFX_MSG_MAP(CAboutDialog)\r
132                 // NOTE: the ClassWizard will add message map macros here\r
133         //}}AFX_MSG_MAP\r
134 END_MESSAGE_MAP()\r
135 \r
136 #endif // GTK_PLUGIN\r
137 \r
138 /////////////////////////////////////////////////////////////////////////////\r
139 // CAboutDialog message handlers\r