/** *** NextButton() *** Iterator to traverse buttontree. Start it with first argument a pointer *** to the root UberButton, and the index int set to -1. Each subsequent call *** gives the pointer to uberbutton, button and button index within uberbutton. *** If all, also returns containers, apart from the UberButton. **/ button_info *NextButton(button_info **ub,button_info **b,int *i,int all) { /* Get next button */ (*i)++; /* Skip fake buttons */ while((*i)<(*ub)->c->num_buttons && !(*ub)->c->buttons[*i]) (*i)++; /* End of contained buttons */ if((*i)>=(*ub)->c->num_buttons) { *b=*ub; *ub=(*b)->parent; /* End of the world as we know it */ if(!(*ub)) { *b=NULL; return *b; } *i=(*b)->n; if((*i)>=(*ub)->c->num_buttons) { fprintf(stderr,"%s: BUG: Couldn't return to uberbutton\n",MyName); exit(2); } NextButton(ub,b,i,all); return *b; } *b=(*ub)->c->buttons[*i]; /* Found new container */ if((*b)->flags & b_Container) { *i=-1; *ub=*b; if(!all) NextButton(ub,b,i,all); return *b; } return *b; }
void MappingWidget::NextButton(MappingButton* button) { auto iterator = std::find(m_buttons.begin(), m_buttons.end(), button); if (iterator == m_buttons.end()) return; if (++iterator == m_buttons.end()) return; MappingButton* next = *iterator; if (next->IsInput() && next->isVisible()) next->Detect(); else NextButton(next); }
static button_info *parse_button_id(char **line) { button_info *b = NULL, *ub = UberButton; int mask; int x, y; int count, i; char *rest; char *s; s = PeekToken(*line, &rest); *line = NULL; if (!s) { show_error("No button id specified\n"); return NULL; } if (*s == '+') { unsigned int JunkWidth; unsigned int JunkHeight; mask = XParseGeometry(s, &x, &y, &JunkWidth, &JunkHeight); if (!(mask & XValue) || (mask & XNegative) || !(mask & YValue) || (mask & YNegative)) { show_error("Illegal button position '%s'\n", s); return NULL; } if (x < 0 || y < 0) { show_error("Button column/row must not be negative\n"); return NULL; } b = get_xy_button(ub, y, x); if (b == NULL) { show_error( "Button at column %d row %d not found\n", x, y); return NULL; } } else if (isdigit(*s)) { x = atoi(s); i = count = -1; /* find the button */ while (NextButton(&ub, &b, &i, 0)) { if (++count == x) break; } if (count != x || b == NULL) { show_error("Button number %d not found\n", x); return NULL; } } else if (isalpha(*s)) { Bool found = False; i = -1; /* find the button */ while (NextButton(&ub, &b, &i, 0)) { if (b->flags.b_Id && StrEquals(b->id, s)) { found = True; break; } } if (found == False) { show_error("Button id '%s' does not exist\n", s); return NULL; } } else { show_error("Invalid button id '%s' specified\n", s); return NULL; } *line = rest; return b; }