rename the directory
[AROS.git] / arch / all-ios / hidd / uikit / bitmapclass.c
blobf76bf174ac87403929bcad92f16311b0c5caef25
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Quartz bitmap class.
6 Lang: English.
7 */
9 #define DEBUG 0
10 #define DNEW(x) x
11 #define DUPD(x)
13 #include <aros/debug.h>
14 #include <hidd/graphics.h>
15 #include <oop/oop.h>
16 #include <proto/hostlib.h>
17 #include <proto/oop.h>
18 #include <proto/utility.h>
20 #include "classbase.h"
21 #include "bitmapclass.h"
23 /****************************************************************************************/
25 OOP_Object *QBitmap__Root__New(OOP_Class *cl, OOP_Object *o, struct pRoot_New *msg)
27 struct UIKitBase *base = cl->UserData;
29 DNEW(bug("QBitmap::New()\n"));
31 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg) msg);
32 if (o)
34 struct bitmap_data *data = OOP_INST_DATA(cl, o);
35 OOP_Object *gfx = NULL;
36 HIDDT_ModeID modeid = vHidd_ModeID_Invalid;
38 /* For faster operation we cache some data about ourselves */
39 data->width = OOP_GET(o, aHidd_BitMap_Width);
40 data->height = OOP_GET(o, aHidd_BitMap_Height);
41 data->mod = OOP_GET(o, aHidd_BitMap_BytesPerRow);
42 OOP_GetAttr(o, aHidd_BitMap_ModeID , &modeid);
43 OOP_GetAttr(o, aHidd_BitMap_GfxHidd , (IPTR *)&gfx);
44 OOP_GetAttr(o, aHidd_ChunkyBM_Buffer, (IPTR *)&data->pixels);
47 * Orientation currently depend on width:height ratio.
48 * For all existing devices this seems to be true. However it's not perfect. Perhaps we need to
49 * add Orientation attribute to sync class. Or introduce ability to subclass syncs.
50 * In fact would be good to have own support for screen rotation in AROS. This is not designed yet.
52 data->orientation = (data->width > data->height) ? O_LANDSCAPE : O_PORTRAIT;
54 DNEW(bug("[QBitmap] Created bitmap %d x %d\n", data->width, data->height));
55 DNEW(bug("[QBitmap] Buffer at 0x%p, %d bytes per row\n", data->pixels, data->mod));
56 DNEW(bug("[QBitmap] Display driver object: 0x%p\n", gfx));
58 HostLib_Lock();
60 base->iface->NewContext(data);
61 AROS_HOST_BARRIER
63 HostLib_Unlock();
65 DNEW(bug("[QBitmap] Bitmap context: 0x%p\n", data->context));
67 if (!data->context)
69 OOP_MethodID disp_mid = OOP_GetMethodID(IID_Root, moRoot_Dispose);
71 OOP_CoerceMethod(cl, o, &disp_mid);
72 return NULL;
75 if (modeid != vHidd_ModeID_Invalid)
77 OOP_Object *sync = NULL;
78 OOP_Object *pixfmt = NULL;
80 HIDD_Gfx_GetMode(gfx, modeid, &sync, &pixfmt);
82 data->win_width = OOP_GET(sync, aHidd_Sync_HDisp);
83 data->win_height = OOP_GET(sync, aHidd_Sync_VDisp);
85 DNEW(bug("[QBitmap] Display window size: %d x %d\n", data->win_width, data->win_height));
89 return o;
92 /****************************************************************************************/
94 void QBitmap__Root__Dispose(OOP_Class *cl, OOP_Object *o, OOP_Msg msg)
96 struct UIKitBase *base = cl->UserData;
97 struct bitmap_data *data = OOP_INST_DATA(cl, o);
99 HostLib_Lock();
101 base->iface->DisposeContext(data->context);
102 AROS_HOST_BARRIER
104 HostLib_Unlock();
106 OOP_DoSuperMethod(cl, o, msg);
109 /****************************************************************************************/
111 VOID QBitmap__Root__Get(OOP_Class *cl, OOP_Object *o, struct pRoot_Get *msg)
113 struct bitmap_data *data = OOP_INST_DATA(cl, o);
114 ULONG idx;
116 if (IS_BM_ATTR(msg->attrID, idx))
118 switch (idx)
120 case aoHidd_BitMap_LeftEdge:
121 *msg->storage = data->left;
122 return;
124 case aoHidd_BitMap_TopEdge:
125 *msg->storage = data->top;
126 return;
129 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
132 /****************************************************************************************/
134 VOID QBitmap__Root__Set(OOP_Class *cl, OOP_Object *obj, struct pRoot_Set *msg)
136 struct bitmap_data *data = OOP_INST_DATA(cl, obj);
137 struct TagItem *tag, *tstate;
138 ULONG idx;
139 BOOL change_position = FALSE;
140 BOOL show = FALSE;
142 tstate = msg->attrList;
143 while((tag = NextTagItem(&tstate)))
145 if (IS_BM_ATTR(tag->ti_Tag, idx))
147 switch(idx)
149 case aoHidd_BitMap_LeftEdge:
150 data->left = tag->ti_Data;
151 change_position = TRUE;
152 break;
154 case aoHidd_BitMap_TopEdge:
155 data->top = tag->ti_Data;
156 change_position = TRUE;
157 break;
159 case aoHidd_BitMap_Visible:
160 // data->visible = tag->ti_Data;
161 show = tag->ti_Data;
162 break;
167 if (change_position)
169 /* Fix up position. We can completely scroll out
170 of our window into all 4 sides, but not more */
171 if (data->left > data->win_width)
172 data->left = data->win_width;
173 else if (data->left < -data->width)
174 data->left = -data->width;
175 if (data->top > data->win_height)
176 data->top = data->win_height;
177 else if (data->top < -data->height)
178 data->top = -data->height;
180 /* TODO */
183 if (show)
185 /* TODO */
188 OOP_DoSuperMethod(cl, obj, (OOP_Msg)msg);
191 /****************************************************************************************/
193 VOID QBitmap__Hidd_BitMap__UpdateRect(OOP_Class *cl, OOP_Object *o, struct pHidd_BitMap_UpdateRect *msg)
195 struct bitmap_data *data = OOP_INST_DATA(cl, o);
197 /* TODO */