void amiga_init (char *dir) { if ((DefaultPubScreen = LockPubScreen (0)) == 0) exit (1); screen_ratio (DefaultPubScreen); char prog_name[256]; static char font_name[MAXFONTPATH]; char *font_desc, *name_ptr; static WORD pens[] = {-1}; static struct TextAttr font = {NULL, 0, FS_NORMAL, 0}; int window = 0; if (Icon == NULL) { if (GetProgramName (prog_name, 256)) Icon = GetDiskObject (prog_name); } if (Icon) { if (FindToolType (Icon->do_ToolTypes, "WINDOW")) window = 1; if (font_desc = FindToolType (Icon->do_ToolTypes, "FONT")) { strcpy (font_name, font_desc); if (name_ptr = strrchr (font_name, '/')) { font.ta_Name = font_name; font.ta_YSize = atoi (name_ptr + 1); strcpy (name_ptr, ".font"); } } if (font.ta_Name) Font = OpenDiskFont (&font); } if (Font == NULL) { font.ta_Name = "topaz.font"; font.ta_YSize = 8; Font = OpenFont (&font); } if (window == 0) { if ((Screen = OpenScreenTags (0, SA_Pens, pens, SA_DisplayID, GetVPModeID (&DefaultPubScreen->ViewPort), SA_Overscan, OSCAN_TEXT, SA_Depth, 2, SA_Type, CUSTOMSCREEN | AUTOSCROLL, SA_Font, &font, SA_Title, TitleBar, TAG_DONE)) == 0) exit (1); } if ((Window = OpenWindowTags (0, WA_Left, 0, WA_Top, Screen ? 2 : DefaultPubScreen->BarHeight + 1, WA_Width, Screen ? Screen->Width : ScreenWidth, WA_Height, Screen ? Screen->Height - 2 : ScreenHeight - DefaultPubScreen->BarHeight - 1, WA_SmartRefresh, 1, WA_NewLookMenus, 1, WA_AutoAdjust, 1, WA_Borderless, Screen ? 1 : 0, WA_Backdrop, Screen ? 1 : 0, WA_Activate, 1, WA_CloseGadget, Screen ? 0 : 1, WA_DragBar, Screen ? 0 : 1, WA_DepthGadget, Screen ? 0 : 1, WA_SizeGadget, Screen ? 0 : 1, WA_SizeBBottom, Screen ? 0 : 1, WA_Title, TitleBar, WA_ScreenTitle, TitleBar, WA_IDCMP, IDCMP_RAWKEY | IDCMP_VANILLAKEY | IDCMP_MENUPICK | IDCMP_CLOSEWINDOW | IDCMP_CHANGEWINDOW, Screen ? WA_CustomScreen : WA_PubScreen, Screen ? Screen : DefaultPubScreen, TAG_DONE)) == 0) exit (1); ThisProcess = (struct Process *)FindTask(0); OldWindowPtr = ThisProcess->pr_WindowPtr; ThisProcess->pr_WindowPtr = Window; if ((Visual = GetVisualInfo (Window->WScreen, TAG_DONE)) == 0) exit (1); if ((Menus = CreateMenus (NewMenus, GTMN_NewLookMenus, TRUE, TAG_DONE)) == 0) exit (1); LayoutMenus (Menus, Visual, GTMN_NewLookMenus, TRUE, TAG_DONE); SetMenuStrip (Window, Menus); if ((GameReq = alloc_freq (dir)) == 0) exit (1); if ((SaveReq = alloc_freq (dir)) == 0) exit (1); if ((ScriptReq = alloc_freq (dir)) == 0) exit (1); RastPort = Window->RPort; SetDrMd (RastPort, JAM2); SetAPen (RastPort, 1); SetBPen (RastPort, 0); SetFont (RastPort, Font); DisplayHeight = ((Window->Height - Window->BorderTop - Window->BorderBottom) / RastPort->TxHeight) - 1; PreviousHeight = DisplayHeight; reset_cursor (); }
int main(int argc, char **argv) { if ((GTDragBase = OpenLibrary("gtdrag.library",3)) != 0) { if (GTD_AddApp("dragtest",GTDA_NewStyle,TRUE,TAG_END)) { if ((scr = LockPubScreen(NULL)) != 0) { vi = GetVisualInfo(scr,TAG_END); fontheight = scr->Font->ta_YSize; init(); if ((win = initWindow()) != 0) { processMsg(); CloseWindow(win); } FreeGadgets(glist); cleanup(); FreeVisualInfo(vi); UnlockPubScreen(NULL,scr); } GTD_RemoveApp(); } CloseLibrary(GTDragBase); } return 0; }
// Find (and lock) a public screen struct PubScreenNode *LIBFUNC L_FindPubScreen( REG(a0, struct Screen *screen), REG(d0, BOOL lock)) { struct List *pubscreenlist; struct PubScreenNode *node; char *name=0; // Lock the public screen list pubscreenlist=LockPubScreenList(); // Scan it for (node=(struct PubScreenNode *)pubscreenlist->lh_Head; node->psn_Node.ln_Succ; node=(struct PubScreenNode *)node->psn_Node.ln_Succ) { // See if this node is what we're looking for if (node->psn_Screen==screen) { // Get name pointer name=node->psn_Node.ln_Name; // Lock screen? if (lock && !(LockPubScreen(name))) name=0; break; } } // Unlock list UnlockPubScreenList(); // Return node pointer return (name)?node:0; }
void main() { if ((scr = LockPubScreen("Workbench"))) { wnd = OpenWindowTags(NULL, WA_Title, "Textview", WA_CloseGadget, TRUE, WA_DragBar, TRUE, WA_DepthGadget, TRUE, WA_Activate, TRUE, WA_InnerHeight, 400, WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_RAWKEY | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_VANILLAKEY, WA_SizeGadget, TRUE, WA_MinWidth, 100, WA_MinHeight, 100, WA_MaxWidth, -1, WA_MaxHeight, -1, WA_ReportMouse, TRUE, TAG_DONE); if (wnd) { if ((text = Text_Create())) { Text_SetFrameBox(text, scr, wnd->RPort, (LONG) wnd->BorderLeft, (LONG) wnd->BorderTop, wnd->Width - wnd->BorderLeft - wnd->BorderRight - 1, wnd->Height - wnd->BorderTop - wnd->BorderBottom - 1); Text_Load(text, "DH0:"); Text_Redraw(text); loop(); Text_Free(text); } CloseWindow(wnd); } UnlockPubScreen(NULL, scr); } }
void getAROSScreenSize(int *user_width, int *user_height) { // see http://wiki.amigaos.net/index.php/Intuition_Screens // setup a default in case we can't access the Workbench Screen for some reason *user_width = 640; *user_height = 480; struct Screen *my_wbscreen_ptr = LockPubScreen("Workbench"); if( my_wbscreen_ptr == NULL ) { LOG("getAROSScreenSize: failed to lock Workbench screen\n"); } else { *user_width = my_wbscreen_ptr->Width; *user_height = my_wbscreen_ptr->Height; LOG("getAROSScreenSize: Workbench screen size is %d x %d\n", *user_width, *user_height); UnlockPubScreen(NULL, my_wbscreen_ptr); #ifdef __amigaos4__ /* Performance on AmigaOS 4 is reported to be slow when run at 1280x960, so we set a max of 640x480. */ const int max_width_c = 640, max_height_c = 480; if( *user_width > max_width_c ) *user_width = max_width_c; if( *user_height > max_height_c ) *user_height = max_height_c; LOG("size restricted to %d x %d\n", *user_width, *user_height); #endif } }
static void getvisual(void) { if (!(scr = LockPubScreen(NULL))) { cleanup("Can't lock pub screen!"); } }
static void getvisual(void) { if (!(scr = LockPubScreen(0))) { cleanup("Can't lock pub screen!"); } if (!(dri = GetScreenDrawInfo(scr))) { cleanup("Can't get screen drawinfo!"); } vp = &scr->ViewPort; cm = vp->ColorMap; pen1 = ObtainPen(cm, -1, 0, 0, 0, PENF_EXCLUSIVE); pen2 = ObtainPen(cm, -1, 0, 0, 0, PENF_EXCLUSIVE); pens[0] = pen1; pens[1] = pen2; if ((pen1 == -1) || (pen2 == -1)) cleanup("Can't obtain 2 pens!"); if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) >= 15) truecolor = TRUE; }
void openWindow(void) { int windowHeight; struct Screen *lockscreen; strcpy(NiKomReleaseStr, NIKRELEASE " (" __DATE__ " " __TIME__ ")"); sprintf(windowTitle, "NiKom %s, 0 noder aktiva", NiKomReleaseStr); if(!(lockscreen = LockPubScreen(pubscreen[0] == '-' ? NULL : pubscreen))) { cleanup(EXIT_ERROR,"Kunde inte låsa angiven Public Screen\n"); } windowHeight = lockscreen->WBorTop + lockscreen->Font->ta_YSize + 1; NiKWindow = (struct Window *)OpenWindowTags(NULL, WA_Left, xpos, WA_Top, ypos, WA_Width, 500, WA_Height, windowHeight, WA_IDCMP, IDCMP_CLOSEWINDOW, WA_Title, windowTitle, WA_SizeGadget, FALSE, WA_DragBar, TRUE, WA_DepthGadget, TRUE, WA_CloseGadget, TRUE, WA_NoCareRefresh, TRUE, WA_ScreenTitle, "NiKom Server", WA_AutoAdjust, TRUE, WA_PubScreen, lockscreen); UnlockPubScreen(NULL, lockscreen); if(NiKWindow == NULL) { cleanup(EXIT_ERROR, "Could not open window."); } }
int SetupScreen( void ) { if ( ! ( Scr = LockPubScreen( PubScreenName ))) return( 1L ); ComputeFont( 0, 0 ); if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE ))) return( 2L ); return( 0L ); }
struct Window * createMainWindow(int req_width, int req_height) { struct Screen *pubScreen; struct Window *displayWin = NULL; int width, height; pubScreen = LockPubScreen(0); if (pubScreen) { width = ((pubScreen->Width * 4) / 5) & ~0x1f; height = (width * 3 / 4) & ~0x1f; if (req_width && req_width < width) width = req_width & ~0x1f; if (req_height && req_height < height) height = req_height & ~0x1f; if (height >= (pubScreen->Height * 4) / 5) { height = ((pubScreen->Height * 4) / 5) & ~0x1f; width = (height * 4 / 3) & ~0x1f; } } else { width = 320; height = 240; } if ((displayWin = OpenWindowTags(0, WA_PubScreen, (IPTR)pubScreen, WA_Left, 0, WA_Top, (pubScreen) ? pubScreen->BarHeight : 10, WA_InnerWidth, width, WA_InnerHeight, height, WA_Title, (IPTR) "SMP-Smallpt renderer", WA_SimpleRefresh, TRUE, WA_CloseGadget, TRUE, WA_DepthGadget, TRUE, WA_DragBar, TRUE, WA_SizeGadget, FALSE, WA_SizeBBottom, FALSE, WA_SizeBRight, FALSE, WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW, TAG_DONE)) != NULL) { if (pubScreen) UnlockPubScreen(0, pubScreen); } return displayWin; }
static void getvisual(void) { if (!(scr = LockPubScreen(NULL))) { cleanup("Can't lock pub screen!"); } if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) <= 8) { cleanup("Need hi or true color screen!"); } }
static int vsid_menu_create(void) { struct Screen* pubscreen = NULL; int i, j; pubscreen = LockPubScreen(NULL); if (pubscreen == NULL) { return -1; } if (!(VisualInfo = GetVisualInfo(pubscreen, TAG_DONE))) { return -1; } for (i = 0, j = 0; vsid_ui_translation_menu[i].nm_Type != NM_END; i++) { vsid_ui_menu[j].nm_Type = vsid_ui_translation_menu[i].nm_Type; vsid_ui_menu[j].nm_CommKey = vsid_ui_translation_menu[i].nm_CommKey; vsid_ui_menu[j].nm_Flags = vsid_ui_translation_menu[i].nm_Flags; vsid_ui_menu[j].nm_MutualExclude = vsid_ui_translation_menu[i].nm_MutualExclude; vsid_ui_menu[j].nm_UserData = vsid_ui_translation_menu[i].nm_UserData; switch (vsid_ui_translation_menu[i].nm_Label) { case 0: vsid_ui_menu[j++].nm_Label = (STRPTR)NM_BARLABEL; break; default: vsid_ui_menu[j++].nm_Label = translate_text(vsid_ui_translation_menu[i].nm_Label); break; } } vsid_ui_menu[i].nm_Type = NM_END; vsid_ui_menu[i].nm_CommKey = NULL; vsid_ui_menu[i].nm_Flags = 0; vsid_ui_menu[i].nm_MutualExclude = 0L; vsid_ui_menu[i].nm_UserData = NULL; vsid_ui_menu[i].nm_Label = NULL; if (!(vsid_menu = CreateMenus(vsid_ui_menu, GTMN_FrontPen, 0L, TAG_DONE))) { return -1; } LayoutMenus(vsid_menu, VisualInfo, GTMN_NewLookMenus, TRUE, TAG_DONE); SetMenuStrip(vsid_window, vsid_menu); vsid_menu_update(); UnlockPubScreen(NULL, pubscreen); return 0; }
// Open font window BOOL font_open(font_data *data) { struct Screen *screen=NULL; // Screen supplied? if (data->arg_array[ARG_SCREEN]) screen=LockPubScreen((char *)data->arg_array[ARG_SCREEN]); // Fill out new window data->new_win.parent=screen; data->new_win.dims=&data->win_dims; data->new_win.title=GetString(&data->locale,MSG_FONT_TITLE); data->new_win.locale=&data->locale; data->new_win.flags=WINDOW_SCREEN_PARENT|WINDOW_VISITOR|WINDOW_AUTO_KEYS|WINDOW_SIZE_BOTTOM|WINDOW_SIMPLE; // Default dimensions data->win_dims=font_window; // Read settings font_read_settings(data); // Open window if ((data->window=OpenConfigWindow(&data->new_win))) data->list=AddObjectList(data->window,font_objects); // Unlock screen UnlockPubScreen(0,screen); // Failed to open? if (!data->list) return FALSE; // Fix sizing limits WindowLimits(data->window, (font_window.char_dim.Width*data->window->RPort->TxWidth)+font_window.fine_dim.Width, (font_window.char_dim.Height*data->window->RPort->TxHeight)+font_window.fine_dim.Height, ~0,~0); // Add menus AddWindowMenus(data->window,font_menus); // Add AppWindow if (data->appport) data->appwindow=AddAppWindowA(0,0,data->window,data->appport,0); // Get the font font_get_font(data); return TRUE; }
void nsSplashScreenAmigaOS::Open() { if (mIsOpen) return; struct Screen *scr = mIIntuition->LockPubScreen(NULL); uint32 scrWidth, scrHeight; mIIntuition->GetScreenAttrs(scr, SA_Width, &scrWidth, SA_Height, &scrHeight, TAG_DONE); mIIntuition->UnlockPubScreen(NULL, scr); uint32 winX = (scrWidth - splash_img.width) / 2; uint32 winY = (scrHeight - splash_img.height) / 2; mWindow = mIIntuition->OpenWindowTags(NULL, WA_Flags, WFLG_BORDERLESS, WA_IDCMP, 0, WA_Left, winX, WA_Top, winY, WA_InnerWidth, splash_img.width, WA_InnerHeight, splash_img.height, WA_WindowName, "Timberwolf Splash", WA_Hidden, FALSE, TAG_DONE); mIGraphics->BltBitMapTags( BLITA_SrcX, 0, BLITA_SrcY, 0, BLITA_Width, splash_img.width, BLITA_Height, splash_img.height, BLITA_SrcType, BLITT_RGB24, BLITA_Source, splash_img.pixel_data, BLITA_SrcBytesPerRow,splash_img.bytes_per_pixel * splash_img.width, BLITA_DestX, 0, BLITA_DestY, 0, BLITA_DestType, BLITT_RASTPORT, BLITA_Dest, mWindow->RPort, TAG_DONE); mIsOpen = PR_TRUE; }
static void getvisual(void) { if (!(scr = LockPubScreen(NULL))) { cleanup("Can't lock pub screen!"); } if (1) { LONG val; val = GetCyberMapAttr(scr->RastPort.BitMap,CYBRMATTR_PIXFMT); printf("cgfx attribute = %ld\n", val); } if (GetBitMapAttr(scr->RastPort.BitMap, BMA_DEPTH) <= 8) { cleanup("Need hi or true color screen!"); } }
void _glfwPlatformGetDesktopMode( GLFWvidmode *mode ) { struct Screen *pubscreen; ULONG modeID; // Get default public screen screen handle pubscreen = LockPubScreen( NULL ); // Get screen width and height (use actual screen size rather than // ModeID nominal size) mode->Width = (int) pubscreen->Width; mode->Height = (int) pubscreen->Height; // Get ModeID for public screen modeID = GetVPModeID( &pubscreen->ViewPort ); // Release workbench screen UnlockPubScreen( NULL, pubscreen ); // Get color bits information _glfwGetModeIDInfo( modeID, NULL, NULL, &mode->RedBits, &mode->GreenBits, &mode->BlueBits, NULL ); }
/************************************************************************************** ** Main *************************************************************************************** */ VOID main() { struct Screen *pubscreen; struct ViewPort *vp; if ( !(GfxBase = OpenLibrary("graphics.library",0)) ) return(NULL); if ( !(IntuitionBase = OpenLibrary("intuition.library",0)) ) { CloseLibrary(GfxBase); return(NULL); } pubscreen = LockPubScreen(NULL); vp = &pubscreen->ViewPort; SetRGB32 (vp, 4, 123<<24, 123<<24, 123<<24 ); SetRGB32 (vp, 5, 175<<24, 175<<24, 175<<24 ); SetRGB32 (vp, 6, 170<<24, 144<<24, 124<<24 ); SetRGB32 (vp, 7, 255<<24, 169<<24, 151<<24 ); SetRGB32 (vp, 8, 0, 0, 255<<24 ); SetRGB32 (vp, 9, 50<<24, 50<<24, 50<<24 ); SetRGB32 (vp, 10, 96<<24, 128<<24, 96<<24 ); SetRGB32 (vp, 11, 226<<24, 209<<24, 119<<24 ); SetRGB32 (vp, 12, 255<<24, 212<<24, 203<<24 ); SetRGB32 (vp, 13, 122<<24, 96<<24, 72<<24 ); SetRGB32 (vp, 14, 210<<24, 210<<24, 210<<24 ); SetRGB32 (vp, 15, 229<<24, 93<<24, 93<<24 ); UnlockPubScreen(NULL,pubscreen); CloseLibrary(IntuitionBase); CloseLibrary(GfxBase); return(NULL); }
void shutdownwnd_open(void) { if ((scr = LockPubScreen(NULL))) { char *filename; /* get a white pen for the color of our text */ pen = ObtainBestPenA(scr->ViewPort.ColorMap,0xffffffff,0xffffffff,0xffffffff,NULL); if ((filename = mycombinepath(gui_get_images_directory(),"shutdown"))) { if ((obj = LoadAndMapPicture("PROGDIR:Images/shutdown",scr))) { struct BitMapHeader *bmhd = NULL; struct BitMap *bitmap = NULL; GetDTAttrs(obj,PDTA_BitMapHeader,&bmhd,TAG_DONE); GetDTAttrs(obj,PDTA_DestBitMap,&bitmap,TAG_DONE); if (!bitmap) GetDTAttrs(obj,PDTA_BitMap,&bitmap,TAG_DONE); if (bmhd && bitmap) { int width = bmhd->bmh_Width; int height = bmhd->bmh_Height; int wndleft,wndtop; wndleft = (scr->Width - width)/2; wndtop = (scr->Height - height)/2; if ((shutdown_wnd = OpenWindowTags(NULL, WA_SmartRefresh, TRUE, WA_NoCareRefresh, TRUE, WA_Borderless, TRUE, WA_Width, width, WA_Height, height, WA_PubScreen, scr, WA_Left, wndleft, WA_Top, wndtop, WA_BackFill, LAYERS_NOBACKFILL, TAG_DONE))) { BltBitMapRastPort(bitmap,0,0, shutdown_wnd->RPort, 0, 0, width, height, 0xc0); if (!user.config.dont_show_shutdown_text) { struct TextExtent te; const char *txt = _("Shutting down..."); SetDrMd(shutdown_wnd->RPort,JAM1); SetAPen(shutdown_wnd->RPort,pen); TextExtent(shutdown_wnd->RPort,txt,strlen(txt),&te); if ((te.te_Width < width) && (te.te_Height < height)) { /* only draw the text if there is enought space for it */ Move(shutdown_wnd->RPort,(width - te.te_Width)/2, height - te.te_Height - 4 + shutdown_wnd->RPort->TxBaseline); Text(shutdown_wnd->RPort,txt,strlen(txt)); } } } } } free(filename); } } }
void _config_env_screenmode_init_mode(config_env_data *data,BOOL save_depth) { struct DimensionInfo diminfo; char buf[128]; struct Screen *screen; int a; ULONG mode_id=0; BOOL got_dims=0; // Get current screenmode information switch (data->config->screen_mode) { // Existing screen case MODE_WORKBENCHUSE: case MODE_WORKBENCHCLONE: case MODE_PUBLICSCREEN: { // Strip Use/Clone from mode name stccpy(buf,data->mode_name,sizeof(buf)); for (a=strlen(buf)-1;a>=0;a--) { if (buf[a]==':') { buf[a]=0; break; } } // Get screen if (screen=LockPubScreen(buf)) { // Get screen mode mode_id=GetVPModeID(&screen->ViewPort); // Get minimum size if (data->config->screen_mode==MODE_WORKBENCHCLONE) { data->mode_size_limit.MinX=screen->Width; data->mode_size_limit.MinY=screen->Height; // Clone depth if (!save_depth) data->config->screen_depth=screen->RastPort.BitMap->Depth; } else { data->mode_size_limit.MinX=640; data->mode_size_limit.MinY=200; } // Get maximum size data->mode_size_limit.MaxX=screen->Width; data->mode_size_limit.MaxY=screen->Height; // Get default size data->mode_size_default.MaxX=screen->Width; data->mode_size_default.MaxY=screen->Height; // Got dimensions got_dims=1; // Release screen UnlockPubScreen(0,screen); } } break; // Real screen mode default: mode_id=data->config->screen_mode; break; } // Get mode info (if available) if (!(ModeNotAvailable(mode_id)) && (GetDisplayInfoData(0,(char *)&diminfo,sizeof(diminfo),DTAG_DIMS,mode_id))) { // Not already got dimensions? if (!got_dims) { // Get minimum size data->mode_size_limit.MinX=diminfo.MinRasterWidth; data->mode_size_limit.MinY=diminfo.MinRasterHeight; // Get maximum size data->mode_size_limit.MaxX=diminfo.MaxRasterWidth; data->mode_size_limit.MaxY=diminfo.MaxRasterHeight; // Get default size data->mode_size_default.MaxX=diminfo.TxtOScan.MaxX+1; data->mode_size_default.MaxY=diminfo.TxtOScan.MaxY+1; } // Get maximum colours data->mode_max_colours=diminfo.MaxDepth; } // Check settings if (data->mode_size_limit.MinX<640) data->mode_size_limit.MinX=640; if (data->mode_size_limit.MinY<200) data->mode_size_limit.MinY=200; if (data->mode_size_limit.MaxX<data->mode_size_limit.MinX) data->mode_size_limit.MaxX=data->mode_size_limit.MinX; if (data->mode_size_limit.MaxY<data->mode_size_limit.MinY) data->mode_size_limit.MaxY=data->mode_size_limit.MinY; if (data->mode_size_default.MaxX<data->mode_size_limit.MinX) data->mode_size_default.MaxX=data->mode_size_limit.MinX; else if (data->mode_size_default.MaxX>data->mode_size_limit.MaxX) data->mode_size_default.MaxX=data->mode_size_limit.MaxX; if (data->mode_size_default.MaxY<data->mode_size_limit.MinY) data->mode_size_default.MaxY=data->mode_size_limit.MinY; else if (data->mode_size_default.MaxY>data->mode_size_limit.MaxY) data->mode_size_default.MaxY=data->mode_size_limit.MaxY; if (data->mode_max_colours<1) data->mode_max_colours=1; // Fix gadgets _config_env_screenmode_fix_gadgets(data); }
int detect_screen(void) { struct Screen *myScreen; struct Window *myWindow; struct RastPort myRastPort; struct BitMap *myBitMap; APTR bitMapHandle; ULONG result; int bpp = 0; if((ULONG)IntuitionBase == 0) { IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39L); } if((ULONG)GfxBase == 0) { GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39L); } if((ULONG)CyberGfxBase == 0) { CyberGfxBase = OpenLibrary("cybergraphics.library", 0); } if(!CyberGfxBase) { if( !(CyberGfxBase=OpenLibrary("cybergraphics.library",40L))) { printf("Couldn't open cybergraphics."); return(-1); } } myScreen = LockPubScreen(NULL); if(myScreen != NULL) { UnlockPubScreen(NULL, myScreen); } else { printf("Couldnt get screen data.\n"); CloseLibrary((struct Library*)IntuitionBase); CloseLibrary(CyberGfxBase); CloseLibrary((struct Library *)GfxBase); return 5; } myBitMap = AllocBitMap(1, 1, 8, BMF_MINPLANES | BMF_DISPLAYABLE, myScreen->RastPort.BitMap); if((ULONG)myBitMap == 0) { printf("Couldnt allocate bitmap.\n"); CloseLibrary(CyberGfxBase); CloseLibrary((struct Library *)GfxBase); CloseLibrary((struct Library *)IntuitionBase); return 6; } //Creates the RastPort used for blitting InitRastPort(&myRastPort); myRastPort.BitMap = myBitMap; result=GetCyberMapAttr(myBitMap, CYBRMATTR_PIXFMT); switch(result) { case 0://PIXFMT_LUT8: bpp = 8; //printf("0"); break; case 1://PIXFMT_RGB15: bpp = 16; //printf("1"); break; case 2://PIXFMT_BGR15: bpp = 16; //printf("2"); break; case 3://PIXFMT_RGB15PC: bpp = 16; //printf("3"); break; case 4://PIXFMT_BGR15PC: bpp = 16; //printf("4"); break; case 5://PIXFMT_RGB16: bpp = 16; //printf("5"); break; case 6://PIXFMT_BGR16: bpp = 16; //printf("6"); break; case 7://PIXFMT_RGB16PC: bpp = 16; //printf("7"); break; case 8://PIXFMT_BGR16PC: bpp = 16; //printf("8"); break; case 9://PIXFMT_RGB24: bpp = 24; //printf("9"); break; case 10://PIXFMT_BGR24: bpp = 24; //printf("10"); break; case 11://PIXFMT_ARGB32: bpp = 32; //printf("11"); break; case 12://PIXFMT_BGRA32: #if defined NOVA_SDL bpp = 16; //printf("12"); #else bpp = 32; //printf("12"); #endif break; case 13://PIXFMT_RGBA32: bpp = 32; //printf("13"); break; default: bpp = 16; //printf("14"); } #ifdef DEBUG printf("Pixel format: %d \n",result); printf("Bpp: %d ",bpp); #endif FreeBitMap(myBitMap); CloseLibrary((struct Library *)IntuitionBase); //CloseLibrary(CyberGfxBase); //CloseLibrary((struct Library *)GfxBase); return bpp; }
BOOL BuildGUI(char *screenname) { Object **ar = Window_Objs; struct Screen *screen; BOOL OptionFrame = FALSE; LONG indicatorwidth = 100; UpdateStrings(); // Kludge for Piccaso 96/BGUI. if(FindTask("Picasso96")) { PopUpMenus = FALSE; } BGUIBase = (void *)OpenLibrary("bgui.library", 41); if(BGUIBase == NULL) { Printf((char *) msgTextNoOpen, (ULONG) "bgui.library", 41); Printf("\n"); return FALSE; } screen = LockPubScreen(screenname); indicatorwidth = max(indicatorwidth, 16 * screen->RastPort.Font->tf_XSize); if(screen->Height > 240) { OptionFrame = TRUE; } WO_Window = WindowObject, WINDOW_PubScreen, screen, WINDOW_Title, (char *) msgTextProgramName, WINDOW_CloseGadget, FALSE, WINDOW_MenuStrip, Menus, WINDOW_AutoAspect, TRUE, WINDOW_AutoKeyLabel, TRUE, WINDOW_ScaleWidth, 60, WINDOW_ScaleHeight, 20, WINDOW_HelpFile, HELPFILE, WINDOW_HelpNode, "AHI", WINDOW_IDCMPHook, &IDCMPhook, WINDOW_IDCMPHookBits, IDCMP_RAWKEY, WINDOW_MasterGroup, VGroupObject, NormalOffset, /* TABS */ StartMember, ar[ACTID_TABS] = MxObject, MX_Labels, PageNames, MX_TabsObject, TRUE, GA_ID, ACTID_TABS, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_PAGE] = PageObject, NormalSpacing, PAGE_NoBufferRP, TRUE, /* PAGE 1 */ PageMember, HGroupObject, NormalOffset, NormalSpacing, TabAboveFrame, StartMember, vgroup = VGroupObject, NormalSpacing, StartMember, ar[ACTID_UNIT] = CycleObject, CYC_Labels, Units, CYC_Active, state.UnitSelected, CYC_PopActive, PopUpMenus, CYC_Popup, PopUpMenus, GA_ID, ACTID_UNIT, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_MODE] = ListviewObject, // LISTV_EntryArray, Modes, // LISTV_Select, state.ModeSelected, PGA_NewLook, TRUE, GA_ID, ACTID_MODE, EndObject, EndMember, StartMember, HGroupObject, ButtonFrame, FRM_Flags, FRF_RECESSED, StartMember, InfoObject, INFO_TextFormat, (char *) msgProperties, INFO_FixTextWidth,TRUE, INFO_MinLines, 6, EndObject, FixMinWidth, EndMember, StartMember, ar[SHOWID_MODE] = InfoObject, INFO_MinLines, 6, EndObject, EndMember, EndObject, FixMinHeight, EndMember, EndObject /* vgroup */, EndMember, StartMember, VGroupObject, NormalSpacing, VarSpace(1), StartMember, VGroupObject, (OptionFrame ? GROUP_HorizOffset : TAG_IGNORE), GRSPACE_NORMAL, (OptionFrame ? GROUP_VertOffset : TAG_IGNORE), GRSPACE_NORMAL, (OptionFrame ? GROUP_Spacing : TAG_IGNORE), GRSPACE_NORMAL, (OptionFrame ? FRM_Type : TAG_IGNORE), FRTYPE_RIDGE, (OptionFrame ? FRM_Flags : TAG_IGNORE), FRF_RECESSED, (OptionFrame ? FRM_Title : TAG_IGNORE), (char *) msgOptions, StartMember, HGroupObject, StartMember, ar[ACTID_FREQ] = SliderObject, LAB_Label, (char *) msgOptFrequency, SLIDER_Min, 0, SLIDER_Max, state.Frequencies -1 , SLIDER_Level, state.FreqSelected, PGA_NewLook, TRUE, GA_ID, ACTID_FREQ, EndObject, EndMember, StartMember, ar[SHOWID_FREQ] = InfoObject, INFO_TextFormat, getFreq(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_CHANNELS] = SliderObject, LAB_Label, (char *) msgOptChannels, SLIDER_Min, 1, SLIDER_Max, state.Channels, SLIDER_Level, state.ChannelsSelected, PGA_NewLook, TRUE, GA_ID, ACTID_CHANNELS, EndObject, EndMember, StartMember, ar[SHOWID_CHANNELS] = InfoObject, INFO_TextFormat, getChannels(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_OUTVOL] = SliderObject, LAB_Label, (char *) msgOptVolume, SLIDER_Min, 0, SLIDER_Max, state.OutVols-1 , SLIDER_Level, state.OutVolSelected, PGA_NewLook, TRUE, GA_ID, ACTID_OUTVOL, EndObject, EndMember, StartMember, ar[SHOWID_OUTVOL] = InfoObject, INFO_TextFormat, getOutVol(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_MONVOL] = SliderObject, LAB_Label, (char *) msgOptMonitor, SLIDER_Min, 0, SLIDER_Max, state.MonVols-1 , SLIDER_Level, state.MonVolSelected, PGA_NewLook, TRUE, GA_ID, ACTID_MONVOL, EndObject, EndMember, StartMember, ar[SHOWID_MONVOL] = InfoObject, INFO_TextFormat, getMonVol(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_GAIN] = SliderObject, LAB_Label, (char *) msgOptGain, SLIDER_Min, 0, SLIDER_Max, state.Gains-1 , SLIDER_Level, state.GainSelected, PGA_NewLook, TRUE, GA_ID, ACTID_GAIN, EndObject, EndMember, StartMember, ar[SHOWID_GAIN] = InfoObject, INFO_TextFormat, getGain(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_INPUT] = SliderObject, LAB_Label, (char *) msgOptInput, SLIDER_Min, 0, SLIDER_Max, state.Inputs-1 , SLIDER_Level, state.InputSelected, PGA_NewLook, TRUE, GA_ID, ACTID_INPUT, EndObject, EndMember, StartMember, ar[SHOWID_INPUT] = InfoObject, INFO_TextFormat, getInput(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, StartMember, HGroupObject, StartMember, ar[ACTID_OUTPUT] = SliderObject, LAB_Label, (char *) msgOptOutput, SLIDER_Min, 0, SLIDER_Max, state.Outputs-1 , SLIDER_Level, state.OutputSelected, PGA_NewLook, TRUE, GA_ID, ACTID_OUTPUT, EndObject, EndMember, StartMember, ar[SHOWID_OUTPUT] = InfoObject, INFO_TextFormat, getOutput(), INFO_VertOffset, 0, EndObject, FixWidth(indicatorwidth), EndMember, EndObject, FixMinHeight, EndMember, EndObject /* vgroup "Options" */, FixMinHeight, EndMember, VarSpace(1), EndObject /* vgroup */, EndMember, EndObject, /* (EndMember) page */ /* PAGE 2 */ PageMember, HGroupObject, NormalSpacing, TabAboveFrame, VarSpace(1), StartMember, VGroupObject, NormalSpacing, VarSpace(1), StartMember, VGroupObject, NormalOffset, NormalSpacing, RidgeFrame, FRM_Flags, FRF_RECESSED, FrameTitle((char *) msgGlobalOptions), StartMember, HGroupObject, NormalSpacing, StartMember, VGroupObject, NormalSpacing, StartMember, ar[ACTID_DEBUG] = CycleObject, LAB_Label, (char *) msgGlobOptDebugLevel, LAB_Place, PLACE_LEFT, CYC_Labels, DebugLabels, CYC_Active, globalprefs.ahigp_DebugLevel, CYC_PopActive, PopUpMenus, CYC_Popup, PopUpMenus, GA_ID, ACTID_DEBUG, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_ECHO] = CycleObject, LAB_Label, (char *) msgGlobOptEcho, LAB_Place, PLACE_LEFT, CYC_Labels, EchoLabels, CYC_Active, (globalprefs.ahigp_DisableEcho ? 2 : 0) | (globalprefs.ahigp_FastEcho ? 1 : 0), CYC_PopActive, PopUpMenus, CYC_Popup, PopUpMenus, GA_ID, ACTID_ECHO, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_SURROUND] = CycleObject, LAB_Label, (char *) msgGlobOptSurround, LAB_Place, PLACE_LEFT, CYC_Labels, SurroundLabels, CYC_Active, globalprefs.ahigp_DisableSurround, GA_ID, ACTID_SURROUND, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_CLIPMV] = CycleObject, LAB_Label, (char *) msgGlobOptMasterVol, LAB_Place, PLACE_LEFT, CYC_Labels, ClipMVLabels, CYC_Active, globalprefs.ahigp_ClipMasterVolume, GA_ID, ACTID_CLIPMV, EndObject, FixMinHeight, EndMember, StartMember, ar[ACTID_CPULIMIT] = SliderObject, LAB_Label, (char *) msgGlobOptCPULimit, SLIDER_Min, 0, SLIDER_Max, 100, SLIDER_Level, (globalprefs.ahigp_MaxCPU * 100 + 32768) >> 16, PGA_NewLook, TRUE, GA_ID, ACTID_CPULIMIT, EndObject, EndMember, EndObject /* vgroup */, EndMember, StartMember, VGroupObject, NormalSpacing, VarSpace(1), StartMember, ar[SHOWID_CPULIMIT] = IndicatorObject,\ INDIC_Min, 0, INDIC_Max, 100, INDIC_Level, (globalprefs.ahigp_MaxCPU * 100 + 32768) / 65536, INDIC_Justification, IDJ_LEFT, INDIC_FormatString, "%ld%%", EndObject, FixMinWidth, FixMinHeight, EndMember, EndObject /* vgroup */, EndMember, EndObject /* hgroup */, EndMember, EndObject, FixMinWidth, FixMinHeight, EndMember, VarSpace(1), EndObject /* vgroup */ , FixMinWidth, EndMember, VarSpace(1), EndObject, /* (EndMember) page */ EndObject /* page */, EndMember, /* BUTTONS */ StartMember, HGroupObject, NormalSpacing, NormalVOffset, StartMember, ar[ACTID_SAVE] = ButtonObject, ButtonFrame, LAB_Label, (char *) msgButtonSave, GA_ID, ACTID_SAVE, EndObject, EndMember, StartMember, ar[ACTID_USE] = ButtonObject, ButtonFrame, LAB_Label, (char *) msgButtonUse, GA_ID, ACTID_USE, EndObject, EndMember, StartMember, ar[ACTID_QUIT] = ButtonObject, ButtonFrame, LAB_Label, (char *) msgButtonCancel, GA_ID, ACTID_QUIT, EndObject, EndMember, EndObject, FixMinHeight, EndMember, EndObject, EndObject; if(WO_Window) { AddMap( ar[ACTID_TABS], ar[ACTID_PAGE], pagemap ); DoMethod( ar[ACTID_FREQ], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_CHANNELS], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_OUTVOL], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_MONVOL], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_GAIN], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_INPUT], BASE_ADDHOOK, &GadgetHook ); DoMethod( ar[ACTID_OUTPUT], BASE_ADDHOOK, &GadgetHook ); AddMap( ar[ACTID_CPULIMIT], ar[SHOWID_CPULIMIT], cpumap); window = WindowOpen(WO_Window); } if(screen) { UnlockPubScreen(NULL, screen); } if(window == NULL) { Printf((char *) msgTextNoWindow); Printf("\n"); return FALSE; } openreq = FileReqObject, ASLFR_Window, window, ASLFR_SleepWindow, TRUE, ASLFR_RejectIcons, TRUE, ASLFR_InitialDrawer, "SYS:Prefs/Presets", EndObject; savereq = FileReqObject, ASLFR_Window, window, ASLFR_SleepWindow, TRUE, ASLFR_RejectIcons, TRUE, ASLFR_InitialDrawer, "SYS:Prefs/Presets", ASLFR_DoSaveMode, TRUE, EndObject; if((openreq == NULL) || (savereq == NULL)) { Printf((char *) msgTextNoFileRequester); Printf("\n"); return FALSE; } // Update the checkmark for "Create Icons?" { struct Menu *menu = NULL; struct MenuItem *item; GetAttr( WINDOW_MenuStrip, WO_Window, (ULONG *) &menu); ClearMenuStrip(window); item = FindMenuItem(ACTID_ICONS); if(item) { if(SaveIcons) item->Flags |= CHECKED; else item->Flags &= ~CHECKED; } ResetMenuStrip(window, menu); } GUINewUnit(); return TRUE; }
/* ** main routine. Open required library and window and draw the images. ** This routine opens a very simple window with no IDCMP. See the ** chapters on "Windows" and "Input and Output Methods" for more info. ** Free all resources when done. */ int main(int argc, char **argv) { struct Screen *screen; struct DrawInfo *drawinfo; struct Window *win; struct IntuiText myIText; struct TextAttr myTextAttr; ULONG myTEXTPEN; ULONG myBACKGROUNDPEN; IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37); if (IntuitionBase) { #ifdef __AROS__ if ((screen = LockPubScreen(NULL))) #else if (screen = LockPubScreen(NULL)) #endif { #ifdef __AROS__ if ((drawinfo = GetScreenDrawInfo(screen))) #else if (drawinfo = GetScreenDrawInfo(screen)) #endif { /* Get a copy of the correct pens for the screen. ** This is very important in case the user or the ** application has the pens set in a unusual way. */ myTEXTPEN = drawinfo->dri_Pens[TEXTPEN]; myBACKGROUNDPEN = drawinfo->dri_Pens[BACKGROUNDPEN]; /* create a TextAttr that matches the specified font. */ myTextAttr.ta_Name = drawinfo->dri_Font->tf_Message.mn_Node.ln_Name; myTextAttr.ta_YSize = drawinfo->dri_Font->tf_YSize; myTextAttr.ta_Style = drawinfo->dri_Font->tf_Style; myTextAttr.ta_Flags = drawinfo->dri_Font->tf_Flags; /* open a simple window on the workbench screen for displaying ** a text string. An application would probably never use such a ** window, but it is useful for demonstrating graphics... */ #ifdef __AROS__ if ((win = OpenWindowTags(NULL, WA_PubScreen, (IPTR)screen, WA_RMBTrap, TRUE, WA_IDCMP, IDCMP_RAWKEY, TAG_END))) #else if (win = OpenWindowTags(NULL, WA_PubScreen, screen, WA_RMBTrap, TRUE, TAG_END)) #endif { myIText.FrontPen = myTEXTPEN; myIText.BackPen = myBACKGROUNDPEN; myIText.DrawMode = JAM2; myIText.LeftEdge = MYTEXT_LEFT; myIText.TopEdge = MYTEXT_TOP; myIText.ITextFont = &myTextAttr; myIText.IText = "Hello, World. ;-)"; myIText.NextText = NULL; /* Draw the text string at 10,10 */ PrintIText(win->RPort,&myIText,10,10); #ifdef __AROS__ /* Wait for keypress */ Wait (1L << win->UserPort->mp_SigBit); #else /* Wait a bit, then quit. ** In a real application, this would be an event loop, ** like the one described in the Intuition Input and ** Output Methods chapter. */ Delay(200); #endif CloseWindow(win); } FreeScreenDrawInfo(screen,drawinfo); } UnlockPubScreen(NULL,screen); } CloseLibrary((struct Library *)IntuitionBase); } return 0; }
void hidd_demo(struct ExecBase * SysBase) { D(bug("graphics.hidd = %08.8lx\n",OpenLibrary("graphics.hidd",0))); D(bug("display.hidd = %08.8lx\n",OpenLibrary("display.hidd",0))); OpenLibrary("hidd.gfx.display",0); { struct GfxBase *GfxBase; BOOL success = FALSE; D(bug("init_gfx(hiddbase=%s)\n", "hidd.gfx.display")); GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37); if (GfxBase) { /* Call private gfx.library call to init the HIDD. Gfx library is responsable for closing the HIDD library (although it will probably not be neccesary). */ D(bug("calling private gfx LateGfxInit()\n")); if (LateGfxInit("hidd.gfx.display")) { struct IntuitionBase *IntuitionBase; D(bug("lategfxinit okay\n")); /* Now that gfx. is guaranteed to be up & working, let intuition open WB screen */ IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37); D(bug("ibase = %lx\n", IntuitionBase)); if (IntuitionBase) { if (LateIntuiInit(NULL)) { success = TRUE; } CloseLibrary((struct Library *)IntuitionBase); } } D(bug("Closing gfx\n")); CloseLibrary((struct Library *)GfxBase); if (success == FALSE) { D(bug("There is something wrong with hidd subsystem...")); while(1) {}; } } } #if 0 { struct IORequest *io; struct MsgPort *mp; mp=CreateMsgPort(); io=CreateIORequest(mp,sizeof(struct IOStdReq)); D(bug("Result of opening device %d\n", OpenDevice("gameport.device",0,io,0))); D(bug("Doing CMD_HIDDINIT...\n")); { UBYTE *data; data = AllocMem(100, MEMF_PUBLIC); strcpy(data, "hidd.bus.mouse"); ioStd(io)->io_Command=32000; ioStd(io)->io_Data=data; ioStd(io)->io_Length=strlen(data); DoIO(io); D(bug("Got io_ERROR=%d",io->io_Error)); } } #endif { struct IntuitionBase *IntuitionBase; struct GfxBase *GfxBase; struct Window * win = NULL; #define XSTART 50 #define YSTART 50 int x = XSTART; int y = YSTART; IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37); GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 37); if (IntuitionBase) { struct TagItem tags[] = { {WA_Width, 100}, {WA_Height, 100}, {WA_Left, x}, {WA_Top, y}, {WA_MinWidth, 100}, {WA_MinHeight, 100}, {WA_MaxWidth, 120}, {WA_MaxHeight, 120}, {WA_Title, (ULONG)"AROS Dream :-)"}, {WA_Activate, 1}, {WA_SizeGadget, TRUE}, {WA_DepthGadget, TRUE}, {TAG_DONE, 0}}; win = OpenWindowTagList(0, tags); } DrawEllipse(win->RPort,160/2-35,120/2-4,80/2,80/2); DrawEllipse(win->RPort,185/2-35,90/2-4,15/2,15/2); DrawEllipse(win->RPort,135/2-35,90/2-4,15/2,15/2); Move(win->RPort,125/2-35,140/2-4); Draw(win->RPort,140/2-35,150/2-4); Draw(win->RPort,180/2-35,150/2-4); Draw(win->RPort,195/2-35,140/2-4); #if 0 if (win) { while (x < 100) { MoveWindow(win,1,0); x++; } while (y < 100) { MoveWindow(win,0,1); y++; } while (x > XSTART) { MoveWindow(win,-1,0); x--; } while (y > YSTART) { MoveWindow(win,0,-1); y--; } } #endif #if 0 if (IntuitionBase) { struct Screen *screen; struct Window *win2; struct IntuiMessage *msg; char ScreenInfo[40]; if ((screen = LockPubScreen(NULL))) { struct TagItem tags[] = { {WA_Width, 640}, {WA_Height, 100}, {WA_Left, 0}, {WA_Top, 79}, {WA_MinWidth, 200}, {WA_MinHeight, 100}, {WA_MaxWidth, 640}, {WA_MaxHeight, 480}, {WA_Title, (ULONG)"AROS !ext" }, {WA_Activate, 1}, {WA_CloseGadget, TRUE}, {WA_SizeGadget, TRUE}, {WA_DepthGadget, TRUE}, {WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_MOUSEMOVE | IDCMP_RAWKEY}, {WA_ReportMouse, TRUE}, {TAG_DONE, 0}}; win2 = OpenWindowTagList(0, tags); sprintf(ScreenInfo,"ScreenWidth: %d, ScreenHeight: %d", screen->Width, screen->Height); if (win2) { BlackPrint(win2->RPort, ScreenInfo, 40, GfxBase); for(;;) { BOOL quitme = FALSE; WaitPort(win2->UserPort); while((msg = ((struct IntuiMessage *)GetMsg(win2->UserPort)))) { switch(msg->Class) { case IDCMP_RAWKEY: { static char hex[] = "0123456789ABCDEF"; char s[9]; s[0] = 'K'; s[1] = 'e'; s[2] = 'y'; s[3] = ' '; s[4] = hex[(msg->Code >> 12) & 0xF]; s[5] = hex[(msg->Code >> 8) & 0xF]; s[6] = hex[(msg->Code >> 4) & 0xF]; s[7] = hex[(msg->Code >> 0) & 0xF]; s[8] = '\0'; BlackPrint(win2->RPort, s, 60, GfxBase); if (msg->Code == 0x45) quitme = TRUE; } break; case IDCMP_MOUSEMOVE: { WORD mx = win2->WScreen->MouseX; WORD my = win2->WScreen->MouseY; char s[20]; sprintf(s, "Mouse: %4d, %4d", mx, my); WhitePrint(win2->RPort, s, 80, GfxBase); #if 0 mx &= 511; my &= 255; SetAPen(&win2->WScreen->RastPort, 1); SetDrMd(&win2->WScreen->RastPort, JAM2); WritePixel(&win2->WScreen->RastPort, mx, my); #endif } break; case IDCMP_CLOSEWINDOW: { quitme = TRUE; } break; } ReplyMsg((struct Message *)msg); } if (quitme) break; } CloseWindow(win2); } UnlockPubScreen(NULL,screen); } } #endif } }
int main(void) { Object *app, *win, *iconCon, *vert, *horiz; Object *strip; struct MUI_CustomClass *iconContainerClass; BOOL running=TRUE; ULONG signals=0; struct Screen *screen; struct NewMenu *menuDat; struct TagItem icTags[6]; ULONG inputResult; MUIMasterBase=OpenLibrary("muimaster.library", 0); if(!MUIMasterBase) printf("could not open muimaster.library\n"); DesktopBase=OpenLibrary("desktop.library", 0); if(!DesktopBase) printf("could not open desktop.library\n"); menuDat=BuildDesktopMenus(); if(!menuDat) kprintf("EEK! EEKK! Menu ERROR!!!\n"); screen=LockPubScreen(NULL); horiz=PropObject, MUIA_Prop_Horiz, TRUE, MUIA_Prop_Entries, 0, MUIA_Prop_UseWinBorder, MUIV_Prop_UseWinBorder_Bottom, End; vert=PropObject, MUIA_Prop_Horiz, FALSE, MUIA_Prop_UseWinBorder, MUIV_Prop_UseWinBorder_Right, End; icTags[0].ti_Tag=MUIA_InnerLeft; icTags[0].ti_Data=0; icTags[1].ti_Tag=MUIA_InnerTop; icTags[1].ti_Data=0; icTags[2].ti_Tag=MUIA_InnerBottom; icTags[2].ti_Data=0; icTags[3].ti_Tag=MUIA_InnerRight; icTags[3].ti_Data=0; icTags[4].ti_Tag=MUIA_FillArea; icTags[4].ti_Data=FALSE; // icTags[1].ti_Tag=ICOA_Directory; // icTags[1].ti_Data="C:"; // icTags[2].ti_Tag=ICA_VertScroller; // icTags[2].ti_Data=vert; // icTags[3].ti_Tag=ICA_HorizScroller; // icTags[3].ti_Data=horiz; icTags[5].ti_Tag=TAG_END; icTags[5].ti_Data=0; kprintf("here1\n"); app=ApplicationObject, SubWindow, win=WindowObject, MUIA_Window_Backdrop, TRUE, MUIA_Window_Borderless, TRUE, MUIA_Window_CloseGadget, FALSE, MUIA_Window_DepthGadget, FALSE, MUIA_Window_SizeGadget, FALSE, MUIA_Window_DragBar, FALSE, MUIA_Window_LeftEdge, 0, MUIA_Window_TopEdge, screen->BarHeight+1, MUIA_Window_Width, screen->Width, MUIA_Window_Height, screen->Height-screen->BarHeight-1, MUIA_Window_Menustrip, strip=MUI_MakeObject(MUIO_MenustripNM, menuDat, 0), // MUIA_Window_UseBottomBorderScroller, TRUE, // MUIA_Window_UseRightBorderScroller, TRUE, MUIA_Window_EraseArea, FALSE, WindowContents, iconCon=CreateDesktopObjectA(CDO_Desktop, icTags), End, End; if(app) { DoMethod(win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit); // these are here temporarily.. DoMethod(vert, MUIM_Notify, MUIA_Prop_First, MUIV_EveryTime, iconCon, 3, MUIM_Set, ICA_ScrollToVert, MUIV_TriggerValue); DoMethod(horiz, MUIM_Notify, MUIA_Prop_First, MUIV_EveryTime, iconCon, 3, MUIM_Set, ICA_ScrollToHoriz, MUIV_TriggerValue); SetAttrs(win, MUIA_Window_Open, TRUE, TAG_DONE); while(running) { inputResult=DoMethod(app, MUIM_Application_Input, &signals); switch(inputResult) { case MUIV_Application_ReturnID_Quit: running=FALSE; break; case 2: running=FALSE; break; default: { // a menuitem was selected... struct MinList *subjects=NULL; Object *member, *ostate; Tag activeSubjectsTag; struct TagItem args[2]; if(inputResult & DOC_DESKTOPOP) { args[0].ti_Tag=DDO_Target; args[0].ti_Data=iconCon; args[1].ti_Tag=TAG_END; args[1].ti_Data=0; DoDesktopOperation(inputResult, args); } else if(inputResult & DOC_ICONOP) { GetAttr(AICA_SelectedIcons, iconCon, &subjects); ostate=subjects->mlh_Head; while((member=NextObject(&ostate))) { args[0].ti_Tag=DDO_Target; args[0].ti_Data=member; args[1].ti_Tag=TAG_END; args[1].ti_Data=0; DoDesktopOperation(inputResult, args); } } else if(inputResult & DOC_WINDOWOP) { GetAttr(DA_ActiveWindow, iconCon, &subjects); args[0].ti_Tag=DDO_Target; args[0].ti_Data=subjects; args[1].ti_Tag=TAG_END; args[1].ti_Data=0; DoDesktopOperation(inputResult, args); } } } if(running && signals) Wait(signals); } SetAttrs(win, MUIA_Window_Open, FALSE, TAG_DONE); DisposeObject(app); } else kprintf("could not create app\n"); CloseLibrary(DesktopBase); CloseLibrary(MUIMasterBase); return 0; }
VOID __stdargs __main( char *argstring ) { static struct Args args; LONG rev; /* Get arguments if started from CLI */ if( !_WBenchMsg ) { if( !( RDArgs = ReadArgs( TEMPLATE, ( IPTR * ) &args, NULL ) ) ) { PrintFault( IoErr(), GetString( MSG_ERROR_ARGS ) ); __exit( 0 ); } } IntuiHook.h_Entry = ( HOOKFUNC ) IntuiMsgFunc; // DefaultPrefs.Flags = 0; DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ ].ReqPos = REQPOS_POINTER; DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ ].Size = 75; DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ ].Size = DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].Size = DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ ].Size = 65; DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ ].ReqPos = DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ ].ReqPos = DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].ReqPos = DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ ].ReqPos = DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ ].ReqPos = REQPOS_TOPLEFTSCR; DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ ].LeftOffset = DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ ].LeftOffset = DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].LeftOffset = DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ ].LeftOffset = DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ ].LeftOffset = DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ ].LeftOffset = 25; DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ ].TopOffset = DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ ].TopOffset = DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].TopOffset = DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ ].TopOffset = DefaultPrefs.ReqDefaults[ RTPREF_PALETTEREQ ].TopOffset = DefaultPrefs.ReqDefaults[ RTPREF_OTHERREQ ].TopOffset = 18; DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ ].MinEntries = 10; DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ ].MinEntries = DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].MinEntries = DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ ].MinEntries = 6; DefaultPrefs.ReqDefaults[ RTPREF_FILEREQ ].MaxEntries = 50; DefaultPrefs.ReqDefaults[ RTPREF_FONTREQ ].MaxEntries = DefaultPrefs.ReqDefaults[ RTPREF_SCREENMODEREQ ].MaxEntries = DefaultPrefs.ReqDefaults[ RTPREF_VOLUMEREQ ].MaxEntries = 10; if( !( IntuitionBase = ( struct IntuitionBase * ) OpenLibrary( "intuition.library", 37 ) ) ) { BPTR con; if( ( con = Open( "CON:40/20/320/40/ReqTools 2.8", MODE_NEWFILE ) ) ) { Write( con, "\nNeed OS 2.04 or better!\n", 25 ); Delay( 120L ); Close( con ); } FreeExit( 0 ); } InitLocale(); GfxBase = OpenLib( "graphics.library", 37 ); UtilityBase = OpenLib( "utility.library", 36 ); IconBase = OpenLib( "icon.library", 0 ); GadToolsBase = OpenLib( "gadtools.library", 37 ); ReqToolsBase = OpenLib( "reqtools.library", 38 ); rev = ReqToolsBase->LibNode.lib_Revision; if( ( rev >= 693 && rev <= 811 ) || ( rev >= 347 && rev <= 363 ) ) { LocEZReq( MSG_WRONG_REQTOOLS_VERSION, MSG_ABORT ); FreeExit( RETURN_FAIL ); } if( rtLockPrefs()->PrefsSize != PREFSLEN ) { LocEZReq( MSG_ALL_PREFS_NOT_SUPPORTED, MSG_OK ); } rtUnlockPrefs(); if( _WBenchMsg ) { struct WBArg *wbarg; BPTR oldcd; CreateIcons = TRUE; wbarg = &_WBenchMsg->sm_ArgList[ 0 ]; oldcd = CurrentDir( wbarg->wa_Lock ); if( ( DiskObject = GetDiskObject( wbarg->wa_Name ) ) ) { STRPTR str; if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "CREATEICONS" ) ) ) { CreateIcons = Stricmp( str, "NO" ); } if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "SCREENFONT" ) ) ) { UseScreenFont = Stricmp( str, "NO" ); } if( ( str = FindToolType( (UBYTE **)DiskObject->do_ToolTypes, "PUBSCREEN" ) ) ) { args.PubScreen = str; } } CurrentDir( oldcd ); } else { if( args.ScreenFont ) { UseScreenFont = Stricmp( args.ScreenFont, "NO" ); } } if( !( FileReq = rtAllocRequestA( RT_FILEREQ, NULL ) ) ) { FreeExit( RETURN_FAIL ); } { struct TagItem tags[] = { {RTFI_Dir , (IPTR)"Presets" }, {TAG_DONE } }; rtChangeReqAttrA( FileReq, tags ); } /* Get current prefs from ReqTools */ CopyMem( rtLockPrefs(), &RTPrefs, sizeof( struct ReqToolsPrefs ) ); rtUnlockPrefs(); /* If FROM was used load prefs from disk */ if( args.From ) { if( !LoadConfig( args.From ) ) { FreeExit( RETURN_ERROR ); } } WheelType = GetWheelType( RTPrefs.Flags ); if( !( Screen = LockPubScreen( args.PubScreen ) ) ) { LocEZReq( MSG_COULDNT_LOCK_PUBSCREEN, MSG_ABORT ); FreeExit( RETURN_ERROR ); } if( !( DrawInfo = GetScreenDrawInfo( Screen ) ) ) { LocEZReq( MSG_ERROR_GETSCREENDRAWINFO, MSG_ABORT ); FreeExit( RETURN_ERROR ); } if( !( VisualInfo = GetVisualInfoA( Screen, NULL ) ) ) { LocEZReq( MSG_ERROR_GETVISUALINFO, MSG_ABORT ); FreeExit( RETURN_FAIL ); } if( IntuitionBase->LibNode.lib_Version >= 39 ) { Zoom[ 0 ] = Zoom[ 1 ] = 65535; } else { Zoom[ 1 ] = Screen->BarHeight + 1; } Zoom[ 2 ] = 250; Zoom[ 3 ] = Screen->WBorTop + Screen->Font->ta_YSize + 1; LocalizeMenus( NewMenu ); if( !( Menus = CreateMenusA( NewMenu, NULL ) ) ) { LocEZReq( MSG_ERROR_MENUS, MSG_ABORT ); FreeExit( RETURN_FAIL ); } LayoutMenus( Menus, VisualInfo, GTMN_NewLookMenus, TRUE, TAG_END ); if( !OpenGUI() ) { LocEZReq( MSG_COULDNT_OPEN_WINDOW, MSG_ABORT ); FreeExit( RETURN_FAIL ); } { struct MenuItem *iconItem; iconItem = ItemAddress( Menus, FULLMENUNUM( OPTIONS_MENU, SAVEICONS_ITEM, NOSUB ) ); if( !CreateIcons ) { iconItem->Flags &= ~CHECKED; } } CurrentReq = RTPREF_FILEREQ; ReqDefs = &RTPrefs.ReqDefaults[ CurrentReq ]; LoopGUI(); FreeExit( 0 ); }
/***************************************** * Opens up the window & sets the gadgets * *****************************************/ int setup_window(void) { struct Gadget *g; struct NewGadget ng; UWORD offy; ULONG drawtags[20]; static const char *keyb_langs[] = { "US", "DE", "SE", "FR", "IT", NULL }; scr = LockPubScreen(NULL); if (!scr) return (0); VisInfo = GetVisualInfo(scr, TAG_DONE); if (!VisInfo) return (0); offy = scr->WBorTop + scr->RastPort.TxHeight + 1; /* Create buttons */ g = CreateContext(&glist); if (!g) return (0); ng.ng_TextAttr = &topaz8; ng.ng_VisualInfo = VisInfo; ng.ng_Flags = PLACETEXT_IN; ng.ng_LeftEdge = 284; ng.ng_TopEdge = offy + 86; ng.ng_Width = 96; ng.ng_Height = 15; ng.ng_GadgetText = (UBYTE *) "Hard Reset"; ng.ng_GadgetID = GAD_RESET; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); ng.ng_TopEdge = offy + 105; ng.ng_GadgetText = (UBYTE *) "Debug"; ng.ng_GadgetID = GAD_DEBUG; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); ng.ng_TopEdge = offy + 135; ng.ng_GadgetText = (UBYTE *) "Quit UAE"; ng.ng_GadgetID = GAD_EXITEMU; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); /* Eject buttons */ ng.ng_LeftEdge = 262; ng.ng_TopEdge = offy + 11; ng.ng_Width = 70; ng.ng_GadgetID = GAD_EJECT_DF0; ng.ng_GadgetText = (UBYTE *) "Eject"; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); ng.ng_TopEdge = offy + 28; ng.ng_GadgetID = GAD_EJECT_DF1; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); ng.ng_TopEdge = offy + 45; ng.ng_GadgetID = GAD_EJECT_DF2; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); ng.ng_TopEdge = offy + 62; ng.ng_GadgetID = GAD_EJECT_DF3; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); /* Insert buttons */ ng.ng_LeftEdge = 332; ng.ng_TopEdge = offy + 11; ng.ng_GadgetID = GAD_INSERT_DF0; ng.ng_GadgetText = (UBYTE *) "Insert"; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); ng.ng_TopEdge = offy + 28; ng.ng_GadgetID = GAD_INSERT_DF1; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); ng.ng_TopEdge = offy + 45; ng.ng_GadgetID = GAD_INSERT_DF2; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); ng.ng_TopEdge = offy + 62; ng.ng_GadgetID = GAD_INSERT_DF3; g = CreateGadget(BUTTON_KIND, g, &ng, TAG_DONE); /* Sound & Joystick buttons */ ng.ng_LeftEdge = 133; ng.ng_TopEdge = 97; ng.ng_GadgetID = GAD_SOUND; ng.ng_GadgetText = (UBYTE *) "Sound:"; ng.ng_Flags = PLACETEXT_LEFT; g = CreateGadget(CHECKBOX_KIND, g, &ng, GTCB_Checked, config.do_output_sound ? 1 : 0, TAG_DONE); ng.ng_TopEdge = 114; ng.ng_GadgetID = GAD_JOYSTICK; ng.ng_GadgetText = (UBYTE *) "Fake Joystick:"; g = CreateGadget(CHECKBOX_KIND, g, &ng, GTCB_Checked, config.do_fake_joystick ? 1 : 0, TAG_DONE); ng.ng_TopEdge = 129; ng.ng_GadgetID = GAD_LANGUAGE; ng.ng_GadgetText = (UBYTE *) "Language:"; g = CreateGadget(CYCLE_KIND, g, &ng, GTCY_Labels, (ULONG) keyb_langs, GTCY_Active, config.keyboard, TAG_DONE); ng.ng_TopEdge = 146; ng.ng_GadgetID = GAD_FRAMERATE; ng.ng_GadgetText = (UBYTE *) "Framerate:"; g = CreateGadget(INTEGER_KIND, g, &ng, GTIN_Number, config.framerate, TAG_DONE); newwindow.Title = "UAE-Control"; newwindow.Width = 419; newwindow.Height = 171; newwindow.LeftEdge = 20; newwindow.TopEdge = 20; newwindow.FirstGadget = glist; newwindow.Screen = scr; /* Store screen ptr */ window = OpenWindow(&newwindow); if (!window) return (0); /* Draw texts etc... */ SetAPen(window->RPort, 1); SetDrMd(window->RPort, JAM2); Move(window->RPort, 19, offy + 11 + 10); Text(window->RPort, (UBYTE *) "DF0:", 4); Move(window->RPort, 19, offy + 28 + 10); Text(window->RPort, (UBYTE *) "DF1:", 4); Move(window->RPort, 19, offy + 45 + 10); Text(window->RPort, (UBYTE *) "DF2:", 4); Move(window->RPort, 19, offy + 62 + 10); Text(window->RPort, (UBYTE *) "DF3:", 4); drawtags[0] = GT_VisualInfo; drawtags[1] = (ULONG) VisInfo; drawtags[2] = GTBB_Recessed; drawtags[3] = 1; drawtags[4] = TAG_DONE; DrawBevelBoxA(window->RPort, 14, offy + 10, 390, 17, (struct TagItem *) &drawtags); DrawBevelBoxA(window->RPort, 14, offy + 27, 390, 17, (struct TagItem *) &drawtags); DrawBevelBoxA(window->RPort, 14, offy + 44, 390, 17, (struct TagItem *) &drawtags); DrawBevelBoxA(window->RPort, 14, offy + 61, 390, 17, (struct TagItem *) &drawtags); print_drive_status(); return (1); }
// Open progress window void progress_open(ProgressWindow *prog) { struct IBox win; struct TextFont *font; struct Screen *wbscreen=0,*screen; struct LibData *libdata; short a,last=-1; // Already open? if (prog->pw_Window) { // If we have an owner window, move in front of it if (prog->pw_OwnerWindow) MoveWindowInFrontOf(prog->pw_Window,prog->pw_OwnerWindow); return; } // Get library data pointer libdata=(struct LibData *)prog->pw_Lib->ml_UserData; // Got a screen to open on? if (!(screen=prog->pw_Screen) && !(prog->pw_OwnerWindow && (screen=prog->pw_OwnerWindow->WScreen))) { // Lock public screen if (!(wbscreen=LockPubScreen(0))) return; // Use this screen screen=wbscreen; } // Get font pointer font=screen->RastPort.Font; // Initial size win.Width=0; win.Height=0; // Clear coordinates for (a=0;a<PROG_LAST;a++) { prog->pw_Coords[a].Left=0; prog->pw_Coords[a].Top=0; prog->pw_Coords[a].Width=0; prog->pw_Coords[a].Height=0; } // Want filename display? if (prog->pw_Flags&PWF_FILENAME) { // Get position prog->pw_Coords[PROG_NAME].Width=font->tf_XSize*24; prog->pw_Coords[PROG_NAME].Height=font->tf_YSize; // Want size display? if (prog->pw_Flags&PWF_FILESIZE) { char *ptr; short len; // Get appropriate string ptr=GetString(&libdata->locale,(prog->pw_Flags&PWF_SWAP)?MSG_FILE_FIT:MSG_SIZE_FIT); // Get length of byte string len=TextLength(&screen->RastPort,ptr,strlen(ptr)); // Get position prog->pw_Coords[PROG_SIZE].Left= prog->pw_Coords[PROG_NAME].Left+ prog->pw_Coords[PROG_NAME].Width+32; prog->pw_Coords[PROG_SIZE].Width=len; prog->pw_Coords[PROG_SIZE].Height=font->tf_YSize; // Cache size string prog->pw_SizeString=GetString(&libdata->locale,(prog->pw_Flags&PWF_SWAP)?MSG_FILE:MSG_SIZE); last=PROG_SIZE; } // Set last id else last=PROG_NAME; } // Want information display? if (prog->pw_Flags&PWF_INFO) { // Get position prog->pw_Coords[PROG_INFO].Top=(prog->pw_Flags&PWF_FILENAME)?font->tf_YSize+2:0; prog->pw_Coords[PROG_INFO].Width=40*font->tf_XSize; prog->pw_Coords[PROG_INFO].Height=font->tf_YSize; last=PROG_INFO; } // Want information display? if (prog->pw_Flags&PWF_INFO2) { // Get position prog->pw_Coords[PROG_INFO2].Top=prog->pw_Coords[last].Top+prog->pw_Coords[last].Height+2; prog->pw_Coords[PROG_INFO2].Width=40*font->tf_XSize; prog->pw_Coords[PROG_INFO2].Height=font->tf_YSize; last=PROG_INFO2; } // Want information display? if (prog->pw_Flags&PWF_INFO3) { // Get position prog->pw_Coords[PROG_INFO3].Top=prog->pw_Coords[last].Top+prog->pw_Coords[last].Height+2; prog->pw_Coords[PROG_INFO3].Width=40*font->tf_XSize; prog->pw_Coords[PROG_INFO3].Height=font->tf_YSize; last=PROG_INFO3; } // Want bar graph? if (prog->pw_Flags&PWF_GRAPH) { // Get position if (last>-1) prog->pw_Coords[PROG_GRAPH].Top=prog->pw_Coords[last].Top+prog->pw_Coords[last].Height+3; prog->pw_Coords[PROG_GRAPH].Width=40*font->tf_XSize; prog->pw_Coords[PROG_GRAPH].Height=font->tf_YSize+6; last=PROG_GRAPH; } // Get window size for (a=0;a<=last;a++) { short x,y; // Get bottom-left coordinates of this item x=prog->pw_Coords[a].Left+prog->pw_Coords[a].Width-1; y=prog->pw_Coords[a].Top+prog->pw_Coords[a].Height-1; // Check against current window size if (win.Width<x) win.Width=x; if (win.Height<y) win.Height=y; } // Info can grow to fill window if (prog->pw_Flags&PWF_INFO) { // Check against width if (prog->pw_Coords[PROG_INFO].Width<win.Width) prog->pw_Coords[PROG_INFO].Width=win.Width; } // Info can grow to fill window if (prog->pw_Flags&PWF_INFO2) { // Check against width if (prog->pw_Coords[PROG_INFO2].Width<win.Width) prog->pw_Coords[PROG_INFO2].Width=win.Width; } // Info can grow to fill window if (prog->pw_Flags&PWF_INFO3) { // Check against width if (prog->pw_Coords[PROG_INFO3].Width<win.Width) prog->pw_Coords[PROG_INFO3].Width=win.Width; } // As can the graph if (prog->pw_Flags&PWF_GRAPH) { // Check against width if (prog->pw_Coords[PROG_GRAPH].Width<win.Width) prog->pw_Coords[PROG_GRAPH].Width=win.Width; } // Filename can too if there's no filesize if ((prog->pw_Flags&(PWF_FILENAME|PWF_FILESIZE))==PWF_FILENAME) { // Check against width if (prog->pw_Coords[PROG_NAME].Width<win.Width) prog->pw_Coords[PROG_NAME].Width=win.Width; } // If there's a filesize, it should be right-justified if (prog->pw_Flags&PWF_FILESIZE) { // Right-justify prog->pw_Coords[PROG_SIZE].Left=win.Width-prog->pw_Coords[PROG_SIZE].Width; } // Want abort gadget? if ((prog->pw_SigTask || prog->pw_Flags&PWF_ABORT) && !(prog->pw_Flags&PWF_NOABORT)) { char *ptr=GetString(&libdata->locale,MSG_ABORT); short len; // Get length of abort string len=TextLength(&screen->RastPort,ptr,strlen(ptr)); // Get gadget size prog->pw_Coords[PROG_LAST].Width=len+16; prog->pw_Coords[PROG_LAST].Height=font->tf_YSize+6; // Got a graph? if (prog->pw_Flags&PWF_GRAPH) { // Shrink graph to fit progress gadget prog->pw_Coords[PROG_GRAPH].Width-=prog->pw_Coords[PROG_LAST].Width+8; } // Otherwise, grow window by height of gadget else { win.Height+=prog->pw_Coords[PROG_LAST].Height; if (win.Width<prog->pw_Coords[PROG_LAST].Width) win.Width=prog->pw_Coords[PROG_LAST].Width; } // Position gadget prog->pw_Coords[PROG_LAST].Left=win.Width-prog->pw_Coords[PROG_LAST].Width; prog->pw_Coords[PROG_LAST].Top=win.Height-prog->pw_Coords[PROG_LAST].Height+1; } // Get border sizes prog->pw_Offset.x=6; prog->pw_Offset.y=6; // Add additional space to window win.Width+=prog->pw_Offset.x<<1; win.Height+=prog->pw_Offset.y<<1; // Add system border sizes win.Width+=screen->WBorLeft+screen->WBorRight; win.Height+=screen->WBorTop+screen->WBorBottom+font->tf_YSize+1; // Is window position valid? if (prog->pw_PosValid) { // Get saved position win.Left=prog->pw_WindowPos.x; win.Top=prog->pw_WindowPos.y; } // Calculate window position else if (prog->pw_OwnerWindow) { // Center in owner window win.Left=prog->pw_OwnerWindow->LeftEdge+((prog->pw_OwnerWindow->Width-win.Width)>>1); win.Top=prog->pw_OwnerWindow->TopEdge+((prog->pw_OwnerWindow->Height-win.Height)>>1); }
void main() { ULONG class,code; struct Gadget *gadget; struct IntuiMessage *message; struct DrawInfo *dri; BOOL running=TRUE; unless(Scr=LockPubScreen("Workbench")) LEAVE; unless(dri=GetScreenDrawInfo(Scr)) LEAVE; unless(SmartBitMapBase=OpenLibrary("images/smartbitmap.image",36L)) LEAVE; unless(ImClass=GetSmartBitMapClass()) LEAVE; GetRGB32(Scr->ViewPort.ColorMap,0,1,&pal[0].R); unless(Im=NewObject(ImClass,NULL, IA_Left,25, IA_Top,25, IA_Width,20, SMBM_Border,FALSE, SMBM_SelBorder,TRUE, SMBM_Screen,Scr, SMBM_BitMap,&TBCOLORWHEELBitMap, // SMBM_BitMap,&Size45UDBitMap, SMBM_Palette,pal, TAG_DONE)) LEAVE; unless(MainWnd=OpenWindowTags(NULL, WA_Left,0, WA_Top,0, WA_Width,600, WA_Height,200, WA_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_GADGETUP, WA_Flags,WFLG_CLOSEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_ACTIVATE|WFLG_SIZEGADGET, WA_CustomScreen,Scr, TAG_DONE)) LEAVE; DrawImageState(MainWnd->RPort,(struct Image *)Im,0,0,IDS_NORMAL,dri); while(running) { Wait(1L<<MainWnd->UserPort->mp_SigBit); while(message=GT_GetIMsg(MainWnd->UserPort)) { class=message->Class; code=message->Code; gadget=(struct Gadget *)message->IAddress; GT_ReplyIMsg(message); switch(class) { case IDCMP_CLOSEWINDOW: running=FALSE; break; } } } end: if(MainWnd) { CloseWindow(MainWnd); } if(Im) DisposeObject(Im); if(SmartBitMapBase) CloseLibrary(SmartBitMapBase); if(dri) FreeScreenDrawInfo(Scr,dri); if(Scr) UnlockPubScreen(NULL,Scr); }
BOOL BuildGUI(char *screenname) { Object **ar = Window_Objs; struct Screen *screen; BOOL OptionFrame = FALSE; LONG indicatorwidth = 100; Object *l1, *l2, *l3, *l4, *l5, *l6, *l7; UpdateStrings(); if (ButtonBase == NULL) { /* force it open */ Printf((char *) msgTextNoOpen, "button.gadget", __classactversion); Printf("\n"); return FALSE; } /* Dynamic */ unitlist = ChooserLabelsA( (STRPTR *) Units); modelist = BrowserNodesA( (STRPTR *) Modes); infolist = BrowserNodes2(infotexts, infoargs); /* Static */ pagelist = ClickTabs( (char *) msgPageMode, (char *) msgPageAdvanced, NULL); debuglist = ChooserLabels( (char *) msgDebugNone, (char *) msgDebugLow, (char *) msgDebugHigh, (char *) msgDebugFull, NULL); echolist = ChooserLabels( (char *) msgEchoEnabled, (char *) msgEchoFast, (char *) msgEchoDisabled, NULL); surroundlist = ChooserLabels( (char *) msgSurroundEnabled, (char *) msgSurroundDisabled, NULL); clipMVlist = ChooserLabels( (char *) msgMVNoClip, (char *) msgMVClip, NULL); screen = LockPubScreen(screenname); vi = GetVisualInfoA(screen, NULL); Menu = CreateMenusA(NewMenus, NULL); if(vi == NULL || Menu == NULL) { Printf((char *) msgTextNoWindow); Printf("\n"); return FALSE; } if(!LayoutMenus(Menu, vi, GTMN_NewLookMenus, TRUE, TAG_DONE)) { Printf((char *) msgTextNoWindow); Printf("\n"); return FALSE; } indicatorwidth = max(indicatorwidth, 16 * screen->RastPort.Font->tf_XSize); if(screen->Height > 240) { OptionFrame = TRUE; } ar[ACTID_PAGE] = PageObject, PAGE_Current, 0, /* PAGE 1 */ PAGE_Add, HLayoutObject, LAYOUT_VertAlignment, LALIGN_CENTER, LAYOUT_AddChild, VLayoutObject, LAYOUT_AddChild, ar[ACTID_UNIT] = PopUpObject, CHOOSER_Labels, unitlist, CHOOSER_Active, state.UnitSelected, ChooserEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, ar[ACTID_MODE] = ListBrowserObject, LISTBROWSER_Labels, modelist, LISTBROWSER_MakeVisible,state.ModeSelected, LISTBROWSER_Selected, state.ModeSelected, LISTBROWSER_ShowSelected,TRUE, ListBrowserEnd, LAYOUT_AddChild, ar[SHOWID_MODE] = ListBrowserObject, LISTBROWSER_Labels, infolist, LISTBROWSER_ColumnInfo, (ULONG)&ci, LISTBROWSER_AutoFit, TRUE, LISTBROWSER_VertSeparators, FALSE, GA_ReadOnly, TRUE, ListBrowserEnd, CHILD_MaxHeight, screen->RastPort.Font->tf_YSize * 6 + 6, // UHH!! LayoutEnd, LAYOUT_AddChild, HLayoutObject, (OptionFrame ? LAYOUT_SpaceOuter : TAG_IGNORE), TRUE, (OptionFrame ? LAYOUT_RightSpacing : TAG_IGNORE), 0, (OptionFrame ? LAYOUT_BevelStyle : TAG_IGNORE), BVS_GROUP, (OptionFrame ? LAYOUT_Label : TAG_IGNORE), (char *) msgOptions, LAYOUT_AddChild, VLayoutObject, LAYOUT_AddChild, l1 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_FREQ] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.Frequencies, SLIDER_Level, state.FreqSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptFrequency, LabelEnd, LAYOUT_AddChild, ar[SHOWID_FREQ] = ButtonObject, GA_Text, getFreq(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l2 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_CHANNELS] = SliderObject, SLIDER_Min, 1, SLIDER_Max, state.Channels, SLIDER_Level, state.ChannelsSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptChannels, LabelEnd, LAYOUT_AddChild, ar[SHOWID_CHANNELS] = ButtonObject, GA_Text, getChannels(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l3 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_OUTVOL] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.OutVols, SLIDER_Level, state.OutVolSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptVolume, LabelEnd, LAYOUT_AddChild, ar[SHOWID_OUTVOL] = ButtonObject, GA_Text, getOutVol(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l4 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_MONVOL] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.MonVols, SLIDER_Level, state.MonVolSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptMonitor, LabelEnd, LAYOUT_AddChild, ar[SHOWID_MONVOL] = ButtonObject, GA_Text, getMonVol(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l5 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_GAIN] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.Gains, SLIDER_Level, state.GainSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptGain, LabelEnd, LAYOUT_AddChild, ar[SHOWID_GAIN] = ButtonObject, GA_Text, getGain(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l6 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_INPUT] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.Inputs, SLIDER_Level, state.InputSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptInput, LabelEnd, LAYOUT_AddChild, ar[SHOWID_INPUT] = ButtonObject, GA_Text, getInput(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LAYOUT_AddChild, l7 = HLayoutObject, LAYOUT_AddChild, ar[ACTID_OUTPUT] = SliderObject, SLIDER_Min, 0, SLIDER_Max, state.Outputs, SLIDER_Level, state.OutputSelected, SLIDER_Orientation, SORIENT_HORIZ, GA_UserData, &GadgetHook, SliderEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgOptOutput, LabelEnd, LAYOUT_AddChild, ar[SHOWID_OUTPUT] = ButtonObject, GA_Text, getOutput(), GA_ReadOnly, TRUE, BUTTON_BevelStyle, BVS_NONE, BUTTON_Transparent, TRUE, BUTTON_Justification, BCJ_LEFT, ButtonEnd, CHILD_MinWidth, indicatorwidth, CHILD_MaxWidth, indicatorwidth, LayoutEnd, LayoutEnd, LayoutEnd, CHILD_WeightedHeight, 0, LayoutEnd, /* PAGE 2 */ PAGE_Add, HLayoutObject, LAYOUT_VertAlignment, LALIGN_CENTER, LAYOUT_HorizAlignment, LALIGN_CENTER, LAYOUT_AddChild, VLayoutObject, LAYOUT_SpaceOuter, TRUE, LAYOUT_BevelStyle, BVS_GROUP, LAYOUT_Label, (char *) msgGlobalOptions, LAYOUT_VertAlignment, LALIGN_BOTTOM, LAYOUT_AddChild, ar[ACTID_DEBUG] = PopUpObject, CHOOSER_Labels, debuglist, CHOOSER_Active, globalprefs.ahigp_DebugLevel, ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptDebugLevel, LabelEnd, LAYOUT_AddChild, ar[ACTID_ECHO] = PopUpObject, CHOOSER_Labels, echolist, CHOOSER_Active, (globalprefs.ahigp_DisableEcho ? 2 : 0) | (globalprefs.ahigp_FastEcho ? 1 : 0), ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptEcho, LabelEnd, LAYOUT_AddChild, ar[ACTID_SURROUND] = PopUpObject, CHOOSER_Labels, surroundlist, CHOOSER_Active, globalprefs.ahigp_DisableSurround, ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptSurround, LabelEnd, LAYOUT_AddChild, ar[ACTID_CLIPMV] = PopUpObject, CHOOSER_Labels, clipMVlist, CHOOSER_Active, globalprefs.ahigp_ClipMasterVolume, ChooserEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptMasterVol, LabelEnd, LAYOUT_AddChild, ar[ACTID_CPULIMIT] = IntegerObject, INTEGER_MaxChars, 3, INTEGER_MinVisible, 3, INTEGER_Minimum, 0, INTEGER_Maximum, 100, INTEGER_Number, (globalprefs.ahigp_MaxCPU * 100 + 32768) >> 16, INTEGER_Arrows, TRUE, IntegerEnd, CHILD_Label, LabelObject, LABEL_Text, (char *) msgGlobOptCPULimit, LabelEnd, LayoutEnd, CHILD_WeightedHeight, 0, CHILD_WeightedWidth, 0, LayoutEnd, PageEnd; if(ar[ACTID_PAGE] != NULL) { SetAttrs( l1, LAYOUT_AlignLabels, l2, TAG_DONE); SetAttrs( l2, LAYOUT_AlignLabels, l3, TAG_DONE); SetAttrs( l3, LAYOUT_AlignLabels, l4, TAG_DONE); SetAttrs( l4, LAYOUT_AlignLabels, l5, TAG_DONE); SetAttrs( l5, LAYOUT_AlignLabels, l6, TAG_DONE); SetAttrs( l6, LAYOUT_AlignLabels, l7, TAG_DONE); SetAttrs( l7, LAYOUT_AlignLabels, l1, TAG_DONE); } WO_Window = WindowObject, WA_PubScreen, screen, WA_Title, (char *) msgTextProgramName, WA_CloseGadget, TRUE, WA_DepthGadget, TRUE, WA_DragBar, TRUE, WA_Activate, TRUE, WA_SizeGadget, TRUE, WA_SizeBBottom, TRUE, WA_NewLookMenus, TRUE, WA_InnerWidth, 800, WA_InnerHeight, 400, WINDOW_MenuStrip, Menu, WINDOW_Position, WPOS_CENTERSCREEN, WINDOW_GadgetUserData, WGUD_HOOK, WINDOW_IDCMPHook, &IDCMPhook, WINDOW_IDCMPHookBits, IDCMP_RAWKEY, WINDOW_Layout, VLayoutObject, LAYOUT_SpaceOuter, TRUE, LAYOUT_DeferLayout, TRUE, /* TABS */ LAYOUT_AddChild, ar[LAYOUT_PAGE] = VLayoutObject, LAYOUT_AddChild, ar[ACTID_TABS] = ClickTabObject, CLICKTAB_Labels, pagelist, CLICKTAB_Current, 0L, ICA_TARGET, ar[ACTID_PAGE], ICA_MAP, MapTab2Page, ClickTabEnd, LAYOUT_AddChild, ar[ACTID_PAGE], LayoutEnd, /* BUTTONS */ LAYOUT_AddChild, HLayoutObject, LAYOUT_EvenSize, TRUE, LAYOUT_AddChild, ar[ACTID_SAVE] = ButtonObject, GA_Text, (char *) msgButtonSave, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, ar[ACTID_USE] = ButtonObject, GA_Text, (char *) msgButtonUse, ButtonEnd, CHILD_WeightedHeight, 0, LAYOUT_AddChild, ar[ACTID_QUIT] = ButtonObject, GA_Text, (char *) msgButtonCancel, ButtonEnd, CHILD_WeightedHeight, 0, LayoutEnd, CHILD_WeightedHeight, 0, LayoutEnd, WindowEnd; if(WO_Window) { int i; for(i = 0; i < ACTID_COUNT; i++) { if(Window_Objs[i] != NULL) { SetAttrs(Window_Objs[i], GA_ID, i, GA_RelVerify, TRUE, TAG_END); } } Window = (struct Window *) CA_OpenWindow(WO_Window); } if(screen) { UnlockPubScreen(NULL, screen); } if(Window == NULL) { Printf((char *) msgTextNoWindow); Printf("\n"); return FALSE; } openreq = GetFileObject, GETFILE_RejectIcons, TRUE, GETFILE_Drawer, "SYS:Prefs/Presets", EndObject; savereq = GetFileObject, GETFILE_RejectIcons, TRUE, GETFILE_Drawer, "SYS:Prefs/Presets", GETFILE_DoSaveMode, TRUE, EndObject; if((openreq == NULL) || (savereq == NULL)) { Printf((char *) msgTextNoFileRequester); Printf("\n"); return FALSE; } // Update the checkmark for "Create Icons?" { struct Menu *menu; struct MenuItem *item; menu = Menu; ClearMenuStrip(Window); item = FindMenuItem(ACTID_ICONS); if(item) { if(SaveIcons) item->Flags |= CHECKED; else item->Flags &= ~CHECKED; } ResetMenuStrip(Window, menu); } GUINewUnit(); return TRUE; }
// Build requester BOOL simple_build(simplereq_data *data) { struct DOpusSimpleRequest *simple; short count,object,pos; struct TextFont *font=0; struct RastPort rp; struct Screen *scr,*pub=0; short font_try; // Get simple pointer simple=data->simple; // Get screen pointer if (simple->flags&SRF_SCREEN_PARENT && data->parent) scr=data->parent; else if (data->parent) scr=((struct Window *)data->parent)->WScreen; else if ((pub=LockPubScreen(0))) scr=pub; else return 0; // Initialise dummy rastport InitRastPort(&rp); // Try 3 fonts (screen font, default font, topaz) for (font_try=0;font_try<3;font_try++) { short width,len,pos; char *ptr; // Get font if (font_try==0) font=scr->RastPort.Font; else if (font_try==1) font=((struct GfxBase *)GfxBase)->DefaultFont; else font=topaz_font; // Set font in dummy rastport SetFont(&rp,font); // Initialise counts data->text_lines=0; data->max_text_width=0; // Get max text width and number of lines for (pos=0,len=0,ptr=simple->message;;pos++) { // End of a line? if (simple->message[pos]=='\0' || simple->message[pos]=='\n') { // Get text width width=TextLength(&rp,ptr,len); // See if this is the longest line if (width>data->max_text_width) data->max_text_width=width; // Reset length, increment line count len=0; ptr=simple->message+pos+1; ++data->text_lines; // End of text? if (simple->message[pos]=='\0') break; } // Otherwise, increment length else len++; } // Will fit in screen? if (data->max_text_width<scr->Width-TEXT_X_SPACE) break; } // Add space to text if (data->max_text_width>=scr->Width-TEXT_X_SPACE) data->max_text_width=scr->Width; else data->max_text_width+=TEXT_X_SPACE; // Save font to use simple->font=font; // Unlock public screen if (pub) UnlockPubScreen(0,pub); // Count gadgets for (count=0;simple->gadgets[count];count++) { short width; // Get width of gadget text width=TextLength(&rp,simple->gadgets[count],strlen(simple->gadgets[count])); // Add to total gadget width data->max_gadget_width+=width+GAD_X_EXTRA; } // Save count data->gadget_count=count; // Are gadgets bigger than text? if (data->max_gadget_width+((count-1)*GAD_X_SPACE)>data->max_text_width) { // Add spacing between gadgets data->max_gadget_width+=((count-1)*GAD_X_SPACE); } // Calculate window width data->req_dims.fine_dim.Width=10+ ((data->max_text_width>data->max_gadget_width)?data->max_text_width:data->max_gadget_width); // Height is number of text lines plus one line for gadgets data->req_dims.char_dim.Height=data->text_lines+1; data->req_dims.fine_dim.Height=39+((data->text_lines-1)*3); // String gadget? if (simple->string_buffer) { // Get string length data->string_len=simple->string_len; // Add height data->req_dims.char_dim.Height++; data->req_dims.fine_dim.Height+=5; // Second string gadget? if (data->string_len<0) { // Fix length data->string_len=-data->string_len; data->string_buffer_2=simple->string_buffer+data->string_len+1; data->string_len_2=data->string_len; // Adjust height data->req_dims.char_dim.Height++; data->req_dims.fine_dim.Height+=5; } else if (simple->flags&SRF_BUFFER2) { data->string_buffer_2=simple->string_buffer_2; data->string_len_2=simple->string_len_2; // Adjust height data->req_dims.char_dim.Height++; data->req_dims.fine_dim.Height+=5; } } // Checkmark? if (simple->flags&SRF_CHECKMARK) { // Adjust height data->req_dims.char_dim.Height++; data->req_dims.fine_dim.Height+=9; } // Fill out NewConfigWindow data->new_win.dims=&data->req_dims; data->new_win.title=simple->title; data->new_win.flags=WINDOW_NO_CLOSE|WINDOW_AUTO_KEYS|WINDOW_REQ_FILL; if (simple->flags&SRF_SCREEN_PARENT) data->new_win.flags|=WINDOW_SCREEN_PARENT; data->new_win.font=simple->font; // Calculate number of objects we'll need; area plus text plus gadgets plus end data->object_count=data->text_lines+data->gadget_count+2; // If strbuf is supplied, need a string gadget if (simple->string_buffer) { ++data->object_count; if (data->string_buffer_2) ++data->object_count; if (simple->flags&SRF_FILEREQ && simple->filereq) ++data->object_count; } // Checkmark? if (simple->flags&SRF_CHECKMARK) ++data->object_count; // Allocate objects if (!(data->objects=(ObjectDef *)L_AllocMemH(data->memory,sizeof(ObjectDef)*data->object_count))) return 0; // Fill out text area data->objects[0].type=OD_AREA; data->objects[0].char_dims.Width=SIZE_MAXIMUM; data->objects[0].char_dims.Height=data->text_lines+((simple->flags&SRF_CHECKMARK)?1:0); data->objects[0].fine_dims.Left=3; data->objects[0].fine_dims.Top=3; data->objects[0].fine_dims.Width=-3; data->objects[0].fine_dims.Height=24+((data->text_lines-1)*3)+((simple->flags&SRF_CHECKMARK)?9:0); data->objects[0].gadgetid=32767; data->objects[0].flags=AREAFLAG_RECESSED|AREAFLAG_ERASE|AREAFLAG_THIN; // Layout tags data->rel_tags[0].ti_Tag=GTCustom_LayoutRel; data->rel_tags[0].ti_Data=32767; data->rel_tags[1].ti_Tag=TAG_END; // Allocate key array data->keys=(unsigned char *)L_AllocMemH(data->memory,data->gadget_count); // Build objects; first text for (pos=0,object=1,data->start_pos=0;;pos++) { // End of a text line? if (simple->message[pos]=='\0' || simple->message[pos]=='\n') { // Fill out text object data->objects[object].type=OD_TEXT; data->objects[object].object_kind=TEXTPEN; data->objects[object].char_dims.Top=object-1; data->objects[object].char_dims.Width=SIZE_MAXIMUM; data->objects[object].char_dims.Height=1; data->objects[object].fine_dims.Top=10+((object-1)*3); // Get copy of text if ((data->objects[object].gadget_text= (ULONG)L_AllocMemH(data->memory,(pos-data->start_pos)+1))) { CopyMem( simple->message+data->start_pos, (char *)data->objects[object].gadget_text, pos-data->start_pos); data->objects[object].flags=TEXTFLAG_TEXT_STRING|TEXTFLAG_NO_USCORE; } // Flags and id data->objects[object].flags|=TEXTFLAG_CENTER; data->objects[object].gadgetid=GAD_TEXT_ID; data->objects[object].taglist=data->rel_tags; // Save start position for next line, increment object count data->start_pos=pos+1; ++object; // End of text? if (simple->message[pos]=='\0') break; } } // String gadget? if (simple->string_buffer) { // Second string gadget? if (data->string_buffer_2) { data->objects[object].type=OD_GADGET; data->objects[object].object_kind=(simple->flags&SRF_LONGINT)?INTEGER_KIND:STRING_KIND; data->objects[object].char_dims.Top=POS_RIGHT_JUSTIFY-2; data->objects[object].char_dims.Width=SIZE_MAXIMUM; data->objects[object].char_dims.Height=1; data->objects[object].fine_dims.Left=3; data->objects[object].fine_dims.Top=-16; data->objects[object].fine_dims.Width=-3; data->objects[object].fine_dims.Height=4; data->objects[object].gadgetid=GAD_STRING2_ID; data->objects[object].taglist=data->tags2; // String tags data->tags2[0].ti_Tag=(simple->flags&SRF_LONGINT)?GTIN_Number:TAG_IGNORE; data->tags2[0].ti_Data=(simple->flags&SRF_LONGINT)?(ULONG)atoi(data->string_buffer_2):0; data->tags2[1].ti_Tag=(simple->flags&SRF_LONGINT)?GTIN_MaxChars:GTST_MaxChars; data->tags2[1].ti_Data=data->string_len; data->tags2[2].ti_Tag=STRINGA_Justification; data->tags2[2].ti_Data=(simple->flags&SRF_CENTJUST)? GACT_STRINGCENTER:((simple->flags&SRF_RIGHTJUST)?GACT_STRINGRIGHT:GACT_STRINGLEFT); data->tags2[3].ti_Tag=GTCustom_PathFilter; data->tags2[3].ti_Data=(simple->flags&SRF_PATH_FILTER)?1:0; data->tags2[4].ti_Tag=GTCustom_Secure; data->tags2[4].ti_Data=(simple->flags&SRF_SECURE)?1:0; data->tags2[5].ti_Tag=GTCustom_ThinBorders; data->tags2[5].ti_Data=TRUE; data->tags2[6].ti_Tag=TAG_END; // Increment object ++object; } // File requester? if (simple->flags&SRF_FILEREQ && simple->filereq) { // Popup button data->objects[object].type=OD_GADGET; data->objects[object].object_kind=POPUP_BUTTON_KIND; data->objects[object].char_dims.Top=POS_RIGHT_JUSTIFY-1; data->objects[object].char_dims.Width=0; data->objects[object].char_dims.Height=1; data->objects[object].fine_dims.Left=3; data->objects[object].fine_dims.Top=-11; data->objects[object].fine_dims.Width=28; data->objects[object].fine_dims.Height=4; data->objects[object].gadgetid=GAD_POPUP_ID; data->objects[object].taglist=0; // Increment object ++object; } // String gadget data->objects[object].type=OD_GADGET; data->objects[object].object_kind=(simple->flags&SRF_LONGINT)?INTEGER_KIND:STRING_KIND; data->objects[object].char_dims.Top=POS_RIGHT_JUSTIFY-1; data->objects[object].char_dims.Width=SIZE_MAXIMUM; data->objects[object].char_dims.Height=1; data->objects[object].fine_dims.Left=(simple->flags&SRF_FILEREQ && simple->filereq)?31:3; data->objects[object].fine_dims.Top=-11; data->objects[object].fine_dims.Width=-3; data->objects[object].fine_dims.Height=4; data->objects[object].gadgetid=GAD_STRING_ID; data->objects[object].taglist=data->tags; // String tags data->tags[0].ti_Tag=(simple->flags&SRF_LONGINT)?GTIN_Number:TAG_IGNORE; data->tags[0].ti_Data=(simple->flags&SRF_LONGINT)?(ULONG)atoi(simple->string_buffer):0; data->tags[1].ti_Tag=(simple->flags&SRF_LONGINT)?GTIN_MaxChars:GTST_MaxChars; data->tags[1].ti_Data=data->string_len; data->tags[2].ti_Tag=STRINGA_Justification; data->tags[2].ti_Data=(simple->flags&SRF_CENTJUST)? GACT_STRINGCENTER:((simple->flags&SRF_RIGHTJUST)?GACT_STRINGRIGHT:GACT_STRINGLEFT); data->tags[3].ti_Tag=GTCustom_NoSelectNext; data->tags[3].ti_Data=TRUE; data->tags[4].ti_Tag=GTCustom_History; data->tags[4].ti_Data=(simple->flags&SRF_HISTORY)?(ULONG)simple->history:0; data->tags[5].ti_Tag=GTCustom_PathFilter; data->tags[5].ti_Data=(simple->flags&SRF_PATH_FILTER)?1:0; data->tags[6].ti_Tag=GTCustom_Secure; data->tags[6].ti_Data=(simple->flags&SRF_SECURE)?1:0; data->tags[7].ti_Tag=GTCustom_ThinBorders; data->tags[7].ti_Data=TRUE; data->tags[8].ti_Tag=TAG_END; // Increment object ++object; } // Checkmark? if (simple->flags&SRF_CHECKMARK) { // Fill out gadget data->objects[object].type=OD_GADGET; data->objects[object].object_kind=CHECKBOX_KIND; data->objects[object].char_dims.Top=POS_RIGHT_JUSTIFY; data->objects[object].char_dims.Left=POS_CENTER; data->objects[object].char_dims.Height=1; data->objects[object].fine_dims.Left=FPOS_TEXT_OFFSET+(strlen(simple->check_text)>>1); data->objects[object].fine_dims.Top=-4; data->objects[object].fine_dims.Width=28; data->objects[object].fine_dims.Height=6; data->objects[object].gadget_text=(ULONG)simple->check_text; data->objects[object].flags=TEXTFLAG_TEXT_STRING|PLACETEXT_RIGHT; data->objects[object].gadgetid=GAD_CHECK_ID; data->objects[object].taglist=data->rel_tags; // Increment object ++object; }