本文整理汇总了C++中Invoke函数的典型用法代码示例。如果您正苦于以下问题:C++ Invoke函数的具体用法?C++ Invoke怎么用?C++ Invoke使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Invoke函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Invoke
void ArpTwoStateButton::MouseDown(BPoint where)
{
inherited::MouseDown(where);
mSwitched = !mPressed;
/* Quick hack */
mPressed = !mPressed;
BMessage* msg = 0;
if( Message() ) msg = new BMessage( *Message() );
if( msg ) msg->AddBool("on", mPressed);
Invoke(msg);
Invalidate();
}
示例2: va_start
void uDelegate::Invoke(uTRef retval, size_t count, ...)
{
va_list ap;
va_start(ap, count);
void** args = count > 0
? (void**)U_ALLOCA(count * sizeof(void*))
: NULL;
for (size_t i = 0; i < count; i++)
args[i] = va_arg(ap, void*);
va_end(ap);
Invoke(retval, args, count);
}
示例3: string
void
Spinner::MessageReceived(BMessage *msg)
{
if (msg->what == M_TEXT_CHANGED) {
BString string(fTextControl->Text());
int32 newvalue = 0;
sscanf(string.String(),"%ld",&newvalue);
if (newvalue >= GetMin() && newvalue <= GetMax()) {
// new value is in range, so set it and go
SetValue(newvalue);
Invoke();
Draw(Bounds());
ValueChanged(Value());
} else {
// new value is out of bounds. Clip to range if current value is not
// at the end of its range
if (newvalue < GetMin() && Value() != GetMin()) {
SetValue(GetMin());
Invoke();
Draw(Bounds());
ValueChanged(Value());
} else if (newvalue>GetMax() && Value() != GetMax()) {
SetValue(GetMax());
Invoke();
Draw(Bounds());
ValueChanged(Value());
} else {
char string[100];
sprintf(string,"%ld",Value());
fTextControl->SetText(string);
}
}
}
else
BControl::MessageReceived(msg);
}
示例4: TEST_F
TEST_F(DataTest, testGetData) {{
InSequence s;
char buffer[256];
memset(buffer, 0, sizeof(buffer));
HDDEDATA hData = (HDDEDATA)88772;
EXPECT_CALL(winApi, DdeGetData(hData, _, sizeof(buffer), 5))
.Times(1)
.WillOnce(Invoke(this, &DataTest::DdeGetData));
auto_drop<Data> data(new Data(&instance, &winApi, hData));
ASSERT_EQ(8, data->getData((LPBYTE)buffer, sizeof(buffer), 5));
ASSERT_STREQ("zulu 19", buffer);
}}
示例5: TEST_F
TEST_F(ScriptRunnerTest, QueueReentrantScript_Async)
{
MockScriptLoader scriptLoader1(m_element.get());
MockScriptLoader scriptLoader2(m_element.get());
MockScriptLoader scriptLoader3(m_element.get());
m_scriptRunner->queueScriptForExecution(&scriptLoader1, ScriptRunner::ASYNC_EXECUTION);
m_scriptRunner->queueScriptForExecution(&scriptLoader2, ScriptRunner::ASYNC_EXECUTION);
m_scriptRunner->queueScriptForExecution(&scriptLoader3, ScriptRunner::ASYNC_EXECUTION);
m_scriptRunner->notifyScriptReady(&scriptLoader1, ScriptRunner::ASYNC_EXECUTION);
EXPECT_CALL(scriptLoader1, execute()).WillOnce(Invoke([&scriptLoader2, this] {
m_order.push_back(1);
m_scriptRunner->notifyScriptReady(&scriptLoader2, ScriptRunner::ASYNC_EXECUTION);
}));
EXPECT_CALL(scriptLoader2, execute()).WillOnce(Invoke([&scriptLoader3, this] {
m_order.push_back(2);
m_scriptRunner->notifyScriptReady(&scriptLoader3, ScriptRunner::ASYNC_EXECUTION);
}));
EXPECT_CALL(scriptLoader3, execute()).WillOnce(Invoke([this] {
m_order.push_back(3);
}));
// Make sure that re-entrant calls to notifyScriptReady don't cause ScriptRunner::execute to do
// more work than expected.
m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1));
m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1, 2));
m_platform.runSingleTask();
EXPECT_THAT(m_order, ElementsAre(1, 2, 3));
}
示例6: switch
void ArpColourControl::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case _R_MSG:
Invoke();
if (mR && mA) {
((_ArpRgbaControl*)mA)->SetColor(mR->Value(), -1, -1);
mA->Invalidate();
}
// printf("R Changed\n");
break;
case _G_MSG:
Invoke();
if (mG && mA) {
((_ArpRgbaControl*)mA)->SetColor(-1, mG->Value(), -1);
mA->Invalidate();
}
// printf("G Changed\n");
break;
case _B_MSG:
Invoke();
if (mB && mA) {
((_ArpRgbaControl*)mA)->SetColor(-1, -1, mB->Value());
mA->Invalidate();
}
// printf("B Changed\n");
break;
case _A_MSG:
Invoke();
// printf("A Changed\n");
break;
default:
inherited::MessageReceived(msg);
break;
}
}
示例7: TEST_F
TEST_F(ScriptRunnerTest, QueueReentrantScript_ManyAsyncScripts)
{
OwnPtrWillBeRawPtr<MockScriptLoader> scriptLoaders[20];
for (int i = 0; i < 20; i++)
scriptLoaders[i] = nullptr;
for (int i = 0; i < 20; i++) {
scriptLoaders[i] = MockScriptLoader::create(m_element.get());
EXPECT_CALL(*scriptLoaders[i], isReady()).WillRepeatedly(Return(true));
m_scriptRunner->queueScriptForExecution(scriptLoaders[i].get(), ScriptRunner::ASYNC_EXECUTION);
if (i > 0) {
EXPECT_CALL(*scriptLoaders[i], execute()).WillOnce(Invoke([this, i] {
m_order.append(i);
}));
}
}
m_scriptRunner->notifyScriptReady(scriptLoaders[0].get(), ScriptRunner::ASYNC_EXECUTION);
m_scriptRunner->notifyScriptReady(scriptLoaders[1].get(), ScriptRunner::ASYNC_EXECUTION);
EXPECT_CALL(*scriptLoaders[0], execute()).WillOnce(Invoke([&scriptLoaders, this] {
for (int i = 2; i < 20; i++)
m_scriptRunner->notifyScriptReady(scriptLoaders[i].get(), ScriptRunner::ASYNC_EXECUTION);
m_order.append(0);
}));
m_platform.runAllTasks();
int expected[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
};
EXPECT_THAT(m_order, testing::ElementsAreArray(expected));
}
示例8: Bounds
void
BIconButton::MouseUp(BPoint where)
{
if (!IsValid())
return;
if (IsEnabled() && _HasFlags(STATE_PRESSED)
&& Bounds().Contains(where)) {
Invoke();
} else if (Bounds().Contains(where))
SetInside(true);
_SetFlags(STATE_PRESSED, false);
_SetTracking(false);
}
示例9: MouseDown
virtual void MouseDown(BPoint point)
{
// Don't reopen the menu if it's already open or freshly closed.
bigtime_t clickSpeed = 2000000;
get_click_speed(&clickSpeed);
bigtime_t clickTime = Window()->CurrentMessage()->FindInt64("when");
if (!IsEnabled() || (Value() == B_CONTROL_ON)
|| clickTime < fCloseTime + clickSpeed) {
return;
}
// Invoke must be called before setting B_CONTROL_ON
// for the button to stay "down"
Invoke();
SetValue(B_CONTROL_ON);
}
示例10: Bounds
void
BRadioButton::MouseUp(BPoint point)
{
if (!IsTracking())
return;
fOutlined = Bounds().Contains(point);
if (fOutlined) {
fOutlined = false;
SetValue(B_CONTROL_ON);
Invoke();
}
Invalidate();
SetTracking(false);
}
示例11: main
int main()
{
Lua lua;
auto global = lua.GetGlobalEnvironment();
// Write a function in Lua
lua.RunScript(
"function addTwo(a)\n"
" return a+2\n"
"end\n"
);
auto addTwo = global.Get< LuaFunction<int(int)> >("addTwo");
return addTwo.Invoke(5) != 7;
}
示例12: get_click_speed
void ArpIntControl::MouseUp(BPoint pt)
{
if (IsEnabled() == false) return;
if (mMotion) mMotion->MouseUp(pt);
if ( mDownPt == pt && Bounds().Contains(pt) ) {
/* Start the edit timer in case the user is invoking an inline
* text view.
*/
bigtime_t doubleClickTime;
get_click_speed(&doubleClickTime);
doubleClickTime *= 2;
SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
StartTimer(BMessage(EDIT_START_MSG), doubleClickTime);
} else Invoke();
}
示例13: SetValue
void
BButton::MouseUp(BPoint where)
{
if (!IsTracking())
return;
if (Bounds().Contains(where)) {
if (fBehavior == B_TOGGLE_BEHAVIOR)
SetValue(_Flag(FLAG_WAS_PRESSED) ? B_CONTROL_OFF : B_CONTROL_ON);
Invoke();
} else if (_Flag(FLAG_FLAT))
Invalidate();
SetTracking(false);
}
示例14: SetValue
//------------------------------------------------------------------------------
void BControl::KeyDown(const char *bytes, int32 numBytes)
{
if (*bytes == B_ENTER || *bytes == B_SPACE)
{
if (!fEnabled)
return;
if (Value())
SetValue(B_CONTROL_OFF);
else
SetValue(B_CONTROL_ON);
Invoke();
}
else
BView::KeyDown(bytes, numBytes);
}
示例15: switch
void
ColorStepView::MessageReceived(BMessage *message)
{
switch (message->what) {
case kMSGSliderChanged:
fSliderPosition = fSlider->Position();
_CalculatePerformanceSteps();
Invalidate();
break;
case kSteppingChanged:
Invoke();
break;
default:
BView::MessageReceived(message);
break;
}
}