void tilesetRequesterRefresh(FrameworkWindow *tilesetRequester) {
  ProjectWindowData *projectData;
  TilesetRequesterData *data = tilesetRequester->data;
  TilesetRequesterGadgets *gadgets = tilesetRequester->gadgets->data;

  projectData = tilesetRequester->parent->parent->data;

  GT_SetGadgetAttrs(gadgets->tilesetListGadget, tilesetRequester->intuitionWindow, NULL,
    GTLV_Labels, ~0,
    TAG_END);

  freeNumberedList(data->tilesetNames);
  data->tilesetNames = newNumberedList(projectDataGetTilesetName, projectData, TILESETS);
  if(!data->tilesetNames) {
    fprintf(stderr, "tilesetRequesterRefresh: couldn't make tileset name list\n");
    goto error;
  }

  GT_SetGadgetAttrs(gadgets->tilesetListGadget, tilesetRequester->intuitionWindow, NULL,
    GTLV_Labels, data->tilesetNames,
    TAG_END);

  GT_RefreshWindow(tilesetRequester->intuitionWindow, NULL);

  return;
error:
  return;
}
Ejemplo n.º 2
0
int OpenBlankerWindow( void )
{
	struct NewGadget	ng;
	struct Gadget	*g;
	UWORD		lc, tc;
	UWORD		wleft = BlankerLeft, wtop = BlankerTop, ww, wh;

	ComputeFont( BlankerWidth, BlankerHeight );

	ww = ComputeX( BlankerWidth );
	wh = ComputeY( BlankerHeight );

	if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
	if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;

	if ( ! ( BlankerFont = OpenDiskFont( Font )))
		return( 5L );

	if ( ! ( g = CreateContext( &BlankerGList )))
		return( 1L );

	for( lc = 0, tc = 0; lc < Blanker_CNT; lc++ ) {

		CopyMem((char * )&BlankerNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));

		ng.ng_VisualInfo = VisualInfo;
		ng.ng_TextAttr   = Font;
		ng.ng_LeftEdge   = OffX + ComputeX( ng.ng_LeftEdge );
		ng.ng_TopEdge    = OffY + ComputeY( ng.ng_TopEdge );
		ng.ng_Width      = ComputeX( ng.ng_Width );
		ng.ng_Height     = ComputeY( ng.ng_Height);

		BlankerGadgets[ lc ] = g = CreateGadgetA((ULONG)BlankerGTypes[ lc ], g, &ng, ( struct TagItem * )&BlankerGTags[ tc ] );

		while( BlankerGTags[ tc ] ) tc += 2;
		tc++;

		if ( NOT g )
			return( 2L );
	}

	if ( ! ( BlankerWnd = OpenWindowTags( NULL,
				WA_Left,	wleft,
				WA_Top,		wtop,
				WA_Width,	ww + OffX + Scr->WBorRight,
				WA_Height,	wh + OffY + Scr->WBorBottom,
				WA_IDCMP,	BUTTONIDCMP|LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
				WA_Flags,	WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SIZEBBOTTOM|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP,
				WA_Gadgets,	BlankerGList,
				WA_Title,	BlankerWdt,
				WA_ScreenTitle,	"Garshneblanker",
				WA_PubScreen,	Scr,
				TAG_DONE )))
	return( 4L );

	GT_RefreshWindow( BlankerWnd, NULL );

	return( 0L );
}
Ejemplo n.º 3
0
int OpenBlockSelectWindow( void )
{
	struct NewGadget	ng;
	struct Gadget	*g;
	UWORD		lc, tc;
	UWORD		offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1;

	if ( ! ( g = CreateContext( &BlockSelectGList ))){
		CloseBlockSelectWindow();
		return( 1L );
	}

	for( lc = 0, tc = 0; lc < BlockSelect_CNT; lc++ ) {

		CopyMem((char * )&BlockSelectNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));

		ng.ng_VisualInfo = VisualInfo;
		ng.ng_TextAttr   = &topaz8;
		ng.ng_LeftEdge  += offx;
		ng.ng_TopEdge   += offy;

		BlockSelectGadgets[ lc ] = g = CreateGadgetA((ULONG)BlockSelectGTypes[ lc ], g, &ng, ( struct TagItem * )&BlockSelectGTags[ tc ] );

		while( BlockSelectGTags[ tc ] ) tc += 2;
		tc++;

		if ( NOT g ){
			CloseBlockSelectWindow();
			return( 2L );
		}
	}

	if ( ! ( BlockSelectWnd = OpenWindowTags( NULL,
				WA_Left,	BlockSelectLeft,
				WA_Top,		BlockSelectTop,
				WA_Width,	BlockSelectWidth,
				WA_Height,	BlockSelectHeight + offy,
				WA_IDCMP,	LISTVIEWIDCMP | BUTTONIDCMP | IDCMP_NEWSIZE | IDCMP_REFRESHWINDOW | IDCMP_RAWKEY,
				WA_Flags,	WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH,
				WA_Gadgets,	BlockSelectGList,
				WA_Title,	BlockSelectWdt,
				WA_MinWidth,	160,
				WA_MinHeight,	60,
				WA_MaxWidth,	720,
				WA_MaxHeight,	467,
				WA_AutoAdjust,	TRUE,
				WA_PubScreen,Scr,
				TAG_DONE )))
	{
		CloseBlockSelectWindow();
		return( 4L );
	}

	GT_RefreshWindow( BlockSelectWnd, NULL );

	return( 0L );
}
Ejemplo n.º 4
0
int lib_gadtools_f_GT_RefreshWindow_2(emumsg_syscall_t *msg)
{
	/* Make real syscall */
	GT_RefreshWindow(
		(struct Window *)msg->arg[1]._aptr,
		(struct Requester *)msg->arg[2]._aptr
	);

	return HOOK_DONE;
}
Ejemplo n.º 5
0
static void resizeWindow(FrameworkWindow *window) {
  if(window->gadgets) {
    RemoveGList(window->intuitionWindow, window->gadgets->glist, -1);
    (*window->kind->freeGadgets)(window->gadgets);
    SetRast(window->intuitionWindow->RPort, 0);
    window->gadgets = (*window->kind->buildGadgets)(window->intuitionWindow->Width, window->intuitionWindow->Height, window->data);
    if(!window->gadgets) {
      fprintf(stderr, "resizeWindow: couldn't create gadgets\n");
      goto error;
    }
    AddGList(window->intuitionWindow, window->gadgets->glist, (UWORD)~0, -1, NULL);
    RefreshWindowFrame(window->intuitionWindow);
    RefreshGList(window->gadgets->glist, window->intuitionWindow, NULL, -1);
    GT_RefreshWindow(window->intuitionWindow, NULL);
  }

  return;

error:
  return;
}
Ejemplo n.º 6
0
static BOOL LayOutReq (struct AHIAudioModeRequesterExt *req, struct TextAttr *TextAttr)
{
  struct Gadget *gad;
  struct NewGadget ng;

  struct TextAttr *gadtextattr;
  struct TextFont *font;
  LONG   fontwidth,buttonheight,buttonwidth,pixels;
  struct IntuiText intuitext = {1,0,JAM1,0,0,NULL,NULL,NULL};
  LONG  sliderlevels,sliderlevel;
  LONG  selected;

  selected=GetSelected(req);
  GetSliderAttrs(req,&sliderlevels,&sliderlevel);

// Calculate gadget area
  req->gx=req->Window->BorderLeft+4;
  req->gy=req->Window->BorderTop+2;
  req->gw=req->Window->Width-req->gx-(req->Window->BorderRight+4);
  req->gh=req->Window->Height-req->gy-(req->Window->BorderBottom+2);

  if(req->Gadgets)
  {
    RemoveGList(req->Window,req->Gadgets,-1);
    FreeGadgets(req->Gadgets);
    SetAPen(req->Window->RPort,0);
    SetDrMd(req->Window->RPort,JAM1);
    EraseRect(req->Window->RPort, req->Window->BorderLeft, req->Window->BorderTop,
        req->Window->Width-req->Window->BorderRight-1,req->Window->Height-req->Window->BorderBottom-1);
    RefreshWindowFrame(req->Window);
  }
  req->Gadgets=NULL;
  if((gad=CreateContext(&req->Gadgets)))
  {
    if(TextAttr)
      gadtextattr=TextAttr;
    else
      gadtextattr=req->Window->WScreen->Font;

    if((font=OpenFont(gadtextattr)))
    {
      fontwidth=font->tf_XSize;
      CloseFont(font);
    }
    else
      return FALSE;

    buttonheight=gadtextattr->ta_YSize+6;
    intuitext.ITextFont=gadtextattr;
    intuitext.IText=req->PositiveText;
    buttonwidth=IntuiTextLength(&intuitext);
    intuitext.IText=req->NegativeText;
    pixels=IntuiTextLength(&intuitext);
    buttonwidth=max(pixels,buttonwidth);
    buttonwidth+=4+fontwidth;

// Create gadgets and check if they fit
    // Do the two buttons fit?
    if(2*buttonwidth > req->gw)
      return FALSE;
    ng.ng_TextAttr=gadtextattr;
    ng.ng_VisualInfo=req->vi;
    ng.ng_UserData=req;
// OK button
    ng.ng_LeftEdge=req->gx;
    ng.ng_TopEdge=req->gy+req->gh-buttonheight;
    ng.ng_Width=buttonwidth;
    ng.ng_Height=buttonheight;
    ng.ng_GadgetText=req->PositiveText;
    ng.ng_GadgetID=OKBUTTON;
    ng.ng_Flags=PLACETEXT_IN;
    gad=CreateGadget(BUTTON_KIND,gad,&ng,TAG_END);
// Cancel button
    ng.ng_LeftEdge=req->gx+req->gw-ng.ng_Width;
    ng.ng_GadgetText=req->NegativeText;
    ng.ng_GadgetID=CANCELBUTTON;
    gad=CreateGadget(BUTTON_KIND,gad,&ng,TAG_END);
// Frequency
    if(req->Flags & freqgad)
    {
      intuitext.IText = GetString(msgReqFrequency, req->Catalog);
      pixels=IntuiTextLength(&intuitext)+INTERWIDTH;
      if(pixels+MINSLIDERWIDTH+INTERWIDTH+FREQLEN2*fontwidth > req->gw)
        return FALSE;
      ng.ng_Width=req->gw-pixels-INTERWIDTH-FREQLEN2*fontwidth;
      ng.ng_LeftEdge=req->gx+pixels;
      ng.ng_TopEdge-=2+buttonheight;
      ng.ng_GadgetText = GetString(msgReqFrequency, req->Catalog);
      ng.ng_GadgetID=FREQSLIDER;
      ng.ng_Flags=PLACETEXT_LEFT;
      gad=CreateGadget(SLIDER_KIND,gad,&ng,
          GTSL_Min,0,
          GTSL_Max,sliderlevels-1,
          GTSL_Level,sliderlevel,
          GTSL_LevelFormat, (ULONG) FREQTEXT2,
          GTSL_MaxLevelLen,FREQLEN2,
          GTSL_LevelPlace,PLACETEXT_RIGHT,
          GTSL_DispFunc, (ULONG) m68k_IndexToFrequency,
          GA_RelVerify,TRUE,
          GA_Disabled,!sliderlevels || (req->tempAudioID == AHI_DEFAULT_ID),
          TAG_DONE);
      req->slidergadget=gad;   // Save for HadleReq()...
    }
// ListView
    if((ng.ng_Height=ng.ng_TopEdge-2-req->gy) < buttonheight)
      return FALSE;
    ng.ng_LeftEdge=req->gx;
    ng.ng_TopEdge=req->gy;
    ng.ng_Width=req->gw;
    ng.ng_GadgetText=NULL,
    ng.ng_GadgetID=LISTVIEW;
    ng.ng_Flags=PLACETEXT_ABOVE;
    gad=CreateGadget(LISTVIEW_KIND,gad,&ng,
        GTLV_ScrollWidth,(fontwidth>8 ? fontwidth*2 : 18),
        GTLV_Labels, (ULONG) req->list,
        GTLV_ShowSelected,NULL,
        ((selected == ~0) || (GadToolsBase->lib_Version >= 39) ? TAG_IGNORE : GTLV_Top),selected,
        (selected == ~0 ? TAG_IGNORE : GTLV_MakeVisible),selected,
        GTLV_Selected,selected,
        TAG_DONE);
    req->listviewgadget=gad;   // Save for HadleReq()...

    if(!gad)
      return FALSE;
  }
  else
    return FALSE;

  AddGList(req->Window,req->Gadgets,~0,-1,NULL);
  RefreshGList(req->Gadgets,req->Window,NULL,-1);
  GT_RefreshWindow(req->Window,NULL);

  return TRUE;
}
Ejemplo n.º 7
0
struct Window *initWindow(void)
{
  struct Window *win;

