void BIconButton::MouseDown(BPoint where) { if (!IsValid()) return; if (IsEnabled()) { if (Bounds().Contains(where)) { SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); _SetFlags(STATE_PRESSED, true); _SetTracking(true); } else { _SetFlags(STATE_PRESSED, false); _SetTracking(false); } } }
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); }
/*! \brief Sets the decorator's window flags While this call will not update the screen, it will affect how future updates work and immediately affects input handling. \param flags New value for the flags */ void Decorator::SetFlags(uint32 flags, BRegion* updateRegion) { // we're nice to our subclasses - we make sure B_NOT_{H|V|}_RESIZABLE // are in sync (it's only a semantical simplification, not a necessity) if ((flags & (B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE)) == (B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE)) flags |= B_NOT_RESIZABLE; if (flags & B_NOT_RESIZABLE) flags |= B_NOT_H_RESIZABLE | B_NOT_V_RESIZABLE; _SetFlags(flags, updateRegion); _InvalidateFootprint(); // the border might have changed (smaller/larger tab) }
void BIconButton::MouseMoved(BPoint where, uint32 transit, const BMessage* message) { if (!IsValid()) return; uint32 buttons = 0; Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); // catch a mouse up event that we might have missed if (!buttons && _HasFlags(STATE_PRESSED)) { MouseUp(where); return; } if (buttons != 0 && !IsTracking()) return; SetInside((transit == B_INSIDE_VIEW || transit == B_ENTERED_VIEW) && IsEnabled()); if (IsTracking()) _SetFlags(STATE_PRESSED, Bounds().Contains(where)); }
void BIconButton::SetInside(bool inside) { _SetFlags(STATE_INSIDE, inside); }
void BIconButton::SetValue(int32 value) { BControl::SetValue(value); _SetFlags(STATE_PRESSED, value != 0); }
void BIconButton::SetPressed(bool pressed) { _SetFlags(STATE_FORCE_PRESSED, pressed); }