/*! \brief Set the image list. * * \param inImageList wxImageList& * \return void * */ void wxsImageTreeEditorDlg::SetImageList(wxImageList &inImageList) { int i, n; wxString ss, tt; wxBitmap bmp; // save the image list in the tree control Tree1->SetImageList(&inImageList); // valid list given? n = inImageList.GetImageCount(); if(n <= 0){ cbNormal->Enable(false); cbSelected->Enable(false); cbExpanded->Enable(false); cbSelExpanded->Enable(false); } else { cbNormal->Enable(true); cbSelected->Enable(true); cbExpanded->Enable(true); cbSelExpanded->Enable(true); } // set images in the drop-down lists cbNormal->Clear(); cbSelected->Clear(); cbExpanded->Clear(); cbSelExpanded->Clear(); ss = _("<none>"); cbNormal->Append(ss); cbSelected->Append(ss); cbExpanded->Append(ss); cbSelExpanded->Append(ss); for(i = 0; i < n; i++){ ss.Printf(wxT("%d"), i); bmp = inImageList.GetBitmap(i); cbNormal->Append(ss, bmp); cbSelected->Append(ss, bmp); cbExpanded->Append(ss, bmp); cbSelExpanded->Append(ss, bmp); } // default selections cbNormal->SetSelection(0); cbSelected->SetSelection(0); cbExpanded->SetSelection(0); cbSelExpanded->SetSelection(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); }
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); } }