2 Copyright 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/utility.h>
8 #include <intuition/windecorclass.h>
9 #include <intuition/scrdecorclass.h>
10 #include <intuition/screens.h>
12 #include <proto/dos.h>
14 #include "intuition_intern.h"
15 #include "inputhandler_actions.h"
17 /*****************************************************************************
20 #include <proto/intuition.h>
22 struct RemoveDecoratorMsg
{
23 struct IntuiActionMsg msg
;
24 struct NewDecorator
*nd
;
27 static VOID
int_removedecorator(struct RemoveDecoratorMsg
*m
, struct IntuitionBase
*IntuitionBase
);
29 AROS_LH2(void, ChangeDecoration
,
32 AROS_LHA(ULONG
, ID
, D0
),
33 AROS_LHA(struct NewDecorator
*, nd
, A0
),
36 struct IntuitionBase
*, IntuitionBase
, 153, Intuition
)
39 setup a new decorator for intuition windows, screens or menus
42 ID - identifier for decorations, see screens.h
43 nd - an ID dependent NewDecorator structure
45 void - this Function cannot fail,
48 the function fails if screens are open, use ChangeIntuition() to notify applications that
49 the UI will be changed
59 *****************************************************************************/
63 ObtainSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
64 if (ID
== DECORATION_SET
)
68 /* if the current decorator isnĀ“t used remove it */
70 struct NewDecorator
* tnd
;
71 tnd
= ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
;
72 if ((tnd
!= NULL
) && (tnd
!= nd
))
74 if ((tnd
->nd_cnt
== 0) && (tnd
->nd_Port
!= NULL
))
76 struct RemoveDecoratorMsg msg
;
78 DoASyncAction((APTR
)int_removedecorator
, &msg
.msg
, sizeof(msg
), IntuitionBase
);
87 if (nd
->nd_Pattern
!= NULL
)
89 nd
->nd_IntPattern
= AllocVec(strlen(nd
->nd_Pattern
) * 2 + 1, MEMF_CLEAR
);
90 if (nd
->nd_IntPattern
) {
91 struct DosLibrary
*DOSBase
;
92 DOSBase
= OpenLibrary("dos.library", 40);
95 if (ParsePattern(nd
->nd_Pattern
, nd
->nd_IntPattern
, strlen(nd
->nd_Pattern
) * 2 + 1) == -1) {
96 FreeVec(nd
->nd_IntPattern
);
97 nd
->nd_IntPattern
= NULL
;
100 CloseLibrary((struct Library
*) DOSBase
);
105 Enqueue(&((struct IntIntuitionBase
*)(IntuitionBase
))->Decorations
, nd
);
109 ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
= nd
;
110 ((struct IntIntuitionBase
*)(IntuitionBase
))->WinDecorObj
= nd
->nd_Window
;
111 ((struct IntIntuitionBase
*)(IntuitionBase
))->MenuDecorObj
= nd
->nd_Menu
;
112 ((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorObj
= nd
->nd_Screen
;
115 ReleaseSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
120 /* This is called on the input.device's context */
122 static VOID
int_removedecorator(struct RemoveDecoratorMsg
*m
,
123 struct IntuitionBase
*IntuitionBase
)
125 struct DecoratorMessage msg
;
126 struct MsgPort
*port
= CreateMsgPort();
130 if (m
->nd
->nd_IntPattern
) FreeVec(m
->nd
->nd_IntPattern
);
131 msg
.dm_Message
.mn_ReplyPort
= port
;
132 msg
.dm_Message
.mn_Magic
= MAGIC_DECORATOR
;
133 msg
.dm_Message
.mn_Version
= DECORATOR_VERSION
;
134 msg
.dm_Class
= DM_CLASS_DESTROYDECORATOR
;
137 msg
.dm_Object
= (IPTR
) m
->nd
;
138 PutMsg(m
->nd
->nd_Port
, (struct Message
*) &msg
);