/*! * called from CMainDocument::HandleCompletedRPC() after wxEVT_RPC_FINISHED event */ void CDlgEventLog::OnRefresh() { bool isConnected; static wxString strLastMachineName = wxEmptyString; wxString strNewMachineName = wxEmptyString; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); if (!IsShown()) return; if (!m_bProcessingRefreshEvent) { m_bProcessingRefreshEvent = true; wxASSERT(m_pList); wxInt32 iRowCount = GetDocCount(); long topItem = m_pList->GetTopItem(); if (0 >= iRowCount) { m_pList->DeleteAllItems(); ResetMessageFiltering(); m_iPreviousFirstMsgSeqNum = 0; m_iPreviousLastMsgSeqNum = 0; } else { // If connected computer changed, reset message filtering isConnected = wxGetApp().GetDocument()->IsConnected(); if (isConnected) { pDoc->GetConnectedComputerName(strNewMachineName); if (strLastMachineName != strNewMachineName) { strLastMachineName = strNewMachineName; m_bWasConnected = false; ResetMessageFiltering(); m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum(); m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum - 1; iRowCount = m_iTotalDocCount; // In case we had filtering set } } // If connection status changed, adjust color of messages display if (m_bWasConnected != isConnected) { m_bWasConnected = isConnected; SetTextColor(); // Force a complete update m_pList->DeleteAllItems(); m_pList->SetItemCount(iRowCount); m_iPreviousRowCount = 0; // Force scrolling to bottom } else { // Connection status didn't change if (m_iPreviousLastMsgSeqNum != pDoc->GetLastMsgSeqNum()) { if (m_iPreviousRowCount == iRowCount) { m_pList->Refresh(); } else { m_pList->SetItemCount(iRowCount); } } } } if (iRowCount > 1) { if (s_bFilteringChanged) { m_pList->EnsureVisible(iRowCount - 1); s_bFilteringChanged = false; } else { if (m_iPreviousLastMsgSeqNum != pDoc->GetLastMsgSeqNum()) { if (EnsureLastItemVisible()) { m_pList->EnsureVisible(iRowCount - 1); } else if (topItem > 0) { int n = topItem - m_iNumDeletedFilteredRows; if (n < 0) n = 0; Freeze(); // Avoid flicker if selected rows are visible m_pList->EnsureVisible(n); Thaw(); } } } } m_iPreviousRowCount = iRowCount; if (m_iTotalDocCount > 0) { m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum(); m_iPreviousLastMsgSeqNum = pDoc->GetLastMsgSeqNum(); } UpdateButtons(); m_bProcessingRefreshEvent = false; } }
bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin CDlgEventLog member initialisation CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); m_iPreviousRowCount = 0; m_iTotalDocCount = 0; m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum(); m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum - 1; m_iNumDeletedFilteredRows = 0; m_iTotalDeletedFilterRows = 0; if (!s_bIsFiltered) { s_strFilteredProjectName.clear(); } m_iFilteredIndexes.Clear(); m_bProcessingRefreshEvent = false; m_bWasConnected = false; m_bEventLogIsOpen = true; ////@end CDlgEventLog member initialisation CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxPoint oTempPoint; wxSize oTempSize; wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); if ((pos == wxDefaultPosition) && (size == wxDefaultSize)) { // Get size and position from the previous configuration GetWindowDimensions( oTempPoint, oTempSize ); #ifdef __WXMSW__ // Get the current display space for the current window int iDisplay = wxNOT_FOUND; if ( wxGetApp().GetFrame() != NULL ) iDisplay = wxDisplay::GetFromWindow(wxGetApp().GetFrame()); if ( iDisplay == wxNOT_FOUND ) iDisplay = 0; wxDisplay *display = new wxDisplay(iDisplay); wxRect rDisplay = display->GetClientArea(); // Check that the saved height and width is not larger than the displayable space. // If it is, then reduce the size. if ( oTempSize.GetWidth() > rDisplay.width ) oTempSize.SetWidth(rDisplay.width); if ( oTempSize.GetHeight() > rDisplay.height ) oTempSize.SetHeight(rDisplay.height); // Check if part of the display was going to be off the screen, if so, center the // display on that axis if ( oTempPoint.x < rDisplay.x ) { oTempPoint.x = rDisplay.x; } else if ( oTempPoint.x + oTempSize.GetWidth() > rDisplay.x + rDisplay.width ) { oTempPoint.x = rDisplay.x + rDisplay.width - oTempSize.GetWidth(); } if ( oTempPoint.y < rDisplay.y ) { oTempPoint.y = rDisplay.y; } else if ( oTempPoint.y + oTempSize.GetHeight() > rDisplay.y + rDisplay.height ) { oTempPoint.y = rDisplay.y + rDisplay.height - oTempSize.GetHeight(); } delete display; #endif #ifdef __WXMAC__ // If the user has changed the arrangement of multiple // displays, make sure the window title bar is still on-screen. if (!IsWindowOnScreen(oTempPoint.x, oTempPoint.y, oTempSize.GetWidth(), oTempSize.GetHeight())) { oTempPoint.y = oTempPoint.x = 30; } #endif // ! __WXMAC__ } else { oTempPoint = pos; oTempSize = size; } wxDialog::Create( parent, id, caption, oTempPoint, oTempSize, style ); SetSizeHints(DLGEVENTLOG_MIN_WIDTH, DLGEVENTLOG_MIN_HEIGHT); SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); // Initialize Application Title wxString strCaption = caption; if (strCaption.IsEmpty()) { strCaption.Printf(_("%s - Event Log"), pSkinAdvanced->GetApplicationName().c_str()); } SetTitle(strCaption); // Initialize Application Icon SetIcons(*pSkinAdvanced->GetApplicationIcon()); CreateControls(); // Create List Pane Items m_pList->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 109); m_pList->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 130); m_pList->InsertColumn(COLUMN_MESSAGE, _("Message"), wxLIST_FORMAT_LEFT, 378); m_pMessageInfoAttr = new wxListItemAttr( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); m_pMessageErrorAttr = new wxListItemAttr( *wxRED, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); #if EVENT_LOG_STRIPES m_pMessageInfoGrayAttr = new wxListItemAttr( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxColour(240, 240, 240), wxNullFont ); m_pMessageErrorGrayAttr = new wxListItemAttr(*wxRED, wxColour(240, 240, 240), wxNullFont); #else m_pMessageInfoGrayAttr = new wxListItemAttr(*m_pMessageInfoAttr); m_pMessageErrorGrayAttr = new wxListItemAttr(*m_pMessageErrorAttr); #endif SetTextColor(); RestoreState(); OnRefresh(); // Register that we had the Event Log open immediately SaveState(); m_Shortcuts[0].Set(wxACCEL_CTRL|wxACCEL_SHIFT, (int)'F', ID_SGDIAGNOSTICLOGFLAGS); m_pAccelTable = new wxAcceleratorTable(1, m_Shortcuts); SetAcceleratorTable(*m_pAccelTable); return true; }
// NOTE: this function is designed to be called only // from CDlgEventLog::OnRefresh(). If you need to call it // from other routines, it will need modification. // // Get the (possibly filtered) item count (i.e., the Row count) and // make any needed adjustments if oldest items have been deleted. wxInt32 CDlgEventLog::GetDocCount() { int i, j, numDeletedRows; CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); m_iTotalDocCount = pDoc->GetMessageCount(); numDeletedRows = pDoc->GetFirstMsgSeqNum() - m_iPreviousFirstMsgSeqNum; if ((numDeletedRows < 0) || (m_iPreviousFirstMsgSeqNum < 0)) { numDeletedRows = 0; } m_iNumDeletedFilteredRows = 0; if (s_bIsFiltered) { if (numDeletedRows > 0) { // Remove any deleted messages from our filtered list while (m_iFilteredIndexes.GetCount() > 0) { if (m_iFilteredIndexes[0] >= numDeletedRows) break; m_iFilteredIndexes.RemoveAt(0); m_iNumDeletedFilteredRows++; m_iTotalDeletedFilterRows++; } // Adjust the remaining indexes for (i = m_iFilteredIndexes.GetCount()-1; i >= 0; i--) { m_iFilteredIndexes[i] -= numDeletedRows; } } // Add indexes of new messages to filtered list as appropriate i = m_iTotalDocCount - (pDoc->GetLastMsgSeqNum() - m_iPreviousLastMsgSeqNum); if (i < 0) i = 0; for (; i < m_iTotalDocCount; i++) { MESSAGE* message = pDoc->message(i); if (message->project.empty() || (message->project == s_strFilteredProjectName)) { m_iFilteredIndexes.Add(i); } } m_iFilteredDocCount = (int)(m_iFilteredIndexes.GetCount()); } else { m_iFilteredDocCount = m_iTotalDocCount; m_iNumDeletedFilteredRows = numDeletedRows; } if (numDeletedRows > 0) { // Adjust the selected row numbers wxArrayInt arrSelRows; i = -1; for (;;) { i = m_pList->GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (i < 0) break; arrSelRows.Add(i); } int count = arrSelRows.Count(); for (i=0; i<count; i++) { m_pList->SetItemState(arrSelRows[i], 0, wxLIST_STATE_SELECTED); } for (i=0; i<count; i++) { if ((j = arrSelRows[i] - m_iNumDeletedFilteredRows) >= 0) { m_pList->SetItemState(j, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); } } } return s_bIsFiltered ? m_iFilteredDocCount : m_iTotalDocCount; }
bool CDlgEventLog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { ////@begin CDlgEventLog member initialisation CMainDocument* pDoc = wxGetApp().GetDocument(); wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); m_iPreviousRowCount = 0; m_iTotalDocCount = 0; m_iPreviousFirstMsgSeqNum = pDoc->GetFirstMsgSeqNum(); m_iPreviousLastMsgSeqNum = m_iPreviousFirstMsgSeqNum - 1; m_iNumDeletedFilteredRows = 0; m_iTotalDeletedFilterRows = 0; if (!s_bIsFiltered) { s_strFilteredProjectName.clear(); } m_iFilteredIndexes.Clear(); m_bProcessingRefreshEvent = false; m_bWasConnected = false; m_bEventLogIsOpen = true; ////@end CDlgEventLog member initialisation CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxPoint oTempPoint; wxSize oTempSize; wxASSERT(pSkinAdvanced); wxASSERT(wxDynamicCast(pSkinAdvanced, CSkinAdvanced)); if ((pos == wxDefaultPosition) && (size == wxDefaultSize)) { // Get size and position from the previous configuration GetWindowDimensions( oTempPoint, oTempSize ); #ifdef __WXMSW__ // Windows does some crazy things if the initial position is a negative // value. oTempPoint.x = wxDefaultCoord; oTempPoint.y = wxDefaultCoord; #endif #ifdef __WXMAC__ // If the user has changed the arrangement of multiple // displays, make sure the window title bar is still on-screen. if (!IsWindowOnScreen(oTempPoint.x, oTempPoint.y, oTempSize.GetWidth(), oTempSize.GetHeight())) { oTempPoint.y = oTempPoint.x = 30; } #endif // ! __WXMAC__ } else { oTempPoint = pos; oTempSize = size; } wxDialog::Create( parent, id, caption, oTempPoint, oTempSize, style ); SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS); // Initialize Application Title wxString strCaption = caption; if (strCaption.IsEmpty()) { strCaption.Printf(_("%s - Event Log"), pSkinAdvanced->GetApplicationName().c_str()); } SetTitle(strCaption); // Initialize Application Icon wxIconBundle icons; icons.AddIcon(*pSkinAdvanced->GetApplicationIcon()); icons.AddIcon(*pSkinAdvanced->GetApplicationIcon32()); SetIcons(icons); CreateControls(); // Create List Pane Items m_pList->InsertColumn(COLUMN_PROJECT, _("Project"), wxLIST_FORMAT_LEFT, 109); m_pList->InsertColumn(COLUMN_TIME, _("Time"), wxLIST_FORMAT_LEFT, 130); m_pList->InsertColumn(COLUMN_MESSAGE, _("Message"), wxLIST_FORMAT_LEFT, 378); m_pMessageInfoAttr = new wxListItemAttr( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); m_pMessageErrorAttr = new wxListItemAttr( *wxRED, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), wxNullFont ); #if EVENT_LOG_STRIPES m_pMessageInfoGrayAttr = new wxListItemAttr( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT), wxColour(240, 240, 240), wxNullFont ); m_pMessageErrorGrayAttr = new wxListItemAttr(*wxRED, wxColour(240, 240, 240), wxNullFont); #else m_pMessageInfoGrayAttr = new wxListItemAttr(*m_pMessageInfoAttr); m_pMessageErrorGrayAttr = new wxListItemAttr(*m_pMessageErrorAttr); #endif SetTextColor(); RestoreState(); OnRefresh(); return true; }