/** * @brief Disables a button. * * @param wid ID of the window to get widget from. * @param name Name of the button to disable. */ void window_disableButton( const unsigned int wid, char* name ) { Widget *wgt; /* Get the widget. */ wgt = btn_get( wid, name ); if (wgt == NULL) return; /* Disable button. */ wgt->dat.btn.disabled = 1; wgt_rmFlag(wgt, WGT_FLAG_CANFOCUS); }
/** * @brief Disables a button. * * @param wid ID of the window to get widget from. * @param name Name of the button to disable. */ void window_disableButton( const unsigned int wid, char* name ) { Widget *wgt; Window *wdw; /* Get the widget. */ wgt = btn_get( wid, name ); if (wgt == NULL) return; /* Disable button. */ wgt->dat.btn.disabled = 1; wgt_rmFlag(wgt, WGT_FLAG_CANFOCUS); /* Sanitize focus. */ wdw = window_wget(wid); toolkit_focusSanitize(wdw); }
/** * @brief Adds a button widget to a window, with a hotkey that enables the button to be activated with that key. * * Position origin is 0,0 at bottom left. If you use negative X or Y * positions. They actually count from the opposite side in. * * @param wid ID of the window to add the widget to. * @param x X position within the window to use. * @param y Y position within the window to use. * @param w Width of the widget. * @param h Height of the widget. * @param name Name of the widget to use internally. * @param display Text displayed on the button (centered). * @param call Function to call when button is pressed. Parameter passed * is the name of the button. * @param key Hotkey for using the button without it being focused. */ void window_addButtonKey( const unsigned int wid, const int x, const int y, const int w, const int h, char* name, char* display, void (*call) (unsigned int wgt, char* wdwname), SDLKey key ) { Window *wdw = window_wget(wid); Widget *wgt = window_newWidget(wdw, name); if (wgt == NULL) return; /* generic */ wgt->type = WIDGET_BUTTON; /* specific */ wgt->keyevent = btn_key; wgt->render = btn_render; wgt->cleanup = btn_cleanup; wgt_setFlag(wgt, WGT_FLAG_CANFOCUS); wgt->dat.btn.display = strdup(display); wgt->dat.btn.disabled = 0; /* initially enabled */ wgt->dat.btn.fptr = call; if (key != 0) { wgt->dat.btn.key = key; btn_updateHotkey(wgt); } /* position/size */ wgt->w = (double) w; wgt->h = (double) h; toolkit_setPos( wdw, wgt, x, y ); if (wgt->dat.btn.fptr == NULL) { /* Disable if function is NULL. */ wgt->dat.btn.disabled = 1; wgt_rmFlag(wgt, WGT_FLAG_CANFOCUS); } if (wdw->focus == -1) /* initialize the focus */ toolkit_nextFocus( wdw ); }