//! [0] Window::Window(QWidget *parent) : QWidget(parent) { confBrowseButton = createButton(tr("&Browse..."), SLOT(browse())); startButton = createButton(tr("&Start"), SLOT(goDarc())); startButton->setEnabled(false); cancelButton = createButton(tr("&Cancel"), SLOT(cancel())); homePath = QDir::homePath()+tr("/lotuce2/conf/"); configFileComboBox = createComboBox(homePath); configFileLabel = new QLabel(tr("Darc Config File:")); //! [0] //! [1] QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(configFileLabel, 0, 0); mainLayout->addWidget(configFileComboBox, 0, 1); mainLayout->addWidget(confBrowseButton, 0, 2); mainLayout->addWidget(cancelButton, 1, 2); mainLayout->addWidget(startButton, 1, 3); setLayout(mainLayout); setWindowTitle(tr("Lotuce2")); resize(700, 300); }
void ActionChoiceWindow::createButtons( ActionNode* actions, const CEGUI::Point& center, float radius, float angle, float angleWidth) { PushButton* button = NULL; if (actions->isLeaf()) { button = createButton(actions->getAction()->getName(), center); } else { if (actions->getGroup() != NULL) { button = createButton(actions->getGroup()->getName(), center); } const NodeSet children = actions->getChildren(); float angleStep = angleWidth / (float)children.size(); float ang = children.size()>1 ? angle - angleWidth : angle - 180; for (NodeSet::const_iterator iter = children.begin(); iter != children.end(); iter++) { CEGUI::Point centerChild = getPositionOnCircle(center, radius, ang); createButtons(*iter, centerChild, radius, ang, 60); ang += angleStep; } } actions->setButton(button); if (button != NULL) mWindow->addChildWindow(button); }
Advisor::Advisor(QWidget *parent) : QWidget(parent) { showAgain = true; //signalMapper = new QSignalMapper(this); display = new QTextEdit(); display->setReadOnly(true); display->setAlignment(Qt::AlignLeft); //display->setMaxLength(20); QFont font = display->font(); font.setPointSize(font.pointSize()); display->setFont(font); QPushButton *adviceButton = createButton(tr("Advice"),SLOT(adviceClicked())); QPushButton *weatherButton = createButton(tr("Weather"), SLOT(weatherClicked())); QPushButton *reminderButton = createButton(tr("Reminder"), SLOT(reminderClicked())); QPushButton *quitButton = createButton(tr("Quit"), SLOT(quitClicked())); QGridLayout *mainLayout = new QGridLayout; //mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addWidget(display, 0,0,1,12); mainLayout->addWidget(adviceButton, 1,0,1,12); mainLayout->addWidget(weatherButton, 2, 0, 1, 12); mainLayout->addWidget(reminderButton, 3, 0, 1, 12); mainLayout->addWidget(quitButton, 4 ,0, 1, 12); //connect(signalMapper, SIGNAL(mapped(QString)), this, SIGNAL(clicked(QString))); setLayout(mainLayout); setWindowTitle(tr("Advisor")); }
// ---------------------------------------------------------------------- Calculator::Calculator(QWidget* pwgt/*= 0*/) : QWidget(pwgt) { m_plcd = new QLCDNumber(12); m_plcd->setSegmentStyle(QLCDNumber::Flat); m_plcd->setMinimumSize(150, 50); QChar aButtons[4][4] = {{'7', '8', '9', '/'}, {'4', '5', '6', '*'}, {'1', '2', '3', '-'}, {'0', '.', '=', '+'} }; //Layout setup QGridLayout* ptopLayout = new QGridLayout; ptopLayout->addWidget(m_plcd, 0, 0, 1, 4); ptopLayout->addWidget(createButton("CE"), 1, 3); for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { ptopLayout->addWidget(createButton(aButtons[i][j]), i + 2, j); } } setLayout(ptopLayout); }
CreateFileDialog::CreateFileDialog(QTextEdit *textEdit, QString *fileName, QMainWindow *mainWindow) { this->textEdit = textEdit; this->fileName = fileName; this->mainWindow = mainWindow; fileNameEdit = new QLineEdit; fileNameLabel = new QLabel(tr("Имя файла:")); okButton = createButton(tr("&Ok"), SLOT(createFile())); cancelButton = createButton(tr("&Cancel"), SLOT(close())); QHBoxLayout *buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); buttonsLayout->addWidget(okButton); buttonsLayout->addWidget(cancelButton); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(fileNameLabel, 0, 0, 1, 3); mainLayout->addWidget(fileNameEdit, 1, 0, 1, 3); mainLayout->addLayout(buttonsLayout, 2, 0, 1, 3); setLayout(mainLayout); setWindowTitle(tr("New file")); resize(200, 100); subwindow = emarea->addSubWindow(this, windowType()); }
//! [0] Window::Window(QWidget *parent) : QWidget(parent) { browseButton = createButton(tr("&Browse..."), SLOT(browse())); findButton = createButton(tr("&Find"), SLOT(find())); fileComboBox = createComboBox(tr("*")); textComboBox = createComboBox(); directoryComboBox = createComboBox(QDir::currentPath()); fileLabel = new QLabel(tr("Named:")); textLabel = new QLabel(tr("Containing text:")); directoryLabel = new QLabel(tr("In directory:")); filesFoundLabel = new QLabel; createFilesTable(); //! [0] //! [1] QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(fileLabel, 0, 0); mainLayout->addWidget(fileComboBox, 0, 1, 1, 2); mainLayout->addWidget(textLabel, 1, 0); mainLayout->addWidget(textComboBox, 1, 1, 1, 2); mainLayout->addWidget(directoryLabel, 2, 0); mainLayout->addWidget(directoryComboBox, 2, 1); mainLayout->addWidget(browseButton, 2, 2); mainLayout->addWidget(filesTable, 3, 0, 1, 3); mainLayout->addWidget(filesFoundLabel, 4, 0, 1, 2); mainLayout->addWidget(findButton, 4, 2); setLayout(mainLayout); setWindowTitle(tr("Find Files")); resize(700, 300); }
void Screenshot::createButtonsLayout() { #ifdef Q_WS_QWS QMenu *contextMenu = QSoftMenuBar::menuFor(this); contextMenu->addAction( tr("New"), this, SLOT( newScreenshot())); contextMenu->addAction( tr("Save"), this, SLOT( saveScreenshot())); contextMenu->addAction( tr("Quit"), this, SLOT( close())); #else newScreenshotButton = createButton(tr("New Screenshot"), this, SLOT(newScreenshot())); saveScreenshotButton = createButton(tr("Save Screenshot"), this, SLOT(saveScreenshot())); quitScreenshotButton = createButton(tr("Quit"), this, SLOT(close())); buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); buttonsLayout->addWidget(newScreenshotButton); buttonsLayout->addWidget(saveScreenshotButton); buttonsLayout->addWidget(quitScreenshotButton); #endif }
void PhysicsClientExample::createButtons() { bool isTrigger = false; if (m_guiHelper && m_guiHelper->getParameterInterface()) { m_guiHelper->getParameterInterface()->removeAllParameters(); createButton("Load URDF",CMD_LOAD_URDF, isTrigger); createButton("Step Sim",CMD_STEP_FORWARD_SIMULATION, isTrigger); createButton("Send Bullet Stream",CMD_SEND_BULLET_DATA_STREAM, isTrigger); createButton("Get State",CMD_REQUEST_ACTUAL_STATE, isTrigger); createButton("Send Desired State",CMD_SEND_DESIRED_STATE, isTrigger); createButton("Create Box Collider",CMD_CREATE_BOX_COLLISION_SHAPE,isTrigger); createButton("Create Cylinder Body",CMD_CREATE_RIGID_BODY,isTrigger); createButton("Reset Simulation",CMD_RESET_SIMULATION,isTrigger); createButton("Initialize Pose",CMD_INIT_POSE, isTrigger); createButton("Set gravity", CMD_SEND_PHYSICS_SIMULATION_PARAMETERS, isTrigger); if (m_physicsClientHandle && m_selectedBody>=0) { int numJoints = b3GetNumJoints(m_physicsClientHandle,m_selectedBody); for (int i=0;i<numJoints;i++) { b3JointInfo info; b3GetJointInfo(m_physicsClientHandle,m_selectedBody,i,&info); b3Printf("Joint %s at q-index %d and u-index %d\n",info.m_jointName,info.m_qIndex,info.m_uIndex); if (info.m_flags & JOINT_HAS_MOTORIZED_POWER) { if (m_numMotors<MAX_NUM_MOTORS) { char motorName[1024]; sprintf(motorName,"%s q", info.m_jointName); // MyMotorInfo2* motorInfo = &m_motorTargetVelocities[m_numMotors]; MyMotorInfo2* motorInfo = &m_motorTargetPositions[m_numMotors]; motorInfo->m_velTarget = 0.f; motorInfo->m_posTarget = 0.f; motorInfo->m_uIndex = info.m_uIndex; motorInfo->m_qIndex = info.m_qIndex; // SliderParams slider(motorName,&motorInfo->m_velTarget); // slider.m_minVal=-4; // slider.m_maxVal=4; SliderParams slider(motorName,&motorInfo->m_posTarget); slider.m_minVal=-4; slider.m_maxVal=4; if (m_guiHelper && m_guiHelper->getParameterInterface()) { m_guiHelper->getParameterInterface()->registerSliderFloatParameter(slider); } m_numMotors++; } } } } } }
DialogPanel::DialogPanel(const sf::Vector2i& res, const std::vector<std::string>& dialog, const sf::Font& font, const sf::Color& color, const float& outline, const sf::Color& outlineColor) : curDiag(0), dialogue(dialog) { panelRect = sf::Shape(sf::Shape::Rectangle(sf::Vector2f(20, res.y - 170), sf::Vector2f(res.x - 100, res.y - 20), color, outline, outlineColor)); createString("dialogString", dialog.at(curDiag), font, 24, sf::Vector2f(30, res.y - 160)); createButton("nextButton", next, sf::Vector2f(res.x - 170, res.y - 60), 60, "Next", font); createButton("previousButton", previous, sf::Vector2f(res.x - 300, res.y - 60), 100, "Previous", font, sf::Color(100, 100, 120, 255)); }
Gui::Gui(HINSTANCE instance, CameraTranslator* frontCameraTranslator, CameraTranslator* rearCameraTranslator, Blobber* blobberFront, Blobber* blobberRear, int width, int height) : instance(instance), frontCameraTranslator(frontCameraTranslator), rearCameraTranslator(rearCameraTranslator), blobberFront(blobberFront), blobberRear(blobberRear), width(width), height(height), activeWindow(NULL), quitRequested(false) { WNDCLASSEX wClass; ZeroMemory(&wClass, sizeof(WNDCLASSEX)); wClass.cbClsExtra = NULL; wClass.cbSize = sizeof(WNDCLASSEX); wClass.cbWndExtra = NULL; wClass.hbrBackground = (HBRUSH)COLOR_WINDOW; wClass.hCursor = LoadCursor(NULL, IDC_ARROW); wClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wClass.hInstance = instance; wClass.lpfnWndProc = (WNDPROC)WinProc; wClass.lpszClassName = "Window Class"; wClass.lpszMenuName = NULL; wClass.style = CS_HREDRAW | CS_VREDRAW; if (!RegisterClassEx(&wClass)) { int nResult = GetLastError(); MessageBox( NULL, "Window class creation failed", "Window Class Failed", MB_ICONERROR ); } ZeroMemory(&msg, sizeof(MSG)); addMouseListener(this); mouseX = 0; mouseY = 0; mouseDown = false; mouseBtn = MouseListener::MouseBtn::LEFT; brushRadius = 50; frontRGB = createWindow(width, height, "Camera 1 RGB"); rearRGB = createWindow(width, height, "Camera 2 RGB"); frontClassification = createWindow(width, height, "Camera 1 classification"); rearClassification = createWindow(width, height, "Camera 2 classification"); selectedColorName = ""; Blobber::Color* color; for (int i = 0; i < blobberFront->getColorCount(); i++) { color = blobberFront->getColor(i); createButton(color->name, 20, 40 + i * 18, 160, 1); } createButton("Clear all", 20 + 160 + 10, 40, 100, 2); clearSelectedBtn = createButton("Clear selected", 20 + 280 + 10, 40, 140, 3, false); createButton("Quit", Config::cameraWidth - 80, 20, 60, 4); }
void MainWindow::createButtonLayout() { buttonLayout=new QHBoxLayout; buttonupdate = createButton(tr("Update Weight"), this, SLOT(updateWeight())); buttonexit = createButton(tr("Quit"), this, SLOT(close())); buttonLayout->addStretch(); buttonLayout->addWidget(buttonupdate); buttonLayout->addWidget(buttonexit); }
//! [0] PathSetting::PathSetting(QWidget *parent) : QDialog(parent) { readSettings(); _dcmrawpathLineEdit = createLineEdit(_dcmrawpath); _outputpathLineEdit = createLineEdit(_outputpath); _archivepathLineEdit = createLineEdit(_archivepath); _dcmrawpathbrowseButton = createButton(tr("&Browse..."), SLOT(browsedcmrawpath())); _outputpathbrowseButton = createButton(tr("&Browse..."), SLOT(browseoutputpath())); _archivepathbrowseButton = createButton(tr("&Browse..."), SLOT(browsearchivepath())); _dcmrawpathLabel = new QLabel("Dicom-RAW Path:"); _outputpathLabel = new QLabel("Output Path: "); _cb_archiveactive = new QCheckBox("Auto Archive:"); _cb_archiveactive->setChecked(_archiveactive); archiveactive(); connect(_cb_archiveactive, SIGNAL(stateChanged(int)), this, SLOT(archiveactive())); _spacer_line = new QSpacerItem( 450, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); QPushButton *pb_ok = createButton("Ok", SLOT(okbutton())); QPushButton *pb_cancle = createButton("Cancel", SLOT(cancelbutton())); QHBoxLayout* buttonsLayout = new QHBoxLayout; //buttonsLayout->addStretch(); buttonsLayout->addItem(_spacer_line); buttonsLayout->addWidget(pb_ok); buttonsLayout->addWidget(pb_cancle); QGridLayout *pathLayout = new QGridLayout; pathLayout->addWidget(_dcmrawpathLabel, 0, 0); pathLayout->addWidget(_dcmrawpathLineEdit, 0, 1); pathLayout->addWidget(_dcmrawpathbrowseButton, 0, 2); pathLayout->addWidget(_outputpathLabel, 1, 0); pathLayout->addWidget(_outputpathLineEdit, 1, 1); pathLayout->addWidget(_outputpathbrowseButton, 1, 2); pathLayout->addWidget(_cb_archiveactive, 3, 0); pathLayout->addWidget(_archivepathLineEdit, 3, 1); pathLayout->addWidget(_archivepathbrowseButton, 3, 2); QVBoxLayout *layout = new QVBoxLayout; layout->addLayout(pathLayout); layout->addLayout(buttonsLayout); setLayout(layout); setWindowTitle(tr("Path Settings")); //resize(600, 175); }
Private() : position(KoFlake::TopLeftCorner) { topLeft = createButton(KoFlake::TopLeftCorner); topLeft->setChecked(true); topRight = createButton(KoFlake::TopRightCorner); center = createButton(KoFlake::CenteredPosition); bottomRight = createButton(KoFlake::BottomRightCorner); bottomLeft = createButton(KoFlake::BottomLeftCorner); }
bool ChoiceLayer::init() { if (!Layer::init()) return false; auto button0 = createButton(0); auto button1 = createButton(1); return true; }
//! [8] void Screenshot::createButtonsLayout() { newScreenshotButton = createButton(tr("New Screenshot"), this, SLOT(newScreenshot())); saveScreenshotButton = createButton(tr("Save Screenshot"), this, SLOT(saveScreenshot())); quitScreenshotButton = createButton(tr("Quit"), this, SLOT(close())); buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); buttonsLayout->addWidget(newScreenshotButton); buttonsLayout->addWidget(saveScreenshotButton); buttonsLayout->addWidget(quitScreenshotButton); }
Widget* initializeChooseWorldWindow(SDL_Surface* windowSurface) { Widget* window = createWindow(windowSurface); char stringBuffer[SELECT_WORLD_STRING_LENGTH]; char digitBuffer[2]; strcpy(stringBuffer, SELECT_WORLD_COOSE_TEXT); SDL_Rect panelRect = { 300, 150, 400, 600 }; Widget* panel = createPanel(windowSurface, panelRect, SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B)); addChild(window, panel); SDL_Rect labelRect = { 35, 20, 20, 20 }; Widget* label; if (currSelectionWindow == LOAD) { label = createLabel(labelRect, LOAD_GAME_TITLE, window->image, 0, 0, bitmapfont1, NULL); } else if (currSelectionWindow == EDIT) { label = createLabel(labelRect, EDIT_GAME_TITLE, window->image, 0, 0, bitmapfont1, NULL); } else { label = createLabel(labelRect, SAVE_GAME_TITLE, window->image, 0, 0, bitmapfont1, NULL); } addChild(panel, label); SDL_Rect buttonSelectRect = { 20, 60, 20, 20 }; SDL_Rect buttonDoneRect = { 20, 130, 20, 20 }; SDL_Rect buttonBackRect = { 20, 200, 20, 20 }; SDL_Rect buttonUpRect = { 186, 60, 20, 20 }; SDL_Rect buttonDownRect = { 186, 84, 20, 20 }; sprintf(digitBuffer, "%d", currWorld); strcat(stringBuffer, digitBuffer); Widget* buttonSelect = createButton(buttonSelectRect, stringBuffer, window->image, MARKED, "select_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 25, 10, BUTTON_SELECT_WORLD, bitmapfont1); addChild(panel, buttonSelect); Widget* buttonDone = createButton(buttonDoneRect, SELECT_WORLD_DONE_TEXT, window->image, REGULAR, "button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 25, 10, BUTTON_SELECT_WORLD_DONE, bitmapfont1); addChild(panel, buttonDone); Widget* buttonBack = createButton(buttonBackRect, SELECT_WORLD_BACK_TEXT, window->image, REGULAR, "button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SELECT_WORLD_BACK, bitmapfont1); addChild(panel, buttonBack); Widget* buttonUp = createButton(buttonUpRect, NULL, window->image, REGULAR, "up_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SELECT_WORLD_INCREASE, bitmapfont1); addChild(panel, buttonUp); Widget* buttonDown = createButton(buttonDownRect, NULL, window->image, REGULAR, "down_button.bmp", SDL_MapRGB(pixel_format, COLOR_R, COLOR_G, COLOR_B), 20, 10, BUTTON_SELECT_WORLD_DECREASE, bitmapfont1); addChild(panel, buttonDown); return window; }
void TDDSubMenu::setupHeader(const Color4B &headerColor) { GLfloat parentH = this->getContentSize().height; GLfloat width = this->getContentSize().width; GLfloat height = kHeaderHeight; LayerColor *headerLayer = LayerColor::create(headerColor, width, height); Point pos = Point(0, parentH - height); headerLayer->setPosition(pos); this->addChild(headerLayer); // Setting Buttons float scale = TDDHelper::getBestScale(); // Size screenSize = TDDHelper::getScreenSize(); int midY = height/2; int buttonW = (int)(scale * 50); int buttonH = height; int leftButtonX = buttonW / 2; int rightButtonX = width - leftButtonX; int midX = width/2; Size size = Size(buttonW, buttonH); ControlButton *button; pos.x = leftButtonX; pos.y = midY; button = createButton("back", kActionTagBack, pos, size); headerLayer->addChild(button); mBackButton = button; pos.x = rightButtonX; pos.y = midY; button = createButton("hide", kActionTagToggle, pos, size); headerLayer->addChild(button); button->addTargetWithActionForControlEvents(this, cccontrol_selector(TDDSubMenu::touchUpInsideAction), Control::EventType::TOUCH_UP_INSIDE); mToggleButton = button; // Label Label *title = Label::createWithSystemFont("MENU", "Arial", 15); title->setColor(Color3B::WHITE); title->setPosition(Point(midX, midY)); headerLayer->addChild(title); // mHeaderLayer = headerLayer; }
QDialogButtonBox* DiagramToolBox::createButtonBox() { QList<QAction*> actions = DiagramToolBox::actions(); mButtonBox = new QDialogButtonBox(); mButtonBox->setCenterButtons(true); mButtonBox->addButton(createButton(actions[SelectModeAction]), QDialogButtonBox::ActionRole); mButtonBox->addButton(createButton(actions[ScrollModeAction]), QDialogButtonBox::ActionRole); mButtonBox->addButton(createButton(actions[ZoomModeAction]), QDialogButtonBox::ActionRole); mButtonBox->addButton(createButton( mDiagramView->actions()[DiagramView::PropertiesAction]), QDialogButtonBox::ActionRole); return mButtonBox; }
MainWindow::MainWindow() { mainLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); setWindowTitle("Fizjoterapia"); createButton("Nowa wizyta", "Rozpocznij tworzenie nowej wizyty", SLOT(clickedNewVisit())); createButton("Pacjenci i choroby", "Przeglądaj pacjentów i historię chorób", SLOT(clickedHistory())); createButton("Dodaj pacjenta", "Dodaj nowego pacjenta do bazy", SLOT(clickedNewPatient())); }
void initMenuRender() { Background = createPicture(BACKGROUNDPATH,0,0,1); choixJeu = createButton("Play",100,150,5); choixStat = createButton("Statistic",100,210,5); choixQuit = createButton("Exit",100,270,5); choixJeu.callback = *CMode; choixQuit.callback = *CGameQuit; choixStat.callback = *CStat; renderinitialised=1; }
int QUMessageBox::showMessage(const QString &title, const QString &msg, const QStringList &buttons, int defaultIndex, int widthHint) { /* debug start */ delete one; delete two; delete three; /* debug end */ if(defaultIndex == -1) defaultIndex = (buttons.size() / 2 - 1); for(int i = 1; i < buttons.size(); i += 2) { buttonLayout->addWidget(createButton( QIcon(buttons.at(i - 1)), buttons.at(i), (i - 1) / 2 == defaultIndex)); } setWindowTitle(title); message->setText(msg); resize(widthHint > -1 ? widthHint : width(), minimumSizeHint().height()); exec(); return _choice; }
ControlButton* ButtonUtils::createButton(const std::string& frameName, Size size, const std::string& label, float labelSize, Color3B labelColor) { //auto normal = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(frameName)); //auto highLight = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(frameName)); //auto disable = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(frameName)); //auto btn = ControlButton::create(label,"Arial",labelSize); ////¸ù¾Ý״̬ÉèÖñ³¾° //btn->setBackgroundSpriteForState(normal,Control::State::NORMAL); //btn->setBackgroundSpriteForState(highLight,Control::State::HIGH_LIGHTED); //btn->setBackgroundSpriteForState(disable,Control::State::DISABLED); ////¸ù¾Ý״̬ÉèÖð´Å¥ÎÄ×ÖÑÕÉ« //btn->setTitleColorForState(labelColor,Control::State::NORMAL); //btn->setTitleColorForState(labelColor,Control::State::HIGH_LIGHTED); //btn->setTitleColorForState(labelColor,Control::State::DISABLED); ////--TODOÉèÖô¥Ãþ¼¶±ð //return btn; return createButton(frameName,frameName,frameName,size,label,labelSize,labelColor); }
bool MYDISP::createButton(int id, char * name, int x, int y) { HBMP hbmp; /* Check that the ID is in range and the requested button record isn't already ** in use. */ if ((id < 0) || (id >= NUM_BUTTONS) || ((rgbtn[id].fs & fsBtnAlloc) != 0)) { return false; } /* Load the bitmap used to render the button. */ if ((hbmp = mtds.LoadBitmap(name)) == 0) { #if !defined(__SIM__) #if defined(__MTDSTRACE__) Serial.print("!createButton "); Serial.println(mtds.GetLastError(), HEX); #endif #endif return false; } /* Create the button. */ return createButton(id, hbmp, 0, x, y); }
void MainScene::showProducts(const std::vector<InAppProduct> & products, bool consumeOnClick) { actionsMenu->setVisible(false); backMenu->setVisible(true); Vector<MenuItem*> items; for (auto & product: products) { string text = product.title; text += " " + product.localizedPrice; text += " stock: " + to_string((service->stockOfProduct(product.productId))); items.pushBack(createButton(text.c_str(), [=](Ref *){ if (consumeOnClick) { consumeProduct(product.productId); } else { purchaseProduct(product.productId); } })); } if (productsMenu) { productsMenu->removeFromParent(); } productsMenu = Menu::createWithArray(items); productsMenu->alignItemsVerticallyWithPadding(15); productsMenu->setPosition(Vec2(this->getContentSize().width/2, this->getContentSize().height/2)); this->addChild(productsMenu); }
void ChoiceLayer::setChoices(vector<string> choices) { size_t btnCount = getChildrenCount(); size_t choiceCount = choices.size(); float btnHeight = GlobalConfig::getInstance()->getChoiceMenuFontSize() + 10; float spaceBetweenBtn = btnHeight; float deltaUnit = btnHeight + spaceBetweenBtn; float initHeight = choiceCount % 2 == 0 ? spaceBetweenBtn*0.5 + (choiceCount / 2 - 1)*deltaUnit : spaceBetweenBtn + btnHeight*0.5 + ((choiceCount - 1) / 2 - 1)*deltaUnit; if (choiceCount > btnCount) for (int i = btnCount; i<choices.size(); i++) { auto btn = createButton(i, choices[i]); } for (int i = 0; i < choiceCount; i++) { auto btn = (ControlButton*)getChildByTag(i); string choice = choices.at(i); btn->setPosition(Vec2(0, initHeight - i*deltaUnit)); #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) GBKToUTF(choice); #endif btn->setTitleForState(choice, Control::State::NORMAL); btn->setOpacity(255); } }
MenuPanel::MenuPanel(MenuElements& elements, const sf::Vector2f& position) : m_position(position) { for(auto button = begin(elements.buttons); button != end(elements.buttons); ++button) createButton(*button); for(auto checkbox = begin(elements.checkboxes); checkbox != end(elements.checkboxes); ++checkbox) createCheckBox(*checkbox); for(auto slider = begin(elements.slider); slider != end(elements.slider); ++slider) createSlider(*slider); for(auto label = begin(elements.labels); label != end(elements.labels); ++label) createLabel(*label); for(auto sprite = begin(elements.sprites); sprite != end(elements.sprites); ++sprite) createSprite(*sprite); for(auto inputbox = begin(elements.infobox); inputbox != end(elements.infobox); ++inputbox) createInputBox(*inputbox); for(auto it = begin(elements.animationContainer); it != end(elements.animationContainer); ++it) createAnimationContainer(std::move(*it)); setCorrelation(); std::sort(m_elements.begin(), m_elements.end(), [](const std::unique_ptr<MenuElement>& a, const std::unique_ptr<MenuElement>& b) -> bool { return a->getId() < b->getId(); }); }
w_Home::w_Home(QWidget *parent) : QWidget(parent) { label = new QLabel(this); label->setScaledContents(true); label->setPixmap(QPixmap(":/image/001.png")); progreess = new QProgressBar(this); createButton(); QVBoxLayout *layout = new QVBoxLayout; layout->addStretch(); layout->addWidget(progreess); layout->addWidget(new QLabel(this)); layout->addLayout(buttonLayout); this->setLayout(layout); // canState = CAN_BUS_FREE; // canStep = CAN_BUS_FREE; // waveCount = 0; // timeCount = 0; // isFinish = false; // isStart = false; }
void TabControl::_createItemButton() { Button* button = createButton(); button->eventMouseButtonClick += newDelegate(this, &TabControl::notifyPressedBarButtonEvent); button->_setInternalData(mItemButton.size()); // порядковый номер mItemButton.push_back(button); }
KGVisualItemGroup::KGVisualItemGroup(QGraphicsWidget *parent) : QGraphicsWidget(parent, Qt::Widget), m_isFiltered(0) { FlowLayout *layout = new FlowLayout; layout->setSpacing(Qt::Horizontal, 40); layout->setSpacing(Qt::Vertical, 40); layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); layout->setContentsMargins(40,40,20,10); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); setLayout(layout); KGVisualAppendItem *appendItem = new KGVisualAppendItem(KGVisualAppendItem::APPEND, this); appendItem->setPreferredSize(225, 155); layout->addItem(appendItem); p_visualInsertItem = new KGVisualAppendItem(KGVisualAppendItem::INSERT, this); p_visualInsertItem->setPreferredSize(40, 155); p_visualInsertItem->setVisible(false); setAcceptHoverEvents(true); setAcceptDrops(false); QGraphicsProxyWidget *w = createButton(); w->setPos(0, 40); w->setParentItem(this); //setFlags(QGraphicsItem::ItemHasNoContents); }
Calculator::Calculator(QWidget* pwgt/*= 0*/) : QWidget(pwgt) { m_plcd = new QLCDNumber(12); m_plcd->setMinimumSize(150, 50); QString aButtons[5][5]= {{"MS","M-","M+","MR","CE"}, {"7","8","9","/","Pow"}, {"4","5","6","*","Sqrt"}, {"1","2","3","-","ln"}, {"0","abs",".","+","="}}; //Layout setup QGridLayout* ptopLayout = new QGridLayout; ptopLayout->addWidget(m_plcd, 0, 0, 1, 5); // ptopLayout->addWidget(createButton("CE"), 1,4); for (int i = 0; i < 5; ++i) { for (int j = 0; j < 5; ++j) { ptopLayout->addWidget(createButton(aButtons[i][j]), i + 2, j); } } setLayout(ptopLayout); }