source: titan/titan/inputhelp.h @ 15152

Last change on this file since 15152 was 11112, checked in by nit, 12 years ago

[titan] make textinput thread safe

File size: 4.3 KB
Line 
1#ifndef INPUTHELP_H
2#define INPUTHELP_H
3
4void inputhelpnum(struct skin* inputhelp, struct skin* inputbox, char num, int flag)
5{
6        inputboxff(inputhelp, inputbox, flag);
7        inputboxchar(inputhelp, inputbox, num, flag);
8        drawscreen(inputhelp, flag);
9}
10
11char* screeninputhelp(char* text, int flag)
12{
13        int rcret = 0, tmpscreencalc = 0;
14        struct skin* inputhelp = getscreen("inputhelp");
15        struct skin* grid = NULL;
16        struct skin* grid1 = getscreennode(inputhelp, "grid1");
17        struct skin* grid2 = getscreennode(inputhelp, "grid2");
18        struct skin* inputbox = getscreennode(inputhelp, "inputbox");
19        char* tmpstr = NULL;
20
21        grid1->hidden = NO;
22        grid2->hidden = YES;
23        grid = grid1;
24        if(text != NULL && strlen(text) > 0)
25        {
26                inputbox->aktpage = strlen(text);
27        }
28        changeinput(inputbox, text);
29        tmpscreencalc = status.screencalc;
30        status.screencalc = 0;
31        drawscreen(inputhelp, flag);
32        addscreenrc(inputhelp, grid);
33
34        while(1)
35        {
36                rcret = waitrc(inputhelp, 0, 0);
37
38                if(rcret == getrcconfigint("rcexit", NULL))
39                {
40                        tmpstr = ostrcat(tmpstr, text, 1, 0);
41                        break;
42                }
43                if(rcret == getrcconfigint("rcff", NULL))
44                        inputboxright(inputhelp, inputbox, flag);
45                if(rcret == getrcconfigint("rcfr", NULL))
46                        inputboxleft(inputhelp, inputbox, flag);
47                if(rcret == getrcconfigint("rc0", NULL))
48                        inputhelpnum(inputhelp, inputbox, '0', flag);
49                if(rcret == getrcconfigint("rc1", NULL))
50                        inputhelpnum(inputhelp, inputbox, '1', flag);
51                if(rcret == getrcconfigint("rc2", NULL))
52                        inputhelpnum(inputhelp, inputbox, '2', flag);
53                if(rcret == getrcconfigint("rc3", NULL))
54                        inputhelpnum(inputhelp, inputbox, '3', flag);
55                if(rcret == getrcconfigint("rc4", NULL))
56                        inputhelpnum(inputhelp, inputbox, '4', flag);
57                if(rcret == getrcconfigint("rc5", NULL))
58                        inputhelpnum(inputhelp, inputbox, '5', flag);
59                if(rcret == getrcconfigint("rc6", NULL))
60                        inputhelpnum(inputhelp, inputbox, '6', flag);
61                if(rcret == getrcconfigint("rc7", NULL))
62                        inputhelpnum(inputhelp, inputbox, '7', flag);
63                if(rcret == getrcconfigint("rc8", NULL))
64                        inputhelpnum(inputhelp, inputbox, '8', flag);
65                if(rcret == getrcconfigint("rc9", NULL))
66                        inputhelpnum(inputhelp, inputbox, '9', flag);
67
68                if(rcret == getrcconfigint("rcok", NULL) || rcret == getrcconfigint("rcred", NULL) || rcret == getrcconfigint("rcgreen", NULL) || rcret == getrcconfigint("rcyellow", NULL) || rcret == getrcconfigint("rcblue", NULL))
69                {
70                        if(grid->select != NULL && grid->select->name != NULL)
71                        {
72                                if(rcret == getrcconfigint("rcgreen", NULL) || (rcret == getrcconfigint("rcok", NULL) && ostrcmp(grid->select->name, "ok") == 0))
73                                {
74                                        tmpstr = ostrcat(tmpstr, inputbox->input, 1, 0);
75                                        break;
76                                }
77                                if(rcret == getrcconfigint("rcred", NULL) || (rcret == getrcconfigint("rcok", NULL) && ostrcmp(grid->select->name, "bs") == 0))
78                                {
79                                        inputboxfr(inputhelp, inputbox, flag);
80                                        continue;
81                                }
82                                if(rcret == getrcconfigint("rcok", NULL) && ostrcmp(grid->select->name, "clear") == 0)
83                                {
84                                        changeinput(inputbox, NULL);
85                                        drawscreen(inputhelp, flag);
86                                        continue;
87                                }
88                                if(rcret == getrcconfigint("rcok", NULL) && ostrcmp(grid->select->name, "left") == 0)
89                                {
90                                        inputboxleft(inputhelp, inputbox, flag);
91                                        drawscreen(inputhelp, flag);
92                                        continue;
93                                }
94                                if(rcret == getrcconfigint("rcok", NULL) && ostrcmp(grid->select->name, "right") == 0)
95                                {
96                                        inputboxright(inputhelp, inputbox, flag);
97                                        drawscreen(inputhelp, flag);
98                                        continue;
99                                }
100                                if(rcret == getrcconfigint("rcblue", NULL) || (rcret == getrcconfigint("rcok", NULL) && ostrcmp(grid->select->name, "switch") == 0))
101                                {
102                                        if(grid1->hidden == YES)
103                                        {
104                                                delownerrc(inputhelp);
105                                                grid = grid1;
106                                                grid1->hidden = NO;
107                                                grid2->hidden = YES;
108                                                addscreenrc(inputhelp, grid);
109                                        }
110                                        else
111                                        {
112                                                delownerrc(inputhelp);
113                                                grid = grid2;
114                                                grid1->hidden = YES;
115                                                grid2->hidden = NO;
116                                                addscreenrc(inputhelp, grid);
117                                        }
118                                        drawscreen(inputhelp, flag);
119                                        continue;
120                                }
121                                if(rcret == getrcconfigint("rcyellow", NULL))
122                                {
123                                        inputboxff(inputhelp, inputbox, flag);
124                                        inputboxchar(inputhelp, inputbox, ' ', flag);
125                                        drawscreen(inputhelp, flag);
126                                        continue;
127                                }
128
129                                inputboxff(inputhelp, inputbox, flag);
130                                inputboxchar(inputhelp, inputbox, grid->select->name[0], flag);
131                        }
132                }
133        }
134
135        delownerrc(inputhelp);
136        clearscreen(inputhelp);
137        drawscreen(skin, flag);
138        status.screencalc = tmpscreencalc;
139        return tmpstr;
140}
141
142#endif
Note: See TracBrowser for help on using the repository browser.