2 Copyright © 1995-2014, 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>
36 struct IntuitionBase
*IntuitionBase
;
37 struct GfxBase
*GfxBase
;
38 struct DosLibrary
*DOSBase
;
40 struct Window
*openwindow(struct Screen
*screen
, const char *title
, LONG x
, LONG y
, LONG w
, LONG h
);
42 ULONG
handleevents(struct Window
*win
, struct Screen
*screen
, WORD x
, WORD y
);
49 WORD
drawtext(struct Window
*win
, WORD x
, WORD y
, char *fmt
, ...)
53 struct IntuiText it
= {
63 vsprintf(buf
, fmt
, args
);
65 PrintIText(win
->RPort
, &it
, x
, y
);
66 return y
+ win
->IFont
->tf_YSize
;
69 int __nocommandline
= 1;
71 int main(int argc
, char **argv
)
73 struct myargs args
= {NULL
};
76 if ((IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 0)))
78 if ((GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library", 0)))
80 if ((DOSBase
= (struct DosLibrary
*) OpenLibrary("dos.library",0)))
82 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
);
84 struct Screen
*screen
;
87 struct TagItem tags
[] = {
98 {SA_Title
, (IPTR
)"Screen opening and movement test"},
99 {SA_ErrorCode
, (IPTR
)&oserr
},
104 tags
[0].ti_Data
= *args
.width
;
106 tags
[1].ti_Data
= *args
.height
;
108 tags
[2].ti_Data
= *args
.depth
;
109 printf("Opening screen, size: %lux%lu, depth: %lu\n", tags
[0].ti_Data
, tags
[1].ti_Data
, tags
[3].ti_Data
);
111 tags
[3].ti_Tag
= SA_DisplayID
;
112 tags
[3].ti_Data
= strtoul(args
.mode
, NULL
, 16);
113 printf("ModeID: 0x%08lX\n", tags
[3].ti_Data
);
116 tags
[4].ti_Tag
= SA_AutoScroll
;
117 tags
[4].ti_Data
= *args
.scroll
;
118 printf("SA_AutoScroll: %ld\n", tags
[4].ti_Data
);
121 tags
[5].ti_Tag
= SA_Draggable
;
122 tags
[5].ti_Data
= *args
.drag
;
123 printf("SA_Draggable: %ld\n", tags
[5].ti_Data
);
126 tags
[6].ti_Tag
= SA_LikeWorkbench
;
127 tags
[6].ti_Data
= *args
.likewb
;
128 printf("SA_LikeWorkbench: %ld\n", tags
[6].ti_Data
);
131 tags
[7].ti_Tag
= SA_Overscan
;
132 tags
[7].ti_Data
= *args
.oscan
;
133 printf("SA_Overscan: %ld\n", tags
[7].ti_Data
);
136 tags
[8].ti_Tag
= SA_Left
;
137 tags
[8].ti_Data
= *args
.left
;
138 printf("SA_Left: %ld\n", tags
[8].ti_Data
);
141 tags
[9].ti_Tag
= SA_Top
;
142 tags
[9].ti_Data
= *args
.top
;
143 printf("SA_Top: %ld\n", tags
[9].ti_Data
);
146 screen
= OpenScreenTagList(NULL
, tags
);
148 w1
= openwindow(screen
, "Screen data", W1_LEFT
, W1_TOP
, W1_WIDTH
, W1_HEIGHT
);
150 WORD x
= w1
->BorderLeft
;
151 WORD y
= w1
->BorderTop
;
152 struct BitMap
*bitmap
= screen
->RastPort
.BitMap
;
154 y
= drawtext(w1
, x
, y
, "Requested size: %lux%lu", tags
[0].ti_Data
, tags
[1].ti_Data
);
155 y
= drawtext(w1
, x
, y
, "Requested depth: %lu", tags
[2].ti_Data
);
157 y
= drawtext(w1
, x
, y
, "Requested ModeID: 0x%08lX", tags
[3].ti_Data
);
158 y
= drawtext(w1
, x
, y
, "Actual size: %ux%u", screen
->Width
, screen
->Height
);
159 y
= drawtext(w1
, x
, y
, "Actual ModeID: 0x%08X", screen
->ViewPort
.ColorMap
->VPModeID
);
160 y
= drawtext(w1
, x
, y
, "Flags: 0x%04lX", screen
->Flags
);
161 y
= drawtext(w1
, x
, y
, "BitMap size: %ux%u", GetBitMapAttr(bitmap
, BMA_WIDTH
), GetBitMapAttr(bitmap
, BMA_HEIGHT
));
162 y
= drawtext(w1
, x
, y
, "BitMap depth: %u", GetBitMapAttr(bitmap
, BMA_DEPTH
));
163 handleevents(w1
, screen
, x
, y
);
168 printf("Failed to open screen, error: %d\n", (int)oserr
);
171 printf("Error parsing arguments\n");
172 CloseLibrary((struct Library
*)DOSBase
);
174 CloseLibrary((struct Library
*)GfxBase
);
176 CloseLibrary((struct Library
*) IntuitionBase
);
183 struct Window
*openwindow(struct Screen
*screen
, const char *title
, LONG x
, LONG y
, LONG w
, LONG h
)
186 struct Window
*window
;
187 printf("Opening window, screen=0x%p\n", screen
);
189 window
= OpenWindowTags(NULL
,
190 WA_IDCMP
, IDCMP_CLOSEWINDOW
| IDCMP_INTUITICKS
,
195 WA_CustomScreen
, screen
,
197 WA_DepthGadget
, TRUE
,
199 WA_CloseGadget
, TRUE
,
200 WA_NoCareRefresh
, TRUE
,
201 WA_NotifyDepth
, TRUE
,
206 printf("Window opened\n");
211 ULONG
handleevents(struct Window
*win
, struct Screen
*screen
, WORD x
, WORD y
)
213 struct IntuiMessage
*imsg
;
215 struct MsgPort
*port
= win
->UserPort
;
216 BOOL terminated
= FALSE
;
221 if ((imsg
= (struct IntuiMessage
*)GetMsg(port
)) != NULL
)
226 case IDCMP_CLOSEWINDOW
:
230 case IDCMP_INTUITICKS
:
231 y1
= drawtext(win
, x
, y
, "Screen position: (%d, %d) ", screen
->LeftEdge
, screen
->TopEdge
);
232 y1
= drawtext(win
, x
, y1
, "Mouse position: (%d, %d) ", screen
->MouseX
, screen
->MouseY
);
233 y1
= drawtext(win
, x
, y1
, "ViewPort size: %dx%d ", screen
->ViewPort
.DWidth
, screen
->ViewPort
.DHeight
);
234 y1
= drawtext(win
, x
, y1
, "ViewPort position: (%d, %d) ", screen
->ViewPort
.DxOffset
, screen
->ViewPort
.DyOffset
);
235 y1
= drawtext(win
, x
, y1
, "RasInfo position: (%d, %d) ", screen
->ViewPort
.RasInfo
->RxOffset
, screen
->ViewPort
.RasInfo
->RyOffset
);
236 y1
= drawtext(win
, x
, y1
, "Window position: (%d, %d) ", win
->LeftEdge
, win
->TopEdge
);
237 drawtext(win
, x
, y1
, "Window mouse position: (%d, %d) ",
238 win
->MouseX
, win
->MouseY
);
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() */