2008-08-06 18:36:30 +00:00
|
|
|
// This file is part of BOINC.
|
2007-03-17 19:37:56 +00:00
|
|
|
// http://boinc.berkeley.edu
|
2008-08-06 18:36:30 +00:00
|
|
|
// Copyright (C) 2008 University of California
|
2007-03-17 19:37:56 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// 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.
|
2007-03-17 19:37:56 +00:00
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
2007-03-17 19:37:56 +00:00
|
|
|
// 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.
|
|
|
|
//
|
2008-08-06 18:36:30 +00:00
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-03-17 19:37:56 +00:00
|
|
|
//
|
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
|
|
|
#pragma implementation "ProjectListCtrl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "stdwx.h"
|
|
|
|
#include "BOINCGUIApp.h"
|
|
|
|
#include "ProjectListCtrl.h"
|
|
|
|
|
|
|
|
////@begin XPM images
|
2007-11-07 18:08:21 +00:00
|
|
|
#include "res/externalweblink.xpm"
|
2007-03-17 19:37:56 +00:00
|
|
|
////@end XPM images
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListCtrl event definitions
|
|
|
|
*/
|
2009-06-23 15:20:48 +00:00
|
|
|
DEFINE_EVENT_TYPE( wxEVT_PROJECTLIST_ITEM_CHANGE )
|
|
|
|
DEFINE_EVENT_TYPE( wxEVT_PROJECTLIST_ITEM_DISPLAY )
|
2007-03-17 19:37:56 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListCtrl type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( CProjectListCtrl, wxScrolledWindow )
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( ProjectListCtrlEvent, wxNotifyEvent )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListCtrl event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( CProjectListCtrl, wxScrolledWindow )
|
|
|
|
|
|
|
|
////@begin CProjectListCtrl event table entries
|
2009-06-23 15:20:48 +00:00
|
|
|
EVT_SET_FOCUS( CProjectListCtrl::OnFocusChanged )
|
|
|
|
EVT_KILL_FOCUS( CProjectListCtrl::OnFocusChanged )
|
|
|
|
EVT_KEY_DOWN( CProjectListCtrl::OnKeyPressed )
|
|
|
|
EVT_KEY_UP( CProjectListCtrl::OnKeyPressed )
|
2007-03-17 19:37:56 +00:00
|
|
|
////@end CProjectListCtrl event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListCtrl constructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
CProjectListCtrl::CProjectListCtrl( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-06-19 07:51:22 +00:00
|
|
|
CProjectListCtrl::CProjectListCtrl( wxWindow* parent )
|
2007-03-17 19:37:56 +00:00
|
|
|
{
|
2009-06-19 07:51:22 +00:00
|
|
|
Create( parent );
|
2007-03-17 19:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectList creator
|
|
|
|
*/
|
|
|
|
|
2009-06-19 07:51:22 +00:00
|
|
|
bool CProjectListCtrl::Create( wxWindow* parent )
|
2007-03-17 19:37:56 +00:00
|
|
|
{
|
|
|
|
////@begin CProjectListCtrl member initialisation
|
|
|
|
m_pMainSizer = NULL;
|
|
|
|
////@end CProjectListCtrl member initialisation
|
2009-06-23 15:20:48 +00:00
|
|
|
m_pCurrentSelection = NULL;
|
2007-03-17 19:37:56 +00:00
|
|
|
|
|
|
|
////@begin CProjectListCtrl creation
|
2009-06-23 15:20:48 +00:00
|
|
|
wxScrolledWindow::Create( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxSUNKEN_BORDER | wxVSCROLL | wxTAB_TRAVERSAL );
|
|
|
|
|
2009-04-08 04:55:48 +00:00
|
|
|
SetMinSize(GetSize());
|
2007-03-17 19:37:56 +00:00
|
|
|
|
|
|
|
CreateControls();
|
|
|
|
|
|
|
|
SetBackgroundColour( wxT("WHITE") );
|
|
|
|
SetScrollRate( 0, 25 );
|
|
|
|
|
|
|
|
GetSizer()->Fit(this);
|
|
|
|
////@end CProjectListCtrl creation
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Control creation for ProjectListCtrl
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListCtrl::CreateControls()
|
|
|
|
{
|
|
|
|
////@begin CProjectListCtrl content construction
|
2007-11-07 18:08:21 +00:00
|
|
|
|
|
|
|
wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(0, 1, 0, 0);
|
|
|
|
itemFlexGridSizer5->AddGrowableCol(0);
|
|
|
|
|
|
|
|
wxFlexGridSizer* itemFlexGridSizer6 = new wxFlexGridSizer(1, 1, 0, 0);
|
|
|
|
itemFlexGridSizer6->AddGrowableRow(0);
|
|
|
|
itemFlexGridSizer6->AddGrowableCol(0);
|
|
|
|
itemFlexGridSizer5->Add(itemFlexGridSizer6, 0, wxGROW|wxGROW|wxALL, 0);
|
2009-06-23 15:20:48 +00:00
|
|
|
|
2007-03-17 19:37:56 +00:00
|
|
|
m_pMainSizer = new wxBoxSizer(wxVERTICAL);
|
2009-06-23 15:20:48 +00:00
|
|
|
itemFlexGridSizer6->Add(m_pMainSizer, 0, wxGROW|wxGROW|wxALL, 5);
|
2007-11-07 18:08:21 +00:00
|
|
|
|
|
|
|
SetSizer(itemFlexGridSizer5);
|
|
|
|
|
2007-03-17 19:37:56 +00:00
|
|
|
////@end CProjectListCtrl content construction
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2009-06-23 15:20:48 +00:00
|
|
|
* event handler for window
|
2007-03-17 19:37:56 +00:00
|
|
|
*/
|
|
|
|
|
2009-06-23 22:31:43 +00:00
|
|
|
void CProjectListCtrl::OnItemChange( CProjectListItemCtrl* pSelectedItem ) {
|
2007-03-17 19:37:56 +00:00
|
|
|
|
2009-06-23 15:20:48 +00:00
|
|
|
// Fire an event for the parent window notifing it of the new selection.
|
2007-03-17 19:37:56 +00:00
|
|
|
if (pSelectedItem) {
|
2009-06-23 15:20:48 +00:00
|
|
|
|
|
|
|
// Store so we know where we are
|
|
|
|
m_pCurrentSelection = pSelectedItem;
|
2007-03-17 19:37:56 +00:00
|
|
|
|
|
|
|
// Fire Event
|
|
|
|
ProjectListCtrlEvent evt(
|
2009-06-23 15:20:48 +00:00
|
|
|
wxEVT_PROJECTLIST_ITEM_CHANGE,
|
2007-03-17 19:37:56 +00:00
|
|
|
pSelectedItem->GetTitle(),
|
2009-02-05 05:57:30 +00:00
|
|
|
pSelectedItem->GetURL(),
|
|
|
|
pSelectedItem->IsSupported()
|
2007-03-17 19:37:56 +00:00
|
|
|
);
|
|
|
|
evt.SetEventObject(this);
|
|
|
|
|
|
|
|
GetParent()->AddPendingEvent( evt );
|
|
|
|
}
|
2009-06-23 15:20:48 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListCtrl::OnItemDisplay( wxCommandEvent& event ) {
|
|
|
|
|
|
|
|
// Fire an event for the parent window notifing it to display more information.
|
|
|
|
CProjectListItemCtrl* pItem = wxDynamicCast(event.GetEventObject(), CProjectListItemCtrl);
|
|
|
|
if (pItem) {
|
|
|
|
|
|
|
|
// Fire Event
|
|
|
|
ProjectListCtrlEvent evt(
|
|
|
|
wxEVT_PROJECTLIST_ITEM_DISPLAY,
|
|
|
|
pItem->GetTitle(),
|
|
|
|
pItem->GetURL(),
|
|
|
|
pItem->IsSupported()
|
|
|
|
);
|
|
|
|
evt.SetEventObject(this);
|
|
|
|
|
|
|
|
GetParent()->AddPendingEvent( evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* event handler for window
|
|
|
|
*/
|
|
|
|
|
2009-06-23 22:31:43 +00:00
|
|
|
void CProjectListCtrl::OnItemFocusChange( CProjectListItemCtrl* pSelectedItem ) {
|
2009-06-23 15:20:48 +00:00
|
|
|
|
2009-06-23 22:23:20 +00:00
|
|
|
// Reset the background color back to the default
|
|
|
|
wxWindowList::compatibility_iterator current = GetChildren().GetFirst();
|
|
|
|
while (current) {
|
2009-06-23 22:31:43 +00:00
|
|
|
wxWindow* child = current->GetData();
|
|
|
|
|
|
|
|
child->SetBackgroundColour( wxNullColour );
|
|
|
|
child->Refresh();
|
|
|
|
|
2009-06-23 22:23:20 +00:00
|
|
|
current = current->GetNext();
|
|
|
|
}
|
2009-06-23 15:20:48 +00:00
|
|
|
|
2009-06-23 22:23:20 +00:00
|
|
|
// Set the background color of the window that threw the event to the
|
|
|
|
// default background color of a selected control.
|
|
|
|
if (pSelectedItem) {
|
|
|
|
pSelectedItem->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT) );
|
|
|
|
pSelectedItem->Refresh();
|
2009-06-23 15:20:48 +00:00
|
|
|
|
2009-06-23 22:31:43 +00:00
|
|
|
OnItemChange( pSelectedItem );
|
2009-06-23 15:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_SET_FOCUS, wxEVT_KILL_FOCUS event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListCtrl::OnFocusChanged( wxFocusEvent& event ) {
|
|
|
|
|
|
|
|
if ( wxEVT_SET_FOCUS == event.GetEventType() ) {
|
|
|
|
// Control has focus
|
|
|
|
if (!m_pCurrentSelection) {
|
|
|
|
// Set the focus to the first child
|
|
|
|
GetChildren().GetFirst()->GetData()->SetFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_KEY_DOWN, wxEVT_KEY_UP event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListCtrl::OnKeyPressed( wxKeyEvent& event ) {
|
|
|
|
wxWindowList list;
|
|
|
|
list = GetChildren();
|
|
|
|
|
|
|
|
if ( (wxEVT_KEY_DOWN == event.GetEventType()) && (WXK_DOWN == event.GetKeyCode()) ) {
|
|
|
|
|
|
|
|
wxWindowList::compatibility_iterator iter = GetChildren().GetLast();
|
|
|
|
while (iter) {
|
|
|
|
wxWindow* pCurentWindow = iter->GetData();
|
|
|
|
if (pCurentWindow == m_pCurrentSelection) {
|
|
|
|
wxWindowListNode* pNextNode = iter->GetNext();
|
|
|
|
if (pNextNode) {
|
|
|
|
wxWindow* pNextWindow = pNextNode->GetData();
|
|
|
|
if (pNextWindow) {
|
|
|
|
pNextWindow->SetFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iter = iter->GetPrevious();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ( (wxEVT_KEY_DOWN == event.GetEventType()) && (WXK_UP == event.GetKeyCode()) ) {
|
|
|
|
|
|
|
|
wxWindowList::compatibility_iterator iter = GetChildren().GetFirst();
|
|
|
|
while (iter) {
|
|
|
|
wxWindow* pCurentWindow = iter->GetData();
|
|
|
|
if (pCurentWindow == m_pCurrentSelection) {
|
|
|
|
wxWindowListNode* pPreviousNode = iter->GetPrevious();
|
|
|
|
if (pPreviousNode) {
|
|
|
|
wxWindow* pPreviousWindow = pPreviousNode->GetData();
|
|
|
|
if (pPreviousWindow) {
|
|
|
|
pPreviousWindow->SetFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iter = iter->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ( (wxEVT_KEY_DOWN == event.GetEventType()) && (WXK_TAB == event.GetKeyCode()) ) {
|
|
|
|
|
|
|
|
if (wxMOD_SHIFT == event.GetModifiers()) {
|
|
|
|
Navigate( wxNavigationKeyEvent::IsBackward & wxNavigationKeyEvent::WinChange );
|
|
|
|
} else {
|
|
|
|
Navigate( wxNavigationKeyEvent::IsForward & wxNavigationKeyEvent::WinChange );
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
event.Skip();
|
|
|
|
}
|
2007-03-17 19:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Append a new entry to the project list.
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool CProjectListCtrl::Append(
|
|
|
|
wxString strTitle,
|
2009-02-05 05:57:30 +00:00
|
|
|
wxString strURL,
|
|
|
|
bool bSupported
|
2007-03-17 19:37:56 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
CProjectListItemCtrl* pItem = new CProjectListItemCtrl();
|
|
|
|
pItem->Create( this );
|
|
|
|
pItem->SetTitle( strTitle );
|
|
|
|
pItem->SetURL( strURL );
|
2009-02-05 05:57:30 +00:00
|
|
|
pItem->SetSupportedStatus( bSupported );
|
2009-06-23 15:20:48 +00:00
|
|
|
|
2007-03-17 19:37:56 +00:00
|
|
|
m_pMainSizer->Add( pItem, 0, wxEXPAND );
|
|
|
|
|
|
|
|
FitInside();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemCtrl type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( CProjectListItemCtrl, wxPanel )
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemCtrl event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( CProjectListItemCtrl, wxPanel )
|
|
|
|
|
|
|
|
////@begin CProjectListItemCtrl event table entries
|
|
|
|
EVT_ENTER_WINDOW( CProjectListItemCtrl::OnMouseEnterLeave )
|
|
|
|
EVT_LEAVE_WINDOW( CProjectListItemCtrl::OnMouseEnterLeave )
|
|
|
|
EVT_LEFT_DOWN( CProjectListItemCtrl::OnMouseClick )
|
|
|
|
EVT_LEFT_UP( CProjectListItemCtrl::OnMouseClick )
|
2009-06-23 15:20:48 +00:00
|
|
|
EVT_KEY_DOWN( CProjectListItemCtrl::OnKeyPressed )
|
|
|
|
EVT_KEY_UP( CProjectListItemCtrl::OnKeyPressed )
|
2007-11-07 18:08:21 +00:00
|
|
|
EVT_BUTTON( ID_WEBSITEBUTTON, CProjectListItemCtrl::OnWebsiteButtonClick )
|
2007-03-17 19:37:56 +00:00
|
|
|
////@end CProjectListItemCtrl event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemCtrl constructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
CProjectListItemCtrl::CProjectListItemCtrl( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CProjectListItemCtrl::CProjectListItemCtrl( wxWindow* parent )
|
|
|
|
{
|
|
|
|
Create( parent );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemCtrl creator
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool CProjectListItemCtrl::Create( wxWindow* parent )
|
|
|
|
{
|
|
|
|
////@begin CProjectListItemCtrl member initialisation
|
2007-03-20 19:04:27 +00:00
|
|
|
m_pTitleStaticCtrl = NULL;
|
2007-11-07 18:08:21 +00:00
|
|
|
m_pWebsiteButtonCtrl = NULL;
|
2007-03-20 19:04:27 +00:00
|
|
|
m_strTitle = wxEmptyString;
|
2007-03-17 19:37:56 +00:00
|
|
|
m_strURL = wxEmptyString;
|
2009-02-05 05:57:30 +00:00
|
|
|
m_bSupported = false;
|
2007-03-17 19:37:56 +00:00
|
|
|
////@end CProjectListItemCtrl member initialisation
|
|
|
|
|
|
|
|
////@begin CProjectListItemCtrl creation
|
2009-06-23 15:20:48 +00:00
|
|
|
wxPanel::Create( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxNO_BORDER | wxWANTS_CHARS | wxTAB_TRAVERSAL );
|
2007-03-17 19:37:56 +00:00
|
|
|
|
|
|
|
CreateControls();
|
|
|
|
GetSizer()->Fit(this);
|
|
|
|
////@end CProjectListItemCtrl creation
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Control creation for CProjectListItemCtrl
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListItemCtrl::CreateControls()
|
|
|
|
{
|
|
|
|
////@begin CProjectListItemCtrl content construction
|
|
|
|
|
2007-11-07 18:08:21 +00:00
|
|
|
wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxVERTICAL);
|
2007-03-19 20:00:43 +00:00
|
|
|
|
2007-11-07 18:08:21 +00:00
|
|
|
wxFlexGridSizer* itemFlexGridSizer8 = new wxFlexGridSizer(1, 2, 0, 0);
|
|
|
|
itemFlexGridSizer8->AddGrowableRow(0);
|
|
|
|
itemFlexGridSizer8->AddGrowableCol(0);
|
2009-06-23 15:20:48 +00:00
|
|
|
itemBoxSizer7->Add(itemFlexGridSizer8, 0, wxGROW|wxALL, 0);
|
2007-03-17 19:37:56 +00:00
|
|
|
|
2007-03-20 19:04:27 +00:00
|
|
|
m_pTitleStaticCtrl = new CProjectListItemStaticCtrl;
|
2007-11-07 18:08:21 +00:00
|
|
|
m_pTitleStaticCtrl->Create( this, wxID_STATIC, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemFlexGridSizer8->Add(m_pTitleStaticCtrl, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 0);
|
|
|
|
|
2009-06-23 15:20:48 +00:00
|
|
|
m_pWebsiteButtonCtrl = new CProjectListItemBitmapCtrl;
|
2007-11-15 15:59:59 +00:00
|
|
|
m_pWebsiteButtonCtrl->Create( this, ID_WEBSITEBUTTON, wxBitmap(externalweblink_xpm), wxDefaultPosition, wxSize(12,12), wxNO_BORDER );
|
2007-11-07 18:08:21 +00:00
|
|
|
itemFlexGridSizer8->Add(m_pWebsiteButtonCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
|
|
|
|
|
|
|
|
SetSizer(itemBoxSizer7);
|
2007-03-17 19:37:56 +00:00
|
|
|
|
|
|
|
////@end CProjectListItemCtrl content construction
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_ENTER_WINDOW, wxEVT_LEAVE_WINDOW event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListItemCtrl::OnMouseEnterLeave( wxMouseEvent& event ) {
|
|
|
|
m_bLeftButtonDownDetected = false;
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_LEFT_DOWN, wxEVT_LEFT_UP event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListItemCtrl::OnMouseClick( wxMouseEvent& event ) {
|
|
|
|
|
|
|
|
if ( event.LeftDown() ) {
|
|
|
|
m_bLeftButtonDownDetected = true;
|
|
|
|
} else {
|
|
|
|
if ( m_bLeftButtonDownDetected ) {
|
2009-06-23 22:17:49 +00:00
|
|
|
CProjectListCtrl* pParent = wxDynamicCast(GetParent(), CProjectListCtrl);
|
|
|
|
if (pParent) {
|
2009-06-23 22:31:43 +00:00
|
|
|
pParent->OnItemFocusChange( this );
|
2009-06-23 22:17:49 +00:00
|
|
|
}
|
2007-03-17 19:37:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
event.Skip();
|
|
|
|
|
2009-06-23 15:20:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_KEY_DOWN, wxEVT_KEY_UP event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListItemCtrl::OnKeyPressed( wxKeyEvent& event ) {
|
|
|
|
CProjectListCtrl* pParent = wxDynamicCast(GetParent(), CProjectListCtrl);
|
|
|
|
if (pParent) {
|
|
|
|
pParent->OnKeyPressed( event );
|
|
|
|
}
|
2007-03-17 19:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-07 18:08:21 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for window
|
|
|
|
*/
|
|
|
|
|
2009-06-23 15:20:48 +00:00
|
|
|
void CProjectListItemCtrl::OnWebsiteButtonClick( wxCommandEvent& event ) {
|
2007-11-07 18:08:21 +00:00
|
|
|
|
|
|
|
if (!m_strURL.IsEmpty()) {
|
2009-06-23 15:20:48 +00:00
|
|
|
// We now have focus, report that to the parent
|
|
|
|
CProjectListCtrl* pParent = wxDynamicCast(GetParent(), CProjectListCtrl);
|
|
|
|
if (pParent) {
|
|
|
|
pParent->OnItemDisplay( event );
|
|
|
|
}
|
2007-11-07 18:08:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-03-17 19:37:56 +00:00
|
|
|
|
|
|
|
bool CProjectListItemCtrl::SetTitle( wxString strTitle ) {
|
2007-11-07 18:08:21 +00:00
|
|
|
if (m_pTitleStaticCtrl) m_pTitleStaticCtrl->SetLabel( strTitle );
|
2007-03-19 17:58:08 +00:00
|
|
|
m_strTitle = strTitle;
|
2007-03-17 19:37:56 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool CProjectListItemCtrl::SetURL( wxString strURL ) {
|
2007-11-07 18:08:21 +00:00
|
|
|
if (m_pWebsiteButtonCtrl) {
|
|
|
|
wxString strBuffer = wxEmptyString;
|
|
|
|
|
|
|
|
strBuffer.Printf(
|
|
|
|
_("Click here to go to %s's website."),
|
|
|
|
m_strTitle.c_str()
|
|
|
|
);
|
|
|
|
|
|
|
|
m_pWebsiteButtonCtrl->SetToolTip(strBuffer);
|
2007-03-19 20:00:43 +00:00
|
|
|
}
|
2007-03-17 19:37:56 +00:00
|
|
|
m_strURL = strURL;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-03-19 17:58:08 +00:00
|
|
|
|
2009-02-05 05:57:30 +00:00
|
|
|
bool CProjectListItemCtrl::SetSupportedStatus( bool bSupported ) {
|
|
|
|
if (m_pTitleStaticCtrl) {
|
|
|
|
m_pTitleStaticCtrl->Enable( bSupported );
|
|
|
|
}
|
|
|
|
m_bSupported = bSupported;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-19 17:58:08 +00:00
|
|
|
/*!
|
|
|
|
* CProjectListItemStaticCtrl type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( CProjectListItemStaticCtrl, wxStaticText )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemStaticCtrl event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( CProjectListItemStaticCtrl, wxStaticText )
|
|
|
|
|
|
|
|
////@begin CProjectListItemStaticCtrl event table entries
|
|
|
|
EVT_ENTER_WINDOW( CProjectListItemStaticCtrl::OnMouseEnterLeave )
|
|
|
|
EVT_LEAVE_WINDOW( CProjectListItemStaticCtrl::OnMouseEnterLeave )
|
|
|
|
EVT_LEFT_DOWN( CProjectListItemStaticCtrl::OnMouseClick )
|
|
|
|
EVT_LEFT_UP( CProjectListItemStaticCtrl::OnMouseClick )
|
|
|
|
////@end CProjectListItemStaticCtrl event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemStaticCtrl constructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
CProjectListItemStaticCtrl::CProjectListItemStaticCtrl( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CProjectListItemStaticCtrl::CProjectListItemStaticCtrl(
|
|
|
|
wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Create (parent, id, label, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemStaticCtrl creator
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool CProjectListItemStaticCtrl::Create(
|
|
|
|
wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxString& name
|
|
|
|
)
|
|
|
|
{
|
2009-06-23 15:20:48 +00:00
|
|
|
bool retval = false;
|
2007-03-19 17:58:08 +00:00
|
|
|
|
2009-06-23 15:20:48 +00:00
|
|
|
retval = wxStaticText::Create (parent, id, label, pos, size, style, name);
|
2007-03-19 17:58:08 +00:00
|
|
|
|
2009-06-23 15:20:48 +00:00
|
|
|
return retval;
|
2007-03-19 17:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_ENTER_WINDOW, wxEVT_LEAVE_WINDOW event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListItemStaticCtrl::OnMouseEnterLeave( wxMouseEvent& event ) {
|
|
|
|
CProjectListItemCtrl* pParent = wxDynamicCast(GetParent(), CProjectListItemCtrl);
|
|
|
|
if (pParent) {
|
|
|
|
pParent->OnMouseEnterLeave( event );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_LEFT_DOWN, wxEVT_LEFT_UP event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListItemStaticCtrl::OnMouseClick( wxMouseEvent& event ) {
|
|
|
|
CProjectListItemCtrl* pParent = wxDynamicCast(GetParent(), CProjectListItemCtrl);
|
|
|
|
if (pParent) {
|
|
|
|
pParent->OnMouseClick( event );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-23 15:20:48 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemBitmapCtrl type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( CProjectListItemBitmapCtrl, wxStaticBitmap )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemBitmapCtrl event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( CProjectListItemBitmapCtrl, wxStaticBitmap )
|
|
|
|
|
|
|
|
////@begin CProjectListItemBitmapCtrl event table entries
|
|
|
|
EVT_ENTER_WINDOW( CProjectListItemBitmapCtrl::OnMouseEnterLeave )
|
|
|
|
EVT_LEAVE_WINDOW( CProjectListItemBitmapCtrl::OnMouseEnterLeave )
|
|
|
|
EVT_LEFT_DOWN( CProjectListItemBitmapCtrl::OnMouseClick )
|
|
|
|
EVT_LEFT_UP( CProjectListItemBitmapCtrl::OnMouseClick )
|
|
|
|
////@end CProjectListItemBitmapCtrl event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemBitmapCtrl constructors
|
|
|
|
*/
|
|
|
|
|
|
|
|
CProjectListItemBitmapCtrl::CProjectListItemBitmapCtrl( )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CProjectListItemBitmapCtrl::CProjectListItemBitmapCtrl(
|
|
|
|
wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxString& name
|
|
|
|
)
|
|
|
|
{
|
|
|
|
Create (parent, id, bitmap, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* CProjectListItemBitmapCtrl creator
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool CProjectListItemBitmapCtrl::Create(
|
|
|
|
wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, const wxPoint& pos, const wxSize& size, long style, const wxString& name
|
|
|
|
)
|
|
|
|
{
|
|
|
|
bool retval = false;
|
|
|
|
|
|
|
|
retval = wxStaticBitmap::Create (parent, id, bitmap, pos, size, style, name);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_ENTER_WINDOW, wxEVT_LEAVE_WINDOW event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListItemBitmapCtrl::OnMouseEnterLeave( wxMouseEvent& event ) {
|
|
|
|
m_bLeftButtonDownDetected = false;
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_LEFT_DOWN, wxEVT_LEFT_UP event handler for window
|
|
|
|
*/
|
|
|
|
|
|
|
|
void CProjectListItemBitmapCtrl::OnMouseClick( wxMouseEvent& event ) {
|
|
|
|
|
|
|
|
if ( event.LeftDown() ) {
|
|
|
|
m_bLeftButtonDownDetected = true;
|
|
|
|
} else {
|
|
|
|
if ( m_bLeftButtonDownDetected ) {
|
|
|
|
// The control that reported the down event is also
|
|
|
|
// the one reporting the up event, so it is a valid
|
|
|
|
// click event.
|
|
|
|
wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED);
|
|
|
|
evt.SetId( ID_WEBSITEBUTTON );
|
|
|
|
evt.SetEventObject(this);
|
|
|
|
|
|
|
|
GetParent()->AddPendingEvent( evt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
event.Skip();
|
|
|
|
|
|
|
|
}
|
|
|
|
|