status_t BControl::Invoke(BMessage* message) { bool notify = false; uint32 kind = InvokeKind(¬ify); if (!message && !notify) message = Message(); BMessage clone(kind); if (!message) { if (!IsWatched()) return B_BAD_VALUE; } else clone = *message; clone.AddInt64("when", (int64)system_time()); clone.AddPointer("source", this); clone.AddInt32("be:value", fValue); clone.AddMessenger("be:sender", BMessenger(this)); // ToDo: is this correct? If message == NULL (even if IsWatched()), we always return B_BAD_VALUE status_t err; if (message) err = BInvoker::Invoke(&clone); else err = B_BAD_VALUE; // TODO: asynchronous messaging SendNotices(kind, &clone); return err; }
status_t BIconRule::Invoke(BMessage* message) { bool notify = false; uint32 kind = InvokeKind(¬ify); BMessage clone(kind); status_t err = B_BAD_VALUE; if (!message && !notify) message = Message(); if (!message) { if (!IsWatched()) return err; } else clone = *message; clone.AddInt64("when", (int64)system_time()); clone.AddPointer("source", this); clone.AddMessenger("be:sender", BMessenger(this)); clone.AddInt32("index", fSelIndex); if (message) err = BInvoker::Invoke(&clone); SendNotices(kind, &clone); return err; }
void BTextControl::SetText(const char *text) { if (InvokeKind() != B_CONTROL_INVOKED) return; fText->SetText(text); if (IsFocus()) fText->SetInitialText(); fText->Invalidate(); }
status_t BListView::Invoke(BMessage* message) { // Note, this is more or less a copy of BControl::Invoke() and should // stay that way (ie. changes done there should be adopted here) bool notify = false; uint32 kind = InvokeKind(¬ify); BMessage clone(kind); status_t err = B_BAD_VALUE; if (!message && !notify) message = Message(); if (!message) { if (!IsWatched()) return err; } else clone = *message; clone.AddInt64("when", (int64)system_time()); clone.AddPointer("source", this); clone.AddMessenger("be:sender", BMessenger(this)); if (fListType == B_SINGLE_SELECTION_LIST) clone.AddInt32("index", fFirstSelected); else { if (fFirstSelected >= 0) { for (int32 i = fFirstSelected; i <= fLastSelected; i++) { if (ItemAt(i)->IsSelected()) clone.AddInt32("index", i); } } } if (message) err = BInvoker::Invoke(&clone); SendNotices(kind, &clone); return err; }