  gad[0] = CreateContext(&glist);

  ng.ng_LeftEdge = 8;
  ng.ng_TopEdge = fontheight+7;
  ng.ng_Width = 192;
  ng.ng_Height = 11*fontheight+4;
  ng.ng_VisualInfo = vi;
  ng.ng_TextAttr = scr->Font;
  ng.ng_GadgetText = NULL;
  ng.ng_UserData = NULL;
  ng.ng_GadgetID = 1;
  lvgad[0] = CreateGadget(LISTVIEW_KIND,gad[0],&ng,GTLV_Labels,&list[0],TAG_END);

  ng.ng_LeftEdge = 206;
  ng.ng_Width = 186;
  ng.ng_GadgetText = NULL;
  ng.ng_GadgetID++;
  lvgad[1] = CreateGadget(LISTVIEW_KIND,lvgad[0],&ng,GTLV_Labels,&list[1],TAG_END);

  ng.ng_TopEdge += ng.ng_Height+3;
  ng.ng_LeftEdge = 8;
  ng.ng_Height = fontheight+4;
  ng.ng_Width = TLn("New")+16;
  ng.ng_Flags = PLACETEXT_IN;
  ng.ng_GadgetText = "New";
  ng.ng_GadgetID++;
  gad[0] = CreateGadget(BUTTON_KIND,lvgad[1],&ng,GA_Immediate,TRUE,TAG_END);

