2 Copyright 1995-2011, 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 struct RemoveDecoratorMsg
19 struct IntuiActionMsg msg
;
20 struct NewDecorator
*nd
;
23 static VOID
int_removedecorator(struct RemoveDecoratorMsg
*m
, struct IntuitionBase
*IntuitionBase
);
25 /*****************************************************************************
28 #include <proto/intuition.h>
30 AROS_LH2(void, ChangeDecoration
,
33 AROS_LHA(ULONG
, ID
, D0
),
34 AROS_LHA(struct NewDecorator
*, nd
, A0
),
37 struct IntuitionBase
*, IntuitionBase
, 152, Intuition
)
40 Setup a new decorator for intuition windows, screens or menus.
43 ID - identifier for decorations, see screens.h
44 nd - an ID dependent NewDecorator structure
47 void - this Function cannot fail,
50 The function fails if screens are open, use ChangeIntuition() to notify applications that
51 the UI will be changed.
53 This function is private and AROS-specific. Do not use it in regular applications.
64 *****************************************************************************/
68 ObtainSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
69 if (ID
== DECORATION_SET
)
73 /* if the current decorator isnĀ“t used remove it */
75 struct NewDecorator
* tnd
;
76 tnd
= ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
;
77 if ((tnd
!= NULL
) && (tnd
!= nd
))
79 if ((tnd
->nd_cnt
== 0) && (tnd
->nd_Port
!= NULL
))
81 struct RemoveDecoratorMsg msg
;
83 DoASyncAction((APTR
)int_removedecorator
, &msg
.msg
, sizeof(msg
), IntuitionBase
);
92 if (nd
->nd_Pattern
!= NULL
)
94 nd
->nd_IntPattern
= AllocVec(strlen(nd
->nd_Pattern
) * 2 + 1, MEMF_CLEAR
);
95 if (nd
->nd_IntPattern
)
97 struct DosLibrary
*DOSBase
= GetPrivIBase(IntuitionBase
)->DOSBase
;
99 GetPrivIBase(IntuitionBase
)->DOSBase
= DOSBase
= (struct DosLibrary
*)OpenLibrary("dos.library", 36);
103 if (ParsePattern(nd
->nd_Pattern
, nd
->nd_IntPattern
, strlen(nd
->nd_Pattern
) * 2 + 1) == -1)
105 FreeVec(nd
->nd_IntPattern
);
106 nd
->nd_IntPattern
= NULL
;
114 Enqueue(&((struct IntIntuitionBase
*)(IntuitionBase
))->Decorations
, (struct Node
*)nd
);
118 ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
= nd
;
119 ((struct IntIntuitionBase
*)(IntuitionBase
))->WinDecorObj
= nd
->nd_Window
;
120 ((struct IntIntuitionBase
*)(IntuitionBase
))->MenuDecorObj
= nd
->nd_Menu
;
121 ((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorObj
= nd
->nd_Screen
;
124 ReleaseSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
129 /* This is called on the input.device's context */
131 static VOID
int_removedecorator(struct RemoveDecoratorMsg
*m
,
132 struct IntuitionBase
*IntuitionBase
)
134 struct DecoratorMessage msg
;
135 struct MsgPort
*port
= CreateMsgPort();
138 Remove((struct Node
*)m
->nd
);
139 if (m
->nd
->nd_IntPattern
) FreeVec(m
->nd
->nd_IntPattern
);
140 msg
.dm_Message
.mn_ReplyPort
= port
;
141 msg
.dm_Message
.mn_Magic
= MAGIC_DECORATOR
;
142 msg
.dm_Message
.mn_Version
= DECORATOR_VERSION
;
143 msg
.dm_Class
= DM_CLASS_DESTROYDECORATOR
;
146 msg
.dm_Object
= (IPTR
) m
->nd
;
147 PutMsg(m
->nd
->nd_Port
, (struct Message
*) &msg
);