1 /*----------------------------------------------------------------------------
2 --
3 --  Module:           xitPixmDia
4 --
5 --  Project:          xit  - X Internal Toolkit
6 --  System:           xit  - X Internal Toolkit
7 --    Subsystem:      <>
8 --    Function block: <>
9 --
10 --  Description:
11 --    Manages an information dialog where Enter and Return are used as
12 --    activate keys. If a pixmap is supplied, it is displayed.
13 --
14 --  Filename:         xitPixmDia.c
15 --
16 --  Authors:          Roger Larsson, Ulrika Bornetun
17 --  Creation date:    1993-03-25
18 --
19 --
20 --  (C) Copyright Ulrika Bornetun, Roger Larsson (1995)
21 --      All rights reserved
22 --
23 --  Permission to use, copy, modify, and distribute this software and its
24 --  documentation for any purpose and without fee is hereby granted,
25 --  provided that the above copyright notice appear in all copies. Ulrika
26 --  Bornetun and Roger Larsson make no representations about the usability
27 --  of this software for any purpose. It is provided "as is" without express
28 --  or implied warranty.
29 ----------------------------------------------------------------------------*/
30 
31 /* SCCS module identifier. */
32 static char SCCSID[] = "@(#) Module: xitPixmDia.c, Version: 1.1, Date: 95/02/18 15:10:44";
33 
34 
35 /*----------------------------------------------------------------------------
36 --  Include files
37 ----------------------------------------------------------------------------*/
38 
39 #include <X11/Intrinsic.h>
40 #include <X11/Shell.h>
41 
42 #include <Xm/Xm.h>
43 #include <Xm/MessageB.h>
44 
45 #include "xitTools.h"
46 
47 
48 /*----------------------------------------------------------------------------
49 --  Macro definitions
50 ----------------------------------------------------------------------------*/
51 
52 
53 /*----------------------------------------------------------------------------
54 --  Type declarations
55 ----------------------------------------------------------------------------*/
56 
57 
58 /*----------------------------------------------------------------------------
59 --  Global definitions
60 ----------------------------------------------------------------------------*/
61 
62 
63 /*----------------------------------------------------------------------------
64 --  Function prototypes
65 ----------------------------------------------------------------------------*/
66 
67 static void
68   removeCB( Widget               widget,
69             Widget               toplevel_widget,
70             XmAnyCallbackStruct  *call_data );
71 
72 
73 /*----------------------------------------------------------------------------
74 --  Functions
75 ----------------------------------------------------------------------------*/
76 
77 Widget
xitCreatePixmapDialog(Widget parent,char * dialog_name,char * title,char * message,Pixmap pixmap,void (* okCB)(),void * ok_client_data)78   xitCreatePixmapDialog( Widget  parent,
79                          char    *dialog_name,
80                          char    *title,
81                          char    *message,
82                          Pixmap  pixmap,
83                          void    (*okCB) (),
84                          void    *ok_client_data )
85 {
86 
87   /* Variablesf. */
88   Arg        args[ 5 ];
89   Cardinal   n;
90   Widget     button;
91   Widget     w;
92   XmString   xstr;
93 
94 
95   /* Code. */
96 
97   n = 0;
98   XtSetArg( args[ n ], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL ); n++;
99   XtSetArg( args[ n ], XmNnoResize, True ); n++;
100 
101   w = XmCreateInformationDialog( parent, dialog_name, args, n );
102 
103   if( strlen( message ) > 0 ) {
104     xstr = XmStringCreateLtoR( message, CS );
105 
106     n = 0;
107     XtSetArg( args[ n ], XmNmessageString, xstr ); n++;
108     XtSetValues( w, args, n );
109     XmStringFree( xstr );
110   }
111 
112   if( strlen( title ) > 0 ) {
113     xstr = XmStringCreateLtoR( title, CS );
114 
115     n = 0;
116     XtSetArg( args[ n ], XmNdialogTitle, xstr ); n++;
117     XtSetValues( w, args, n );
118     XmStringFree( xstr );
119   }
120 
121   /* Unmanage the cancel and help buttons. */
122   button = XmMessageBoxGetChild( w, XmDIALOG_CANCEL_BUTTON );
123   XtUnmanageChild( button );
124 
125   button = XmMessageBoxGetChild( w, XmDIALOG_HELP_BUTTON );
126   XtUnmanageChild( button );
127 
128   /* Any Pixmap to set? */
129   if( pixmap != XmUNSPECIFIED_PIXMAP ) {
130     n = 0;
131     XtSetArg( args[ n ], XmNsymbolPixmap, pixmap ); n++;
132     XtSetValues( w, args, n );
133   }
134 
135 
136   /* Add callback? */
137   if( okCB != NULL ) {
138     XtAddCallback( w, XmNokCallback,
139                    (XtCallbackProc) okCB, (XtPointer) ok_client_data );
140     XtAddCallback( w, XmNokCallback,
141                    (XtCallbackProc) removeCB, (XtPointer) w );
142   } else {
143     XtAddCallback( w, XmNokCallback,
144                    (XtCallbackProc) removeCB, (XtPointer) w );
145   }
146 
147   XtManageChild( w );
148 
149 
150   return( w );
151 
152 } /* xitCreatePixmapDialog */
153 
154 
155 /*----------------------------------------------------------------------*/
156 
157 static void
removeCB(Widget widget,Widget toplevel_widget,XmAnyCallbackStruct * call_data)158   removeCB( Widget               widget,
159             Widget               toplevel_widget,
160             XmAnyCallbackStruct  *call_data )
161 {
162 
163   /* Code. */
164 
165   XtDestroyWidget( toplevel_widget );
166 
167   return;
168 
169 } /* removeCB */
170