00001
00030 #include <stdio.h>
00031
00032 #include <Xm/Xm.h>
00033 #include <Xm/MwmUtil.h>
00034 #include <Xm/PushB.h>
00035 #include <Xm/BulletinB.h>
00036 #include <Xm/Frame.h>
00037 #include <Xm/Label.h>
00038 #include <Xm/DrawingA.h>
00039
00040 #include "../../config.h"
00041 #include "util.h"
00042 #include "credits_dialog.h"
00043
00044
00045
00046 static Widget credits_dialog = NULL;
00047
00048
00060 static void
00061 on_credits_dialog_close_button_clicked (Widget w, XtPointer client_data, XtPointer call_data)
00062 {
00063 XtUnmanageChild (credits_dialog);
00064 }
00065
00066
00078 static void
00079 create_credits_dialog (Widget parent)
00080 {
00081 Widget credits_dialog_drawing_area;
00082 Widget credits_dialog_frame;
00083 Widget credits_dialog_close_button;
00084 Widget credits_dialog_label;
00085 Arg args[10];
00086 XmString xmstrings[10];
00087 XmFontList fontlist;
00088 int n;
00089
00090
00091 n=0;
00092 XtSetArg (args[n], XmNtitle, "Credits");
00093 n++;
00094 XtSetArg( args[n], XmNdeleteResponse, XmDO_NOTHING);
00095 n++;
00096 XtSetArg (args[n], XmNmwmFunctions,
00097 MWM_FUNC_RESIZE|MWM_FUNC_MOVE|MWM_FUNC_MINIMIZE|MWM_FUNC_MAXIMIZE);
00098 n++;
00099 XtSetArg( args[n], XmNbackground, get_pixel ("gray"));
00100 n++;
00101 credits_dialog = XmCreateBulletinBoardDialog (parent, "credits_dialog", args, n);
00102
00103 XtSetArg (args[0], XmNbackground, get_pixel ("gray"));
00104 credits_dialog_drawing_area = XtCreateManagedWidget ("credits_dialog_drawing_area",
00105 xmDrawingAreaWidgetClass, credits_dialog, args, 1);
00106
00107 XtSetArg (args[0], XmNshadowThickness, 5);
00108 XtSetArg (args[1], XmNshadowType, XmSHADOW_OUT);
00109 credits_dialog_frame = XtCreateManagedWidget ("credits_dialog_frame", xmFrameWidgetClass,
00110 credits_dialog_drawing_area, args, 2);
00111
00112 XtSetArg (args[0], XmNforeground, get_pixel ("black"));
00113 XtSetArg (args[1], XmNbackground, get_pixel ("gray"));
00114 fontlist = get_fontlist (parent, "-adobe-helvetica-bold-r-normal--14-140-75-75-p-82-iso8859-1");
00115 XtSetArg (args[2], XmNfontList, fontlist);
00116 xmstrings[0] = XmStringCreateSimple ("Close");
00117 XtSetArg (args[3], XmNlabelString, xmstrings[0]);
00118 XtSetArg (args[4], XmNshowAsDefault, 1);
00119 XtSetArg (args[5], XmNy, 200);
00120 XtSetArg (args[6], XmNx, 155);
00121 credits_dialog_close_button = XtCreateManagedWidget
00122 (
00123 "credits_dialog_close_button",
00124 xmPushButtonWidgetClass,
00125 credits_dialog_drawing_area,
00126 args,
00127 7
00128 );
00129 XtAddCallback (credits_dialog_close_button, XmNactivateCallback,
00130 on_credits_dialog_close_button_clicked, NULL);
00131 XmStringFree (xmstrings[0]);
00132 XmFontListFree (fontlist);
00133
00134 XtSetArg (args[0], XmNalignment, XmALIGNMENT_BEGINNING);
00135 XtSetArg (args[1], XmNtraversalOn, False);
00136 XtSetArg (args[2], XmNmarginHeight, 10);
00137 XtSetArg (args[3], XmNmarginWidth, 10);
00138 XtSetArg (args[4], XmNrecomputeSize, True);
00139 XtSetArg (args[5], XmNforeground, get_pixel ("black"));
00140 XtSetArg (args[6], XmNbackground, get_pixel ("gray"));
00141 xmstrings[0] = create_credits_dialog_xmstring ();
00142 XtSetArg (args[7], XmNlabelString, xmstrings[0]);
00143 fontlist = get_fontlist (parent, "-adobe-helvetica-medium-r-normal--14-140-75-75-p-77-iso8859-1");
00144 XtSetArg (args[8], XmNfontList, fontlist);
00145 credits_dialog_label = XtCreateManagedWidget
00146 (
00147 "credits_dialog_label",
00148 xmLabelWidgetClass,
00149 credits_dialog_frame,
00150 args,
00151 9
00152 );
00153 XmStringFree (xmstrings[0]);
00154 XmFontListFree (fontlist);
00155
00156 }
00157
00158
00167 static XmString
00168 create_credits_dialog_xmstring ()
00169 {
00170 XmString xms;
00171 XmString nxt;
00172 XmString lst;
00173
00174 lst = XmStringCreateLtoR ("Written by:\n", XmSTRING_DEFAULT_CHARSET);
00175 nxt = XmStringCreateLtoR ("Bert Timmerman <bert.timmerman@xs4all.nl>\n", XmSTRING_DEFAULT_CHARSET);
00176 xms = XmStringConcat (lst, nxt);
00177 XmStringFree (lst);
00178 XmStringFree (nxt);
00179 nxt = xms;
00180
00181 lst = XmStringCreateLtoR ("\n", XmSTRING_DEFAULT_CHARSET);
00182 xms = XmStringConcat (xms, lst);
00183 XmStringFree (lst);
00184 XmStringFree (nxt);
00185 return (xms);
00186 }
00187
00188
00196 void
00197 show_credits_dialog ()
00198 {
00199 if (!credits_dialog)
00200 {
00201 create_credits_dialog (shell);
00202 }
00203 XtManageChild (credits_dialog);
00204 }
00205
00206
00207