2010-05-11 19:10:29 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2010-06-23 16:59:35 +00:00
|
|
|
#pragma implementation "NoticeListCtrl.h"
|
2010-05-11 19:10:29 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
2010-06-23 16:59:35 +00:00
|
|
|
#include "Events.h"
|
2010-05-11 19:10:29 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2010-06-30 18:52:20 +00:00
|
|
|
#include "MainDocument.h"
|
2010-06-23 16:59:35 +00:00
|
|
|
#include "NoticeListCtrl.h"
|
2010-05-11 19:10:29 +00:00
|
|
|
|
|
|
|
////@begin XPM images
|
|
|
|
////@end XPM images
|
|
|
|
|
2010-07-09 10:18:48 +00:00
|
|
|
#if wxUSE_ACCESSIBILITY || defined(__WXMAC__)
|
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
|
2010-07-09 10:18:48 +00:00
|
|
|
IMPLEMENT_CLASS( CNoticeListCtrlAccessible, wxObject )
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrlAccessible::CNoticeListCtrlAccessible(wxWindow* win) {
|
2010-05-11 19:10:29 +00:00
|
|
|
mp_win = win;
|
|
|
|
SetupMacAccessibilitySupport();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrlAccessible::~CNoticeListCtrlAccessible() {
|
2010-05-11 19:10:29 +00:00
|
|
|
RemoveMacAccessibilitySupport();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Gets the name of the specified object.
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::GetName(int childId, wxString* name)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-30 18:52:20 +00:00
|
|
|
static wxString strBuffer;
|
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
if (childId == wxACC_SELF)
|
|
|
|
{
|
2010-06-23 21:44:31 +00:00
|
|
|
*name = _("Notice List");
|
2010-05-11 19:10:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-30 18:52:20 +00:00
|
|
|
CMainDocument* pDoc = wxDynamicCast(wxGetApp().GetDocument(), CMainDocument);
|
|
|
|
strBuffer = wxEmptyString;
|
|
|
|
|
|
|
|
if (pDoc)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-07-08 11:55:43 +00:00
|
|
|
strBuffer = wxString(process_client_message(pDoc->notice(childId-1)->title), wxConvUTF8);
|
|
|
|
strBuffer = StripHTMLTags(strBuffer);
|
2010-06-30 18:52:20 +00:00
|
|
|
*name = strBuffer.c_str();
|
2010-05-11 19:10:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Can return either a child object, or an integer
|
|
|
|
// representing the child element, starting from 1.
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::HitTest(const wxPoint& pt, int* childId, wxAccessible** /*childObject*/)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl* pCtrl = wxDynamicCast(GetWindow(), CNoticeListCtrl);
|
2010-05-11 19:10:29 +00:00
|
|
|
if (pCtrl)
|
|
|
|
{
|
|
|
|
*childId = pCtrl->HitTest(pt);
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the rectangle for this object (id = 0) or a child element (id > 0).
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::GetLocation(wxRect& rect, int elementId)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl* pCtrl = wxDynamicCast(GetWindow(), CNoticeListCtrl);
|
2010-05-11 19:10:29 +00:00
|
|
|
if (pCtrl && (0 == elementId))
|
|
|
|
{
|
|
|
|
// List control
|
|
|
|
rect.SetPosition(pCtrl->GetScreenPosition());
|
|
|
|
rect.SetWidth(pCtrl->GetSize().GetWidth());
|
|
|
|
rect.SetHeight(pCtrl->GetSize().GetHeight());
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
else if (pCtrl && (0 != elementId))
|
|
|
|
{
|
|
|
|
// List item
|
|
|
|
wxSize cCtrlSize = pCtrl->GetClientSize();
|
|
|
|
|
|
|
|
// Set the initial control postition to the absolute coords of the upper
|
|
|
|
// left hand position of the control
|
|
|
|
rect.SetPosition(pCtrl->GetScreenPosition());
|
2010-07-08 11:55:43 +00:00
|
|
|
rect.width = cCtrlSize.GetWidth() - 1;
|
|
|
|
rect.height = pCtrl->GetItemHeight(elementId - 1) - 1;
|
|
|
|
|
|
|
|
// Items can have different heights
|
|
|
|
int firstVisibleItem = (int)pCtrl->GetFirstVisibleLine();
|
|
|
|
int yOffset = 0;
|
|
|
|
for (int i=firstVisibleItem; i<(elementId - 1); ++i) {
|
|
|
|
yOffset += pCtrl->GetItemHeight((size_t)i);
|
2010-05-11 19:10:29 +00:00
|
|
|
}
|
2010-07-08 11:55:43 +00:00
|
|
|
rect.SetTop(rect.GetTop() + yOffset);
|
|
|
|
rect.height -= 1;
|
2010-05-11 19:10:29 +00:00
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Gets the number of children.
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::GetChildCount(int* childCount)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl* pCtrl = wxDynamicCast(GetWindow(), CNoticeListCtrl);
|
2010-05-11 19:10:29 +00:00
|
|
|
if (pCtrl)
|
|
|
|
{
|
|
|
|
*childCount = (int)pCtrl->GetItemCount();
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Performs the default action. childId is 0 (the action for this object)
|
|
|
|
// or > 0 (the action for a child).
|
|
|
|
// Return wxACC_NOT_SUPPORTED if there is no default action for this
|
|
|
|
// window (e.g. an edit control).
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::DoDefaultAction(int childId)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl* pCtrl = wxDynamicCast(GetWindow(), CNoticeListCtrl);
|
2010-06-30 18:52:20 +00:00
|
|
|
CMainDocument* pDoc = wxDynamicCast(wxGetApp().GetDocument(), CMainDocument);
|
2010-05-11 19:10:29 +00:00
|
|
|
if (pCtrl && (childId != wxACC_SELF))
|
|
|
|
{
|
|
|
|
// Zero-based array index
|
|
|
|
int iRealChildId = childId - 1;
|
|
|
|
|
|
|
|
pCtrl->SetSelection(iRealChildId);
|
|
|
|
|
|
|
|
// Fire Event
|
2010-06-23 16:59:35 +00:00
|
|
|
NoticeListCtrlEvent evt(
|
|
|
|
wxEVT_NOTICELIST_ITEM_CHANGE,
|
2010-06-30 18:52:20 +00:00
|
|
|
pDoc->notice(iRealChildId)->seqno,
|
|
|
|
wxString(pDoc->notice(iRealChildId)->link, wxConvUTF8)
|
2010-05-11 19:10:29 +00:00
|
|
|
);
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
evt.SetEventObject(pCtrl);
|
|
|
|
#else
|
|
|
|
evt.SetEventObject(this);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pCtrl->GetParent()->AddPendingEvent( evt );
|
|
|
|
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
2010-06-23 16:59:35 +00:00
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the description for this object or a child.
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::GetDescription(int childId, wxString* description)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-30 18:52:20 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
static wxString strBuffer;
|
2010-07-08 11:55:43 +00:00
|
|
|
wxDateTime dtBuffer;
|
|
|
|
wxString strDescription;
|
|
|
|
wxString strProjectName = wxEmptyString;
|
|
|
|
wxString strArrivalTime = wxEmptyString;
|
2010-06-30 18:52:20 +00:00
|
|
|
|
|
|
|
if (pDoc && (childId != wxACC_SELF))
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-30 18:52:20 +00:00
|
|
|
strBuffer = wxEmptyString;
|
|
|
|
if (pDoc)
|
|
|
|
{
|
2010-07-08 11:55:43 +00:00
|
|
|
strDescription = wxString(process_client_message(pDoc->notice(childId-1)->description.c_str()), wxConvUTF8);
|
|
|
|
strProjectName = wxString(pDoc->notice(childId-1)->project_name, wxConvUTF8);
|
|
|
|
dtBuffer.Set((time_t)pDoc->notice(childId-1)->arrival_time);
|
|
|
|
strArrivalTime = dtBuffer.Format();
|
|
|
|
if (strProjectName.IsEmpty()) {
|
|
|
|
strBuffer.Printf(_("%s; received on %s"), strDescription.c_str(), strArrivalTime.c_str());
|
|
|
|
} else {
|
|
|
|
strBuffer.Printf(_("%s; received from %s; on %s"), strDescription.c_str(), strProjectName.c_str(), strArrivalTime.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
strBuffer = StripHTMLTags(strBuffer);
|
2010-06-30 18:52:20 +00:00
|
|
|
*description = strBuffer.c_str();
|
2010-07-08 11:55:43 +00:00
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
return wxACC_OK;
|
|
|
|
}
|
2010-05-11 19:10:29 +00:00
|
|
|
}
|
2010-06-30 18:52:20 +00:00
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-08 11:55:43 +00:00
|
|
|
wxString CNoticeListCtrlAccessible::StripHTMLTags(wxString inBuf) {
|
|
|
|
wxString outBuf = wxEmptyString;
|
|
|
|
wxString tempBuf = inBuf;
|
|
|
|
|
|
|
|
while (!tempBuf.IsEmpty()) {
|
|
|
|
outBuf += tempBuf.BeforeFirst(wxT('<'));
|
|
|
|
tempBuf = tempBuf.AfterFirst(wxT('<'));
|
|
|
|
if (tempBuf.IsEmpty()) break;
|
|
|
|
tempBuf = tempBuf.AfterFirst(wxT('>'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return outBuf;
|
|
|
|
}
|
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
#ifndef __WXMAC__
|
|
|
|
|
|
|
|
// Navigates from fromId to toId/toObject.
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::Navigate(
|
2010-05-11 19:10:29 +00:00
|
|
|
wxNavDir navDir, int fromId, int* toId, wxAccessible** toObject
|
|
|
|
) {
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl* pCtrl = wxDynamicCast(GetWindow(), CNoticeListCtrl);
|
2010-05-11 19:10:29 +00:00
|
|
|
*toObject = NULL;
|
|
|
|
|
|
|
|
if (0 != fromId)
|
|
|
|
{
|
|
|
|
switch (navDir)
|
|
|
|
{
|
|
|
|
case wxNAVDIR_PREVIOUS:
|
|
|
|
case wxNAVDIR_UP:
|
|
|
|
if (1 == fromId)
|
|
|
|
{
|
|
|
|
return wxACC_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*toId = fromId - 1;
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case wxNAVDIR_NEXT:
|
|
|
|
case wxNAVDIR_DOWN:
|
|
|
|
if ((int)pCtrl->GetItemCount() == fromId)
|
|
|
|
{
|
|
|
|
return wxACC_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*toId = fromId + 1;
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
return wxACC_FALSE;
|
|
|
|
break;
|
|
|
|
case wxNAVDIR_LEFT:
|
|
|
|
return wxACC_FALSE;
|
|
|
|
break;
|
|
|
|
case wxNAVDIR_RIGHT:
|
|
|
|
return wxACC_FALSE;
|
|
|
|
break;
|
|
|
|
case wxNAVDIR_FIRSTCHILD:
|
|
|
|
if (1 == fromId)
|
|
|
|
{
|
|
|
|
return wxACC_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*toId = 1;
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case wxNAVDIR_LASTCHILD:
|
|
|
|
if ((int)pCtrl->GetItemCount() == fromId)
|
|
|
|
{
|
|
|
|
return wxACC_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*toId = (int)pCtrl->GetItemCount();
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Gets the default action for this object (0) or > 0 (the action for a child).
|
|
|
|
// Return wxACC_OK even if there is no action. actionName is the action, or the empty
|
|
|
|
// string if there is no action.
|
|
|
|
// The retrieved string describes the action that is performed on an object,
|
|
|
|
// not what the object does as a result. For example, a toolbar button that prints
|
|
|
|
// a document has a default action of "Press" rather than "Prints the current document."
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::GetDefaultAction(int childId, wxString* actionName)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl* pCtrl = wxDynamicCast(GetWindow(), CNoticeListCtrl);
|
2010-05-11 19:10:29 +00:00
|
|
|
if (pCtrl && (childId != wxACC_SELF))
|
|
|
|
{
|
|
|
|
*actionName = _("Click");
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns a role constant.
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::GetRole(int childId, wxAccRole* role)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
if (childId == wxACC_SELF)
|
|
|
|
{
|
|
|
|
*role = wxROLE_SYSTEM_LIST;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*role = wxROLE_SYSTEM_LISTITEM;
|
|
|
|
}
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns a role constant.
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::GetState(int childId, long* state)
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
if (childId == wxACC_SELF)
|
|
|
|
{
|
|
|
|
*state = wxACC_STATE_SYSTEM_DEFAULT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl* pCtrl = wxDynamicCast(GetWindow(), CNoticeListCtrl);
|
2010-05-11 19:10:29 +00:00
|
|
|
if (pCtrl && (pCtrl->IsSelected(childId - 1)))
|
|
|
|
{
|
|
|
|
*state = wxACC_STATE_SYSTEM_SELECTABLE |
|
|
|
|
wxACC_STATE_SYSTEM_FOCUSABLE |
|
|
|
|
wxACC_STATE_SYSTEM_SELECTED |
|
|
|
|
wxACC_STATE_SYSTEM_FOCUSED;
|
|
|
|
}
|
|
|
|
else if (pCtrl && (pCtrl->IsVisible(childId - 1)))
|
|
|
|
{
|
|
|
|
*state = wxACC_STATE_SYSTEM_SELECTABLE |
|
|
|
|
wxACC_STATE_SYSTEM_FOCUSABLE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*state = wxACC_STATE_SYSTEM_SELECTABLE |
|
|
|
|
wxACC_STATE_SYSTEM_FOCUSABLE |
|
|
|
|
wxACC_STATE_SYSTEM_OFFSCREEN |
|
|
|
|
wxACC_STATE_SYSTEM_INVISIBLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return wxACC_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Selects the object or child.
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::Select(int , wxAccSelectionFlags )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Gets a variant representing the selected children
|
|
|
|
// of this object.
|
|
|
|
// Acceptable values:
|
|
|
|
// - a null variant (IsNull() returns true)
|
|
|
|
// - a list variant (GetType() == wxT("list"))
|
|
|
|
// - an integer representing the selected child element,
|
|
|
|
// or 0 if this object is selected (GetType() == wxT("long"))
|
|
|
|
// - a "void*" pointer to a wxAccessible child object
|
2010-06-23 16:59:35 +00:00
|
|
|
wxAccStatus CNoticeListCtrlAccessible::GetSelections(wxVariant* )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
// Let the framework handle the other cases.
|
|
|
|
return wxACC_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
#endif // ifndef __WXMAC__
|
2010-07-06 19:26:53 +00:00
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
#endif // wxUSE_ACCESSIBILITY || defined(__WXMAC__)
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2010-06-23 16:59:35 +00:00
|
|
|
* CNoticeListCtrl event definitions
|
2010-05-11 19:10:29 +00:00
|
|
|
*/
|
2010-06-23 16:59:35 +00:00
|
|
|
DEFINE_EVENT_TYPE( wxEVT_NOTICELIST_ITEM_CHANGE )
|
|
|
|
DEFINE_EVENT_TYPE( wxEVT_NOTICELIST_ITEM_DISPLAY )
|
2010-05-11 19:10:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2010-06-23 16:59:35 +00:00
|
|
|
* CNoticeListCtrl type definition
|
2010-05-11 19:10:29 +00:00
|
|
|
*/
|
2010-06-23 16:59:35 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS( CNoticeListCtrl, wxHtmlListBox )
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( NoticeListCtrlEvent, wxNotifyEvent )
|
2010-05-11 19:10:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2010-06-23 16:59:35 +00:00
|
|
|
* CNoticeListCtrl event table definition
|
2010-05-11 19:10:29 +00:00
|
|
|
*/
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
BEGIN_EVENT_TABLE( CNoticeListCtrl, wxHtmlListBox )
|
|
|
|
|
|
|
|
////@begin CNoticeListCtrl event table entries
|
|
|
|
EVT_LISTBOX(ID_LIST_NOTIFICATIONSVIEW, CNoticeListCtrl::OnSelected)
|
|
|
|
EVT_LISTBOX_DCLICK(ID_LIST_NOTIFICATIONSVIEW, CNoticeListCtrl::OnDClicked)
|
|
|
|
EVT_HTML_CELL_CLICKED(ID_LIST_NOTIFICATIONSVIEW, CNoticeListCtrl::OnClicked)
|
|
|
|
EVT_HTML_LINK_CLICKED(ID_LIST_NOTIFICATIONSVIEW, CNoticeListCtrl::OnLinkClicked)
|
|
|
|
////@end CNoticeListCtrl event table entries
|
2010-05-11 19:10:29 +00:00
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
2010-06-23 16:59:35 +00:00
|
|
|
* CNoticeListCtrl constructors
|
2010-05-11 19:10:29 +00:00
|
|
|
*/
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl::CNoticeListCtrl( )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl::CNoticeListCtrl( wxWindow* parent )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
Create( parent );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
CNoticeListCtrl::~CNoticeListCtrl( )
|
2010-06-30 09:38:43 +00:00
|
|
|
{
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
if (m_accessible) {
|
|
|
|
delete m_accessible;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-11 19:10:29 +00:00
|
|
|
/*!
|
2010-06-23 16:59:35 +00:00
|
|
|
* CNoticeListCtrl creator
|
2010-05-11 19:10:29 +00:00
|
|
|
*/
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
bool CNoticeListCtrl::Create( wxWindow* parent )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-23 16:59:35 +00:00
|
|
|
////@begin CNoticeListCtrl member initialisation
|
|
|
|
////@end CNoticeListCtrl member initialisation
|
2010-05-11 19:10:29 +00:00
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
////@begin CNoticeListCtrl creation
|
|
|
|
wxHtmlListBox::Create( parent, ID_LIST_NOTIFICATIONSVIEW, wxDefaultPosition, wxDefaultSize,
|
2010-05-11 19:10:29 +00:00
|
|
|
wxSUNKEN_BORDER | wxTAB_TRAVERSAL );
|
|
|
|
|
|
|
|
#if wxUSE_ACCESSIBILITY
|
2010-06-23 16:59:35 +00:00
|
|
|
SetAccessible(new CNoticeListCtrlAccessible(this));
|
2010-05-11 19:10:29 +00:00
|
|
|
#endif
|
|
|
|
#ifdef __WXMAC__
|
2010-06-23 16:59:35 +00:00
|
|
|
m_accessible = new CNoticeListCtrlAccessible(this);
|
2010-05-11 19:10:29 +00:00
|
|
|
#endif
|
2010-06-23 16:59:35 +00:00
|
|
|
////@end CNoticeListCtrl creation
|
2010-05-11 19:10:29 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
void CNoticeListCtrl::OnSelected( wxCommandEvent& event )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
// Fire Event
|
2010-06-23 16:59:35 +00:00
|
|
|
NoticeListCtrlEvent evt(
|
|
|
|
wxEVT_NOTICELIST_ITEM_CHANGE,
|
2010-06-30 18:52:20 +00:00
|
|
|
event.GetInt(),
|
|
|
|
wxEmptyString
|
2010-05-11 19:10:29 +00:00
|
|
|
);
|
|
|
|
evt.SetEventObject(this);
|
|
|
|
|
|
|
|
GetParent()->AddPendingEvent( evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
void CNoticeListCtrl::OnClicked( wxHtmlCellEvent& event )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
void CNoticeListCtrl::OnDClicked( wxCommandEvent& event )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
void CNoticeListCtrl::OnLinkClicked( wxHtmlLinkEvent& event )
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
|
|
|
// Fire Event
|
2010-06-23 16:59:35 +00:00
|
|
|
NoticeListCtrlEvent evt(
|
|
|
|
wxEVT_NOTICELIST_ITEM_DISPLAY,
|
2010-06-30 18:52:20 +00:00
|
|
|
event.GetInt(),
|
|
|
|
event.GetLinkInfo().GetHref()
|
2010-05-11 19:10:29 +00:00
|
|
|
);
|
|
|
|
evt.SetEventObject(this);
|
|
|
|
|
|
|
|
GetParent()->AddPendingEvent( evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
wxString CNoticeListCtrl::OnGetItem(size_t i) const
|
2010-05-11 19:10:29 +00:00
|
|
|
{
|
2010-06-30 18:52:20 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxString strTitle = wxEmptyString;
|
|
|
|
wxString strDescription = wxEmptyString;
|
|
|
|
wxString strProjectName = wxEmptyString;
|
|
|
|
wxString strURL = wxEmptyString;
|
|
|
|
wxString strArrivalTime = wxEmptyString;
|
2010-05-11 19:10:29 +00:00
|
|
|
wxString strBuffer = wxEmptyString;
|
2010-06-23 16:59:35 +00:00
|
|
|
wxString strTemp = wxEmptyString;
|
2010-06-30 18:52:20 +00:00
|
|
|
wxDateTime dtBuffer;
|
|
|
|
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2010-06-23 16:59:35 +00:00
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
NOTICE* np = pDoc->notice((unsigned int)i);
|
|
|
|
|
|
|
|
strProjectName = wxString(np->project_name, wxConvUTF8);
|
|
|
|
strURL = wxString(np->link, wxConvUTF8);
|
|
|
|
strTitle = wxString(process_client_message(np->title), wxConvUTF8);
|
|
|
|
strDescription = wxString(process_client_message(np->description.c_str()), wxConvUTF8);
|
|
|
|
|
|
|
|
dtBuffer.Set((time_t)np->arrival_time);
|
|
|
|
strArrivalTime = dtBuffer.Format();
|
|
|
|
|
|
|
|
if (!strTitle.IsEmpty()) {
|
2010-06-23 16:59:35 +00:00
|
|
|
strTemp.Printf(
|
|
|
|
wxT("<b>%s</b><br>"),
|
2010-06-30 18:52:20 +00:00
|
|
|
strTitle.c_str()
|
2010-06-23 16:59:35 +00:00
|
|
|
);
|
|
|
|
strBuffer += strTemp;
|
|
|
|
}
|
2010-05-11 19:10:29 +00:00
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
strBuffer += strDescription;
|
2010-05-11 19:10:29 +00:00
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
strBuffer += wxT("<br><font size=-2 color=#8f8f8f>");
|
2010-05-11 19:10:29 +00:00
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
if (!strProjectName.IsEmpty()) {
|
2010-06-23 16:59:35 +00:00
|
|
|
strTemp.Printf(
|
2010-06-23 21:44:31 +00:00
|
|
|
wxT("%s %s<br>"),
|
|
|
|
_("From"),
|
2010-06-30 18:52:20 +00:00
|
|
|
strProjectName.c_str()
|
2010-06-23 16:59:35 +00:00
|
|
|
);
|
|
|
|
strBuffer += strTemp;
|
2010-05-11 19:10:29 +00:00
|
|
|
}
|
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
strBuffer += strArrivalTime;
|
2010-05-11 19:10:29 +00:00
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
if (!strURL.IsEmpty()) {
|
2010-06-23 16:59:35 +00:00
|
|
|
strTemp.Printf(
|
2010-06-23 21:44:31 +00:00
|
|
|
wxT(" · <a target=_new href=%s>%s</a> "),
|
2010-06-30 18:52:20 +00:00
|
|
|
strURL.c_str(),
|
2010-06-23 21:44:31 +00:00
|
|
|
_("more...")
|
2010-06-23 16:59:35 +00:00
|
|
|
);
|
|
|
|
strBuffer += strTemp;
|
2010-05-11 19:10:29 +00:00
|
|
|
}
|
|
|
|
|
2010-06-23 16:59:35 +00:00
|
|
|
strBuffer += wxT("</font><hr>\n");
|
|
|
|
|
|
|
|
return strBuffer;
|
2010-05-11 19:10:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2010-06-30 18:52:20 +00:00
|
|
|
* Update the UI.
|
2010-06-28 02:41:34 +00:00
|
|
|
*/
|
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
bool CNoticeListCtrl::UpdateUI()
|
2010-06-25 15:30:20 +00:00
|
|
|
{
|
2010-06-30 18:52:20 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
2010-06-28 18:05:31 +00:00
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
wxASSERT(pDoc);
|
|
|
|
wxASSERT(wxDynamicCast(pDoc, CMainDocument));
|
2010-06-28 18:05:31 +00:00
|
|
|
|
2010-06-30 18:52:20 +00:00
|
|
|
if (pDoc->GetNoticeCount() < 0) return true;
|
2010-06-28 02:41:34 +00:00
|
|
|
|
2010-06-30 20:12:24 +00:00
|
|
|
if (
|
2010-06-30 23:42:34 +00:00
|
|
|
((int)GetItemCount() != pDoc->GetNoticeCount()) ||
|
2010-06-30 20:12:24 +00:00
|
|
|
pDoc->notices.complete
|
|
|
|
) {
|
2010-06-30 18:52:20 +00:00
|
|
|
SetItemCount(pDoc->GetNoticeCount());
|
2010-06-30 23:42:34 +00:00
|
|
|
pDoc->notices.complete = false;
|
2010-06-28 18:05:31 +00:00
|
|
|
}
|
2010-06-25 15:30:20 +00:00
|
|
|
return true;
|
|
|
|
}
|