Documentation fix. This was discussed at the dev. mailing list and
[cake.git] / test / desktop / loaddesktop.c
blob1ffb036d85e62329d11f4685bfb2892c51748288
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #define DEBUG 1
7 #include <aros/debug.h>
9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include <libraries/mui.h>
12 #include <libraries/desktop.h>
14 #include <proto/exec.h>
15 #include <proto/dos.h>
16 #include <proto/desktop.h>
17 #include <proto/graphics.h>
18 #include <proto/intuition.h>
19 #include <proto/icon.h>
20 #include <proto/layers.h>
21 #include <proto/alib.h>
22 #include <proto/muimaster.h>
23 #include <proto/utility.h>
25 #include <workbench/workbench.h>
27 #include <stdio.h>
28 #include <stdlib.h>
30 struct Library *DesktopBase;
31 struct Library *MUIMasterBase;
33 int main(void)
35 Object *app, *win, *iconCon, *vert, *horiz;
36 Object *strip;
37 struct MUI_CustomClass *iconContainerClass;
38 BOOL running=TRUE;
39 ULONG signals=0;
40 struct Screen *screen;
41 struct NewMenu *menuDat;
42 struct TagItem icTags[6];
43 ULONG inputResult;
45 MUIMasterBase=OpenLibrary("muimaster.library", 0);
46 if(!MUIMasterBase)
47 printf("could not open muimaster.library\n");
48 DesktopBase=OpenLibrary("desktop.library", 0);
49 if(!DesktopBase)
50 printf("could not open desktop.library\n");
52 menuDat=BuildDesktopMenus();
53 if(!menuDat)
54 kprintf("EEK! EEKK! Menu ERROR!!!\n");
56 screen=LockPubScreen(NULL);
58 horiz=PropObject,
59 MUIA_Prop_Horiz, TRUE,
60 MUIA_Prop_Entries, 0,
61 MUIA_Prop_UseWinBorder, MUIV_Prop_UseWinBorder_Bottom,
62 End;
63 vert=PropObject,
64 MUIA_Prop_Horiz, FALSE,
65 MUIA_Prop_UseWinBorder, MUIV_Prop_UseWinBorder_Right,
66 End;
68 icTags[0].ti_Tag=MUIA_InnerLeft;
69 icTags[0].ti_Data=0;
70 icTags[1].ti_Tag=MUIA_InnerTop;
71 icTags[1].ti_Data=0;
72 icTags[2].ti_Tag=MUIA_InnerBottom;
73 icTags[2].ti_Data=0;
74 icTags[3].ti_Tag=MUIA_InnerRight;
75 icTags[3].ti_Data=0;
76 icTags[4].ti_Tag=MUIA_FillArea;
77 icTags[4].ti_Data=FALSE;
78 // icTags[1].ti_Tag=ICOA_Directory;
79 // icTags[1].ti_Data="C:";
80 // icTags[2].ti_Tag=ICA_VertScroller;
81 // icTags[2].ti_Data=vert;
82 // icTags[3].ti_Tag=ICA_HorizScroller;
83 // icTags[3].ti_Data=horiz;
84 icTags[5].ti_Tag=TAG_END;
85 icTags[5].ti_Data=0;
87 kprintf("here1\n");
89 app=ApplicationObject,
90 SubWindow, win=WindowObject,
91 MUIA_Window_Backdrop, TRUE,
92 MUIA_Window_Borderless, TRUE,
93 MUIA_Window_CloseGadget, FALSE,
94 MUIA_Window_DepthGadget, FALSE,
95 MUIA_Window_SizeGadget, FALSE,
96 MUIA_Window_DragBar, FALSE,
97 MUIA_Window_LeftEdge, 0,
98 MUIA_Window_TopEdge, screen->BarHeight+1,
99 MUIA_Window_Width, screen->Width,
100 MUIA_Window_Height, screen->Height-screen->BarHeight-1,
101 MUIA_Window_Menustrip, strip=MUI_MakeObject(MUIO_MenustripNM, menuDat, 0),
102 // MUIA_Window_UseBottomBorderScroller, TRUE,
103 // MUIA_Window_UseRightBorderScroller, TRUE,
104 MUIA_Window_EraseArea, FALSE,
105 WindowContents, iconCon=CreateDesktopObjectA(CDO_Desktop, icTags),
106 End,
107 End;
110 if(app)
112 DoMethod(win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
114 // these are here temporarily..
115 DoMethod(vert, MUIM_Notify, MUIA_Prop_First, MUIV_EveryTime, iconCon, 3, MUIM_Set, ICA_ScrollToVert, MUIV_TriggerValue);
116 DoMethod(horiz, MUIM_Notify, MUIA_Prop_First, MUIV_EveryTime, iconCon, 3, MUIM_Set, ICA_ScrollToHoriz, MUIV_TriggerValue);
118 SetAttrs(win, MUIA_Window_Open, TRUE, TAG_DONE);
120 while(running)
122 inputResult=DoMethod(app, MUIM_Application_Input, &signals);
123 switch(inputResult)
125 case MUIV_Application_ReturnID_Quit:
126 running=FALSE;
127 break;
128 case 2:
129 running=FALSE;
130 break;
131 default:
133 // a menuitem was selected...
134 struct MinList *subjects=NULL;
135 Object *member, *ostate;
136 Tag activeSubjectsTag;
137 struct TagItem args[2];
139 if(inputResult & DOC_DESKTOPOP)
141 args[0].ti_Tag=DDO_Target;
142 args[0].ti_Data=iconCon;
143 args[1].ti_Tag=TAG_END;
144 args[1].ti_Data=0;
146 DoDesktopOperation(inputResult, args);
148 else if(inputResult & DOC_ICONOP)
150 GetAttr(AICA_SelectedIcons, iconCon, &subjects);
152 ostate=subjects->mlh_Head;
153 while((member=NextObject(&ostate)))
155 args[0].ti_Tag=DDO_Target;
156 args[0].ti_Data=member;
157 args[1].ti_Tag=TAG_END;
158 args[1].ti_Data=0;
160 DoDesktopOperation(inputResult, args);
163 else if(inputResult & DOC_WINDOWOP)
165 GetAttr(DA_ActiveWindow, iconCon, &subjects);
167 args[0].ti_Tag=DDO_Target;
168 args[0].ti_Data=subjects;
169 args[1].ti_Tag=TAG_END;
170 args[1].ti_Data=0;
172 DoDesktopOperation(inputResult, args);
177 if(running && signals)
178 Wait(signals);
181 SetAttrs(win, MUIA_Window_Open, FALSE, TAG_DONE);
183 DisposeObject(app);
185 else
186 kprintf("could not create app\n");
189 CloseLibrary(DesktopBase);
190 CloseLibrary(MUIMasterBase);
192 return 0;