2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
11 #include <exec/types.h>
12 #include <graphics/rastport.h>
13 #include <graphics/gfxmacros.h>
14 #include <intuition/intuition.h>
15 #include <proto/dos.h>
16 #include <proto/exec.h>
17 #include <proto/graphics.h>
18 #include <proto/intuition.h>
40 struct IntuitionBase
*IntuitionBase
;
41 struct GfxBase
*GfxBase
;
42 struct DosLibrary
*DOSBase
;
44 struct Window
*openwindow(struct Screen
*screen
, const char *title
, LONG x
, LONG y
, LONG w
, LONG h
);
46 ULONG
handleevents(struct Window
*win
, struct Screen
*screen
, WORD x
, WORD y
);
53 WORD
drawtext(struct Window
*win
, WORD x
, WORD y
, char *fmt
, ...)
57 struct IntuiText it
= {
67 vsprintf(buf
, fmt
, args
);
69 PrintIText(win
->RPort
, &it
, x
, y
);
70 return y
+ win
->IFont
->tf_YSize
;
73 int __nocommandline
= 1;
75 int main(int argc
, char **argv
)
77 struct myargs args
= {NULL
};
80 if ((IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 0)))
82 if ((GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 0)))
84 if ((DOSBase
= (struct DosLibrary
*) OpenLibrary("dos.library",0)))
86 rda
= ReadArgs("LEFT/K/N,TOP/K/N,WIDTH/N,HEIGHT/N,DEPTH/K/N,MODEID/K,OVERSCAN/K/N,SCROLL/K/N,DRAG/K/N,LIKEWB/K/N", (IPTR
*)&args
, NULL
);
88 struct Screen
*screen
;
91 struct TagItem tags
[] = {
102 {SA_Title
, "Screen opening and movement test"},
103 {SA_ErrorCode
, &oserr
},
108 tags
[0].ti_Data
= *args
.width
;
110 tags
[1].ti_Data
= *args
.height
;
112 tags
[2].ti_Data
= *args
.depth
;
113 printf("Opening screen, size: %lux%lu, depth: %lu\n", tags
[0].ti_Data
, tags
[1].ti_Data
, tags
[3].ti_Data
);
115 tags
[3].ti_Tag
= SA_DisplayID
;
116 tags
[3].ti_Data
= strtoul(args
.mode
, NULL
, 16);
117 printf("ModeID: 0x%08lX\n", tags
[3].ti_Data
);
120 tags
[4].ti_Tag
= SA_AutoScroll
;
121 tags
[4].ti_Data
= *args
.scroll
;
122 printf("SA_Autoscroll: %ld\n", tags
[4].ti_Data
);
125 tags
[5].ti_Tag
= SA_Draggable
;
126 tags
[5].ti_Data
= *args
.drag
;
127 printf("SA_Draggable: %ld\n", tags
[5].ti_Data
);
130 tags
[6].ti_Tag
= SA_LikeWorkbench
;
131 tags
[6].ti_Data
= *args
.likewb
;
132 printf("SA_LikeWorkbench: %ld\n", tags
[6].ti_Data
);
135 tags
[7].ti_Tag
= SA_Overscan
;
136 tags
[7].ti_Data
= *args
.oscan
;
137 printf("SA_Overscan: %ld\n", tags
[7].ti_Data
);
140 tags
[8].ti_Tag
= SA_Left
;
141 tags
[8].ti_Data
= *args
.left
;
142 printf("SA_Left: %ld\n", tags
[8].ti_Data
);
145 tags
[9].ti_Tag
= SA_Top
;
146 tags
[9].ti_Data
= *args
.top
;
147 printf("SA_Left: %ld\n", tags
[9].ti_Data
);
150 screen
= OpenScreenTagList(NULL
, tags
);
152 w1
= openwindow(screen
, "Screen data", W1_LEFT
, W1_TOP
, W1_WIDTH
, W1_HEIGHT
);
154 WORD x
= w1
->BorderLeft
;
155 WORD y
= w1
->BorderTop
;
156 struct BitMap
*bitmap
= screen
->RastPort
.BitMap
;
158 y
= drawtext(w1
, x
, y
, "Requested size: %lux%lu", tags
[0].ti_Data
, tags
[1].ti_Data
);
159 y
= drawtext(w1
, x
, y
, "Requested depth: %lu", tags
[2].ti_Data
);
161 y
= drawtext(w1
, x
, y
, "Requested ModeID: 0x%08lX", tags
[3].ti_Data
);
162 y
= drawtext(w1
, x
, y
, "Actual size: %ux%u", screen
->Width
, screen
->Height
);
163 y
= drawtext(w1
, x
, y
, "Actual ModeID: 0x%08X", screen
->ViewPort
.ColorMap
->VPModeID
);
164 y
= drawtext(w1
, x
, y
, "Flags: 0x%04lX", screen
->Flags
);
165 y
= drawtext(w1
, x
, y
, "BitMap size: %ux%u", GetBitMapAttr(bitmap
, BMA_WIDTH
), GetBitMapAttr(bitmap
, BMA_HEIGHT
));
166 y
= drawtext(w1
, x
, y
, "BitMap depth: %u", GetBitMapAttr(bitmap
, BMA_DEPTH
));
167 handleevents(w1
, screen
, x
, y
);
172 printf("Failed to open screen, error: %d\n", oserr
);
175 printf("Error parsing arguments\n");
176 CloseLibrary((struct Library
*)DOSBase
);
178 CloseLibrary((struct Library
*)GfxBase
);
180 CloseLibrary((struct Library
*) IntuitionBase
);
187 struct Window
*openwindow(struct Screen
*screen
, const char *title
, LONG x
, LONG y
, LONG w
, LONG h
)
190 struct Window
*window
;
191 printf("Opening window, screen=0x%p\n", screen
);
193 window
= OpenWindowTags(NULL
,
194 WA_IDCMP
, IDCMP_CLOSEWINDOW
| IDCMP_INTUITICKS
,
199 WA_CustomScreen
, screen
,
201 WA_DepthGadget
, TRUE
,
203 WA_CloseGadget
, TRUE
,
204 WA_NoCareRefresh
, TRUE
,
205 WA_NotifyDepth
, TRUE
,
210 printf("Window opened\n");
215 ULONG
handleevents(struct Window
*win
, struct Screen
*screen
, WORD x
, WORD y
)
217 struct IntuiMessage
*imsg
;
219 struct MsgPort
*port
= win
->UserPort
;
220 BOOL terminated
= FALSE
;
225 if ((imsg
= (struct IntuiMessage
*)GetMsg(port
)) != NULL
)
230 case IDCMP_CLOSEWINDOW
:
233 case IDCMP_INTUITICKS
:
234 y1
= drawtext(win
, x
, y
, "Screen position: (%d, %d) ", screen
->LeftEdge
, screen
->TopEdge
);
235 y1
= drawtext(win
, x
, y1
, "Mouse position: (%d, %d) ", screen
->MouseX
, screen
->MouseY
);
236 y1
= drawtext(win
, x
, y1
, "ViewPort size: %dx%d ", screen
->ViewPort
.DWidth
, screen
->ViewPort
.DHeight
);
237 y1
= drawtext(win
, x
, y1
, "ViewPort position: (%d, %d) ", screen
->ViewPort
.DxOffset
, screen
->ViewPort
.DyOffset
);
238 drawtext(win
, x
, y1
, "RasInfo position: (%d, %d) ", screen
->ViewPort
.RasInfo
->RxOffset
, screen
->ViewPort
.RasInfo
->RyOffset
);
241 } /* switch (imsg->Class) */
242 ReplyMsg((struct Message
*)imsg
);
245 } /* if ((imsg = GetMsg(port)) != NULL) */
248 Wait(1L << port
->mp_SigBit
);
250 } /* while (!terminated) */
254 } /* HandleEvents() */