1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                RESWIN.CC                                  */
4 /*                                                                           */
5 /* (C) 1993-95  Ullrich von Bassewitz                                        */
6 /*              Wacholderweg 14                                              */
7 /*              D-70597 Stuttgart                                            */
8 /* EMail:       uz@ibb.schwaben.com                                          */
9 /*                                                                           */
10 /*****************************************************************************/
11 
12 
13 
14 // $Id$
15 //
16 // $Log$
17 //
18 //
19 
20 
21 
22 #include "resed.h"
23 
24 
25 
26 /*****************************************************************************/
27 /*                             class ResEditApp                              */
28 /*****************************************************************************/
29 
30 
31 
Header()32 void ResEditApp::Header ()
33 {
34     // Create a pointer alias to the lowest object in the hierarchy that
35     // has a header
36     Window *W = (Window *) Res;
37 
38     int Abort;
39     String Header (W->GetHeader ());
40     NamePrompt (" New header", Header, Abort);
41     if (!Abort) {
42         W->SetHeader (Header);
43         ResChanged = 1;
44     }
45 }
46 
47 
48 
Footer()49 void ResEditApp::Footer ()
50 {
51     // Create a pointer alias to the lowest object in the hierarchy that
52     // has a footer
53     Window *W = (Window *) Res;
54 
55     int Abort;
56     String Footer (W->GetFooter ());
57     NamePrompt (" New footer ", Footer, Abort);
58     if (!Abort) {
59         W->SetFooter (Footer);
60         ResChanged = 1;
61     }
62 }
63 
64 
65 
Size()66 void ResEditApp::Size ()
67 {
68     // Create a pointer alias to the lowest object in the hierarchy that
69     // is sizeable
70     Window *W = (Window*) Res;
71 
72     // Remember the old window flags
73     u16 OldFlags = W->Flags;
74 
75     // Enable moving and resizing
76     W->Flags |= wfCanMove | wfCanResize;
77 
78     // Go...
79     W->MoveResize ();
80 
81     // Restore the old flags
82     W->Flags = OldFlags;
83 
84 }
85 
86 
Color()87 void ResEditApp::Color ()
88 {
89     // Cast the Resource to the lowest object in the hierarchy that is able
90     // to change the palette
91     Window *W = (Window *) Res;
92 
93     // Decide wich palette
94     switch (SimpleMenue ("Choose palette", "@Blue\n@Gray\n@Cyan\n@Red\nBl@ack\n@Error")) {
95 
96         case 0:
97             // Abort
98             return;
99 
100         case 1:
101             W->SetPalette (paBlue);
102             break;
103 
104         case 2:
105             W->SetPalette (paGray);
106             break;
107 
108         case 3:
109             W->SetPalette (paCyan);
110             break;
111 
112         case 4:
113             W->SetPalette (paRed);
114             break;
115 
116         case 5:
117             W->SetPalette (paBlack);
118             break;
119 
120         case 6:
121             W->SetPalette (paError);
122             break;
123     }
124 
125     // Resource is changed now
126     ResChanged = 1;
127 
128 }
129 
130 
131 
BackgroundChar()132 void ResEditApp::BackgroundChar ()
133 {
134 }
135 
136 
137 
Number()138 void ResEditApp::Number ()
139 {
140 }
141 
142 
143 
IgnoreAccept(int On)144 void ResEditApp::IgnoreAccept (int On)
145 {
146     ItemWindow * Win = (ItemWindow *) Res;
147     if (On) {
148         Win->Flags |= wfIgnoreAccept;
149     } else {
150         Win->Flags &= ~wfIgnoreAccept;
151     }
152     ResChanged = 1;
153 }
154 
155 
156 
Modal(int On)157 void ResEditApp::Modal (int On)
158 {
159     ItemWindow * Win = (ItemWindow *) Res;
160     if (On) {
161         Win->Flags |= wfModal;
162     } else {
163         Win->Flags &= ~wfModal;
164     }
165     ResChanged = 1;
166 }
167 
168 
169 
LRLink(int On)170 void ResEditApp::LRLink (int On)
171 {
172     ItemWindow * Win = (ItemWindow *) Res;
173     if (On) {
174         Win->Flags |= wfLRLink;
175     } else {
176         Win->Flags &= ~wfLRLink;
177     }
178     ResChanged = 1;
179 }
180 
181 
182 
Visible(int On)183 void ResEditApp::Visible (int On)
184 {
185     ItemWindow* Win = (ItemWindow*) Res;
186     if (On) {
187         Win->Flags |= wfSaveVisible;
188     } else {
189         Win->Flags &= ~wfSaveVisible;
190     }
191     ResChanged = 1;
192 }
193 
194 
195 
CenterX(int On)196 void ResEditApp::CenterX (int On)
197 {
198     Window *Win = (Window *) Res;
199     if (On) {
200         Win->SetOption (cfCenterX);
201     } else {
202         Win->ResetOption (cfCenterX);
203     }
204     ResChanged = 1;
205 }
206 
207 
208 
CenterY(int On)209 void ResEditApp::CenterY (int On)
210 {
211     Window* Win = (Window*) Res;
212     if (On) {
213         Win->SetOption (cfCenterY);
214     } else {
215         Win->ResetOption (cfCenterY);
216     }
217     ResChanged = 1;
218 }
219 
220 
221 
CanMove(int On)222 void ResEditApp::CanMove (int On)
223 {
224     Window* Win = (Window*) Res;
225     if (On) {
226         Win->Flags |= wfCanMove;
227     } else {
228         Win->Flags &= ~wfCanMove;
229     }
230     ResChanged = 1;
231 }
232 
233 
234 
CanResize(int On)235 void ResEditApp::CanResize (int On)
236 {
237     Window* Win = (Window*) Res;
238     if (On) {
239         Win->Flags |= wfCanResize;
240     } else {
241         Win->Flags &= ~wfCanResize;
242     }
243     ResChanged = 1;
244 }
245 
246 
247 
Test()248 void ResEditApp::Test ()
249 {
250     if (ResID == ID_Menue || ResID == ID_TopMenueBar) {
251 
252         // Some sort of Menue
253         GenericMenue *M = (GenericMenue *) Res;
254 
255         // Set it active
256         M->Activate ();
257 
258         // Show a status line
259         StatusLine->Push (siEsc_Abort);
260 
261         // If there are items, work with the menue, else show it
262         if (M->ItemCount > 0) {
263             M->RegisterItemKeys ();
264             while (M->GetChoice () != 0) ;
265             M->UnregisterItemKeys ();
266         } else {
267             int Done = 0;
268             while (!Done) {
269                 switch (KbdGet ()) {
270 
271                     case vkAbort:
272                     case kbEsc:
273                         Done = 1;
274 
275                 }
276             }
277         }
278 
279         // Deactivate the window, pop the statusline
280         M->Deactivate ();
281         StatusLine->Pop ();
282 
283         // Resource has changed
284         ResChanged = 1;
285 
286     } else {
287 
288         // Wrong type of resource
289         ErrorMsg ("Cannot test this type of resource");
290 
291     }
292 
293 }
294 
295 
296