1 // $Id: xxHelpBox.cc 4497 2012-05-27 00:33:09Z flaterco $
2 
3 /*  xxHelpBox  Plain old, non-scrollable, window with text in it.
4 
5     Copyright (C) 1998  David Flater.
6 
7     This program is free software: you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation, either version 3 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #include "xtide.hh"
22 #include "xxHelpBox.hh"
23 
24 
dismissCallback(Widget w unusedParameter,XtPointer client_data,XtPointer call_data unusedParameter)25 static void dismissCallback (Widget w unusedParameter,
26                              XtPointer client_data,
27                              XtPointer call_data unusedParameter) {
28   assert (client_data);
29   delete ((xxHelpBox *)client_data)->dismiss();
30 }
31 
32 
xxHelpBox(const xxWidget & parent,const Dstr & help)33 xxHelpBox::xxHelpBox (const xxWidget &parent, const Dstr &help):
34   xxWindow (parent, boxContainer) {
35 
36   setTitle ("About...");
37   Arg labelArgs[3] =  {
38     {XtNbackground, (XtArgVal)xxX::pixels[Colors::background]},
39     {XtNforeground, (XtArgVal)xxX::pixels[Colors::foreground]},
40     {fontArgName, xxX::monoFontArgValue}
41   };
42   {
43     Widget labelWidget = xxX::createXtWidget (help.aschar(),
44       labelWidgetClass, container->widget(), labelArgs, 3);
45     label = xxX::wrap (labelWidget);
46   }
47 
48   {
49     Arg buttonArgs[2] =  {
50       {XtNbackground, (XtArgVal)xxX::pixels[Colors::button]},
51       {XtNforeground, (XtArgVal)xxX::pixels[Colors::foreground]}
52     };
53     Widget buttonwidget = xxX::createXtWidget ("Dismiss", commandWidgetClass,
54       container->widget(), buttonArgs, 2);
55     XtAddCallback (buttonwidget, XtNcallback, dismissCallback,
56      (XtPointer)this);
57     dismissButton = xxX::wrap (buttonwidget);
58   }
59 
60   realize();
61   fixSize();
62 }
63 
64 
~xxHelpBox()65 xxHelpBox::~xxHelpBox() {
66   unrealize();
67 }
68 
69 
globalRedraw()70 void xxHelpBox::globalRedraw() {
71   xxWindow::globalRedraw();
72   Arg buttonArgs[2] =  {
73     {XtNbackground, (XtArgVal)xxX::pixels[Colors::button]},
74     {XtNforeground, (XtArgVal)xxX::pixels[Colors::foreground]}
75   };
76   assert (dismissButton.get());
77   XtSetValues (dismissButton->widget(), buttonArgs, 2);
78   Arg args[2] =  {
79     {XtNbackground, (XtArgVal)xxX::pixels[Colors::background]},
80     {XtNforeground, (XtArgVal)xxX::pixels[Colors::foreground]}
81   };
82   assert (label.get());
83   XtSetValues (label->widget(), args, 2);
84 }
85 
86 // Cleanup2006 Done
87