예제 #1
0
int AddFlagImages( wxImageList& imgs )
{
	int poszero = 0;
	for ( int i = 0; flag_xpm[i]; ++i ) {
		const int index = imgs.Add( wxBitmap( const_cast<const char**>( flag_xpm[i] ) ) );
		if ( i == 0 ) poszero = index;
		m_name_to_pos[TowxString( flag_str[i] )] = i;
	}
	return poszero;
}
예제 #2
0
CMuleListCtrl::CMuleListCtrl(wxWindow *parent, wxWindowID winid, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name)
	: MuleExtern::wxGenericListCtrl(parent, winid, pos, size, style, validator, name)
{
	m_sort_func = NULL;
	m_tts_time = 0;
	m_tts_item = -1;
	m_isSorting = false;

	if (imgList.GetImageCount() == 0) {
		imgList.Add(wxBitmap(sort_dn_xpm));
		imgList.Add(wxBitmap(sort_up_xpm));
		imgList.Add(wxBitmap(sort_dnx2_xpm));
		imgList.Add(wxBitmap(sort_upx2_xpm));
	}

	// Default sort-order is to sort by the first column (asc).
	m_sort_orders.push_back(CColPair(0, 0));
	
	SetImageList(&imgList, wxIMAGE_LIST_SMALL);
}
예제 #3
0
void MyFrame::InitImageList()
{
    wxSize iconSize = wxArtProvider::GetSizeHint(wxART_LIST);
    if ( iconSize == wxDefaultSize )
        iconSize = wxSize(16, 16);

    m_imageList = new wxImageList(iconSize.x, iconSize.y);

    // The order should be the same as for the enum elements.
    static const char* const icons[] =
    {
        wxART_NORMAL_FILE,
        wxART_FOLDER,
        wxART_FOLDER_OPEN
    };

    for ( unsigned n = 0; n < WXSIZEOF(icons); n++ )
    {
        m_imageList->Add
                     (
                        wxArtProvider::GetIcon(icons[n], wxART_LIST, iconSize)
                     );
    }
}
예제 #4
0
파일: amuleDlg.cpp 프로젝트: marcoll/amule
void CamuleDlg::ShowConnectionState(bool skinChanged)
{
	static wxImageList status_arrows(16,16,true,0);
	if (!status_arrows.GetImageCount()) {
		// Generate the image list (This is only done once)
		for (int t = 0; t < 7; ++t) {
			status_arrows.Add(connImages(t));
		}
	}

	m_serverwnd->UpdateED2KInfo();
	m_serverwnd->UpdateKadInfo();


	////////////////////////////////////////////////////////////
	// Determine the status of the networks
	//
	enum ED2KState { ED2KOff = 0, ED2KLowID = 1, ED2KConnecting = 2, ED2KHighID = 3, ED2KUndef = -1 };
	enum EKadState { EKadOff = 4, EKadFW = 5, EKadConnecting = 5, EKadOK = 6, EKadUndef = -1 };

	ED2KState ed2kState = ED2KOff;
	EKadState kadState  = EKadOff;

	////////////////////////////////////////////////////////////
	// Update the label on the status-bar and determine
	// the states of the two networks.
	//
	wxString msgED2K;
	if (theApp->IsConnectedED2K()) {
		CServer* server = theApp->serverconnect->GetCurrentServer();
		if (server) {
			msgED2K = CFormat(wxT("eD2k: %s")) % server->GetListName();
		}

		if (theApp->serverconnect->IsLowID()) {
			ed2kState = ED2KLowID;
		} else {
			ed2kState = ED2KHighID;
		}
	} else if (theApp->serverconnect->IsConnecting()) {
		msgED2K = _("eD2k: Connecting");

		ed2kState = ED2KConnecting;
	} else if (thePrefs::GetNetworkED2K()) {
		msgED2K = _("eD2k: Disconnected");
	}

	wxString msgKad;
	if (theApp->IsConnectedKad()) {
		if (theApp->IsFirewalledKad()) {
			msgKad = _("Kad: Firewalled");

			kadState = EKadFW;
		} else {
			msgKad = _("Kad: Connected");

			kadState = EKadOK;
		}
	} else if (theApp->IsKadRunning()) {
		msgKad = _("Kad: Connecting");

		kadState = EKadConnecting;
	} else if (thePrefs::GetNetworkKademlia()) {
		msgKad = _("Kad: Off");
	}

	wxStaticText* connLabel = CastChild( wxT("connLabel"), wxStaticText );
	{ wxCHECK_RET(connLabel, wxT("'connLabel' widget not found")); }

	wxString labelMsg;
	if (msgED2K.Length() && msgKad.Length()) {
		labelMsg = msgED2K + wxT(" | ") + msgKad;
	} else {
		labelMsg = msgED2K + msgKad;
	}

	connLabel->SetLabel(labelMsg);
	connLabel->GetParent()->Layout();


	////////////////////////////////////////////////////////////
	// Update the connect/disconnect/cancel button.
	//
	enum EConnState {
		ECS_Unknown,
		ECS_Connected,
		ECS_Connecting,
		ECS_Disconnected
	};

	static EConnState s_oldState = ECS_Unknown;
	EConnState currentState = ECS_Disconnected;

	if (theApp->serverconnect->IsConnecting() ||
			(theApp->IsKadRunning() && !theApp->IsConnectedKad())) {
		currentState = ECS_Connecting;
	} else if (theApp->IsConnected()) {
		currentState = ECS_Connected;
	} else {
		currentState = ECS_Disconnected;
	}

	if ( (true == skinChanged) || (currentState != s_oldState) ) {
		wxWindowUpdateLocker freezer(m_wndToolbar);

		wxToolBarToolBase* toolbarTool = m_wndToolbar->RemoveTool(ID_BUTTONCONNECT);

		switch (currentState) {
			case ECS_Connecting:
				toolbarTool->SetLabel(_("Cancel"));
				toolbarTool->SetShortHelp(_("Stop the current connection attempts"));
				toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(2));
				break;

			case ECS_Connected:
				toolbarTool->SetLabel(_("Disconnect"));
				toolbarTool->SetShortHelp(_("Disconnect from the currently connected networks"));
				toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(1));
				break;

			default:
				toolbarTool->SetLabel(_("Connect"));
				toolbarTool->SetShortHelp(_("Connect to the currently enabled networks"));
				toolbarTool->SetNormalBitmap(m_tblist.GetBitmap(0));
		}

		m_wndToolbar->InsertTool(0, toolbarTool);
		m_wndToolbar->Realize();
		m_wndToolbar->EnableTool(ID_BUTTONCONNECT, (thePrefs::GetNetworkED2K() || thePrefs::GetNetworkKademlia()) && theApp->ipfilter->IsReady());

		s_oldState = currentState;
	}


	////////////////////////////////////////////////////////////
	// Update the globe-icon in the lower-right corner.
	// (only if connection state has changed)
	//
	static ED2KState s_ED2KOldState = ED2KUndef;
	static EKadState s_EKadOldState = EKadUndef;
	if (ed2kState != s_ED2KOldState || kadState != s_EKadOldState) {
		s_ED2KOldState = ed2kState;
		s_EKadOldState = kadState;
		wxStaticBitmap* connBitmap = CastChild( wxT("connImage"), wxStaticBitmap );
		wxCHECK_RET(connBitmap, wxT("'connImage' widget not found"));

		wxBitmap statusIcon = connBitmap->GetBitmap();
		// Sanity check - otherwise there's a crash here if aMule runs out of resources
		if (statusIcon.GetRefData() == NULL) {
			return;
		}

		wxMemoryDC bitmapDC(statusIcon);

		status_arrows.Draw(kadState, bitmapDC, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT);
		status_arrows.Draw(ed2kState, bitmapDC, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT);

		connBitmap->SetBitmap(statusIcon);
	}
}