CMouseEventResult CWaveDisplay::onMouseMoved(CPoint& where, const CButtonState& buttons) { if (buttons.isLeftButton() && getViewSize().pointInside(where)) this->where = where; return CMouseEventResult::kMouseEventHandled; }
//---------------------------------------------------------------------------------------------------- CMouseEventResult UIViewCreatorDataSource::dbOnMouseDown (const CPoint& where, const CButtonState& buttons, int32_t row, int32_t column, CDataBrowser* browser) { mouseDownRow = row; if (buttons.isLeftButton ()) { if (!buttons.isDoubleClick ()) return kMouseEventHandled; addViewToCurrentEditView (); } else if (buttons.isRightButton ()) { const std::string& viewName = getStringList ()->at (static_cast<uint32_t> (mouseDownRow)); std::string menuEntryName = "Add a new '" + viewName + "'"; COptionMenu menu; menu.setStyle (kPopupStyle); menu.addEntry (menuEntryName.c_str ()); CPoint menuLocation (where); browser->localToFrame (menuLocation); if (menu.popup (browser->getFrame (), menuLocation)) { if (menu.getEntry (menu.getLastResult ())) addViewToCurrentEditView (); } } mouseDownRow = -1; return kMouseDownEventHandledButDontNeedMovedOrUpEvents; }
//----------------------------------------------------------------------------- CMouseEventResult CSegmentButton::onMouseDown (CPoint& where, const CButtonState& buttons) { if (buttons.isLeftButton ()) { float newValue = 0; float valueOffset = 1.f / (segments.size () - 1); uint32_t currentIndex = getSegmentIndex (getValueNormalized ()); for (Segments::const_iterator it = segments.begin (), end = segments.end (); it != end; ++it, newValue += valueOffset) { if ((*it).rect.pointInside (where)) { uint32_t newIndex = getSegmentIndex (newValue); if (newIndex != currentIndex) { beginEdit (); setSelectedSegment (newIndex); valueChanged (); endEdit (); invalid (); } break; } } } return kMouseDownEventHandledButDontNeedMovedOrUpEvents; }
//---------------------------------------------------------------------------------------------------- CMouseEventResult UITagsDataSource::dbOnMouseDown (const CPoint& where, const CButtonState& buttons, int32_t row, int32_t column, CDataBrowser* browser) { if (buttons.isLeftButton () && buttons.isDoubleClick ()) { UTF8StringPtr value = column == 0 ? names.at (row).c_str () : tags.at (row).c_str (); browser->beginTextEdit (CDataBrowser::Cell (row, column), value); } return kMouseDownEventHandledButDontNeedMovedOrUpEvents; }
//------------------------------------------------------------------------ CMouseEventResult CCheckBox::onMouseDown (CPoint& where, const CButtonState& buttons) { if (buttons.isLeftButton ()) { beginEdit (); previousValue = value; return onMouseMoved (where, buttons); } return kMouseDownEventHandledButDontNeedMovedOrUpEvents; }
//---------------------------------------------------------------------------------------------------- CMouseEventResult UIViewCreatorDataSource::dbOnMouseMoved (const CPoint& where, const CButtonState& buttons, int32_t row, int32_t column, CDataBrowser* browser) { if (mouseDownRow >= 0 && buttons.isLeftButton ()) { SharedPointer<UISelection> selection = createSelection (); CMemoryStream stream (1024, 1024, false); if (selection->store (stream, description)) { stream.end (); CDropSource* dropSource = new CDropSource (stream.getBuffer (), static_cast<uint32_t> (stream.tell ()), CDropSource::kText); browser->doDrag (dropSource); dropSource->forget (); } mouseDownRow = -1; } return kMouseEventNotHandled; }
//---------------------------------------------------------------------------------------------------- CMouseEventResult UISearchTextField::onMouseDown (CPoint& where, const CButtonState& buttons) { if (buttons.isLeftButton ()) { if (!getText ().empty ()) { if (getClearMarkRect ().pointInside (where)) { beginEdit (); setText (""); valueChanged (); endEdit (); return kMouseDownEventHandledButDontNeedMovedOrUpEvents; } } } return CTextEdit::onMouseDown (where, buttons); }
//------------------------------------------------------------------------ CMouseEventResult CMultiStateButton::onMouseDown(CPoint& where, const CButtonState& buttons) { if (!getMouseEnabled()) return CMouseEventResult::kMouseEventNotHandled; if (!(buttons.isLeftButton())) return CMouseEventResult::kMouseEventNotHandled; value = (float)(value + 1.0 / (double)(nStates)); if (value >= 1.0) value = 0.0; //draw (pContext); // doIdleStuff (); if (listener) listener->valueChanged(this); return CMouseEventResult::kMouseEventHandled; }
// OF THE POSSIBILITY OF SUCH DAMAGE. //----------------------------------------------------------------------------- #include "../unittests.h" #include "../../../lib/cbuttonstate.h" namespace VSTGUI { TESTCASE(CButtonStateTests, TEST(test, CButtonState s; EXPECT(s.getButtonState () == 0); EXPECT(s.getModifierState () == 0); s = kLButton; EXPECT(s.isLeftButton () == true); s |= kShift; EXPECT(s.isLeftButton () == true); EXPECT(s.getModifierState () == kShift); s = kRButton; EXPECT(s.isRightButton () == true); s |= kDoubleClick; EXPECT(s.isDoubleClick () == true); EXPECT(s & CButtonState (kDoubleClick)); CButtonState s2 (s); EXPECT(s == s2); s2 = ~s; EXPECT(s != s2); ); );