2 Copyright © 1995-1997 Stefan Stuntz.
3 Copyright © 2009-2011, The AROS Development Team.
9 #include <proto/intuition.h>
10 #include <proto/muiscreen.h>
11 #include <proto/muimaster.h>
15 #include "screenlist_class.h"
16 #include "editwindow_class.h"
17 #include "editpanel_class.h"
18 #include "screenpanel_class.h"
20 /****************************************************************************************/
22 struct ScreenPanel_Data
37 /****************************************************************************************/
39 IPTR
ScreenPanel_Finish(struct IClass
*cl
, Object
*obj
, struct MUIP_ScreenPanel_Finish
*msg
)
41 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
42 struct MUI_PubScreenDesc
*desc
;
44 Object
*win
= msg
->win
;
49 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, i
, &desc
);
51 return 0; /* should never happen */
52 if (desc
->UserData
== win
)
56 desc
->UserData
= NULL
;
60 DoMethod(win
, MUIM_EditPanel_GetScreen
, desc
);
63 DoMethod(data
->LV_Screens
, MUIM_List_Redraw
, i
);
64 DoMethod(obj
, MUIM_ScreenPanel_SetStates
);
66 set(win
, MUIA_Window_Open
, FALSE
);
67 DoMethod((Object
*)xget(obj
, MUIA_ApplicationObject
), OM_REMMEMBER
, win
);
68 MUI_DisposeObject(win
);
72 /****************************************************************************************/
74 IPTR
ScreenPanel_Edit(struct IClass
*cl
, Object
*obj
, Msg msg
)
76 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
77 struct MUI_PubScreenDesc
*desc
;
79 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &desc
);
83 set((Object
*)xget(obj
, MUIA_ApplicationObject
), MUIA_Application_Sleep
, TRUE
);
87 if ((desc
->UserData
= (APTR
)NewObject(CL_EditWindow
->mcc_Class
, NULL
,
88 MUIA_Window_Width
, MUIV_Window_Width_MinMax(0),
89 MUIA_Window_Height
, MUIV_Window_Height_MinMax(0),
90 MUIA_EditWindow_Title
, desc
->Name
,
91 MUIA_EditWindow_Originator
, obj
,
94 DoMethod((Object
*)xget(obj
, MUIA_ApplicationObject
), OM_ADDMEMBER
, desc
->UserData
);
95 DoMethod(desc
->UserData
,MUIM_EditPanel_SetScreen
, desc
);
96 DoMethod(data
->LV_Screens
, MUIM_List_Redraw
, MUIV_List_Redraw_Active
);
101 set(desc
->UserData
, MUIA_Window_Open
, TRUE
);
105 set((Object
*)xget(obj
, MUIA_ApplicationObject
), MUIA_Application_Sleep
, FALSE
);
111 /****************************************************************************************/
113 IPTR
ScreenPanel_Delete(struct IClass
*cl
, Object
*obj
, Msg msg
)
115 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
116 struct MUI_PubScreenDesc
*desc
;
118 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &desc
);
123 MUIS_ClosePubScreen(desc
->Name
);
124 DoMethod(data
->LV_Screens
, MUIM_List_Remove
, MUIV_List_Remove_Active
);
133 /****************************************************************************************/
135 IPTR
ScreenPanel_Create(struct IClass
*cl
, Object
*obj
, Msg msg
)
137 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
138 DoMethod(data
->LV_Screens
, MUIM_List_InsertSingle
, NULL
, MUIV_List_Insert_Bottom
);
139 set(data
->LV_Screens
, MUIA_List_Active
, MUIV_List_Active_Bottom
);
144 /****************************************************************************************/
146 IPTR
ScreenPanel_Copy(struct IClass
*cl
, Object
*obj
, Msg msg
)
148 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
149 struct MUI_PubScreenDesc
*new,*src
;
150 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &src
);
151 if ((new = MUIS_AllocPubScreenDesc(src
)))
153 char namebuf
[PSD_MAXLEN_NAME
];
154 strcpy(namebuf
, new->Name
);
155 strcpy(new->Name
, ">");
156 stccpy(new->Name
+ 1, namebuf
, PSD_MAXLEN_NAME
- 1);
157 DoMethod(data
->LV_Screens
, MUIM_List_InsertSingle
, new, MUIV_List_Insert_Bottom
);
158 set(data
->LV_Screens
, MUIA_List_Active
, MUIV_List_Active_Bottom
);
159 MUIS_FreePubScreenDesc(new);
167 /****************************************************************************************/
169 IPTR
ScreenPanel_SetStates(struct IClass
*cl
, Object
*obj
, Msg msg
)
171 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
172 struct MUI_PubScreenDesc
*desc
;
173 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &desc
);
179 set(data->BT_Copy , MUIA_Disabled, FALSE);
180 set(data->BT_Delete, MUIA_Disabled, FALSE);
181 set(data->BT_Edit , MUIA_Disabled, FALSE);
182 set(data->BT_Open , MUIA_Disabled, TRUE );
183 set(data->BT_Close , MUIA_Disabled, TRUE );
184 set(data->BT_Jump , MUIA_Disabled, FALSE);
189 BOOL opened
= TestPubScreen(desc
->Name
);
191 set(data
->BT_Copy
, MUIA_Disabled
, FALSE
);
192 set(data
->BT_Delete
, MUIA_Disabled
, FALSE
);
193 set(data
->BT_Edit
, MUIA_Disabled
, FALSE
);
194 set(data
->BT_Open
, MUIA_Disabled
, opened
);
195 set(data
->BT_Close
, MUIA_Disabled
, !opened
);
196 set(data
->BT_Jump
, MUIA_Disabled
, FALSE
);
201 set(data
->BT_Copy
, MUIA_Disabled
, TRUE
);
202 set(data
->BT_Delete
, MUIA_Disabled
, TRUE
);
203 set(data
->BT_Edit
, MUIA_Disabled
, TRUE
);
204 set(data
->BT_Open
, MUIA_Disabled
, TRUE
);
205 set(data
->BT_Close
, MUIA_Disabled
, TRUE
);
206 set(data
->BT_Jump
, MUIA_Disabled
, TRUE
);
212 /****************************************************************************************/
214 IPTR
ScreenPanel_Close(struct IClass
*cl
, Object
*obj
, Msg msg
)
216 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
217 struct MUI_PubScreenDesc
*desc
;
218 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &desc
);
219 if (!desc
|| !MUIS_ClosePubScreen(desc
->Name
))
225 /****************************************************************************************/
227 IPTR
ScreenPanel_Open(struct IClass
*cl
, Object
*obj
, Msg msg
)
229 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
230 struct MUI_PubScreenDesc
*desc
;
231 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &desc
);
238 if (!MUIS_OpenPubScreen(desc
))
247 /****************************************************************************************/
249 IPTR
ScreenPanel_Jump(struct IClass
*cl
, Object
*obj
, Msg msg
)
251 struct ScreenPanel_Data
*data
= INST_DATA(cl
,obj
);
252 struct MUI_PubScreenDesc
*desc
;
253 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &desc
);
262 (Object
*)xget(obj
, MUIA_ApplicationObject
), MUIM_Application_SetConfigItem
,
263 MUICFG_PublicScreen
, desc
->Name
272 /****************************************************************************************/
274 IPTR
ScreenPanel_Update(struct IClass
*cl
, Object
*obj
, Msg msg
)
276 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
277 DoMethod(data
->LV_Screens
, MUIM_List_Redraw
, MUIV_List_Redraw_All
);
278 DoMethod(obj
, MUIM_ScreenPanel_SetStates
);
283 /****************************************************************************************/
285 IPTR
ScreenPanel_New(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
287 struct ScreenPanel_Data tmp
= {0};
289 obj
= (Object
*)DoSuperNewTags(cl
, obj
, NULL
,
290 MUIA_Group_Horiz
, FALSE
,
291 MUIA_Group_VertSpacing
, 0,
292 Child
, tmp
.LV_Screens
= ListviewObject
,
294 MUIA_Listview_List
, NewObject
296 CL_ScreenList
->mcc_Class
, NULL
, InputListFrame
,
297 MUIA_List_AutoVisible
, TRUE
,
301 Child
, ColGroup(4), GroupSpacing(0), MUIA_Group_SameSize
, TRUE
,
302 Child
, tmp
.BT_Create
= MakeButton(MSG_BUTTON_NEW
),
303 Child
, tmp
.BT_Copy
= MakeButton(MSG_BUTTON_COPY
),
304 Child
, tmp
.BT_Delete
= MakeButton(MSG_BUTTON_DELETE
),
305 Child
, tmp
.BT_Edit
= MakeButton(MSG_BUTTON_EDIT
),
306 Child
, tmp
.BT_Open
= MakeButton(MSG_BUTTON_OPEN
),
307 Child
, tmp
.BT_Close
= MakeButton(MSG_BUTTON_CLOSE
),
308 Child
, tmp
.BT_Jump
= MakeButton(MSG_BUTTON_JUMP
),
310 Child
, tmp
.BT_Foo
= SimpleButton("Foo"),
319 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
323 DoMethod(tmp
.BT_Delete
, MUIM_Notify
, MUIA_Pressed
, FALSE
, obj
, 1, MUIM_ScreenPanel_Delete
);
324 DoMethod(tmp
.BT_Create
, MUIM_Notify
, MUIA_Pressed
, FALSE
, obj
, 1, MUIM_ScreenPanel_Create
);
325 DoMethod(tmp
.BT_Copy
, MUIM_Notify
, MUIA_Pressed
, FALSE
, obj
, 1, MUIM_ScreenPanel_Copy
);
326 DoMethod(tmp
.BT_Edit
, MUIM_Notify
, MUIA_Pressed
, FALSE
, obj
, 1, MUIM_ScreenPanel_Edit
);
327 DoMethod(tmp
.BT_Open
, MUIM_Notify
, MUIA_Pressed
, FALSE
, obj
, 1, MUIM_ScreenPanel_Open
);
328 DoMethod(tmp
.BT_Close
, MUIM_Notify
, MUIA_Pressed
, FALSE
, obj
, 1, MUIM_ScreenPanel_Close
);
329 DoMethod(tmp
.BT_Jump
, MUIM_Notify
, MUIA_Pressed
, FALSE
, obj
, 1, MUIM_ScreenPanel_Jump
);
331 DoMethod(tmp
.BT_Foo
, MUIM_Notify
, MUIA_Pressed
, FALSE
, obj
, 1, MUIM_ScreenPanel_Foo
);
333 DoMethod(tmp
.LV_Screens
, MUIM_Notify
, MUIA_Listview_DoubleClick
, TRUE
, obj
, 1, MUIM_ScreenPanel_Edit
);
334 DoMethod(tmp
.LV_Screens
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
, obj
, 1, MUIM_ScreenPanel_SetStates
);
336 set(tmp
.BT_Delete
, MUIA_ShortHelp
,GetStr(MSG_HELP_DELETESCREEN
));
337 set(tmp
.BT_Create
, MUIA_ShortHelp
,GetStr(MSG_HELP_NEWSCREEN
));
338 set(tmp
.BT_Copy
, MUIA_ShortHelp
,GetStr(MSG_HELP_COPYSCREEN
));
339 set(tmp
.BT_Edit
, MUIA_ShortHelp
,GetStr(MSG_HELP_EDITSCREEN
));
340 set(tmp
.BT_Open
, MUIA_ShortHelp
,GetStr(MSG_HELP_OPENSCREEN
));
341 set(tmp
.BT_Close
, MUIA_ShortHelp
,GetStr(MSG_HELP_CLOSESCREEN
));
342 set(tmp
.BT_Jump
, MUIA_ShortHelp
,GetStr(MSG_HELP_JUMPSCREEN
));
343 set(tmp
.LV_Screens
, MUIA_ShortHelp
,GetStr(MSG_HELP_SCREENLIST
));
345 DoMethod(obj
, MUIM_ScreenPanel_SetStates
);
351 /****************************************************************************************/
353 IPTR
ScreenPanel_Dispose(struct IClass
*cl
, Object
*obj
, Msg msg
)
355 DoMethod(obj
, MUIM_ScreenPanel_CloseWindows
);
356 return(DoSuperMethodA(cl
, obj
, msg
));
358 /****************************************************************************************/
360 IPTR
ScreenPanel_CloseWindows(struct IClass
*cl
, Object
*obj
, Msg msg
)
362 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
363 struct MUI_PubScreenDesc
*desc
;
367 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, i
, &desc
);
371 DoMethod(obj
, MUIM_ScreenPanel_Finish
, desc
->UserData
, FALSE
);
376 /****************************************************************************************/
380 BOOL
SavePubScreen(struct MUI_PubScreenDesc
*desc
)
383 char filename
[PSD_MAXLEN_NAME
+16];
387 strcpy(filename
, "mui:Screens");
388 AddPart(filename
, desc
->Name
, sizeof(filename
));
389 strcat(filename
, ".mps");
391 if (file
= Open(filename
,MODE_NEWFILE
))
393 FPrintf(file
, "T=\"%s\"\n", desc
->Title
);
394 FPrintf(file
, "F=\"%s\"\n", desc
->Font
);
395 FPrintf(file
, "B=\"%s\"\n", desc
->Background
);
396 FPrintf(file
, "W=%ld\n" , desc
->DisplayWidth
);
397 FPrintf(file
, "H=%ld\n" , desc
->DisplayHeight
);
398 FPrintf(file
, "D=%ld\n" , desc
->DisplayDepth
);
399 FPrintf(file
, "I=%ld\n" , desc
->DisplayID
);
400 if (desc
->OverscanType
) FPrintf(file
, "OS\n");
401 if (desc
->AutoScroll
) FPrintf(file
, "AS\n");
402 if (desc
->NoDrag
) FPrintf(file
, "ND\n");
403 if (desc
->Exclusive
) FPrintf(file
, "EX\n");
404 if (desc
->Interleaved
) FPrintf(file
, "IN\n");
405 if (desc
->SysDefault
) FPrintf(file
, "SD\n");
406 if (desc
->Behind
) FPrintf(file
, "BH\n");
407 if (desc
->AutoClose
) FPrintf(file
, "AC\n");
408 if (desc
->CloseGadget
) FPrintf(file
, "CG\n");
410 FPrintf(file
, "PEN=\"");
411 for (p
= 0; p
< PSD_NUMSYSPENS
; p
++)
412 FPrintf(file
, "%ld:%ld ", p
, desc
->SystemPens
[p
]);
413 FPrintf(file
, "\"\n");
415 FPrintf(file
, "PAL=\"");
416 for (p
= 0; p
< PSD_NUMCOLS
; p
++)
419 file
, "%ld:%02lx%02lx%02lx ", p
< 4 ? p
: p
- 8,
420 desc
->Palette
[p
].red
>> 24,
421 desc
->Palette
[p
].green
>> 24,
422 desc
->Palette
[p
].blue
>> 24
424 FPrintf(file
, "\"\n");
434 /****************************************************************************************/
436 IPTR
ScreenPanel_Foo(struct IClass
*cl
, Object
*obj
, Msg msg
)
438 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
439 struct MUI_PubScreenDesc
*desc
;
446 DoMethod(data
->LV_Screens
, MUIM_List_GetEntry
, i
, &desc
);
450 printf("N=\"%s\"\n", desc
->Name
);
451 printf("T=\"%s\"\n", desc
->Title
);
452 printf("F=\"%s\"\n", desc
->Font
);
453 printf("B=\"%s\"\n", desc
->Background
);
454 printf("W=%ld\n" , desc
->DisplayWidth
);
455 printf("H=%ld\n" , desc
->DisplayHeight
);
456 printf("D=%ld\n" , desc
->DisplayDepth
);
457 printf("I=%ld\n" , desc
->DisplayID
);
458 if (desc
->OverscanType
) printf("OS\n");
459 if (desc
->AutoScroll
) printf("AS\n");
460 if (desc
->NoDrag
) printf("ND\n");
461 if (desc
->Exclusive
) printf("EX\n");
462 if (desc
->Interleaved
) printf("IN\n");
463 if (desc
->SysDefault
) printf("SD\n");
464 if (desc
->Behind
) printf("BH\n");
465 if (desc
->AutoClose
) printf("AC\n");
466 if (desc
->CloseGadget
) printf("CG\n");
469 for (p
= 0; p
< PSD_NUMSYSPENS
; p
++)
470 printf("%ld:%ld ", p
, desc
->SystemPens
[p
]);
473 printf("PALETTE=\"");
474 for (p
= 0; p
< PSD_NUMCOLS
; p
++)
477 "%ld:%02lx%02lx%02lx ", p
< 4 ? p
: p
- 8,
478 desc
->Palette
[p
].red
>> 24,
479 desc
->Palette
[p
].green
>> 24,
480 desc
->Palette
[p
].blue
>> 24
496 /****************************************************************************************/
498 BOOPSI_DISPATCHER(IPTR
, ScreenPanel_Dispatcher
, cl
, obj
, msg
)
500 switch (msg
->MethodID
)
503 return ScreenPanel_New(cl
, obj
, (APTR
)msg
);
506 return ScreenPanel_Dispose(cl
, obj
, (APTR
)msg
);
508 case MUIM_ScreenPanel_Create
:
509 return ScreenPanel_Create(cl
, obj
, (APTR
)msg
);
511 case MUIM_ScreenPanel_Copy
:
512 return ScreenPanel_Copy(cl
, obj
, (APTR
)msg
);
514 case MUIM_ScreenPanel_Delete
:
515 return ScreenPanel_Delete(cl
, obj
, (APTR
)msg
);
517 case MUIM_ScreenPanel_Edit
:
518 return ScreenPanel_Edit(cl
, obj
, (APTR
)msg
);
520 case MUIM_ScreenPanel_Finish
:
521 return ScreenPanel_Finish(cl
, obj
, (APTR
)msg
);
523 case MUIM_ScreenPanel_CloseWindows
:
524 return ScreenPanel_CloseWindows(cl
, obj
, (APTR
)msg
);
526 case MUIM_ScreenPanel_SetStates
:
527 return ScreenPanel_SetStates(cl
, obj
, (APTR
)msg
);
529 case MUIM_ScreenPanel_Open
:
530 return ScreenPanel_Open(cl
, obj
, (APTR
)msg
);
532 case MUIM_ScreenPanel_Close
:
533 return ScreenPanel_Close(cl
, obj
, (APTR
)msg
);
535 case MUIM_ScreenPanel_Jump
:
536 return ScreenPanel_Jump(cl
, obj
, (APTR
)msg
);
538 case MUIM_ScreenPanel_Update
:
539 return ScreenPanel_Update(cl
, obj
, (APTR
)msg
);
542 case MUIM_ScreenPanel_Foo
:
543 return ScreenPanel_Foo(cl
, obj
, (APTR
)msg
);
546 case MUIM_ScreenList_Find
:
548 struct ScreenPanel_Data
*data
= INST_DATA(cl
, obj
);
549 return(DoMethodA(data
->LV_Screens
, msg
));
553 return DoSuperMethodA(cl
,obj
,msg
);
555 BOOPSI_DISPATCHER_END
557 /****************************************************************************************/
559 VOID
ScreenPanel_Init(VOID
)
561 CL_ScreenPanel
= MUI_CreateCustomClass
563 NULL
, MUIC_Group
, NULL
, sizeof(struct ScreenPanel_Data
), ScreenPanel_Dispatcher
567 VOID
ScreenPanel_Exit(VOID
)
570 MUI_DeleteCustomClass(CL_ScreenPanel
);