bool ViewCaption::Create(CWnd* parent, int toolbarBmp, const int commands[], int count, const boost::function<void (void)>& on_clicked) { on_clicked_ = on_clicked; CDC dc; dc.CreateCompatibleDC(0); dc.SelectStockObject(DEFAULT_GUI_FONT); TEXTMETRIC tm; dc.GetTextMetrics(&tm); int h= tm.tmHeight + tm.tmInternalLeading + 2; // yes, internal leading is already in tmHeight if (!CWnd::Create(AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, AfxGetApp()->LoadStandardCursor(IDC_ARROW), 0, 0), 0, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CRect(0,0,0,h), parent, -1)) return false; if (!caption_.IsValid()) VERIFY(LoadPingFromRsrc(MAKEINTRESOURCE(IDB_VIEW_CAPTION), caption_)); if (!active_marker_.IsValid()) VERIFY(LoadPingFromRsrc(MAKEINTRESOURCE(IDB_ACTIVE_VIEW), active_marker_)); toolbar_.SetOnIdleUpdateState(false); FancyToolBar::Params p; p.shade = -0.28f; std::string btn(count, 'p'); if (!toolbar_.Create(this, btn.c_str(), commands, toolbarBmp, &p)) return false; toolbar_.SetPadding(CRect(5,4,5,4)); toolbar_.SetOption(FancyToolBar::HOT_OVERLAY, false); toolbar_.SetOwner(parent); return true; }
void VCButton_Test::copy() { QWidget w; Scene* sc = new Scene(m_doc); m_doc->addFunction(sc); VCButton btn(&w, m_doc); btn.setCaption("Foobar"); btn.setIconPath("../../../resources/icons/png/qlcplus.png"); btn.setFunction(sc->id()); btn.setAction(VCButton::Flash); btn.setKeySequence(QKeySequence(keySequenceB)); btn.enableStartupIntensity(true); btn.setStartupIntensity(qreal(0.2)); VCFrame parent(&w, m_doc); VCButton* copy = qobject_cast<VCButton*> (btn.createCopy(&parent)); QVERIFY(copy != NULL); QCOMPARE(copy->caption(), QString("Foobar")); QCOMPARE(copy->iconPath(), QString("../../../resources/icons/png/qlcplus.png")); QCOMPARE(copy->function(), sc->id()); QCOMPARE(copy->action(), VCButton::Flash); QCOMPARE(copy->keySequence(), QKeySequence(keySequenceB)); QCOMPARE(copy->isStartupIntensityEnabled(), true); QCOMPARE(copy->startupIntensity(), qreal(0.2)); delete copy; }
void VCButton_Test::copy() { QWidget w; Scene* sc = new Scene(m_doc); m_doc->addFunction(sc); VCButton btn(&w, m_doc); btn.setCaption("Foobar"); btn.setIcon("../../../gfx/qlc.png"); btn.setFunction(sc->id()); btn.setAction(VCButton::Flash); btn.setKeySequence(QKeySequence(keySequenceB)); btn.setAdjustIntensity(true); btn.setIntensityAdjustment(0.2); VCFrame parent(&w, m_doc); VCButton* copy = qobject_cast<VCButton*> (btn.createCopy(&parent)); QVERIFY(copy != NULL); QCOMPARE(copy->caption(), QString("Foobar")); QCOMPARE(copy->icon(), QString("../../../gfx/qlc.png")); QCOMPARE(copy->function(), sc->id()); QCOMPARE(copy->action(), VCButton::Flash); QCOMPARE(copy->keySequence(), QKeySequence(keySequenceB)); QCOMPARE(copy->adjustIntensity(), true); QCOMPARE(copy->intensityAdjustment(), qreal(0.2)); delete copy; }
// channel if from 0 static void menu_set_adc_direction(u8 channel) { u16 adc, calm; // for channel 2 use throttle, for others steering if (channel == 1) { adc = adc_throttle_ovs; calm = cg.calib_throttle_mid; } else { adc = adc_steering_ovs; calm = cg.calib_steering_mid; } // check steering firstly if (adc_steering_ovs < ((cg.calib_steering_mid - 40) << ADC_OVS_SHIFT)) menu_adc_direction = 0; else if (adc_steering_ovs > ((cg.calib_steering_mid + 40) << ADC_OVS_SHIFT)) menu_adc_direction = 1; // then check throttle if (adc_throttle_ovs < ((cg.calib_throttle_mid - 40) << ADC_OVS_SHIFT)) menu_adc_direction = 0; else if (adc_throttle_ovs > ((cg.calib_throttle_mid + 40) << ADC_OVS_SHIFT)) menu_adc_direction = 1; // and then CH3 button else if (btn(BTN_CH3)) menu_adc_direction ^= 1; // if this channel is using forced values, set it to left/right if (menu_force_value_channel) menu_force_value = menu_adc_direction ? PPM(500) : PPM(-500); }
void VCButton_Test::paint() { QWidget w; VCButton btn(&w, m_doc); w.show(); btn.show(); QTest::qWait(1); btn.setOn(true); btn.update(); QTest::qWait(1); btn.setOn(false); btn.update(); QTest::qWait(1); btn.setIconPath("../../../resources/icons/png/qlcplus.png"); btn.update(); QTest::qWait(1); btn.setCaption("Foobar"); btn.update(); QTest::qWait(1); btn.setAction(VCButton::Flash); btn.update(); QTest::qWait(1); m_doc->setMode(Doc::Operate); btn.update(); QTest::qWait(1); }
// change model name static void menu_name_func(u8 action, void *p) { u8 letter; if (action == MCA_SET_CHG) { // change letter letter = cm.name[menu_set]; if (btn(BTN_ROT_L)) { // lower if (letter == '0') letter = 'Z'; else if (letter == 'A') letter = '9'; else letter--; } else { // upper if (letter == '9') letter = 'A'; else if (letter == 'Z') letter = '0'; else letter++; } cm.name[menu_set] = letter; } else if (action == MCA_SET_NEXT) { // next char if (++menu_set > 2) menu_set = 0; } // show name menu_blink = (u8)(1 << menu_set); // blink only selected char lcd_segment(LS_SYM_MODELNO, LS_ON); lcd_chars(cm.name); }
void BookmarkView::updateTheme() { wxColour bgColor(ThemeMgr::mgr.currentTheme->generalBackground); wxColour textColor(ThemeMgr::mgr.currentTheme->text); wxColour btn(ThemeMgr::mgr.currentTheme->button); wxColour btnHl(ThemeMgr::mgr.currentTheme->buttonHighlight); SetBackgroundColour(bgColor); m_treeView->SetBackgroundColour(bgColor); m_treeView->SetForegroundColour(textColor); m_propPanel->SetBackgroundColour(bgColor); m_propPanel->SetForegroundColour(textColor); m_buttonPanel->SetBackgroundColour(bgColor); m_buttonPanel->SetForegroundColour(textColor); m_labelLabel->SetForegroundColour(textColor); m_frequencyVal->SetForegroundColour(textColor); m_frequencyLabel->SetForegroundColour(textColor); m_bandwidthVal->SetForegroundColour(textColor); m_bandwidthLabel->SetForegroundColour(textColor); m_modulationVal->SetForegroundColour(textColor); m_modulationLabel->SetForegroundColour(textColor); refreshLayout(); }
void VCButton_Test::resetColors() { QWidget w; VCButton btn(&w, m_doc); btn.setForegroundColor(QColor(Qt::red)); btn.setBackgroundColor(QColor(Qt::blue)); m_doc->resetModified(); btn.resetForegroundColor(); QCOMPARE(btn.foregroundColor(), w.palette().color(QPalette::WindowText)); QCOMPARE(btn.backgroundColor(), QColor(Qt::blue)); QCOMPARE(m_doc->isModified(), true); btn.resetForegroundColor(); QCOMPARE(btn.foregroundColor(), w.palette().color(QPalette::WindowText)); QCOMPARE(btn.backgroundColor(), QColor(Qt::blue)); btn.setForegroundColor(QColor(Qt::red)); btn.setBackgroundColor(QColor(Qt::blue)); m_doc->resetModified(); btn.resetBackgroundColor(); QCOMPARE(btn.backgroundColor(), w.palette().color(QPalette::Button)); QCOMPARE(btn.foregroundColor(), QColor(Qt::red)); QCOMPARE(m_doc->isModified(), true); btn.resetBackgroundColor(); QCOMPARE(btn.backgroundColor(), w.palette().color(QPalette::Button)); QCOMPARE(btn.foregroundColor(), QColor(Qt::red)); }
int main(int argc, char **argv) { Iup::Open(argc, argv); Iup::Frame frame(Iup::List().SetAttributes("DROPDOWN=YES, 1=Test, 2=XXX, VALUE=1")); frame.SetAttribute("TITLE", "List"); Iup::Text text; text.SetAttributes("EXPAND = YES, VALUE = \"Enter your text here\""); /* Creates a label */ Iup::Label lbl("This element is a label"); /* Creatas a button */ Iup::Button btn("This button does nothing"); /* Creates handles for manipulating the zbox VALUE */ Iup::SetHandle("frame", frame); Iup::SetHandle("text", text); Iup::SetHandle("lbl", lbl); Iup::SetHandle("btn", btn); /* Creates zbox with four elements */ Iup::Zbox zbox(frame, text, lbl, btn); /* Sets zbox alignment */ zbox.SetAttribute("ALIGNMENT", "ACENTER"); zbox.SetAttribute("VALUE", "text"); zbox.SetAttribute("NAME", "ZBOX"); Iup::List list; Iup::Hbox hbox(list); /* Creates frame */ Iup::Frame frm(hbox); /* Creates dialog */ Iup::Dialog dlg ( Iup::Vbox ( frm, zbox ) ); list.SetAttributes("1 = frame, 2 = text, 3 = lbl, 4 = btn, VALUE=2"); frm.SetAttribute("TITLE", "Select an element"); dlg.SetAttributes("MARGIN=10x10, GAP=10, TITLE = \"IupZbox Example\""); list.SetCallback("ACTION", (Icallback)list_cb); dlg.ShowXY(IUP_CENTER, IUP_CENTER); Iup::MainLoop(); Iup::Close(); return 0; }
int main(int argc, char* argv[]) { QApplication app(argc, argv); QPushButton btn("Quit"); QObject::connect(&btn, &QPushButton::clicked, &app, &QApplication::quit); btn.show(); return app.exec(); }
// ---------------------------------------------------------------------- void EventInputQueue::push_RelativePointerEventCallback(OSObject* target, int buttons_raw, int dx, int dy, AbsoluteTime ts, OSObject* sender, void* refcon) { GlobalLock::ScopedLock lk; if (!lk) return; Params_RelativePointerEventCallback::log(true, Buttons(buttons_raw), dx, dy); // ------------------------------------------------------------ Buttons buttons(buttons_raw); Buttons justPressed; Buttons justReleased; IOHIPointing* device = OSDynamicCast(IOHIPointing, sender); if (!device) return; ListHookedPointing::Item* item = static_cast<ListHookedPointing::Item*>(ListHookedPointing::instance().get(device)); if (!item) return; // ------------------------------------------------------------ CommonData::setcurrent_ts(ts); // ------------------------------------------------------------ justPressed = buttons.justPressed(item->get_previousbuttons()); justReleased = buttons.justReleased(item->get_previousbuttons()); item->set_previousbuttons(buttons); // ------------------------------------------------------------ // divide an event into button and cursormove events. for (int i = 0; i < ButtonStatus::MAXNUM; ++i) { PointingButton btn(1 << i); if (justPressed.isOn(btn)) { Params_RelativePointerEventCallback params(buttons, 0, 0, btn, true); bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } if (justReleased.isOn(btn)) { Params_RelativePointerEventCallback params(buttons, 0, 0, btn, false); bool retainFlagStatusTemporaryCount = Config::get_essential_config(BRIDGE_ESSENTIAL_CONFIG_INDEX_general_lazy_modifiers_with_mouse_event); enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } } // If (dx == 0 && dy == 0), the event is either needless event or just pressing/releasing buttons event. // About just pressing/releasing buttons event, we handled these in the above processes. // So, we can drop (dx == 0 && dy == 0) events in here. if (dx != 0 || dy != 0) { Params_RelativePointerEventCallback params(buttons, dx, dy, PointingButton::NONE, false); bool retainFlagStatusTemporaryCount = true; enqueue_(params, retainFlagStatusTemporaryCount, item->getDeviceIdentifier()); } setTimer(); }
void VCButton_Test::toggle() { QWidget w; Scene* sc = new Scene(m_doc); sc->setValue(0, 0, 255); sc->setFadeInSpeed(1000); sc->setFadeOutSpeed(1000); m_doc->addFunction(sc); VCButton btn(&w, m_doc); btn.setCaption("Foobar"); btn.setFunction(sc->id()); btn.setAction(VCButton::Toggle); btn.setKeySequence(QKeySequence(keySequenceB)); btn.enableStartupIntensity(true); btn.setStartupIntensity(qreal(0.2)); // Mouse button press in design mode doesn't toggle the function QCOMPARE(m_doc->mode(), Doc::Design); QMouseEvent ev(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, 0, 0); btn.mousePressEvent(&ev); QCOMPARE(m_doc->masterTimer()->m_functionList.size(), 0); ev = QMouseEvent(QEvent::MouseButtonRelease, QPoint(0, 0), Qt::LeftButton, 0, 0); btn.mouseReleaseEvent(&ev); QCOMPARE(m_doc->masterTimer()->m_functionList.size(), 0); // Mouse button press in operate mode should toggle the function m_doc->setMode(Doc::Operate); btn.slotKeyPressed(QKeySequence(keySequenceB)); // tell MasterTimer to process start queue m_doc->masterTimer()->timerTick(); QCOMPARE(m_doc->masterTimer()->m_functionList.size(), 1); QCOMPARE(m_doc->masterTimer()->m_functionList[0], sc); QCOMPARE(sc->getAttributeValue(Function::Intensity), btn.startupIntensity()); btn.slotKeyReleased(QKeySequence(keySequenceB)); m_doc->masterTimer()->timerTick(); // Allow MasterTimer to take the function under execution QCOMPARE(sc->stopped(), false); QCOMPARE(btn.isOn(), true); ev = QMouseEvent(QEvent::MouseButtonPress, QPoint(0, 0), Qt::LeftButton, 0, 0); btn.mousePressEvent(&ev); QCOMPARE(sc->m_stop, true); QCOMPARE(btn.isOn(), true); btn.slotFunctionStopped(sc->id()); QCOMPARE(btn.isOn(), false); VCButton another(&w, m_doc); QVERIFY(btn.palette().color(QPalette::Button) != another.palette().color(QPalette::Button)); QTest::qWait(500); QVERIFY(btn.palette().color(QPalette::Button) == another.palette().color(QPalette::Button)); ev = QMouseEvent(QEvent::MouseButtonRelease, QPoint(0, 0), Qt::LeftButton, 0, 0); btn.mouseReleaseEvent(&ev); }
void CCControlBase::layoutChildren(ELayoutMode layoutMode, bool resize) { // now check for all sub layers and call needsLayout to CCArray* children(getChildren()); CCObject* child; const float verticalOffset(static_cast<float>(m_marginV)); if(resize == true) { const CCSize& currentContentSize(getContentSize()); float contentHeight(verticalOffset); // determine the new content height CCARRAY_FOREACH(children, child) { CCControlBase* ctrlBase(dynamic_cast<CCControlBase*>(child)); if(ctrlBase != nullptr) { CCSize preferredSize(CCSizeMake(currentContentSize.width - (m_marginH * 2),0)); CCSize ctrlPreferredSize(ctrlBase->getPreferredSize()); ctrlPreferredSize.width = preferredSize.width; ctrlBase->setPreferredSize(ctrlPreferredSize); ctrlBase->needsLayout(); contentHeight += ctrlBase->getContentSize().height; contentHeight += verticalOffset; } else { CCScale9Sprite* sprite(dynamic_cast<CCScale9Sprite*>(child)); if(sprite == _backGroundSprite) { } else { CCControlButton* btn(dynamic_cast<CCControlButton*>(child)); if(btn != nullptr) { contentHeight += (btn->getContentSize().height + verticalOffset * 2); contentHeight += verticalOffset * 2; } else { CCNode* node(dynamic_cast<CCNode*>(child)); if(node != nullptr) { contentHeight += node->getContentSize().height; contentHeight += verticalOffset; } } } } } CCSize newContentSize(getContentSize()); newContentSize.height = contentHeight; setPreferredSize(newContentSize); needsLayout(); layoutChildren(ELayoutMode_topLeftDown); }
int main(int argc, char **argv) { QApplication app(argc, argv); QPushButton btn("Hello World"); btn.show(); app.exec(); return 0; }
Handler<Element> TabCombo::removeChild(std::size_t const& idx) { Handler<Element> elm(this->frame_->removeChild(idx)); auto const it = this->buttonMap_.find(elm); Handler<TabButton> btn(it->second); this->buttonMap_.erase(it); this->buttons_->removeChild(btn); if(Handler<Element> front = this->frontChild()){ //もうボタンが残っていない場合、nullが帰ってくるので updateButtonState(front, Handler<TabButton>()); } return elm; }
int main(int argc,char **argv) { /* 1.建立QT应用 */ QApplication app(argc,argv); /* 使中文正常显示 */ QTextCodec *codec=QTextCodec::codecForName("gb2312"); QTextCodec::setCodecForTr(codec); /* 2.建立窗体 */ QWidget win; /* 3.调用窗体方法控制窗体 */ //窗体大小400*300 win.resize(400,300); //居中显示 win.move((1024-400)/2,(768-300)/2); //添加button 在窗体中 QPushButton btn("OK",&win); btn.resize(100,30); btn.move(100,100); // 添加QLineEdit对象 在窗体中 // 使中文正常显示 QLineEdit le(QObject::tr("你好"),&win); le.resize(50,50); le.move(20,20); MySlots myslo; /* 点击按钮弹出一个messagebox QObject::connect( &btn,//信号发送者 SIGNAL(clicked()),//发送的信号 &myslo,//信号发送的槽函数的对象 SLOT(handle())//槽函数 ); */ /* 点击按钮退出窗体 */ QObject::connect( &btn,//信号发送者 SIGNAL(clicked()),//发送的信号 &app,//信号发送的槽函数的对象 SLOT(quit())//槽函数 ); win.setVisible(true); /* 4.等待所有窗体子线程终止 */ return app.exec(); }
Handler<Element> TabCombo::removeChild(Handler<Element> const& h) { auto it = this->buttonMap_.find(h); Handler<TabButton> btn(it->second); this->buttonMap_.erase(it); this->buttons_->removeChild(btn); this->frame_->removeChild(h); if(Handler<Element> front = this->frontChild()){ //もうボタンが残っていない場合、nullが帰ってくるので updateButtonState(front, Handler<TabButton>()); } return h; }
void VCButton_Test::bgcolor() { QWidget w; VCButton btn(&w, m_doc); m_doc->resetModified(); btn.setBackgroundColor(QColor(Qt::red)); QCOMPARE(btn.backgroundColor(), QColor(Qt::red)); QCOMPARE(btn.palette().color(QPalette::Button), QColor(Qt::red)); QCOMPARE(m_doc->isModified(), true); QVERIFY(btn.foregroundColor() != QColor(Qt::red)); }
void MediaView::touchEvent(QTouchEvent *e) { switch (e->type()) { case QEvent::TouchBegin: if (_touchPress || e->touchPoints().isEmpty()) return; _touchTimer.start(QApplication::startDragTime()); _touchPress = true; _touchMove = _touchRightButton = false; _touchStart = e->touchPoints().cbegin()->screenPos().toPoint(); break; case QEvent::TouchUpdate: if (!_touchPress || e->touchPoints().isEmpty()) return; if (!_touchMove && (e->touchPoints().cbegin()->screenPos().toPoint() - _touchStart).manhattanLength() >= QApplication::startDragDistance()) { _touchMove = true; } break; case QEvent::TouchEnd: if (!_touchPress) return; if (!_touchMove && App::wnd()) { Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton); QPoint mapped(mapFromGlobal(_touchStart)), winMapped(App::wnd()->mapFromGlobal(_touchStart)); QMouseEvent pressEvent(QEvent::MouseButtonPress, mapped, winMapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers()); pressEvent.accept(); mousePressEvent(&pressEvent); QMouseEvent releaseEvent(QEvent::MouseButtonRelease, mapped, winMapped, _touchStart, btn, Qt::MouseButtons(btn), Qt::KeyboardModifiers()); mouseReleaseEvent(&releaseEvent); if (_touchRightButton) { QContextMenuEvent contextEvent(QContextMenuEvent::Mouse, mapped, _touchStart); contextMenuEvent(&contextEvent); } } else if (_touchMove) { if ((!_leftNavVisible || !_leftNav.contains(mapFromGlobal(_touchStart))) && (!_rightNavVisible || !_rightNav.contains(mapFromGlobal(_touchStart)))) { QPoint d = (e->touchPoints().cbegin()->screenPos().toPoint() - _touchStart); if (d.x() * d.x() > d.y() * d.y() && (d.x() > st::medviewSwipeDistance || d.x() < -st::medviewSwipeDistance)) { moveToPhoto(d.x() > 0 ? -1 : 1); } } } _touchTimer.stop(); _touchPress = _touchMove = _touchRightButton = false; break; case QEvent::TouchCancel: _touchPress = false; _touchTimer.stop(); break; } }
void VCButton_Test::customMenu() { QWidget w; VCButton btn(&w, m_doc); QMenu* menu = btn.customMenu(NULL); QVERIFY(menu != NULL); QCOMPARE(menu->title(), tr("Icon")); QCOMPARE(menu->actions().size(), 2); QCOMPARE(menu->actions()[0], btn.m_chooseIconAction); QCOMPARE(menu->actions()[1], btn.m_resetIconAction); delete menu; }
QGroupBox* GuiPreferences::createCommonGrp(void) { QHBoxLayout* sourceBtnsLyt(new QHBoxLayout()); sourceBtnsLyt = new QHBoxLayout(); sourceBtnsLyt->setContentsMargins(0,0,0,0); sourceBtnsLyt->setMargin(0); for (int i=0; i<MAX_SRCS; ++i) { QRadioButton* btn(new QRadioButton(QString::number(i))); btn->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); m_sourceBtns.push_back(btn); connect(btn, SIGNAL(clicked()), this, SLOT(handleSourceSelected())); sourceBtnsLyt->addWidget(btn); } int line =0; QGridLayout* lyt(new QGridLayout()); lyt->addWidget(new QLabel(tr("Sources")), line, 0), lyt->addLayout(sourceBtnsLyt, line, 1, 1, 1, Qt::AlignLeft); lyt->addWidget(new QLabel(tr("Monitor Web URL*")), ++line, 0), lyt->addWidget(m_monitorUrlField, line, 1), m_monitorTypeField->addItem(tr("Select a monitor type")), m_monitorTypeField->addItems(ngrt4n::sourceTypes()), lyt->addWidget(m_monitorTypeField, line, 2); lyt->addWidget(m_verifySslPeerChkBx, ++line, 0, 1, 3, Qt::AlignCenter); lyt->addWidget(new QLabel(tr("Auth String")), ++line, 0), lyt->addWidget(m_serverPassField, line, 1), lyt->addWidget(m_showAuthInfoChkbx, line, 2); lyt->addWidget(new QLabel(tr("Update Interval")), ++line, 0), m_updateIntervalField->setMinimum(5), m_updateIntervalField->setMaximum(1200), lyt->addWidget(m_updateIntervalField, line, 1), lyt->addWidget(new QLabel(tr("seconds")), line, 2); lyt->addWidget(new QLabel(tr("Language")), ++line, 0), lyt->addWidget(m_languageBoxField); lyt->setColumnStretch(0, 0); lyt->setColumnStretch(1, 1); QGroupBox* bx(new QGroupBox(tr("Common Settings"))); bx->setFlat(false); bx->setLayout(lyt); bx->setAlignment(Qt::AlignLeft); return bx; }
// // Main Routine // int main(void) { #ifdef DEBUG CSerial ser; // declare a UART object ser.enable(); CDebug dbg(ser); // Debug stream use the UART object dbg.start(); #endif // // Optional: Enable tickless technology // #ifndef DEBUG CPowerSave::tickless(true); #endif // // Your setup code here // CButton btn(BUTTON_PIN_0); CBuzzer buz(15); // buzzer on P0.15 buz.enable(); CPin led(LED_PIN_0); led.output(); CTimeout tmLED; // // Enter main loop. // while(1) { // // Your loop code here // switch(btn.isPressed()) { case BTN_PRESSED: buz.post(3); // turn on buzzer x 3 break; case BTN_RELEASED: break; case BTN_NOTHING: break; } if ( tmLED.isExpired(500) ) { tmLED.reset(); led.toggle(); } } }
static void gs_backlight_time(u8 change) { s8 i; u16 *addr = &cg.backlight_time; if (change == 0xff) { lcd_set(L7SEG, LB_EMPTY); return; } if (change) { if (btn(BTN_ROT_L)) { // find lower value for (i = BL_STEPS_SIZE - 1; i >= 0; i--) { if (bl_steps[i] >= *addr) continue; *addr = bl_steps[i]; break; } if (i < 0) *addr = bl_steps[BL_STEPS_SIZE - 1]; } else { // find upper value for (i = 0; i < BL_STEPS_SIZE; i++) { if (bl_steps[i] <= *addr) continue; *addr = bl_steps[i]; break; } if (i == BL_STEPS_SIZE) *addr = bl_steps[0]; } } lcd_7seg(L7_L); if (*addr < 60) { // seconds bl_num2((u8)*addr); lcd_char(LCHR3, 'S'); } else if (*addr < 3600) { // minutes bl_num2((u8)(*addr / 60)); lcd_char(LCHR3, 'M'); } else if (*addr != BACKLIGHT_MAX) { // hours bl_num2((u8)(*addr / 3600)); lcd_char(LCHR3, 'H'); } else { // max lcd_chars("MAX"); } }
int main(int argc, char **argv) { QApplication app(argc, argv); QPushButton btn("Click ME !"); Clicker clicker; QObject::connect( &btn, SIGNAL(clicked()), &clicker, SLOT(doSomething())); btn.show(); app.exec(); return 0; }
void VCButton_Test::icon() { QWidget w; VCButton btn(&w, m_doc); m_doc->resetModified(); btn.setIcon("../../../gfx/qlc.png"); QCOMPARE(btn.icon(), QString("../../../gfx/qlc.png")); QCOMPARE(m_doc->isModified(), true); m_doc->resetModified(); btn.slotResetIcon(); QCOMPARE(btn.icon(), QString()); QCOMPARE(m_doc->isModified(), true); }
void VCButton_Test::iconPath() { QWidget w; VCButton btn(&w, m_doc); m_doc->resetModified(); btn.setIconPath("../../../resources/icons/png/qlcplus.png"); QCOMPARE(btn.iconPath(), QString("../../../resources/icons/png/qlcplus.png")); QCOMPARE(m_doc->isModified(), true); m_doc->resetModified(); btn.slotResetIcon(); QCOMPARE(btn.iconPath(), QString()); QCOMPARE(m_doc->isModified(), true); }
void VCButton_Test::intensity() { QWidget w; VCButton btn(&w, m_doc); btn.setAdjustIntensity(true); QCOMPARE(btn.adjustIntensity(), true); btn.setAdjustIntensity(false); QCOMPARE(btn.adjustIntensity(), false); for (qreal i = -0.5; i < 1.2; i += 0.01) { btn.setIntensityAdjustment(i); QCOMPARE(btn.intensityAdjustment(), CLAMP(i, qreal(0.0), qreal(1.0))); } }
void VCButton_Test::intensity() { QWidget w; VCButton btn(&w, m_doc); btn.enableStartupIntensity(true); QCOMPARE(btn.isStartupIntensityEnabled(), true); btn.enableStartupIntensity(false); QCOMPARE(btn.isStartupIntensityEnabled(), false); for (qreal i = -0.5; i < 1.2; i += 0.01) { btn.setStartupIntensity(i); QCOMPARE(btn.startupIntensity(), CLAMP(i, qreal(0.0), qreal(1.0))); } }
void VCButton_Test::keySequence() { QWidget w; VCButton btn(&w, m_doc); QCOMPARE(btn.keySequence(), QKeySequence()); QKeySequence seq(keySequenceA); btn.setKeySequence(seq); QCOMPARE(btn.keySequence(), seq); seq = QKeySequence(keySequenceB); QVERIFY(btn.keySequence() != seq); btn.setKeySequence(seq); QCOMPARE(btn.keySequence(), seq); }
void VCButton_Test::action() { QWidget w; VCButton btn(&w, m_doc); btn.setAction(VCButton::Flash); QCOMPARE(btn.action(), VCButton::Flash); btn.setAction(VCButton::Toggle); QCOMPARE(btn.action(), VCButton::Toggle); QCOMPARE(VCButton::actionToString(VCButton::Toggle), QString("Toggle")); QCOMPARE(VCButton::actionToString(VCButton::Flash), QString("Flash")); QCOMPARE(VCButton::actionToString((VCButton::Action) 31337), QString("Toggle")); QCOMPARE(VCButton::stringToAction("Toggle"), VCButton::Toggle); QCOMPARE(VCButton::stringToAction("Flash"), VCButton::Flash); QCOMPARE(VCButton::stringToAction("Foobar"), VCButton::Toggle); }