// // HandleEvent // // Event handler // U32 UnitContextButton::HandleEvent(Event &e) { if (e.type == IFace::EventID()) { switch (e.subType) { case IFace::DISPLAYTIP: { if (DisplayTip()) { return (TRUE); } break; } case IFace::TIPDELAY: return (300); case IFace::NOTIFY: { switch (e.iface.p1) { case ICButtonNotify::Pressed: { // Always clear client mode Events::TriggerClientMode(CM_NONE); if (!event.Null()) { Events::HandleDiscreteEvent(NULL, event.crc, 0, 0); } return (TRUE); } case ICButtonNotify::DisabledDown: { if (DisplayTip()) { return (TRUE); } break; } } break; } } } return (ICButton::HandleEvent(e)); }
void JXTipOfTheDayDialog::ParseTips() { const JString& data = JGetString(kStringID); itsTipList->CleanOut(); const JSize len = strlen(kDelimiter); JIndex j = 1, i = j; while (data.LocateNextSubstring(kDelimiter, &j)) { if (j > i) { AddTip(data.GetSubstring(i, j-1)); } j += len; i = j; } if (i <= data.GetLength()) { AddTip(data.GetSubstring(i, data.GetLength())); } assert( !itsTipList->IsEmpty() ); itsTipIndex = theRandomGenerator.UniformLong(1, itsTipList->GetElementCount()); DisplayTip(); }
void JXTipOfTheDayDialog::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsNextTipButton && message.Is(JXButton::kPushed)) { itsTipIndex++; if (!itsTipList->IndexValid(itsTipIndex)) { itsTipIndex = 1; } DisplayTip(); } else if (sender == itsCloseButton && message.Is(JXButton::kPushed)) { if (itsShowAtStartupCB->IsVisible()) { Broadcast(ShowAtStartup(itsShowAtStartupCB->IsChecked())); } Close(); } else { JXDialogDirector::Receive(sender, message); } }