void dispatch() /* Set up a connection to database and dispatch control * based on hgpDo type var. */ { struct sqlConnection *conn = sqlConnect(visiDb); if (cartVarExists(cart, hgpDoThumbnails)) doThumbnails(conn); else if (cartVarExists(cart, hgpDoImage)) doImage(conn); else if (cartVarExists(cart, hgpDoProbe)) doProbe(conn); else if (cartVarExists(cart, hgpDoControls)) doControls(conn); else if (cartVarExists(cart, hgpDoId)) doId(conn); #ifdef SOON else if (cartVarExists(cart, hgpDoConfig)) configPage(conn); #endif /* SOON */ else if (cartVarExists(cart, hgpDoSearch)) doDefault(conn, TRUE); else { char *oldListSpec = hashFindVal(oldCart, hgpListSpec); char *newListSpec = cartOptionalString(cart, hgpListSpec); boolean isNew = differentStringNullOk(oldListSpec, newListSpec); doDefault(conn, isNew); } cartRemovePrefix(cart, hgpDoPrefix); }
/*---------------------------------------------------------------------------*/ void fileExecAction(Widget w, XEvent *event, String *params, Cardinal *num_params) { int i; FileWindowRec *fw; char **argv; i = findWidget(w, &fw); if (i == -1 || !fw) { /* error("Internal error:","widget not found in fileExecAction"); */ return; } if (fw->files[i]->type) { if (*fw->files[i]->type->push_action) if (!strcmp(fw->files[i]->type->push_action, "EDIT")) doEdit(fw->directory, fw->files[i]->name); else if (!strcmp(fw->files[i]->type->push_action, "VIEW")) doView(fw->directory, fw->files[i]->name); else if (!strcmp(fw->files[i]->type->push_action, "IMAGE")) doImage(fw->directory, fw->files[i]->name); else if (!strcmp(fw->files[i]->type->push_action, "SIAGHELP")) doSiaghelp(fw->directory, fw->files[i]->name); else { int k = 0; char *action = varPopup(fw->files[i]->type->icon_bm, fw->files[i]->type->push_action); if (!action) return; argv = (char **) XtMalloc( (user.arg0flag ? 6 : 5) * sizeof(char *)); argv[k++] = user.shell; argv[k++] = "-c"; argv[k++] = action; if (user.arg0flag) argv[k++] = user.shell; argv[k++] = fw->files[i]->name; argv[k] = NULL; executeApplication(user.shell, fw->directory, argv); XTFREE(argv); } } else doEdit(fw->directory, fw->files[i]->name); }
bool IMGUI::doImageButton(int id, const Vector2& position, const Vector2& size, const std::string& image) { doImage(id, position, image); // React to mouse input. if (InputManager::getSingleton()->click()) { Vector2 mousepos = InputManager::getSingleton()->position(); Vector2 btnpos = position - size * 0.5; if (mousepos.x > btnpos.x && mousepos.y > btnpos.y && mousepos.x < btnpos.x + size.x && mousepos.y < btnpos.y + size.y) { return true; } } return false; }
void IMGUI::doChatbox(int id, const Vector2& pos1, const Vector2& pos2, const std::vector<std::string>& entries, unsigned int& selected, const std::vector<bool>& local, unsigned int flags) { assert( entries.size() == local.size() ); int FontSize = (flags & TF_SMALL_FONT ? (FONT_WIDTH_SMALL+LINE_SPACER_SMALL) : (FONT_WIDTH_NORMAL+LINE_SPACER_NORMAL)); QueueObject obj; obj.id = id; obj.pos1 = pos1; obj.pos2 = pos2; obj.type = CHAT; obj.flags = flags; const unsigned int itemsPerPage = int(pos2.y - pos1.y - 10) / FontSize; if (!mInactive) { // M.W. : Activate cursorless object-highlighting once the up or down key is pressed. if (mActiveButton == -1) { switch (mLastKeyAction) { case DOWN: mActiveButton = 0; mLastKeyAction = NONE; break; case UP: mActiveButton = mLastWidget; mLastKeyAction = NONE; break; default: break; } } // Highlight first menu object for arrow key navigation. if (mActiveButton == 0 && !mButtonReset) mActiveButton = id; // React to keyboard input. if (id == mActiveButton) { switch (mLastKeyAction) { case DOWN: mActiveButton = 0; mLastKeyAction = NONE; break; case UP: mActiveButton = mLastWidget; mLastKeyAction = NONE; break; case LEFT: if (selected > 0) { selected--; } mLastKeyAction = NONE; break; case RIGHT: if (selected + 1 < entries.size()) { selected++; } mLastKeyAction = NONE; break; default: break; } } // React to mouse input. Vector2 mousepos = InputManager::getSingleton()->position(); if (mousepos.x > pos1.x && mousepos.y > pos1.y && mousepos.x < pos2.x && mousepos.y < pos2.y) { if (InputManager::getSingleton()->click()) mActiveButton = id; } //entries mouseclick: if (mousepos.x > pos1.x && mousepos.y > pos1.y+5 && mousepos.x < pos2.x-35 && mousepos.y < pos1.y+5+FontSize*itemsPerPage) { if ((InputManager::getSingleton()->mouseWheelUp()) && (selected > 0)) { selected--; } if ((InputManager::getSingleton()->mouseWheelDown()) && (selected + 1 < entries.size())) { selected++; } } //arrows mouseclick: if (mousepos.x > pos2.x-30 && mousepos.x < pos2.x-30+24 && InputManager::getSingleton()->click()) { if (mousepos.y > pos1.y+3 && mousepos.y < pos1.y+3+24 && selected > 0) { selected--; } if (mousepos.y > pos2.y-27 && mousepos.y < pos2.y-27+24 && selected + 1 < entries.size()) { selected++; } } } doImage(GEN_ID, Vector2(pos2.x-15, pos1.y+15), "gfx/pfeil_oben.bmp"); doImage(GEN_ID, Vector2(pos2.x-15, pos2.y-15), "gfx/pfeil_unten.bmp"); unsigned int first = (selected / itemsPerPage) * itemsPerPage; //recalc first if ( !entries.empty() ) { unsigned int last = selected + 1; /// \todo maybe we should adapt selected so we even can't scroll up further! // we don't want negative chatlog, so we just scroll upward without coming to negative // elements. if (last >= itemsPerPage) first = last - itemsPerPage; else first = 0; // check that we don't create out of bounds problems if(last > entries.size()) { last = entries.size(); } obj.entries = std::vector<std::string>(entries.begin()+first, entries.begin()+last); // HACK: we use taxt to store information which text is from local player and which from // remote player. obj.text = ""; for(unsigned int i = first; i < last; ++i) { obj.text += local[i] ? 'L' : 'R'; } } else obj.entries = std::vector<std::string>(); obj.selected = selected-first; mLastWidget = id; mQueue->push(obj); }
SelectBoxAction IMGUI::doSelectbox(int id, const Vector2& pos1, const Vector2& pos2, const std::vector<std::string>& entries, unsigned int& selected, unsigned int flags) { int FontSize = (flags & TF_SMALL_FONT ? (FONT_WIDTH_SMALL+LINE_SPACER_SMALL) : (FONT_WIDTH_NORMAL+LINE_SPACER_NORMAL)); SelectBoxAction changed = SBA_NONE; QueueObject obj; obj.id = id; obj.pos1 = pos1; obj.pos2 = pos2; obj.type = SELECTBOX; obj.flags = flags; const int itemsPerPage = int(pos2.y - pos1.y - 10) / FontSize; int first = (int)(selected / itemsPerPage)*itemsPerPage; //the first visible element in the list if (!mInactive) { // M.W. : Activate cursorless object-highlighting once the up or down key is pressed. if (mActiveButton == -1) { switch (mLastKeyAction) { case DOWN: mActiveButton = 0; mLastKeyAction = NONE; break; case UP: mActiveButton = mLastWidget; mLastKeyAction = NONE; break; default: break; } } // Highlight first menu object for arrow key navigation. if (mActiveButton == 0 && !mButtonReset) mActiveButton = id; // React to keyboard input. if (id == mActiveButton) { obj.type = ACTIVESELECTBOX; switch (mLastKeyAction) { case DOWN: mActiveButton = 0; mLastKeyAction = NONE; break; case UP: mActiveButton = mLastWidget; mLastKeyAction = NONE; break; case LEFT: if (selected > 0) { selected--; changed = SBA_SELECT; } mLastKeyAction = NONE; break; case RIGHT: if (selected + 1 < entries.size()) { selected++; changed = SBA_SELECT; } mLastKeyAction = NONE; break; default: break; } } // React to mouse input. Vector2 mousepos = InputManager::getSingleton()->position(); if (mousepos.x > pos1.x && mousepos.y > pos1.y && mousepos.x < pos2.x && mousepos.y < pos2.y) { obj.type = ACTIVESELECTBOX; if (InputManager::getSingleton()->click()) mActiveButton = id; } //entries mouseclick: if (mousepos.x > pos1.x && mousepos.y > pos1.y+5 && mousepos.x < pos2.x-35 && mousepos.y < pos1.y+5+FontSize*itemsPerPage) { if (InputManager::getSingleton()->click()) { int tmp = (int)((mousepos.y - pos1.y - 5) / FontSize) + first; /// \todo well, it's not really a doulbe click... /// we need to do this in inputmanager if( selected == tmp && InputManager::getSingleton()->doubleClick() ) changed = SBA_DBL_CLICK; if (tmp >= 0 && static_cast<unsigned int>(tmp) < entries.size()) selected = tmp; mActiveButton = id; } if ((InputManager::getSingleton()->mouseWheelUp()) && (selected > 0)) { selected--; changed = SBA_SELECT; } if ((InputManager::getSingleton()->mouseWheelDown()) && (selected + 1 < entries.size())) { selected++; changed = SBA_SELECT; } } //arrows mouseclick: if (mousepos.x > pos2.x-30 && mousepos.x < pos2.x-30+24 && InputManager::getSingleton()->click()) { if (mousepos.y > pos1.y+3 && mousepos.y < pos1.y+3+24 && selected > 0) { selected--; changed = SBA_SELECT; } if (mousepos.y > pos2.y-27 && mousepos.y < pos2.y-27+24 && selected + 1 < entries.size()) { selected++; changed = SBA_SELECT; } } } doImage(GEN_ID, Vector2(pos2.x-15, pos1.y+15), "gfx/pfeil_oben.bmp"); doImage(GEN_ID, Vector2(pos2.x-15, pos2.y-15), "gfx/pfeil_unten.bmp"); first = (selected / itemsPerPage)*itemsPerPage; //recalc first if ( !entries.empty() ) { unsigned int last = first + itemsPerPage; if (last > entries.size()) last = entries.size(); obj.entries = std::vector<std::string>(entries.begin()+first, entries.begin()+last); } else obj.entries = std::vector<std::string>(); obj.selected = selected-first; mLastWidget = id; mQueue->push(obj); return changed; }