//--------------------------------------------------------- void CSAGA_Frame::Show_Tips(bool bShow) { bool bTip; long iTip; #ifdef SHARE_PATH wxFileName fTip(wxT(SHARE_PATH), wxT("saga_tip.txt")); #else wxFileName fTip(g_pSAGA->Get_App_Path(), wxT("saga_gui"), wxT("tip")); #endif wxTipProvider *pTip; bTip = CONFIG_Read(wxT("/TIPS"), wxT("ATSTART"), bTip) ? bTip : true; if( bShow || (bTip && fTip.FileExists()) ) { iTip = CONFIG_Read(wxT("/TIPS"), wxT("CURRENT"), iTip) ? iTip : 0; pTip = wxCreateFileTipProvider(fTip.GetFullPath(), iTip); bTip = wxShowTip(this, pTip, bTip); iTip = pTip->GetCurrentTip(); CONFIG_Write(wxT("/TIPS"), wxT("ATSTART"), bTip); CONFIG_Write(wxT("/TIPS"), wxT("CURRENT"), iTip); delete(pTip); } }
void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event)) { static size_t s_index = (size_t)-1; if ( s_index == (size_t)-1 ) { srand(time(NULL)); // this is completely bogus, we don't know how many lines are there // in the file, but who cares, it's a demo only... s_index = rand() % 5; } wxTipProvider *tipProvider = wxCreateFileTipProvider(_T("tips.txt"), s_index); bool showAtStartup = wxShowTip(this, tipProvider); if ( showAtStartup ) { wxMessageBox(_T("Will show tips on startup"), _T("Tips dialog"), wxOK | wxICON_INFORMATION, this); } s_index = tipProvider->GetCurrentTip(); delete tipProvider; }
/** OnInit * * Initializes the program */ bool ComplxApp::OnInit() { if (!wxApp::OnInit()) return false; SetVendorName("Complx"); SetAppName("Complx"); wxFileConfig *config = new wxFileConfig("Complx"); wxConfigBase::Set(config); srand(time(NULL)); complxframe = new ComplxFrame(decimal, disassemble, stack_size, true_traps, interrupts, highlight, address_str, state_file, files); wxIcon icon(icon32_xpm); complxframe->SetIcon(icon); complxframe->Show(); size_t currentTip = 0; bool show = true; std::string last_ver = config->Read("/firstrun", "").ToStdString(); // use our config object... if (last_ver.empty()) { wxCommandEvent event; complxframe->OnFirstTime(event); config->Write("/firstrun", AutoVersion::FULLVERSION_STRING); config->Flush(); } else { currentTip = config->Read("/currenttip", 0l); config->Read("/showtips", &show); } if (show) { wxTipProvider* tip = wxCreateFileTipProvider("/usr/local/share/complx-tools/complx-tips.txt", currentTip); show = wxShowTip(complxframe, tip, show); config->Write("/showtips", show); config->Write("/currenttip", tip->GetCurrentTip()); config->Flush(); delete tip; } return true; }
int bmx_wxshowtip(wxWindow * parent, wxTipProvider * tip, int showAtStartup) { return static_cast<int>(wxShowTip(parent, tip, static_cast<bool>(showAtStartup))); }