int main(int argc, char **argv) { int x, y; if ((IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 0))) { if ((GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0))) { if ((DOSBase = (struct DosLibrary *) OpenLibrary("dos.library",0))) { struct Window *w1; w1 = openwindow(100, 100, 100, 100); if (w1) { printf( "MoveWindow()...\n" ); for( x=0 ; x<50 ; x++ ) { MoveWindow(w1,1,0); // RefreshWindowFrame(w1); } for( y=0 ; y<50 ; y++ ) { MoveWindow(w1,0,1); // RefreshWindowFrame(w1); } printf( "ChangeWindowBox()...\n" ); for( x=0 ; x<50 ; x++ ) { ChangeWindowBox(w1,150-x,150-x,100+x,100+x); RefreshWindowFrame(w1); } printf( "SizeWindow()...\n" ); for( y=0 ; y<50 ; y++ ) { SizeWindow(w1,-1,-1); RefreshWindowFrame(w1); } printf( "Done!\nPress a key or click closegadget to quit.\n" ); Wait(1L<<w1->UserPort->mp_SigBit); msg = (struct IntuiMessage *)GetMsg(w1->UserPort); /* Catch any message to quit */ ReplyMsg((struct Message *)msg); CloseWindow(w1); } CloseLibrary((struct Library *)DOSBase); } CloseLibrary((struct Library *)GfxBase); } CloseLibrary((struct Library *) IntuitionBase); } return 0; } /* main */
void _glfwPlatformSetWindowPos( int x, int y ) { if( !_glfwWin.Fullscreen ) { ChangeWindowBox( _glfwWin.Window, x, y, _glfwWin.Window->Width, _glfwWin.Window->Height ); } }
void ami_drag_icon_move(void) { if(drag_icon == NULL) return; ChangeWindowBox(drag_icon, scrn->MouseX - (drag_icon_width / 2), scrn->MouseY - (drag_icon_height / 2), drag_icon_width, drag_icon_height); }
bool ami_drag_icon_move(void) { if(drag_icon == NULL) return FALSE; ChangeWindowBox(drag_icon, scrn->MouseX - (drag_icon_width / 2), scrn->MouseY - (drag_icon_height / 2), drag_icon_width, drag_icon_height); return ami_autoscroll; }
// Set size limit for a lister void lister_set_limits(Lister *lister) { short width,height; // In zoomed mode? if (lister->more_flags&LISTERF_TITLEBARRED) return; // Calculate limits lister_calc_limits(lister,lister->window->WScreen); // Get current lister size width=lister->window->Width; height=lister->window->Height; // Bounds check if (width<lister->win_limits.Left) width=lister->win_limits.Left; if (height<lister->win_limits.Top) height=lister->win_limits.Top; // Need to resize? if (width!=lister->window->Width || height!=lister->window->Height) { // Set to infinite limits WindowLimits( lister->window, 1,1, (UWORD)~0,(UWORD)~0); // Change size ChangeWindowBox( lister->window, lister->window->LeftEdge, lister->window->TopEdge, width, height); } // Set window limits WindowLimits( lister->window, lister->win_limits.Left, lister->win_limits.Top, (UWORD)~0, (UWORD)~0); }
// Refresh buttons display void buttons_refresh(Buttons *buttons,ULONG type) { int x,y; Cfg_Button *button; // Lock bank GetSemaphore(&buttons->bank->lock,SEMF_SHARED,0); // Make selector visible if (type&BUTREFRESH_SELECTOR) { if (buttons_visible_select(buttons)) type|=BUTREFRESH_REFRESH; } // Font reset if (type&BUTREFRESH_FONT) { // See if font has changed if ((strcmp( buttons->window->RPort->Font->tf_Message.mn_Node.ln_Name, buttons->bank->window.font_name))!=0 || buttons->window->RPort->Font->tf_YSize!=buttons->bank->window.font_size) { // Get new font buttons_get_font(buttons); // Do full reset type=BUTREFRESH_RESIZE|BUTREFRESH_REFRESH; // Clear resized flag buttons->flags&=~BUTTONF_RESIZED; } } // Resize event? if (type&BUTREFRESH_RESIZE) { unsigned short min_width,min_height; unsigned short max_width,max_height; short border_x=0,border_y=0; // Borderless window? if (buttons->flags&BUTTONF_BORDERLESS) { ULONG flags; short old_width,old_height; ULONG old_border; // Save drag gadget flags and size flags=buttons->drag_gadget.Flags; old_width=buttons->drag_gadget.Width; old_height=buttons->drag_gadget.Height; old_border=buttons->border_type; // See if drag bar orientation has changed if (buttons_fix_drag(buttons)) { short width,height; // Get current width/height width=buttons->window->Width; height=buttons->window->Height; // If bar is now horizontal, it used to be vertical if (buttons->drag_gadget.Flags&GFLG_RELWIDTH && flags&GFLG_RELHEIGHT) { // Adjust accordingly width-=old_width; height+=buttons->drag_gadget.Height; } // And vice versa else if (buttons->drag_gadget.Flags&GFLG_RELHEIGHT && flags&GFLG_RELWIDTH) { // Adjust height-=old_height; width+=buttons->drag_gadget.Width; } // No drag bar else if (!(buttons->drag_gadget.Flags&(GFLG_RELWIDTH|GFLG_RELHEIGHT))) { // Adjust size if (flags&GFLG_RELHEIGHT) { if (old_border&BTNWF_RIGHT_BELOW) border_x=old_width; width-=old_width; } else if (flags&GFLG_RELWIDTH) { if (old_border&BTNWF_RIGHT_BELOW) border_y=old_height; height-=old_height; } } // State of right/below flag changed else if (!(old_border&BTNWF_RIGHT_BELOW) && (buttons->bank->window.flags&BTNWF_RIGHT_BELOW)) { // Move window up or right depending on border if (buttons->bank->window.flags&BTNWF_HORIZ) border_y=-((GUI->screen_info&SCRI_LORES)?DRAG_LO_HEIGHT:DRAG_HI_HEIGHT); else if (buttons->bank->window.flags&BTNWF_VERT) border_x=-DRAG_WIDTH; } // Is size not changing? if (buttons->window->Width==width && buttons->window->Height==height) { // Refresh buttons display type|=BUTREFRESH_REFRESH; RefreshGList(&buttons->drag_gadget,buttons->window,0,1); } // Size is changing so window will be refreshed automatically else { // Resize window ChangeWindowBox( buttons->window, buttons->window->LeftEdge+border_x,buttons->window->TopEdge+border_y, width,height); buttons->flags|=BUTTONF_RESIZED; } // Recalculate internal size buttons_fix_internal(buttons); } // Refresh drag gadget else { RefreshGList(&buttons->drag_gadget,buttons->window,0,1); } } // Get the maximum size of a button buttons_get_max_size(buttons,&max_width,&max_height); // Graphical buttons? if (buttons->bank->window.flags&BTNWF_GFX) { // Maximum is also minimum min_width=max_width; } // Text buttons else { // Get minimum width min_width=TextLength(buttons->window->RPort,"a",1)*6; // Border? if (!(buttons->flags&BUTTONF_BORDERLESS)) { // Calculate button size from window max_width=buttons->window->GZZWidth/buttons->bank->window.columns; } // Is button width less than minimum? if (max_width<min_width) max_width=min_width; } // Store button size buttons->button_width=max_width; buttons->button_height=max_height; // No border or toolbar? if (buttons->flags&(BUTTONF_BORDERLESS|BUTTONF_TOOLBAR)) { short side_borders,top_borders; // Start with maximum columns/rows buttons->button_cols=buttons->bank->window.columns; buttons->button_rows=buttons->bank->window.rows; // Calculate window size max_width=buttons->button_width*buttons->button_cols; max_height=buttons->button_height*buttons->button_rows; // Calculate border sizes side_borders=buttons->window->Width-buttons->internal.Width; top_borders=buttons->window->Height-buttons->internal.Height; // Too big for screen? if (max_width+side_borders>buttons->window->WScreen->Width) { buttons->button_cols=(buttons->window->WScreen->Width-side_borders)/buttons->button_width; max_width=buttons->button_cols*buttons->button_width; } if (max_height+top_borders>buttons->window->WScreen->Height) { buttons->button_rows=(buttons->window->WScreen->Height-top_borders)/buttons->button_height; max_height=buttons->button_rows*buttons->button_height; } // Add border size max_width+=side_borders; max_height+=top_borders; // Minimum is the maximum min_width=max_width; min_height=max_height; } // Normal borders else { // Get columns/rows buttons->button_cols=buttons->window->GZZWidth/buttons->button_width; buttons->button_rows=buttons->window->GZZHeight/buttons->button_height; // Check columns/rows don't exceed actual number of buttons if (buttons->button_cols>buttons->bank->window.columns) buttons->button_cols=buttons->bank->window.columns; if (buttons->button_rows>buttons->bank->window.rows) buttons->button_rows=buttons->bank->window.rows; // Get window minimum size min_width+=buttons->window->BorderLeft+buttons->window->BorderRight; min_height=buttons->window->BorderTop+buttons->window->BorderBottom+buttons->button_height; // Get window maximum size max_width=(!(buttons->bank->window.flags&BTNWF_GFX))?buttons->window->WScreen->Width: buttons->window->BorderLeft+ buttons->window->BorderRight+ buttons->bank->window.columns*buttons->button_width; max_height= buttons->window->BorderTop+ buttons->window->BorderBottom+ buttons->button_height*buttons->bank->window.rows; } // Set window limits WindowLimits(buttons->window,0,0,(ULONG)-1,(ULONG)-1); // See if window size can be changed if (!(buttons->flags&BUTTONF_RESIZED)) { short width,height; // No border? if (buttons->flags&BUTTONF_BORDERLESS) { // Get desired size width=max_width; height=max_height; } // Normal borders else { // Get initial size width=buttons->window->Width; height=buttons->window->Height; // Is window narrower than minimum? if (buttons->window->Width<min_width) width=min_width; // Or wider than maximum? else if (buttons->window->Width>max_width) width=max_width; // Otherwise, size to button boundary else { // Drop back to last whole column width-=buttons->window->GZZWidth-(buttons->button_cols*buttons->button_width); // Size to make window bigger? if (buttons->window->Width>buttons->last_position.Width && buttons->button_cols<buttons->bank->window.columns) { short new_width; // Get new width new_width=width+buttons->button_width; // Would this be legal? if (buttons->window->LeftEdge+new_width<=buttons->window->WScreen->Width) width=new_width; } } // Is window shorter than minimum? if (buttons->window->Height<min_height) height=min_height; // Or taller than maximum? else if (buttons->window->Height>max_height) height=max_height; // Otherwise, size to button boundary else { // Drop back to last whole row height-=buttons->window->GZZHeight-(buttons->button_rows*buttons->button_height); // Size to make window bigger? if (buttons->window->Height>buttons->last_position.Height && buttons->button_rows<buttons->bank->window.rows) { short new_height; // Get new height new_height=height+buttons->button_height; // Would this be legal? if (buttons->window->TopEdge+new_height<=buttons->window->WScreen->Height) height=new_height; } } } // Does window need to be resized? if (buttons->window->Width!=width || buttons->window->Height!=height) { // Resize window ChangeWindowBox( buttons->window, buttons->window->LeftEdge+border_x,buttons->window->TopEdge+border_y, width,height); buttons->flags|=BUTTONF_RESIZED; // Set window limits WindowLimits(buttons->window, min_width, min_height, max_width, max_height); // Unlock bank FreeSemaphore(&buttons->bank->lock); return; } } // Returned from a resize; refresh frame else RefreshWindowFrame(buttons->window); // Save window position buttons->last_position=*((struct IBox *)&buttons->window->LeftEdge); // Set window limits WindowLimits(buttons->window, min_width, min_height, max_width, max_height); // Fix sliders if (buttons->vert_scroll) { SetGadgetAttrs(buttons->vert_scroll,buttons->window,0, PGA_Total,buttons->bank->window.rows, PGA_Visible,buttons->button_rows, TAG_END); } if (buttons->horiz_scroll) { SetGadgetAttrs(buttons->horiz_scroll,buttons->window,0, PGA_Total,buttons->bank->window.columns, PGA_Visible,buttons->button_cols, TAG_END); } // Make sure selector is visible if (buttons->editor) buttons_visible_select(buttons); } // Refresh event if (type&BUTREFRESH_REFRESH) { // Get vertical position if (buttons->vert_scroll) GetAttr(PGA_Top,buttons->vert_scroll,(ULONG *)&buttons->button_top); else buttons->button_top=0; // Horizontal if (buttons->horiz_scroll) GetAttr(PGA_Top,buttons->horiz_scroll,(ULONG *)&buttons->button_left); else buttons->button_left=0; // Draw buttons button=(Cfg_Button *)buttons->bank->buttons.lh_Head; for (y=0;y<buttons->bank->window.rows;y++) { for (x=0;x<buttons->bank->window.columns;x++) { // Check button is valid if (button && !button->node.ln_Succ) button=0; // Is button visible? if (y>=buttons->button_top && y<buttons->button_top+buttons->button_rows && x>=buttons->button_left && x<buttons->button_left+buttons->button_cols) { // Draw button buttons_show_button( buttons, button, x-buttons->button_left, y-buttons->button_top, (button)?button->current:0,0); } // Get next button if (button) button=(Cfg_Button *)button->node.ln_Succ; } } } // Clear resized flag buttons->flags&=~BUTTONF_RESIZED; // Unlock bank FreeSemaphore(&buttons->bank->lock); }
static int get_key(AIN_DeviceID ID, int *keycode, int *offset) { static char *window_text; struct Window *window; AIN_InputEvent *event; int done = 0; window_text = translate_text(IDS_PRESS_KEY_BUTTON); *keycode = *offset = -1; /* no key */ if (ID != -1) { ai_handle[0] = AIN_ObtainDevice(CTX, ID); if (ai_handle[0] != NULL) { AIN_SetDeviceParameter(CTX, ai_handle[0], AINDP_EVENT, TRUE); } } window = OpenWindowTags(NULL, WA_Title, (ULONG)"", WA_Flags, WFLG_NOCAREREFRESH|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_RMBTRAP|WFLG_GIMMEZEROZERO, WA_IDCMP, IDCMP_CLOSEWINDOW|WFLG_REPORTMOUSE|IDCMP_RAWKEY|IDCMP_CHANGEWINDOW, WA_Left, 100, WA_Top, 100, WA_Width, 100, WA_Height, 40, WA_Activate, TRUE, TAG_DONE); if (window != NULL) { struct IntuiMessage *imsg = NULL; ULONG imCode, imClass; /* Resize window and set pens */ int length = TextLength(window->RPort, window_text, strlen(window_text)); ChangeWindowBox(window, 100, 100, window->BorderLeft+length+window->BorderRight+8, window->BorderTop+window->IFont->tf_YSize*2+window->BorderBottom); SetAPen(window->RPort, 1); SetBPen(window->RPort, 0); /* Wait until window has been resized */ while (done == 0) { /* Wait for messages */ Wait((1L << window->UserPort->mp_SigBit) | (1L << ai_port->mp_SigBit)); /* Check for IDCMP messages */ while ((imsg = (struct IntuiMessage *)GetMsg(window->UserPort))) { imClass = imsg->Class; imCode = imsg->Code; ReplyMsg((struct Message *)imsg); if (imClass == IDCMP_CHANGEWINDOW) { Move(window->RPort, 4, window->IFont->tf_YSize); Text(window->RPort, window_text, strlen(window_text)); } else if (imClass == IDCMP_RAWKEY) { imCode &= 0x7f; if (imCode != 69) { *keycode = imCode; } done = 1; /* KEY ok */ } else if (imClass == IDCMP_CLOSEWINDOW) { done = -1; /* cancel */ } } /* Check for AI messages */ if (ai_handle[0] != NULL) { while ((event = AIN_GetEvent(CTX))) { switch(event->Type) { case AINET_AXIS: if ((event->Value >= (ONOFF_VALUE)) || (event->Value <= (-(ONOFF_VALUE)))) { *offset = event->Index; done = 2; /* AI ok */ } break; case AINET_BUTTON: *offset = event->Index; done = 2; /* AI ok */ break; case AINET_HAT: *offset = event->Index; done = 2; /* AI ok */ break; default: break; } AIN_FreeEvent(CTX, event); } } } CloseWindow(window); } if (ai_handle[0] != NULL) { AIN_SetDeviceParameter(CTX, ai_handle[0], AINDP_EVENT, FALSE); /* Remove pending AI messages */ while ((event = AIN_GetEvent(CTX))) { AIN_FreeEvent(CTX, event); } AIN_ReleaseDevice(CTX, ai_handle[0]); ai_handle[0] = NULL; } return done; }