added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / rom / intuition / changedecorationa.c
blob08f7851d3dde1dd1995d3a5b086e9fe244dba8c1
1 /*
2 Copyright 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
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 /*****************************************************************************
19 NAME */
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,
31 /* SYNOPSIS */
32 AROS_LHA(ULONG, ID, D0),
33 AROS_LHA(struct NewDecorator *, nd, A0),
35 /* LOCATION */
36 struct IntuitionBase *, IntuitionBase, 153, Intuition)
38 /* FUNCTION
39 setup a new decorator for intuition windows, screens or menus
41 INPUTS
42 ID - identifier for decorations, see screens.h
43 nd - an ID dependent NewDecorator structure
44 RESULT
45 void - this Function cannot fail,
47 NOTES
48 the function fails if screens are open, use ChangeIntuition() to notify applications that
49 the UI will be changed
51 EXAMPLE
53 BUGS
55 SEE ALSO
57 INTERNALS
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
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;
77 msg.nd = tnd;
78 DoASyncAction((APTR)int_removedecorator, &msg.msg, sizeof(msg), IntuitionBase);
83 nd->nd_cnt = 0;
85 BOOL global = TRUE;
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);
93 if (DOSBase)
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;
99 else global = FALSE;
100 CloseLibrary((struct Library *) DOSBase);
105 Enqueue(&((struct IntIntuitionBase *)(IntuitionBase))->Decorations, nd);
107 if (global)
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);
117 AROS_LIBFUNC_EXIT
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();
127 if (port)
129 Remove(m->nd);
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;
135 msg.dm_Code = 0;
136 msg.dm_Flags = 0;
137 msg.dm_Object = (IPTR) m->nd;
138 PutMsg(m->nd->nd_Port, (struct Message *) &msg);
139 WaitPort(port);
140 GetMsg(port);
141 DeleteMsgPort(port);