ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/crossedit/Cnv/CnvPrompt.c
Revision: 1.2
Committed: Sun Aug 13 17:16:01 2006 UTC (17 years, 10 months ago) by elmex
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
Made server compile with C++.
Removed cfanim plugin and crossedit.
C++ here we come.

File Contents

# User Rev Content
1 root 1.1 #include <Cnv.h>
2     #include <Ansi.h>
3     #include <Xaw.h>
4     #include "debug.h" /* debug1 */
5    
6     /**********************************************************************
7     * prompt
8     **********************************************************************/
9    
10     static int CnvPromptSelect = 0;
11     static int CnvPromptActionFlag = 0;
12     static char CnvPromptString[CnvPromptMax+1];
13     static Widget CnvPromptWidgetText;
14     static void CnvPromptCb (Widget w, XtPointer client, XtPointer call);
15    
16     /*
17     *
18     */
19     static void CnvPromptAction (Widget w, XEvent * event, String * argv, Cardinal * argc)
20     {
21     CnvPromptCb (w, (XtPointer) 1, NULL); /* send Ok to callback */
22     }
23    
24     /*
25     *
26     */
27     XtActionsRec CnvPromptActionTable[] = {
28     { "CnvPromptAction", CnvPromptAction }
29     };
30    
31     /*
32     *
33     */
34     static void CnvPromptCb (Widget w, XtPointer client, XtPointer call)
35     {
36     char *t;
37     CnvPromptSelect = (int) client; /* set cardinal */
38     XtVaGetValues(CnvPromptWidgetText, XtNstring, &t, NULL);
39    
40     snprintf(CnvPromptString, sizeof(CnvPromptString), "%s", t);
41    
42     XtDestroyWidget (CnvGetShell (w));
43     }
44    
45     int CnvPrompt(String msg,String def,String ans,...)
46     {
47     va_list al;
48     Widget shell,cont,sign,use = NULL;
49     int i;
50     String str;
51    
52     CnvPromptString[0] = '\0';
53    
54     if (!CnvPromptActionFlag) {
55     XtAppContext a = XtWidgetToApplicationContext (cnv->shell);
56     XtAppAddActions (a,CnvPromptActionTable,
57     XtNumber (CnvPromptActionTable));
58     }
59    
60     /*** Layout ***/
61     shell = XtVaCreatePopupShell
62     (msg,transientShellWidgetClass,cnv->shell,
63     NULL);
64     cont = XtVaCreateManagedWidget
65     ("cont",formWidgetClass,shell,
66     NULL);
67     sign = XtVaCreateManagedWidget
68     ("sign",labelWidgetClass,cont,
69     XtNbitmap,cnv->xbm.prompt,
70     XtNborderWidth,0,
71     XtNheight,34,
72     NULL);
73     (void) XtVaCreateManagedWidget
74     ("label",labelWidgetClass,cont,
75     XtNlabel,msg,
76     XtNborderWidth,0,
77     XtNheight,34,
78     XtNwidth,300,
79     XtNfromHoriz,sign,
80     NULL);
81     CnvPromptWidgetText = XtVaCreateManagedWidget
82     ("prompt",asciiTextWidgetClass,cont,
83     XtNresizable,True,
84     XtNfromVert,sign,
85     XtNstring,def,
86     XtNeditType,XawtextEdit,
87     XtNaccelerators,
88     XtParseAcceleratorTable
89     ("#override <Key>Return: CnvPromptAction() \n"),
90     XtNtranslations,XtParseTranslationTable
91     ("#override <Key>Return: CnvPromptAction() \n"
92     "<Key>Tab: CnvNop()\n"),
93     XtNwidth,336,
94     NULL);
95    
96     /* Put the cursor at the end of the line. */
97     XtVaSetValues(CnvPromptWidgetText,
98     XtNinsertPosition, strlen(def),
99     NULL);
100    
101     XtInstallAllAccelerators(cont,cont);
102    
103     /*** button-list ***/
104     va_start(al,ans);
105     for(i=1;(str = (String)va_arg(al,String)) != NULL; i++) {
106     use = XtVaCreateManagedWidget
107     (str,commandWidgetClass,cont,
108     XtNfromHoriz, use,
109     XtNfromVert,CnvPromptWidgetText,
110     NULL);
111     XtAddCallback(use,XtNcallback,CnvPromptCb,(XtPointer)i);
112     }
113     va_end(al);
114     /*** looping ***/
115     CnvCenterWidget(shell);
116     XtPopup(shell,XtGrabExclusive);
117     while(!CnvPromptSelect) {
118     XtAppProcessEvent(XtWidgetToApplicationContext(shell),XtIMXEvent);
119     }
120     i = CnvPromptSelect;
121     CnvPromptSelect = 0;
122    
123     debug1("CnvPrompt '%s'\n", CnvPromptString);
124     strncpy(ans,CnvPromptString,CnvPromptMax);
125     ans[CnvPromptMax] = '\0';
126     return i;
127     }
128    
129     /*** end of CnvPrompt.c ***/