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
)
72 /* if the current decorator isnĀ“t used remove it */
74 struct NewDecorator
* tnd
;
75 tnd
= ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
;
76 if ((tnd
!= NULL
) && (tnd
!= nd
))
78 if ((tnd
->nd_cnt
== 0) && (tnd
->nd_Port
!= NULL
))
80 struct RemoveDecoratorMsg msg
;
82 DoASyncAction((APTR
)int_removedecorator
, &msg
.msg
, sizeof(msg
), IntuitionBase
);
91 if (nd
->nd_Pattern
!= NULL
)
93 nd
->nd_IntPattern
= AllocVec(strlen(nd
->nd_Pattern
) * 2 + 1, MEMF_CLEAR
);
94 if (nd
->nd_IntPattern
)
96 struct DosLibrary
*DOSBase
= GetPrivIBase(IntuitionBase
)->DOSBase
;
98 GetPrivIBase(IntuitionBase
)->DOSBase
= DOSBase
= (struct DosLibrary
*)OpenLibrary("dos.library", 36);
102 if (ParsePattern(nd
->nd_Pattern
, nd
->nd_IntPattern
, strlen(nd
->nd_Pattern
) * 2 + 1) == -1)
104 FreeVec(nd
->nd_IntPattern
);
105 nd
->nd_IntPattern
= NULL
;
113 nd
->nd_ScreenObjOffset
= ((IPTR
) ( (char *)&((struct IntScreen
*)0)->ScrDecorObj
- (char *)0 ));
114 nd
->nd_ScreenMenuObjOffset
= ((IPTR
) ( (char *)&((struct IntScreen
*)0)->MenuDecorObj
- (char *)0 ));
115 nd
->nd_ScreenWindowObjOffset
= ((IPTR
) ( (char *)&((struct IntScreen
*)0)->WinDecorObj
- (char *)0 ));
117 bug("intuition.decor: offsets titleobj = %d, menuobj = %d, winobj = %d\n", nd
->nd_ScreenObjOffset
, nd
->nd_ScreenMenuObjOffset
, nd
->nd_ScreenWindowObjOffset
);
118 Enqueue(&((struct IntIntuitionBase
*)(IntuitionBase
))->Decorations
, (struct Node
*)nd
);
122 ((struct IntIntuitionBase
*)(IntuitionBase
))->Decorator
= nd
;
123 ((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorClass
= nd
->nd_ScreenClass
;
124 ((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorTags
= nd
->nd_ScreenTags
;
125 ((struct IntIntuitionBase
*)(IntuitionBase
))->MenuDecorClass
= nd
->nd_MenuClass
;
126 ((struct IntIntuitionBase
*)(IntuitionBase
))->MenuDecorTags
= nd
->nd_MenuTags
;
127 ((struct IntIntuitionBase
*)(IntuitionBase
))->WinDecorClass
= nd
->nd_WindowClass
;
128 ((struct IntIntuitionBase
*)(IntuitionBase
))->WinDecorTags
= nd
->nd_WindowTags
;
131 ReleaseSemaphore(&((struct IntIntuitionBase
*)(IntuitionBase
))->ScrDecorSem
);
136 /* This is called on the input.device's context */
138 static VOID
int_removedecorator(struct RemoveDecoratorMsg
*m
,
139 struct IntuitionBase
*IntuitionBase
)
141 struct DecoratorMessage msg
;
142 struct MsgPort
*port
= CreateMsgPort();
145 Remove((struct Node
*)m
->nd
);
146 if (m
->nd
->nd_IntPattern
) FreeVec(m
->nd
->nd_IntPattern
);
147 msg
.dm_Message
.mn_ReplyPort
= port
;
148 msg
.dm_Message
.mn_Magic
= MAGIC_DECORATOR
;
149 msg
.dm_Message
.mn_Version
= DECORATOR_VERSION
;
150 msg
.dm_Class
= DM_CLASS_DESTROYDECORATOR
;
153 msg
.dm_Object
= (IPTR
) m
->nd
;
154 PutMsg(m
->nd
->nd_Port
, (struct Message
*) &msg
);