/** Preconditions: + button is an array of length MAX_NUM_BUTTONS Postconditions: + Title bar and buttons have been initialized and laid out + for all i in 0..(MAX_NUM_BUTTONS-1), button[i] points to either (1) a valid NextButton instance, if the corresponding button is selected in the current button scheme, or (2) null otherwise. */ void NextClient::initializeButtonsAndTitlebar(QBoxLayout* titleLayout) { // Null the buttons to begin with (they are not guaranteed to be null). for (int i=0; i<MAX_NUM_BUTTONS; i++) { button[i] = NULL; } // The default button positions for other styles do not match the // behavior of older versions of KStep, so we have to set these // manually when customButtonPositions isn't enabled. QString left, right; if (options()->customButtonPositions()) { left = options()->titleButtonsLeft(); right = options()->titleButtonsRight(); } else { left = QString("I"); right = QString("SX"); } // Do actual creation and addition to titleLayout addButtons(titleLayout, left); titlebar = new QSpacerItem(10, titleHeight, QSizePolicy::Expanding, QSizePolicy::Minimum ); titleLayout->addItem(titlebar); addButtons(titleLayout, right); // Finally, activate all live buttons for ( int i = 0; i < MAX_NUM_BUTTONS; i++) { if (button[i]) { button[i]->setMouseTracking( TRUE ); } } }
LevelChooser::LevelChooser(Game *parent) : Menu(parent) { // set size setSceneRect(parent->rect()); m_width = sceneRect().width()/2; setBackgroundBrush(Qt::gray); // sets button attributes b_margin = 20; b_width = m_width - b_margin*2; b_height = 60; // buttons for level chooser QVector<QString> levels = parent->levelList(); // because of laziness, maximum amount of levels is 7 (else they will be positioned outside Xx768 resolution.. int levellimit = 7; for(int i = 0; i < levels.size() && i < levellimit; i++) { Button* button = new Button(b_width, b_height, levels[i], Button::GFunctionPlayLevel); button->levelKey(i); buttons.append(button); } buttons.append(new Button(b_width, b_height, "Back to Main Menu", Button::GFunctionMainMenu)); addButtons(buttons); }
LithologicalUnitEditorDialog::LithologicalUnitEditorDialog(QWidget* parent, LithologicalUnit* p) : DatasetEditorDialog(parent, p) { addMainPage(tr("Lithological Unit")); addIdLabel(); addNameEdit(); _typeV = new LithologicalUnitTypeView(getMainPage(), (static_cast<ProfileLogger*>(QApplication::instance()))->getLithologicalUnitTypeItemModel()); QGridLayout* l = static_cast<QGridLayout*>(getMainPage()->layout()); QLabel* lbl = new QLabel(tr("Unit Type"), getMainPage()); lbl->setAlignment(Qt::AlignTop); l->addWidget(lbl, r, lC); l->addWidget(_typeV, r, wC); r++; addDescriptionEdit(); addButtons(); connect(_typeV, SIGNAL(currentLithologicalUnitTypeChanged(LithologicalUnitType*)), this, SLOT(slotLithologicalUnitTypeChanged(LithologicalUnitType*))); _typeV->selectLithologicalUnitType(getLithologicalUnit()->getLithologicalUnitType()); emit showDatasetRequest(getLithologicalUnit()); slotShowDataset(getLithologicalUnit()); }
int inputBox(const char * text, int height, int width, poptContext optCon, int flags, char ** result) { newtComponent form, entry, okay, cancel, answer, tb; char * val; int rc = DLG_OKAY; int top; val = poptGetArg(optCon); tb = textbox(height - 3 - buttonHeight, width - 2, text, flags, &top); form = newtForm(NULL, NULL, 0); entry = newtEntry(1, top + 1, val, width - 2, &val, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); newtFormAddComponents(form, tb, entry, NULL); addButtons(height, width, form, &okay, &cancel, flags); answer = newtRunForm(form); if (answer == cancel) rc = DLG_CANCEL; *result = val; return rc; }
// ======================================================= int CRestoreOptWindow::create(char *szDevice, char *szImageFile, COptions options) { BEGIN; char szTemp[1024]; SNPRINTF(szTemp, i18n("restore partition from image file")); newtCenteredWindow(78, 20, szTemp); m_labelOptions = newtLabel(1, 1, i18n("Options")); m_checkEraseWithNull = newtCheckbox(1, 3, i18n("Erase free blocks with zero values"), (!!options.bEraseWithNull ? 'X' : ' '), " X", NULL); m_checkSimulateMode = newtCheckbox(1, 2, i18n("Simulation of the restoration (nothing is written)"), (!!options.bSimulateMode ? 'X' : ' '), " X", NULL); m_labelFinish = newtLabel(1, 5, i18n("If finished successfully:")); m_radioFinishWait = newtRadiobutton(1, 6, i18n("Wait"), options.dwFinish == FINISH_WAIT, NULL); m_radioFinishHalt = newtRadiobutton(1, 7, i18n("Halt"), options.dwFinish == FINISH_HALT, m_radioFinishWait); m_radioFinishReboot = newtRadiobutton(1, 8, i18n("Reboot"), options.dwFinish == FINISH_REBOOT, m_radioFinishHalt); m_radioFinishQuit = newtRadiobutton(1, 9, i18n("Quit"), options.dwFinish == FINISH_QUIT, m_radioFinishReboot); addButtons(); m_formMain = newtForm(NULL, NULL, 0); newtFormAddComponents(m_formMain, m_labelOptions, m_checkSimulateMode, m_checkEraseWithNull, NULL); newtFormAddComponents(m_formMain, m_labelFinish, m_radioFinishWait, m_radioFinishHalt, m_radioFinishReboot, m_radioFinishQuit, NULL); //newtFormAddComponents(m_formMain, m_btnRestore, m_btnExit, NULL); addHotKeys(); newtDrawForm(m_formMain); RETURN_int(0); }
// ======================================================= int CRestoreMbrWindow::create() { BEGIN; char szTemp[2048]; SNPRINTF(szTemp, "%s", i18n("Restore an MBR to the hard disk")); newtCenteredWindow(78, 20, szTemp); m_labelList1 = newtLabel(1, 1, i18n("Disk with the MBR to restore")); m_list1 = newtListbox(1, 2, 8, NEWT_FLAG_SCROLL); m_labelList2 = newtLabel(35, 1, i18n("Original MBR to use")); m_list2 = newtListbox(35, 2, 8, NEWT_FLAG_SCROLL); m_labelType = newtLabel(1, 12, i18n("What to restore:")); m_radioFull = newtRadiobutton(1, 13, i18n("The whole MBR"), true, NULL); m_radioBoot = newtRadiobutton(1, 14, "Only the boot loader", false, m_radioFull); m_radioTable = newtRadiobutton(1, 15, "Only the primary partitions table", false, m_radioBoot); addButtons(); m_formMain = newtForm(NULL, NULL, 0); newtFormAddComponents(m_formMain, m_labelList1, m_list1, m_labelList2, m_list2, m_labelType, m_radioFull, m_radioBoot, m_radioTable, NULL); //m_btnOkay, m_btnCancel, NULL); addHotKeys(); newtDrawForm(m_formMain); RETURN_int(0); }
Page createMainMenuPage(){ //Add Background SDL_Surface *bkg = loadImage(MAIN_MENU_BKG); addImageToSurface(bkg, NULL, containerPage.page, NULL); currentPage.bkg = bkg; // CreateButtons Button newGameBtn = createButton_settings(NEW_GAME_BTN_URL, NULL, 1, 150, 42, SCREEN_WIDTH / 2 - 150 / 2, 200); Button loadGameBtn = createButton_settings(LOAD_GAME_BTN_URL, NULL, 2, 150, 42, SCREEN_WIDTH / 2 - 150 / 2, newGameBtn.buttonsDestRect.y + newGameBtn.buttonsDestRect.h + SPACE); Button quitGameBtn = createButton_settings(QUIT_GAME_BTN_URL, NULL, 3, 150, 42, SCREEN_WIDTH / 2 - 150 / 2, loadGameBtn.buttonsDestRect.y + loadGameBtn.buttonsDestRect.h + SPACE); Button *btnLst = (Button*)myMalloc(sizeof(Button)*3); if (btnLst == NULL){ currentPage.isError = 1; return currentPage; } btnLst[0] = newGameBtn; btnLst[1] = loadGameBtn; btnLst[2] = quitGameBtn; currentPage.btnList = btnLst; currentPage.btnListLen = 3; currentPage.id = 1; addButtons(btnLst, 3, containerPage.page); restorDefaultSettings(); return currentPage; }
void ReadMode::switchToMode() { m_ui->helpBar->setText("<font color=\"green\">Enter text and hit the play button to hear the entire sequence.</font>"); m_ui->play->show(); clear(); addButtons(); }
void palOptions(struct cart *cart, struct sqlConnection *conn, void (*addButtons)(), char *extraVar) /* output the options dialog (select MAF file, output options */ { char *database = sqlGetDatabase(conn); hPrintf("<FORM ACTION=\"%s\" NAME=\"mainForm\" METHOD=POST>\n", cgiScriptName()); cartSaveSession(cart); char *mafTable = outMafTableDrop(cart, conn); char *numColumns = cartUsualString(cart, hgtaCGINumColumns, ""); printf("<BR><BR><B>Formatting options:</B><BR>\n"); jsMakeTrackingCheckBox(cart, hgtaCGIGeneExons, hgtaJSGeneExons, FALSE); printf("Separate into exons<BR>"); jsMakeTrackingCheckBox(cart, hgtaCGIGeneNoTrans, hgtaJSGeneNoTrans, FALSE); printf("Show nucleotides<BR>"); jsMakeTrackingCheckBox(cart, hgtaCGIGeneOutBlank, hgtaJSGeneOutBlank, FALSE); printf("Output lines with just dashes<BR>"); jsMakeTrackingCheckBox(cart, hgtaCGIOutTable, hgtaJSOutTable, FALSE); printf("Format output as table "); jsMakeTrackingCheckBox(cart, hgtaCGITruncHeader, hgtaJSTruncHeader, FALSE); printf("Truncate headers at "); cgiMakeTextVar(hgtaCGINumColumns, numColumns, 2); printf("characters (enter zero for no headers)<BR>"); printf("<BR>"); struct trackDb *maftdb = hTrackDbForTrack(database, mafTable); /* get maf parent (if any) */ maftdb->parent = hCompositeTrackDbForSubtrack(database,maftdb); wigMafSpeciesTable(cart, maftdb, mafTable, database); addButtons(); cartSaveSession(cart); hPrintf("</FORM>\n"); /* Hidden form - for benefit of javascript. */ { static char *saveVars[32]; int varCount = ArraySize(curVars); assert(varCount < (sizeof saveVars / sizeof(char *))); memcpy(saveVars, curVars, varCount * sizeof(saveVars[0])); if (extraVar != NULL) { assert(varCount + 1 < (sizeof saveVars / sizeof(char *))); saveVars[varCount] = extraVar; varCount++; } jsCreateHiddenForm(cart, cgiScriptName(), saveVars, varCount); } }
LithologicalUnitTypeEditorDialog::LithologicalUnitTypeEditorDialog(QWidget* parent, LithologicalUnitType* p) : DatasetEditorDialog(parent, p) { addMainPage(tr("Lithological Unit Type")); addIdLabel(); addNameEdit(); addDescriptionEdit(); addButtons(); emit showDatasetRequest(getLithologicalUnitType()); slotShowDataset(getLithologicalUnitType()); }
MessageDialog::MessageDialog(const QString &title, const QString &content, Buttons f, QWidget *parent) : Dialog(parent) { _mainLayout.setContentsMargins(24, 24, 24, 8); _mainLayout.setSpacing(24); _mainLayout.addLayout(&_titleLayout); _mainLayout.addLayout(&_contentLayout); _mainLayout.addLayout(&_actionLayout); setLayout(&_mainLayout); addTitle(title); addButtons(f); addContent(content); }
SpanningOptions::SpanningOptions(const QString & theme,QWidget * parent) : OptionsWidget(theme,parent) { setObjectName("spanningoptions"); m_section = "SpannedText"; QSettings settings(m_settingsFileName,QSettings::IniFormat); settings.setIniCodec("UTF-8"); settings.beginGroup(m_section); settings.beginGroup("Arabic"); m_keys = settings.childKeys(); for(int i=0;i < m_keys.size();i++) { m_names.insert(m_keys[i],QString()); } m_names.insert("bookmarklist",tr("Bookmark list")); m_names.insert("fullsearch",tr("Lexicon search results list")); m_names.insert("fullsearchresults",tr("Lexicon search results summary")); m_names.insert("headsearchlist",tr("Headword search results list")); m_names.insert("headsearchresults",tr("Headword search results summary")); m_names.insert("linktext",tr("Cross reference info box")); m_names.insert("nodeview",tr("Entry viewer heading")); m_names.insert("notebrowser",tr("Note browser")); m_names.insert("pageset",tr("Tab Set lists")); m_names.insert("rootnotfound",tr("Root not found")); m_names.insert("wordnotfound",tr("Word not found")); m_names.insert("tablist",tr("Tab List entries")); m_names.insert("messagebox",tr("Message box")); QVBoxLayout * vlayout = new QVBoxLayout; QFormLayout * formlayout = new QFormLayout; QLineEdit * edit; QString str; for(int i=0;i < m_keys.size();i++) { edit = new QLineEdit; m_edits.insert(m_keys[i],edit); str = m_names.value(m_keys[i]); if (str.isEmpty()) { str = m_keys[i]; } formlayout->addRow(str,edit); } vlayout->addLayout(formlayout); vlayout->addStretch(); setLayout(vlayout); addButtons(); readSettings(); setupConnections(); }
Page createLoadFromSlotPage(){ //Add Background SDL_Surface *bkg = loadImage(LOAD_FROM_SLOT_WINDOW); addImageToSurface(bkg, NULL, containerPage.page, NULL); currentPage.bkg = bkg; // create game mode section int y = 60; int x = 35; Button *btnLst = (Button*)myMalloc(sizeof(Button) * (NUM_OF_SLOTS + 2)); if (btnLst == NULL){ currentPage.isError = 1; return currentPage; } char path[200]; char selected_path[200]; char *btn = "_btn.bmp"; for (int i = 1; i <= NUM_OF_SLOTS; i++){ sprintf(path, "%s%d%s", SLOT_BTN_URL, i, btn); sprintf(selected_path, "%s%d%s", SLOT_SELECTED_BTN_URL, i, btn); Button slot = createButton_settings(path, selected_path, i, 50, 42, x, y); //y = y + slot.buttonsDestRect.h + SPACE; x = x + slot.buttonsDestRect.w + SPACE; btnLst[i - 1] = slot; } // create ok and cancel buttons Button cancelButton = createButton_settings(CANCEL_BTN_URL, NULL, NUM_OF_SLOTS + 1, 150, 42, SCREEN_WIDTH - SPACE - 150, SCREEN_HEIGHT - 30 - 42); Button okButton = createButton_settings(NEXT_BTN_URL, NULL, NUM_OF_SLOTS + 2, 150, 42, cancelButton.buttonsDestRect.x - 30 - cancelButton.buttonsDestRect.w, cancelButton.buttonsDestRect.y); btnLst[NUM_OF_SLOTS] = cancelButton; btnLst[NUM_OF_SLOTS + 1] = okButton; currentPage.btnList = btnLst; currentPage.btnListLen = NUM_OF_SLOTS + 2; currentPage.id = 3; addButtons(btnLst, NUM_OF_SLOTS + 2, containerPage.page); // set default sprintf(path, "%s%d%s", SLOT_SELECTED_BTN_URL, 1, btn); selectButton(path, btnLst[0]); userGuiSettings.savedSlot = 1; updateSurface(containerPage.page); return currentPage; }
SedimentStructureEditorDialog::SedimentStructureEditorDialog(QWidget* parent, SedimentStructure* p) : DatasetWithFileNameEditorDialog(parent, p) { addMainPage(tr("Sediment Structure")); addIdLabel(); addNameEdit(); addFileNameBrowser(tr("Symbol File"), (static_cast<ProfileLogger*> (QApplication::instance()))->getSettings()->getSedimentStructuresPath()); addDescriptionEdit(); addButtons(); emit showDatasetRequest(getSedimentStructure()); slotShowDataset(getSedimentStructure()); }
OutcropQualityEditorDialog::OutcropQualityEditorDialog(QWidget* parent, OutcropQuality* p) : DatasetWithFileNameEditorDialog(parent, p) { addMainPage(tr("Outcrop Quality")); addIdLabel(); addNameEdit(); addFileNameBrowser(tr("Pattern File"), (static_cast<ProfileLogger*>(QApplication::instance()))->getSettings()->getOutcropQualitiesPath()); addDescriptionEdit(); addButtons(); emit showDatasetRequest(getOutcropQuality()); slotShowDataset(getOutcropQuality()); }
void KCommonDecoration::resetLayout() { for (int n=0; n<NumButtons; n++) { if (m_button[n]) { delete m_button[n]; m_button[n] = 0; } } m_buttonsLeft.clear(); m_buttonsRight.clear(); delete m_previewWidget; m_previewWidget = 0; // shown instead of the window contents in decoration previews if(isPreview() ) { m_previewWidget = new QLabel(i18n("%1 is the name of window decoration style", "<center><b>%1 preview</b></center>").arg(visibleName() ), widget()); m_previewWidget->show(); } addButtons(m_buttonsLeft, options()->customButtonPositions() ? options()->titleButtonsLeft() : defaultButtonsLeft(), true); addButtons(m_buttonsRight, options()->customButtonPositions() ? options()->titleButtonsRight() : defaultButtonsRight(), false); updateLayout(); const int minTitleBarWidth = 35; btnHideMinWidth = buttonContainerWidth(m_buttonsLeft,true) + buttonContainerWidth(m_buttonsRight,true) + layoutMetric(LM_TitleEdgeLeft,false) + layoutMetric(LM_TitleEdgeRight,false) + layoutMetric(LM_TitleBorderLeft,false) + layoutMetric(LM_TitleBorderRight,false) + minTitleBarWidth; btnHideLastWidth = 0; }
void MainWindow::on_actionInsert_URDF_file_triggered() { QString filename = QFileDialog::getOpenFileName( this, tr("Select URDF file"), "", "URDF files (*.urdf)" ); URDFparser* parser = URDFparser::getInstance(); ui->robotSimulation->reset(); int result = parser->parseURDF(filename); if(result == 0) { addButtons(); } }
int IDialog::run() { _buttonLayout = new QHBoxLayout; _buttons = new QWidget; addButtons(*_buttonLayout); _buttons->setLayout(_buttonLayout); _mainLayout = new QVBoxLayout; addMainWidgets(*_mainLayout); _mainLayout->addSpacing(12); _mainLayout->addWidget(_buttons); _mainLayout->addStretch(1); setLayout(_mainLayout); show(); exec(); return result(); }
// ======================================================= int CSaveOptWindow::create(char *szImageFile, COptions options) { BEGIN; char szTemp[2048]; newtCenteredWindow(78, 20, i18n("save partition to image file")); m_labelCompression = newtLabel(1, 1, i18n("Compression level")); m_radioCompNone = newtRadiobutton(1, 2, i18n("None (very fast + very big file)"), options.dwCompression == COMPRESS_NONE, NULL); m_radioCompGzip = newtRadiobutton(1, 3, "Gzip (.gz: medium speed + small image file)", options.dwCompression == COMPRESS_GZIP, m_radioCompNone); m_radioCompBzip2 = newtRadiobutton(1, 4, "Bzip2 (.bz2: very slow + very small image file)", options.dwCompression == COMPRESS_BZIP2, m_radioCompGzip); m_labelOptions = newtLabel(1, 7, i18n("Options")); m_checkCheckBeforeSaving = newtCheckbox(1, 8, i18n("Check partition before saving"), (!!options.bCheckBeforeSaving ? 'X' : ' '), " X", NULL); m_checkAskDesc = newtCheckbox(1, 9, i18n("Enter description"), (!!options.bAskDesc ? 'X' : ' '), " X", NULL); m_checkOverwrite = newtCheckbox(1, 10, i18n("Overwrite without prompt"), (!!options.bOverwrite ? 'X' : ' '), " X", NULL); m_labelSplit = newtLabel(1, 12, i18n("Image split mode")); m_radioSplitAuto = newtRadiobutton(1, 13, i18n("Automatic split (when no space left)"), !options.qwSplitSize, NULL); m_radioSplitSize = newtRadiobutton(1, 14, i18n("Into files whose size is:............"), !!options.qwSplitSize, m_radioSplitAuto); SNPRINTF(szTemp, "%llu", (!!options.qwSplitSize) ? (options.qwSplitSize/1024/1024) : 2048); m_editSplitSize = newtEntry(43, 14, szTemp, 8, NULL, 0); m_labelSplitSizeKB = newtLabel(52, 14, i18n("MiB")); m_checkSplitWait = newtCheckbox(1, 15, i18n("Wait after each volume change"), (!!options.bSplitWait ? 'X' : ' '), " X", NULL); m_labelFinish = newtLabel(43, 7, i18n("If finished successfully:")); m_radioFinishWait = newtRadiobutton(43, 8, i18n("Wait"), options.dwFinish == FINISH_WAIT, NULL); m_radioFinishHalt = newtRadiobutton(43, 9, i18n("Halt"), options.dwFinish == FINISH_HALT, m_radioFinishWait); m_radioFinishReboot = newtRadiobutton(43, 10, i18n("Reboot"), options.dwFinish == FINISH_REBOOT, m_radioFinishHalt); m_radioFinishQuit = newtRadiobutton(43,11,i18n("Quit"), options.dwFinish == FINISH_QUIT, m_radioFinishReboot); m_radioFinishLast = newtRadiobutton(43,12,i18n("Last"), options.dwFinish == FINISH_LAST, m_radioFinishQuit); addButtons(); m_formMain = newtForm(NULL, NULL, 0); newtFormAddComponents(m_formMain, m_labelCompression, m_labelOptions, m_labelSplit, NULL); newtFormAddComponents(m_formMain, m_radioCompNone, m_radioCompGzip, m_radioCompBzip2, m_checkCheckBeforeSaving, m_checkAskDesc, m_checkOverwrite, NULL); newtFormAddComponents(m_formMain, m_labelFinish, m_radioFinishWait, m_radioFinishHalt, m_radioFinishReboot, m_radioFinishQuit, m_radioFinishLast, NULL); newtFormAddComponents(m_formMain, m_radioSplitAuto, m_radioSplitSize, m_labelSplitSizeKB, m_editSplitSize, m_checkSplitWait, NULL); addHotKeys(); newtDrawForm(m_formMain); RETURN_int(0); }
void TextLineAdjuster::update(Observable*) { if (updating_) return; updating_ = true; bool need = needButtons(); if (need != have_) { if (need) addButtons(); else removeButtons(); reallocate(); redraw(); have_ = ! have_; } updating_ = false; }
BedCorrelationEditorDialog::BedCorrelationEditorDialog(QWidget* parent, BedCorrelation* p) : DatasetEditorDialog(parent, p) { addMainPage(tr("Bed Correlation")); addIdLabel(); addNameEdit(); addDescriptionEdit(); addButtons(); getNameEdit()->setEnabled(false); setupBedSelectors(); emit showDatasetRequest(getBedCorrelation()); slotShowDataset(getBedCorrelation()); slotShowBedCorrelation(getBedCorrelation()); connect(_leftProfileV, SIGNAL(currentProfileChanged(Profile*)), _leftBedV, SLOT(slotCurrentProfileChanged(Profile*))); connect(_leftProfileV, SIGNAL(currentProfileChanged(Profile*)), _leftBedM, SLOT(slotCurrentProfileChanged(Profile*))); connect(_rightProfileV, SIGNAL(currentProfileChanged(Profile*)), _rightBedV, SLOT(slotCurrentProfileChanged(Profile*))); connect(_rightProfileV, SIGNAL(currentProfileChanged(Profile*)), _rightBedM, SLOT(slotCurrentProfileChanged(Profile*))); connect(_leftBedV, SIGNAL(currentBedChanged(Bed*)), this, SLOT(slotLeftBedChanged(Bed*))); connect(_rightBedV, SIGNAL(currentBedChanged(Bed*)), this, SLOT(slotRightBedChanged(Bed*))); }
Page createAiSettingsPage(){ //Add Background SDL_Surface *bkg = loadImage(AI_SETTINGS_WINDOW); addImageToSurface(bkg, NULL, containerPage.page, NULL); currentPage.bkg = bkg; // create game mode section int y = 50; int x = 35; Button *btnLst = (Button*)myMalloc(sizeof(Button) * 9); if (btnLst == NULL){ // TBD - free all images in current page currentPage.isError = 1; return currentPage; } char path[200]; char selected_path[200]; char *btn = "_btn.bmp"; int width; int height; for (int i = 1; i <= 5; i++){ if (i==5){ sprintf(path, "%s", BEST_BTN_URL); sprintf(selected_path, "%s", BEST_SELECTED_BTN_URL); width = 150; height = 42; } else{ sprintf(path, "%s%d%s", SLOT_BTN_URL, i, btn); sprintf(selected_path, "%s%d%s", SLOT_SELECTED_BTN_URL, i, btn); width = 50; height = 42; } Button difficulty = createButton_settings(path, selected_path, i, width, height, x, y); //y = y + slot.buttonsDestRect.h + SPACE; x = x + difficulty.buttonsDestRect.w + 24; btnLst[i - 1] = difficulty; } Button userColor_black = createButton_settings(BLACK_BTN_URL, BLACK_SELECTED_BTN_URL, 6, 150, 42, 35, 145); Button userColor_white = createButton_settings(WHITE_BTN_URL, WHITE_SELECTED_BTN_URL, 7, 150, 42, userColor_black.buttonsDestRect.x + userColor_black.buttonsDestRect.w + SPACE, 145); btnLst[5] = userColor_black; btnLst[6] = userColor_white; // create ok and cancel buttons Button cancelButton = createButton_settings(CANCEL_BTN_URL, NULL, 8, 150, 42, SCREEN_WIDTH - SPACE - 150, SCREEN_HEIGHT - 30 - 42); Button okButton = createButton_settings(NEXT_BTN_URL, NULL, 9, 150, 42, cancelButton.buttonsDestRect.x - 30 - cancelButton.buttonsDestRect.w, cancelButton.buttonsDestRect.y); btnLst[7] = cancelButton; btnLst[8] = okButton; currentPage.btnList = btnLst; currentPage.btnListLen = 9; currentPage.id = 4; addButtons(btnLst, 9, containerPage.page); // set defaults unsigned int defaultDepth = settings.minmax_depth; if (defaultDepth == BEST){ sprintf(path, "%s", BEST_SELECTED_BTN_URL); selectButton(path, btnLst[4]); } else{ sprintf(path, "%s%d%s", SLOT_SELECTED_BTN_URL, defaultDepth, btn); selectButton(path, btnLst[defaultDepth-1]); } Button defaultUserColorBtn = settings.isUserBlack == 1 ? userColor_black : userColor_white; char *defaultBtnSkin = settings.isUserBlack == 1 ? BLACK_SELECTED_BTN_URL : WHITE_SELECTED_BTN_URL; selectButton(defaultBtnSkin, defaultUserColorBtn); userGuiSettings.difficulty = settings.minmax_depth; userGuiSettings.isUserColorBlack = settings.isUserBlack; updateSurface(containerPage.page); return currentPage; }
void PromptDialog::run() { bps_initialize(); //request all dialog events dialog_request_events(0); if (dialog_create_prompt(&m_dialog) != BPS_SUCCESS) { qDebug() << "Failed to create prompt dialog."; emit cancel(); return; } //set the prompt message if (!m_promptMessage.trimmed().isEmpty() && dialog_set_prompt_message_text(m_dialog, m_promptMessage.toAscii()) != BPS_SUCCESS) { qDebug() << "Failed to set prompt dialog message text."; destroyDialog(); emit cancel(); return; } //set the prompt input field if (!m_inputField.trimmed().isEmpty() && dialog_set_prompt_input_field(m_dialog, m_inputField.toAscii()) != BPS_SUCCESS) { qDebug() << "Failed to set prompt dialog input field."; destroyDialog(); emit cancel(); return; } //set the input placeholder text if (!m_placeholderText.trimmed().isEmpty() && dialog_set_prompt_input_placeholder(m_dialog, m_placeholderText.toAscii()) != BPS_SUCCESS) { qDebug() << "Failed to set prompt dialog placeholder text."; destroyDialog(); emit cancel(); return; } if (!setTitle()) { destroyDialog(); emit cancel(); return; } if (!addButtons()) { destroyDialog(); emit cancel(); return; } if (!showDialog()) { qDebug() << "Failed to show prompt dialog."; destroyDialog(); emit cancel(); return; } bool shutdown = false; while (!shutdown) { bps_event_t* event = NULL; // -1 means that the function waits for an event before returning bps_get_event(&event, -1); if (event) { if (bps_event_get_domain(event) == dialog_get_domain()) { int selectedIndex = dialog_event_get_selected_index(event); const char* label = dialog_event_get_selected_label(event); const char* context = dialog_event_get_selected_context(event); const char* inputfield = dialog_event_get_prompt_input_field(event); if (inputfield != NULL) { m_inputField = inputfield; } if (label != NULL && context != NULL) { if (QString::compare(context, getCancelButtonContext()) == 0) { emit cancel(); } else if (QString::compare(context, getOkButtonContext()) == 0) { emit ok(); } else { emit customButton(selectedIndex, label, context); } } qDebug() << "Got prompt dialog click"; shutdown = true; } } } destroyDialog(); }
Page createSelecetionPage(){ //Add Background SDL_Surface *bkg = loadImage(SELECTION_WINDOW_BKG); addImageToSurface(bkg, NULL, containerPage.page, NULL); currentPage.bkg = bkg; // create game mode section Button game_mode_2PlayersMode = createButton_settings(TWO_PLAYERS_BTN_URL, TWO_PLAYERS_SELECTED_BTN_URL, 1, 150, 42, 35, 50); Button game_mode_playerVsAI = createButton_settings(AGAINS_COMPUTER_BTN_URL, AGAINS_COMPUTER_SELECTED_BTN_URL, 2, 150, 42, game_mode_2PlayersMode.buttonsDestRect.x + game_mode_2PlayersMode.buttonsDestRect.w + SPACE, 50); // create next player section Button next_player_white = createButton_settings(WHITE_BTN_URL, WHITE_SELECTED_BTN_URL, 3, 150, 42, 35, 137); Button next_player_black = createButton_settings(BLACK_BTN_URL, BLACK_SELECTED_BTN_URL, 4, 150, 42, next_player_white.buttonsDestRect.x + next_player_white.buttonsDestRect.w + SPACE, 137); // create next player section Button set_board_no = createButton_settings(NO_BTN_URL, NO_SELECTED_BTN_URL, 5, 150, 42, 35, 222); Button set_board_yes = createButton_settings(YES_BTN_URL, YES_SELECTED_BTN_URL, 6, 150, 42, set_board_no.buttonsDestRect.x + set_board_no.buttonsDestRect.w + SPACE, 222); // create ok and cancel buttons Button cancelButton = createButton_settings(CANCEL_BTN_URL, NULL, 7, 150, 42, SCREEN_WIDTH - SPACE - 150, SCREEN_HEIGHT - 30 - 42); Button okButton = createButton_settings(NEXT_BTN_URL, NULL, 8, 150, 42, cancelButton.buttonsDestRect.x - 30 - cancelButton.buttonsDestRect.w, cancelButton.buttonsDestRect.y); Button *btnLst = (Button*)myMalloc(sizeof(Button) * 8); if (btnLst == NULL){ currentPage.isError = 1; return currentPage; } btnLst[0] = game_mode_2PlayersMode; btnLst[1] = game_mode_playerVsAI; btnLst[2] = next_player_black; btnLst[3] = next_player_white; btnLst[4] = set_board_yes; btnLst[5] = set_board_no; btnLst[6] = cancelButton; btnLst[7] = okButton; currentPage.btnList = btnLst; currentPage.btnListLen = 8; currentPage.id = 2; addButtons(btnLst, 8, containerPage.page); // set defaults Button defaultGameModeBtn = settings.gameMode == TWO_PLAYERS ? game_mode_2PlayersMode : game_mode_playerVsAI; char *defaultBtnSkin = settings.gameMode == TWO_PLAYERS ? TWO_PLAYERS_SELECTED_BTN_URL : AGAINS_COMPUTER_SELECTED_BTN_URL; int isSuccess = selectButton(defaultBtnSkin, defaultGameModeBtn); if (isSuccess == 1){ userGuiSettings.gameMode = settings.gameMode; Button defaultNextPlayer = game_board.isBlackTurn == 1 ? next_player_black : next_player_white; defaultBtnSkin = game_board.isBlackTurn == 1 ? BLACK_SELECTED_BTN_URL : WHITE_SELECTED_BTN_URL; isSuccess = selectButton(defaultBtnSkin, defaultNextPlayer); if (isSuccess == 1){ userGuiSettings.isNextPlayerBlack = game_board.isBlackTurn; isSuccess = selectButton(NO_SELECTED_BTN_URL, set_board_no); if (isSuccess == 1){ userGuiSettings.isSetBoard = 0; } } } if (!isSuccess){ currentPage.isError = 1; return currentPage; } updateSurface(containerPage.page); return currentPage; }
int main(int argc, char *argv[]) { GtkWidget *exp, *vbox1, *vbox, *hbox; gint kateuth = 0; i = 0; gtk_init (&argc, &argv); kateuth = epilogiKate(); main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); // gtk_window_set_icon (GTK_WINDOW(main_window), gdk_pixbuf_new_from_xpm_data((const char **) pixmap)); gtk_window_set_icon (GTK_WINDOW(main_window), gdk_pixbuf_new_from_xpm_data((const char **) icon())); gtk_window_set_title (GTK_WINDOW (main_window), "Βαθμός πτυχίου!"); gtk_window_set_default_size (GTK_WINDOW (main_window), (gint) 700, (gint) 300); gtk_window_set_position (GTK_WINDOW (main_window), GTK_WIN_POS_CENTER); gtk_window_set_resizable(GTK_WINDOW (main_window), FALSE); g_signal_connect (G_OBJECT (main_window), "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_container_set_border_width (GTK_CONTAINER (main_window), 10); vbox = gtk_vbox_new (FALSE, 5); hbox = gtk_hbox_new (FALSE, 5); gtk_box_pack_start (GTK_BOX(hbox), gtk_label_new("Κωδικός"), FALSE, FALSE, 5); gtk_box_pack_start (GTK_BOX(hbox), gtk_label_new("Όνομα μαθήματος"), FALSE, FALSE, 5); gtk_box_pack_end (GTK_BOX(hbox), gtk_label_new("Δ.Μ."), FALSE, FALSE, 5); gtk_box_pack_end (GTK_BOX(hbox), gtk_label_new("Βαθμός"), FALSE, FALSE, 5); gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 5); /* PROTO EKSAMINO */ vbox1 = gtk_vbox_new (FALSE, 5); exp = addTitle("1o εξάμηνο"); gtk_container_add (GTK_CONTAINER (exp), vbox1); addLesson("Μαθηματική ανάλυση I", 0, "5", "[120]", vbox1); addLesson("Φυσική", 0, "5", "[121]", vbox1); addLesson("Προγραμματισμός I", 0, "5", "[122]", vbox1); addLesson("Αρχές Τηλεπικοινωνιών", 0, "5", "[123]", vbox1); addLesson("Ηλεκτρονικά", 0, "5", "[124]", vbox1); addLesson("Διακριτά συστήματα", 0, "5", "[125]", vbox1); gtk_box_pack_start (GTK_BOX(vbox), exp, FALSE, FALSE, 0); /* DEYTERO EKSAMINO */ vbox1 = gtk_vbox_new (FALSE, 5); exp = addTitle("2o εξάμηνο"); gtk_container_add (GTK_CONTAINER (exp), vbox1); addLesson("Μαθηματική ανάλυση II", 0, "5", "[220]", vbox1); addLesson("Φυσικές Αρχές Τεχνολογίας Επικοινωνιών", 0, "6", "[221]", vbox1); addLesson("Αρχιτεκτονική Η/Υ I", 0, "5", "[223]", vbox1); addLesson("Ηλεκτρονικές Τηλεπικοινωνίες", 0, "5", "[224]", vbox1); addLesson("Αριθμητική ανάλυση", 0, "5", "[225]", vbox1); addLesson("Προγραμματισμός II", 0, "5", "[226]", vbox1); gtk_box_pack_start (GTK_BOX(vbox), exp, FALSE, FALSE, 0); /* TRITO EKSAMINO */ vbox1 = gtk_vbox_new (FALSE, 5); exp = addTitle("3o εξάμηνο"); gtk_container_add (GTK_CONTAINER (exp), vbox1); addLesson("Βάσεις δεδομένων I", 0, "5", "[320]", vbox1); addLesson("Δομές δεδομένων και αλγόριθμοι", 0, "5", "[321]", vbox1); addLesson("Θεωρία πιθανοτήτων και στατιστική", 0, "5", "[322]", vbox1); addLesson("Δίκτυα I", 0, "5", "[323]", vbox1); addLesson("Λειτουργικά συστήματα I", 0, "5", "[324]", vbox1); addLesson("Εφαρμογές γραμμική άλγεβρας", 0, "5", "[325]", vbox1); gtk_box_pack_start (GTK_BOX(vbox), exp, FALSE, FALSE, 0); /* TETARTO EKSAMINO */ vbox1 = gtk_vbox_new (FALSE, 5); exp = addTitle("4o εξάμηνο"); gtk_container_add (GTK_CONTAINER (exp), vbox1); addLesson("Αλγόριθμοι και πολυπλοκότητα", 0, "5", "[421]", vbox1); addLesson("Αρχιτεκτονική II", 0, "5", "[422]", vbox1); addLesson("Ανάλυση και σχεδιασμός Π.Σ.", 0, "5", "[425]", vbox1); addLesson("Θεωρία συστημάτων - ΣΑΕ", 0, "5", "[426]", vbox1); addLesson("Δίκτυα II", 0, "5", "[427]", vbox1); gtk_box_pack_start (GTK_BOX(vbox1), gtk_hseparator_new(), FALSE, FALSE, 5); gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("1 από τα 2"), FALSE, FALSE, 5); addLesson("Υπολογισιμότητα", 1, "5", "[423]", vbox1); addLesson("Αρχές γλωσσών προγραμματισμού", 1, "5", "[424]", vbox1); gtk_box_pack_start (GTK_BOX(vbox), exp, FALSE, FALSE, 0); /* PEMPTO EKSAMINO */ vbox1 = gtk_vbox_new (FALSE, 5); exp = addTitle("5o εξάμηνο"); gtk_container_add (GTK_CONTAINER (exp), vbox1); addLesson("Οικονομικά των επιχειρήσεων", 0, "5", "[920]", vbox1); if (kateuth == 0) { gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("Κατεύθυνση πληροφορικής"), FALSE, FALSE, 5); addLesson("Προγραμματισμός III", 0, "7", "[531Π]", vbox1); addLesson("Τεχνολογία λογισμικού", 0, "7", "[532Π]", vbox1); addLesson("Βάσεις δεδομένων II", 0, "6", "[533Π]", vbox1); gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("1 από τα 2"), FALSE, FALSE, 5); addLesson("Λογικός προγραμματισμός", 1, "5", "[534Π]", vbox1); addLesson("Οργάνωση και διαχείριση αρχείων ", 1, "5", "[535Π]", vbox1); } else { gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("Κατεύθυνση τηλεπικοινωνιών και δικτύων"), FALSE, FALSE, 5); addLesson("Επεξεργασία σήματος", 0, "7", "[541Τ]", vbox1); addLesson("Τηλεπικοινωνιακά συστήματα I", 0, "7", "[542Τ]", vbox1); addLesson("Οπτικές επικοινωνίες", 0, "6", "[543Τ]", vbox1); gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("1 από τα 2"), FALSE, FALSE, 5); addLesson("Κινητές επικοινωνίες", 1, "5", "[544Τ]", vbox1); addLesson("Σχεδίαση, μελέτη και υλοποίηση δικτύων", 1, "5", "[545Τ]", vbox1); } gtk_box_pack_start (GTK_BOX(vbox), exp, FALSE, FALSE, 0); /* ΕΚΤΟ EKSAMINO */ vbox1 = gtk_vbox_new (FALSE, 5); exp = addTitle("6o εξάμηνο"); gtk_container_add (GTK_CONTAINER (exp), vbox1); gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("ΔΟΝΑ"), FALSE, FALSE, 5); addLesson("Τεχνική νομοθεσία", 0, "5", "[921]", vbox1); gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("1 από τα 2"), FALSE, FALSE, 5); addLesson("Επιχειρησιακή έρευνα", 1, "5", "[930]", vbox1); addLesson("Διαχείριση έργων πληροφορικής", 1, "5", "[931]", vbox1); if (kateuth == 0) { gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("Κατεύθυνση πληροφορικής (4 από τα 6)"), FALSE, FALSE, 5); addLesson("Τεχνητή νοημοσύνη", 1, "5", "[631Π]", vbox1); addLesson("Προχωρημένες εφαρμογές προγραμματισμού", 1, "5", "[632Π]", vbox1); addLesson("Πολυμέσα", 1, "5", "[633Π]", vbox1); addLesson("Λειτουργικά συστήματα II", 1, "5", "[634Π]", vbox1); addLesson("Δικτυακός προγραμματισμός", 1, "5", "[655]", vbox1); addLesson("Ασφάλεια πληροφοριακών συστημάτων", 1, "5", "[656]", vbox1); } else { gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("Κατεύθυνση τηλεπικοινωνιών και δικτύων (4 από τα 6)"), FALSE, FALSE, 5); addLesson("Επικοινωνίες δεδομένων", 1, "5", "[641Τ]", vbox1); addLesson("Τηλεπικοινωνιακά συστήματα II", 1, "5", "[642Τ]", vbox1); addLesson("Ειδικά θέματα οπτικών επικοινωνιών", 1, "5", "[643Τ]", vbox1); addLesson("Ασύρματες επικοινωνίες", 1, "5", "[644Τ]", vbox1); addLesson("Δικτυακός προγραμματισμός", 1, "5", "[655]", vbox1); addLesson("Ασφάλεια πληροφοριακών συστημάτων", 1, "5", "[656]", vbox1); } gtk_box_pack_start (GTK_BOX(vbox), exp, FALSE, FALSE, 0); /* EBDOMO EKSAMINO */ vbox1 = gtk_vbox_new (FALSE, 5); exp = addTitle("7o εξάμηνο"); gtk_container_add (GTK_CONTAINER (exp), vbox1); gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("ΔΟΝΑ (1 από τα 2)"), FALSE, FALSE, 5); addLesson("Μάρκετινγκ πληροφοριακών συστημάτων", 1, "3", "[922]", vbox1); addLesson("Διδακτική της πληροφορικής", 1, "3", "[923]", vbox1); if (kateuth == 0) { gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("Κατεύθυνση πληροφορικής"), FALSE, FALSE, 5); addLesson("Σεμινάριο θεμάτων τεχνολογικής αιχμής", 0, "6", "[731Π]", vbox1); gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("3 από τα 6"), FALSE, FALSE, 5); addLesson("Ειδικά θέματα βάσεων δεδομένων", 1, "7", "[732Π]", vbox1); addLesson("Ηλεκτρονικό εμπόριο", 1, "7", "[733Π]", vbox1); addLesson("Προγραμματισμός Ιντερνετ", 1, "7", "[734Π]", vbox1); addLesson("Υπολογιστικό πλέγμα", 1, "7", "[735Π]", vbox1); addLesson("Μεταγλωττιστές", 1, "7", "[736Π]", vbox1); addLesson("Κατανεμημένα συστήματα", 1, "7", "[757]", vbox1); } else { gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("Κατεύθυνση τηλεπικοινωνιών και δικτύων"), FALSE, FALSE, 5); addLesson("Σεμινάριο θεμάτων τεχνολογικής αιχμής", 0, "6", "[741Τ]", vbox1); gtk_box_pack_start (GTK_BOX(vbox1), gtk_label_new("3 από τα 6"), FALSE, FALSE, 5); addLesson("Δορυφορικές επικοινωνίες", 1, "7", "[742Τ]", vbox1); addLesson("CDMA", 1, "7", "[743Τ]", vbox1); addLesson("Δικτύωση και αυτοματοποίηση", 1, "7", "[744Τ]", vbox1); addLesson("Ευρυζωνικά δίκτυα", 1, "7", "[745Τ]", vbox1); addLesson("Απόδοση δικτύων", 1, "7", "[746Τ]", vbox1); addLesson("Κατανεμημένα συστήματα", 1, "7", "[757]", vbox1); } gtk_box_pack_start (GTK_BOX(vbox), exp, FALSE, FALSE, 0); addLesson("Πτυχιακή εργασία", 0, "20", "[801]", vbox); gtk_box_pack_start (GTK_BOX(vbox), addButtons(), FALSE, FALSE, 5); gtk_container_add (GTK_CONTAINER (main_window), vbox); gtk_widget_show_all (main_window); gtk_main (); return 0; }
int checkList(const char * text, int height, int width, poptContext optCon, int useRadio, int flags, char *** selections) { newtComponent form, okay, tb, subform, answer; newtComponent sb = NULL, cancel = NULL; const char * arg; char * end; int listHeight; int numBoxes = 0; int allocedBoxes = 5; int i; int numSelected; int rc = DLG_OKAY; char buf[80], format[20]; int maxWidth = 0; int top; struct { const char * text; const char * tag; newtComponent comp; } * cbInfo = malloc(allocedBoxes * sizeof(*cbInfo)); char * cbStates = malloc(allocedBoxes * sizeof(cbStates)); if (!(arg = poptGetArg(optCon))) return DLG_ERROR; listHeight = strtoul(arg, &end, 10); if (*end) return DLG_ERROR; while ((arg = poptGetArg(optCon))) { if (allocedBoxes == numBoxes) { allocedBoxes += 5; cbInfo = realloc(cbInfo, sizeof(*cbInfo) * allocedBoxes); cbStates = realloc(cbStates, sizeof(*cbStates) * allocedBoxes); } cbInfo[numBoxes].tag = arg; if (!(arg = poptGetArg(optCon))) return DLG_ERROR; if (!(flags & FLAG_NOITEM)) { cbInfo[numBoxes].text = arg; if (!(arg = poptGetArg(optCon))) return DLG_ERROR; } else cbInfo[numBoxes].text = ""; if (!strcmp(arg, "1") || !strcasecmp(arg, "on") || !strcasecmp(arg, "yes")) cbStates[numBoxes] = '*'; else cbStates[numBoxes] = ' '; if (wstrlen(cbInfo[numBoxes].tag,-1) > (unsigned int)maxWidth) maxWidth = wstrlen(cbInfo[numBoxes].tag,-1); numBoxes++; } form = newtForm(NULL, NULL, 0); tb = textbox(height - 3 - buttonHeight - listHeight, width - 2, text, flags, &top); if (listHeight < numBoxes) { sb = newtVerticalScrollbar(width - 4, top + 1, listHeight, NEWT_COLORSET_CHECKBOX, NEWT_COLORSET_ACTCHECKBOX); newtFormAddComponent(form, sb); } subform = newtForm(sb, NULL, 0); newtFormSetBackground(subform, NEWT_COLORSET_CHECKBOX); sprintf(format, "%%-%ds %%s", maxWidth); for (i = 0; i < numBoxes; i++) { sprintf(buf, format, cbInfo[i].tag, cbInfo[i].text); if (useRadio) cbInfo[i].comp = newtRadiobutton(4, top + 1 + i, buf, cbStates[i] != ' ', i ? cbInfo[i - 1].comp : NULL); else cbInfo[i].comp = newtCheckbox(4, top + 1 + i, buf, cbStates[i], NULL, cbStates + i); newtFormAddComponent(subform, cbInfo[i].comp); } newtFormSetHeight(subform, listHeight); newtFormSetWidth(subform, width - 10); newtFormAddComponents(form, tb, subform, NULL); addButtons(height, width, form, &okay, &cancel, flags); answer = newtRunForm(form); if (answer == cancel) rc = DLG_CANCEL; if (useRadio) { answer = newtRadioGetCurrent(cbInfo[0].comp); for (i = 0; i < numBoxes; i++) if (cbInfo[i].comp == answer) { *selections = malloc(sizeof(char *) * 2); (*selections)[0] = cbInfo[i].tag; (*selections)[1] = NULL; break; } } else { numSelected = 0; for (i = 0; i < numBoxes; i++) { if (cbStates[i] != ' ') numSelected++; } *selections = malloc(sizeof(char *) * (numSelected + 1)); numSelected = 0; for (i = 0; i < numBoxes; i++) { if (cbStates[i] != ' ') (*selections)[numSelected++] = cbInfo[i].tag; } (*selections)[numSelected] = NULL; } return rc; }
int listBox(const char * text, int height, int width, poptContext optCon, int flags, char ** result) { newtComponent form, okay, tb, answer, listBox; newtComponent cancel = NULL; const char * arg; char * end; int listHeight; int numItems = 0; int allocedItems = 5; int i, top; int rc = DLG_OKAY; char buf[80], format[20]; int maxTagWidth = 0; int maxTextWidth = 0; int scrollFlag; struct { const char * text; const char * tag; } * itemInfo = malloc(allocedItems * sizeof(*itemInfo)); if (!(arg = poptGetArg(optCon))) return DLG_ERROR; listHeight = strtoul(arg, &end, 10); if (*end) return DLG_ERROR; while ((arg = poptGetArg(optCon))) { if (allocedItems == numItems) { allocedItems += 5; itemInfo = realloc(itemInfo, sizeof(*itemInfo) * allocedItems); } itemInfo[numItems].tag = arg; if (!(arg = poptGetArg(optCon))) return DLG_ERROR; if (!(flags & FLAG_NOITEM)) { itemInfo[numItems].text = arg; } else itemInfo[numItems].text = ""; if (wstrlen(itemInfo[numItems].text,-1) > (unsigned int)maxTextWidth) maxTextWidth = wstrlen(itemInfo[numItems].text,-1); if (wstrlen(itemInfo[numItems].tag,-1) > (unsigned int)maxTagWidth) maxTagWidth = wstrlen(itemInfo[numItems].tag,-1); numItems++; } form = newtForm(NULL, NULL, 0); tb = textbox(height - 4 - buttonHeight - listHeight, width - 2, text, flags, &top); if (listHeight >= numItems) { scrollFlag = 0; i = 0; } else { scrollFlag = NEWT_FLAG_SCROLL; i = 2; } listBox = newtListbox(3 + ((width - 10 - maxTagWidth - maxTextWidth - i) / 2), top + 1, listHeight, NEWT_FLAG_RETURNEXIT | scrollFlag); sprintf(format, "%%-%ds %%s", maxTagWidth); for (i = 0; i < numItems; i++) { sprintf(buf, format, itemInfo[i].tag, itemInfo[i].text); newtListboxAddEntry(listBox, buf, (void *) i); } newtFormAddComponents(form, tb, listBox, NULL); addButtons(height, width, form, &okay, &cancel, flags); answer = newtRunForm(form); if (answer == cancel) rc = DLG_CANCEL; i = (int) newtListboxGetCurrent(listBox); *result = itemInfo[i].tag; return rc; }
/** * * @param theme * @param parent */ IconOptions::IconOptions(const QString & theme,QWidget * parent) : OptionsWidget(theme,parent) { setObjectName("iconoptions"); m_section = "Icons"; QVBoxLayout * vlayout = new QVBoxLayout; QFormLayout * layout = new QFormLayout; m_directory = new QLineEdit; QPushButton * directorybtn = new QPushButton(tr("Select directory")); QHBoxLayout * directorylayout = new QHBoxLayout; connect(directorybtn,SIGNAL(clicked()),this,SLOT(onSetDirectory())); directorybtn->setProperty("SID",SID_ICON_DIRECTORY); m_directory->setObjectName(SID_ICON_DIRECTORY); directorylayout->addWidget(m_directory); directorylayout->addWidget(directorybtn); layout->addRow(tr("Image directory"),directorylayout); QHBoxLayout * hlayout = new QHBoxLayout; QFormLayout * leftlayout = new QFormLayout; m_about = new QLineEdit; leftlayout->addRow(tr("About"),addLine(m_about,SID_ICON_ABOUT)); m_back = new QLineEdit; leftlayout->addRow(tr("Back"),addLine(m_back,SID_ICON_BACK)); m_background = new QLineEdit; leftlayout->addRow(tr("Background tab"),addLine(m_background,SID_ICON_NEW_BACKGROUND_TAB)); // new m_bookmarks = new QLineEdit; leftlayout->addRow(tr("Bookmarks"),addLine(m_bookmarks,SID_ICON_BOOKMARKS)); m_clear = new QLineEdit; leftlayout->addRow(tr("Clear"),addLine(m_clear,SID_ICON_CLEAR)); m_collapse = new QLineEdit; leftlayout->addRow(tr("Collapse"),addLine(m_collapse,SID_ICON_COLLAPSE)); // new m_docs = new QLineEdit; leftlayout->addRow(tr("Docs"),addLine(m_docs,SID_ICON_DOCS)); m_exit = new QLineEdit; leftlayout->addRow(tr("Exit"),addLine(m_exit,SID_ICON_EXIT)); m_expand = new QLineEdit; leftlayout->addRow(tr("Expand"),addLine(m_expand,SID_ICON_EXPAND)); //new m_first = new QLineEdit; leftlayout->addRow(tr("First"),addLine(m_first,SID_ICON_FIRST)); m_history = new QLineEdit; leftlayout->addRow(tr("History"),addLine(m_history,SID_ICON_HISTORY)); m_insertLink = new QLineEdit; leftlayout->addRow(tr("Insert Link"),addLine(m_insertLink,SID_ICON_INSERT_LINK)); m_keymaps = new QLineEdit; leftlayout->addRow(tr("Keymaps"),addLine(m_keymaps,SID_ICON_KEYMAPS)); m_keymapsDisabled = new QLineEdit; leftlayout->addRow(tr("Keymaps disabled"),addLine(m_keymapsDisabled,SID_ICON_KEYMAPS_DISABLED)); m_last = new QLineEdit; leftlayout->addRow(tr("Last"),addLine(m_last,SID_ICON_LAST)); m_link = new QLineEdit; leftlayout->addRow(tr("Link"),addLine(m_link,SID_ICON_LINK)); m_list = new QLineEdit; leftlayout->addRow(tr("List"),addLine(m_list,SID_ICON_FLATTEN)); // new m_load = new QLineEdit; leftlayout->addRow(tr("Load"),addLine(m_load,SID_ICON_LOAD)); // new QFormLayout * rightlayout = new QFormLayout; m_localSearch = new QLineEdit; rightlayout->addRow(tr("Local search"),addLine(m_localSearch,SID_ICON_LOCAL_SEARCH)); m_localSearchNext = new QLineEdit; rightlayout->addRow(tr("Local search next"),addLine(m_localSearchNext,SID_ICON_LOCAL_SEARCH_NEXT)); m_logs = new QLineEdit; rightlayout->addRow(tr("Logs"),addLine(m_logs,SID_ICON_LOGS)); m_narrow = new QLineEdit; rightlayout->addRow(tr("Narrow"),addLine(m_narrow,SID_ICON_NARROW)); m_newTab = new QLineEdit; rightlayout->addRow(tr("New tab"),addLine(m_newTab,SID_ICON_NEW_TAB)); // m_next = new QLineEdit; rightlayout->addRow(tr("Next"),addLine(m_next,SID_ICON_NEXT)); m_notes = new QLineEdit; rightlayout->addRow(tr("Notes"),addLine(m_notes,SID_ICON_NOTES)); m_preferences = new QLineEdit; rightlayout->addRow(tr("Preferences"),addLine(m_preferences,SID_ICON_PREFERENCES)); m_print = new QLineEdit; rightlayout->addRow(tr("Print"),addLine(m_print,SID_ICON_PRINT)); m_search = new QLineEdit; rightlayout->addRow(tr("Search"),addLine(m_search,SID_ICON_SEARCH)); m_syncLeft = new QLineEdit; rightlayout->addRow(tr("Sync left"),addLine(m_syncLeft,SID_ICON_SYNC_LEFT)); m_syncRight = new QLineEdit; rightlayout->addRow(tr("Sync right"),addLine(m_syncRight,SID_ICON_SYNC_RIGHT)); m_unlink = new QLineEdit; rightlayout->addRow(tr("Unlink"),addLine(m_unlink,SID_ICON_UNLINK)); m_widen = new QLineEdit; rightlayout->addRow(tr("Widen"),addLine(m_widen,SID_ICON_WIDEN)); m_zoom = new QLineEdit; rightlayout->addRow(tr("Zoom"),addLine(m_zoom,SID_ICON_ZOOM)); m_zoomIn = new QLineEdit; rightlayout->addRow(tr("Zoom in"),addLine(m_zoomIn,SID_ICON_ZOOM_IN)); m_zoomOut = new QLineEdit; rightlayout->addRow(tr("Zoom out"),addLine(m_zoomOut,SID_ICON_ZOOM_OUT)); leftlayout->setVerticalSpacing(5); rightlayout->setVerticalSpacing(5); hlayout->addLayout(leftlayout); hlayout->addSpacing(30); hlayout->addLayout(rightlayout); vlayout->addLayout(layout); vlayout->addLayout(hlayout); vlayout->addStretch(); setLayout(vlayout); addButtons(); readSettings(); setupConnections(); }
SmoothJoystick::SmoothJoystick(uint32_t port): Joystick(port) { addButtons(); robot -> update -> addFunctions(&updateHelper, (void*)this); }
/** * * @param theme * @param parent */ SystemOptions::SystemOptions(const QString & theme,QWidget * parent) : OptionsWidget(theme,parent) { m_section = "System"; m_allowNavMode = false; QVBoxLayout * vlayout = new QVBoxLayout; setObjectName("systemoptions"); m_contentsLinked = new QCheckBox; m_lexicon = new QLineEdit; QPushButton * lexiconbutton = new QPushButton(tr("...")); QHBoxLayout * lexiconlayout = new QHBoxLayout; connect(lexiconbutton,SIGNAL(clicked()),this,SLOT(onSetDatabase())); lexiconlayout->addWidget(m_lexicon); lexiconlayout->addSpacing(10); lexiconlayout->addWidget(lexiconbutton); lexiconlayout->addStretch(); // this->setControlSize(m_lexicon,VLARGE_EDIT); m_interval = new QLineEdit; m_interval->setValidator(new QIntValidator); this->setControlSize(m_interval,SMALL_EDIT); m_docked = new QCheckBox; m_importCheck = new QCheckBox; m_importShow = new QCheckBox; // this->setControlSize(m_focusTab,LARGE_EDIT); m_minimalInterface = new QCheckBox; m_restoreBookmarks = new QCheckBox; m_restoreTabs = new QCheckBox; // m_saveSettings = new QCheckBox; m_saveTabs = new QCheckBox; m_rootNavigation = new QCheckBox; // Root mod // m_runDate = new QDateTimeEdit; // this->setControlSize(m_runDate,VLARGE_EDIT); // Save boo m_showInterfaceWarning = new QCheckBox; m_qtStyle = new QComboBox; m_qtStyle->addItems(QStyleFactory::keys()); m_css = new QLineEdit; QHBoxLayout * csslayout = new QHBoxLayout; QPushButton * cssbutton = new QPushButton(tr("...")); csslayout->addWidget(m_css); csslayout->addSpacing(10); csslayout->addWidget(cssbutton); csslayout->addStretch(); connect(cssbutton,SIGNAL(clicked()),this,SLOT(onSetCss())); m_theme = new QComboBox; m_title = new QLineEdit; m_toolbarText = new QCheckBox; m_useNotes = new QCheckBox; m_notesDb = new QLineEdit; m_optionsWarning = new QCheckBox; QHBoxLayout * noteslayout = new QHBoxLayout; QPushButton * notesbutton = new QPushButton(tr("...")); noteslayout->addWidget(m_notesDb); noteslayout->addSpacing(10); noteslayout->addWidget(notesbutton); noteslayout->addStretch(); connect(notesbutton,SIGNAL(clicked()),this,SLOT(onSetNotesDatabase())); m_historyDb = new QLineEdit; QHBoxLayout * historylayout = new QHBoxLayout; QPushButton * historybutton = new QPushButton(tr("...")); historylayout->addWidget(m_historyDb); historylayout->addSpacing(10); historylayout->addWidget(historybutton); historylayout->addStretch(); connect(historybutton,SIGNAL(clicked()),this,SLOT(onSetHistoryDatabase())); m_keyboard = new QComboBox; m_splashScreen = new QCheckBox; m_splashDuration = new QLineEdit; m_splashDuration->setValidator(new QIntValidator); this->setControlSize(m_splashDuration,SMALL_EDIT); m_allowDuplicates = new QCheckBox; /// there are no other radiobuttons, so just make this the parent QHBoxLayout * tablayout = new QHBoxLayout; m_insertNewTab = new QRadioButton(tr("Insert"),this); m_appendNewTab = new QRadioButton(tr("Append"),this); tablayout->addWidget(m_insertNewTab); tablayout->addSpacing(40); tablayout->addWidget(m_appendNewTab); tablayout->addStretch(); QGroupBox * dbgroup = new QGroupBox(tr("Databases")); QFormLayout * dblayout = new QFormLayout; dblayout->addRow(tr("Lexicon"),lexiconlayout); dblayout->addRow(tr("Notes"),noteslayout); dblayout->addRow(tr("History"),historylayout); dblayout->setVerticalSpacing(VERTICAL_SPACING); dbgroup->setLayout(dblayout); QGroupBox * othergroup = new QGroupBox(tr("Options")); QFormLayout * optionlayout = new QFormLayout; optionlayout->addRow(tr("Title"),m_title); optionlayout->addRow(tr("Application stylesheet"),csslayout); optionlayout->addRow(tr("Theme"),m_theme); optionlayout->addRow(tr("Qt style"),m_qtStyle); optionlayout->addRow(tr("Docked"),m_docked); optionlayout->addRow(tr("New tab behaviour"),tablayout); optionlayout->addRow(tr("Contents linked"),m_contentsLinked); optionlayout->addRow(tr("Restore bookmarks"),m_restoreBookmarks); optionlayout->addRow(tr("Restore tabs"),m_restoreTabs); // optionlayout->addRow(tr("Save settings"),m_saveSettings); // optionlayout->addRow(tr("Run date"),m_runDate); optionlayout->addRow(tr("Minimal interface"),m_minimalInterface); optionlayout->addRow(tr("Show interface warning"),m_showInterfaceWarning); optionlayout->addRow(tr("Show preferences close warning"),m_optionsWarning); optionlayout->addRow(tr("Message duration (secs)"),m_interval); optionlayout->addRow(tr("Toolbar text"),m_toolbarText); if (m_allowNavMode) { optionlayout->addRow(tr("Nav by root"),m_rootNavigation); } else { m_rootNavigation->setVisible(false); } optionlayout->addRow(tr("Allow duplicates"),m_allowDuplicates); // optionlayout->addRow(tr("Use notes"),m_useNotes); optionlayout->addRow(tr("Keyboard"),m_keyboard); QHBoxLayout * splashlayout = new QHBoxLayout; splashlayout->addWidget(m_splashScreen); splashlayout->addSpacing(10); splashlayout->addWidget(new QLabel(tr("Duration (secs)"))); splashlayout->addWidget(m_splashDuration); splashlayout->addSpacing(10); QPushButton * splashbutton = new QPushButton(tr("Show location")); splashlayout->addWidget(splashbutton); connect(splashbutton,SIGNAL(clicked()),this,SLOT(onShowSplash())); splashlayout->addStretch(); optionlayout->addRow(tr("Show splash screen"),splashlayout); optionlayout->addRow(tr("Import links ignore db mismatch"),m_importCheck); optionlayout->addRow(tr("Import links show warning"),m_importShow); optionlayout->setVerticalSpacing(VERTICAL_SPACING); othergroup->setLayout(optionlayout); m_onlineUrl = new QLineEdit; m_onlineCurrentPage = new QLineEdit; m_offlineLocation = new QLineEdit; QHBoxLayout * locationlayout = new QHBoxLayout; QPushButton * locationbutton = new QPushButton(tr("...")); locationlayout->addWidget(m_offlineLocation); locationlayout->addSpacing(10); locationlayout->addWidget(locationbutton); locationlayout->addStretch(); connect(locationbutton,SIGNAL(clicked()),this,SLOT(onOfflineLocation())); m_offlineCurrentPage = new QLineEdit; m_localDocs = new QCheckBox; QGroupBox * docgroup = new QGroupBox(tr("Documentation")); QFormLayout * doclayout = new QFormLayout; doclayout->addRow(tr("Online URL"),m_onlineUrl); doclayout->addRow(tr("Online current page"),m_onlineCurrentPage); doclayout->addRow(tr("Offline location"),locationlayout); doclayout->addRow(tr("Offline current page"),m_offlineCurrentPage); doclayout->addRow(tr("Local documentation"),m_localDocs); doclayout->setVerticalSpacing(VERTICAL_SPACING); docgroup->setLayout(doclayout); vlayout->addWidget(dbgroup); vlayout->addWidget(othergroup); vlayout->addWidget(docgroup); vlayout->addStretch(); setLayout(vlayout); addButtons(); readSettings(); setupConnections(); this->setLineEditSize(VLARGE_EDIT); this->setComboSize(VLARGE_EDIT); }