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
46 void - this Function cannot fail,
49 The function fails if screens are open, use ChangeIntuition() to notify applications that
50 the UI will be changed.
61 *****************************************************************************/
65 ObtainSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
66 if (ID
== DECORATION_SET
)
70 /* if the current decorator isnĀ“t used remove it */
72 struct NewDecorator
* tnd
;
73 tnd
= ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
;
74 if ((tnd
!= NULL
) && (tnd
!= nd
))
76 if ((tnd
->nd_cnt
== 0) && (tnd
->nd_Port
!= NULL
))
78 struct RemoveDecoratorMsg msg
;
80 DoASyncAction((APTR
)int_removedecorator
, &msg
.msg
, sizeof(msg
), IntuitionBase
);
89 if (nd
->nd_Pattern
!= NULL
)
91 nd
->nd_IntPattern
= AllocVec(strlen(nd
->nd_Pattern
) * 2 + 1, MEMF_CLEAR
);
92 if (nd
->nd_IntPattern
) {
93 struct DosLibrary
*DOSBase
;
94 DOSBase
= OpenLibrary("dos.library", 40);
97 if (ParsePattern(nd
->nd_Pattern
, nd
->nd_IntPattern
, strlen(nd
->nd_Pattern
) * 2 + 1) == -1) {
98 FreeVec(nd
->nd_IntPattern
);
99 nd
->nd_IntPattern
= NULL
;
102 CloseLibrary((struct Library
*) DOSBase
);
107 Enqueue(&((struct IntIntuitionBase
*)(IntuitionBase
))->Decorations
, nd
);
111 ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
= nd
;
112 ((struct IntIntuitionBase
*)(IntuitionBase
))->WinDecorObj
= nd
->nd_Window
;
113 ((struct IntIntuitionBase
*)(IntuitionBase
))->MenuDecorObj
= nd
->nd_Menu
;
114 ((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorObj
= nd
->nd_Screen
;
117 ReleaseSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
122 /* This is called on the input.device's context */
124 static VOID
int_removedecorator(struct RemoveDecoratorMsg
*m
,
125 struct IntuitionBase
*IntuitionBase
)
127 struct DecoratorMessage msg
;
128 struct MsgPort
*port
= CreateMsgPort();
132 if (m
->nd
->nd_IntPattern
) FreeVec(m
->nd
->nd_IntPattern
);
133 msg
.dm_Message
.mn_ReplyPort
= port
;
134 msg
.dm_Message
.mn_Magic
= MAGIC_DECORATOR
;
135 msg
.dm_Message
.mn_Version
= DECORATOR_VERSION
;
136 msg
.dm_Class
= DM_CLASS_DESTROYDECORATOR
;
139 msg
.dm_Object
= (IPTR
) m
->nd
;
140 PutMsg(m
->nd
->nd_Port
, (struct Message
*) &msg
);