  ng.ng_LeftEdge += ng.ng_Width+6;
  ng.ng_Width = TLn("Copy")+16;
  ng.ng_GadgetText = "Copy";
  ng.ng_GadgetID++;
  gad[1] = CreateGadget(BUTTON_KIND,gad[0],&ng,TAG_END);

  ng.ng_LeftEdge += ng.ng_Width+6;
  ng.ng_Width = TLn("Delete")+16;
  ng.ng_GadgetText = "Delete";
  ng.ng_GadgetID++;
  gad[2] = CreateGadget(BUTTON_KIND,gad[1],&ng,TAG_END);

  if ((win = OpenWindowTags(NULL,WA_Title,   "gtdrag - Test",
                                WA_Flags,   WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_ACTIVATE,
                                WA_IDCMP,   IDCMP_CLOSEWINDOW | DRAGIDCMP,
                                WA_Width,   400,
                                WA_Height,  fontheight*13+23,
                                WA_Gadgets, glist,
                                TAG_END)) != 0)
  {
    GT_RefreshWindow(win,NULL);
    GTD_AddGadget(LISTVIEW_KIND,lvgad[0],win,GTDA_InternalType, 1,
                                             GTDA_NoPosition,   TRUE,
                                             GTDA_Type,         ODT_NODE,
                                             TAG_END);
    GTD_AddGadget(LISTVIEW_KIND,lvgad[1],win,GTDA_InternalType,1,
                                             GTDA_Same,        TRUE,
                                             GTDA_Type,        ODT_NODE,
                                             TAG_END);
    GTD_AddGadget(BUTTON_KIND,gad[0],win,GTDA_Object,      &in,
                                         GTDA_Image,       in.in_Image,
                                         GTDA_InternalType,2,
                                         GTDA_AcceptTypes, 0,
                                         GTDA_Width,       newImg.Width,
                                         GTDA_Height,      newImg.Height,
                                         TAG_END);
    GTD_AddGadget(BUTTON_KIND,gad[1],win,GTDA_AcceptTypes,1,TAG_END);
    GTD_AddGadget(BUTTON_KIND,gad[2],win,GTDA_AcceptTypes,1,TAG_END);
    GTD_AddWindow(win,TAG_END);
    return(win);
  }
  return(NULL);
}
Ejemplo n.º 8
0
FrameworkWindow *openWindowOnScreen(WindowKind *windowKind, struct Screen *screen, void *data) {
  FrameworkWindow *window;

  windowKind->newWindow.Screen = screen;

  window = malloc(sizeof(FrameworkWindow));
  if(!window) {
    fprintf(stderr, "openWindowOnScreen: failed to allocate window\n");
    goto error;
  }

  window->data = data;
  window->kind = windowKind;
  window->parent = NULL;
  window->children = NULL;
  window->next = NULL;
  window->prev = NULL;
  window->closed = FALSE;

  if(windowKind->buildGadgets) {
    window->gadgets = (*windowKind->buildGadgets)(windowKind->newWindow.Width, windowKind->newWindow.Height, data);
    if(!window->gadgets) {
      fprintf(stderr, "openWindowOnScreen: failed to build gadgets\n");
      goto error_freeWindow;
    }
    windowKind->newWindow.FirstGadget = window->gadgets->glist;
  } else {
    window->gadgets = NULL;
  }

  window->intuitionWindow = OpenWindow(&windowKind->newWindow);
  if(!window->intuitionWindow) {
    fprintf(stderr, "openWindowOnScreen: failed to open window\n");
    goto error_freeGadgets;
  }

  window->treeSigMask = 1L << window->intuitionWindow->UserPort->mp_SigBit;

  if(windowKind->menuSpec) {
    window->menu = createAndLayoutMenuFromSpec(windowKind->menuSpec);
    if(!window->menu) {
      fprintf(stderr, "openWindowOnScreen: failed to create menu\n");
      goto error_closeWindow;
    }
    SetMenuStrip(window->intuitionWindow, window->menu);
  } else {
    window->menu = NULL;
  }

  GT_RefreshWindow(window->intuitionWindow, NULL);

  /* redraw the whole window */
  if(window->kind->refreshWindow) {
    (*window->kind->refreshWindow)(window);
  }

  return window;
error_closeWindow:
  CloseWindow(window->intuitionWindow);
error_freeGadgets:
  if(windowKind->freeGadgets) {
    (*windowKind->freeGadgets)(window->gadgets);
  }
error_freeWindow:
  free(window);
error:
  return NULL;
}
Ejemplo n.º 9
0
void main(int argc, char *argv[])
{
	struct gtbApplication *appl=NULL;
	struct Window *Wnd;
	struct Gadget *GList=NULL;
	Object *prev;

	unless(appl=gtbNewApplication(TAG_DONE)) Leave("Can't create application");
	unless(Scrn=NewObject(appl->ga_ScrClass,NULL,
		SCRN_LikeWorkbench,TRUE,
		SCRN_PubName,APPPUBNAME,
		SCRN_Private,FALSE,
		SCRN_Title,APPPUBNAME,
		TAG_DONE)) Leave("Can't create screen");
	unless(Cdity=NewObject(appl->ga_CxClass,NULL,
		COMM_Name,APPNAME,
		COMM_Title,APPTITLE,
		COMM_Description,APPDESCRIPTION,
		COMM_Unique,TRUE,
		COMM_Notify,TRUE,
		COMM_ShowHide,TRUE,
		COMM_Handler,(ULONG)CdityHandler,
		COMM_AddHotKeyStr,"control t",COMM_AddHotKeyID,1,
		TAG_DONE)) Leave("Can't create commodity");
	unless(CtrlC=NewObject(appl->ga_MsgClass,NULL,
		MESG_SigBit,SIGBREAKF_CTRL_C,
		MESG_Handler,(ULONG)CtrlCHandler,
		TAG_DONE)) Leave("Can't create message handler");
	unless(ARexx=NewObject(appl->ga_ARexxClass,NULL,
		REXX_Name,APPPUBNAME,
		REXX_Extension,APPEXTENSION,
		REXX_CommandTable,commands,
		REXX_Handler,(ULONG)ARexxHandler,
		TAG_DONE)) Leave("Can't create arexx");
	unless(AmigaGuide=NewObject(appl->ga_AGClass,NULL,
		AGUI_Name,APPGUIDE,
		AGUI_ScreenObject,Scrn,
		AGUI_ARexxObject,ARexx,
		AGUI_Activate,TRUE,
		AGUI_BaseName,APPNAME,
		TAG_DONE)) Leave("Can't create amigaguide");
	unless(MainWnd=NewObject(appl->ga_WndClass,NULL,WIND_CenterX,600,WIND_CenterY,20,WIND_Width,200,WIND_Height,200,
		WIND_DragBar,TRUE,
		WIND_DepthGadget,TRUE,
		WIND_SizeGadget,TRUE,
		WIND_CloseGadget,TRUE,
		WIND_Title,APPTITLE,
		WIND_ScreenObject,Scrn,
		WIND_VertScroll,TRUE,
		WIND_VertTotal,10,
		WIND_HorizScroll,TRUE,
		WIND_HorizTotal,10,
		WIND_HorizVisible,5,
		WIND_IDCMP,IDCMP_CLOSEWINDOW|IDCMP_GADGETUP,
		WIND_Handler,(ULONG)WndHandler,
		WIND_Activate,TRUE,
		WIND_MaxWidth,-1,
		WIND_MaxHeight,-1,
		TAG_DONE)) Leave("Can't create window");
	GetAttr(WIND_Window,MainWnd,(ULONG *)&Wnd);

	unless(prev=(Object *)CreateContext(&GList)) Leave("Can't create context");
	unless(prev=gtbCreateGadget(BUTTON_KIND,NULL,NULL,
		GA_Previous,prev,
		GA_Left,Wnd->BorderLeft,
		GA_Top,Wnd->BorderTop,
		GA_Width,100,
		GA_Height,20,
		GA_Text,"Ble",
		GT_ScreenObj,Scrn,
		GT_Handler,(ULONG)Gad1Handler,
		TAG_DONE)) Leave("Can't create gadget 1");
	unless(prev=gtbCreateGadget(STRING_KIND,NULL,NULL,
		GA_Previous,prev,
		GA_Left,Wnd->BorderLeft,
		GA_Top,Wnd->BorderTop+30,
		GA_Width,100,
		GA_Height,20,
		GA_Text,"Ble2",
		GT_ScreenObj,Scrn,
		TAG_DONE)) Leave("Can't create gadget 2");
	unless(prev=gtbCreateGadget(BOOPSI_KIND,NULL,FRBUTTONCLASS,
		GA_Previous,prev,
		GA_Left,Wnd->BorderLeft,
		GA_Top,Wnd->BorderTop+60,
		GA_Width,100,
		GA_Height,20,
		GA_Text,"Ble3",
		ICA_TARGET,ICTARGET_IDCMP,
		TAG_DONE)) Leave("Can't create gadget 3");

	DoMethod(MainWnd,OM_ADDMEMBER,GList);
	RefreshGList(GList,Wnd,NULL,-1);
	GT_RefreshWindow(Wnd,NULL);

	gtbExecuteRexx(ARexx,argv[1]);

	while(gtbHandleObject(MainWnd,Cdity,CtrlC,ARexx,AmigaGuide,TAG_DONE));

	RemoveGList(Wnd,GList,-1);
	gtbFreeGadgets(GList);
end:
	if(AmigaGuide) DisposeObject(AmigaGuide);
	if(ARexx) DisposeObject(ARexx);
	if(MainWnd) DisposeObject(MainWnd);
	if(CtrlC) DisposeObject(CtrlC);
	if(Cdity) DisposeObject(Cdity);
	if(Scrn) DisposeObject(Scrn);
	if(appl) gtbDisposeApplication(appl);
}