/*! \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);
}
Beispiel #2
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;
}
Beispiel #3
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);
}
Beispiel #4
0
   MonkeyTable (wxWindow *parent, const wxString &title, MonkeyPrefs &pref, wxImageList &imgs, const wxSize& size = wxDefaultSize) :
   wxDialog(parent, wxID_ANY, title, wxDefaultPosition, size), prefs(pref)
   {
      filters.push_back(_("Thingy table file (*.tbl)|*.tbl"));

      wxBoxSizer *global_sz = new wxBoxSizer(wxVERTICAL);

      wxStaticText *header = new wxStaticText(this, wxID_ANY, _("You can edit the table values below before saving:"));
      wxDataViewListCtrl *datavw = new wxDataViewListCtrl(this, MonkeyTable_DataTable);

      datavw->AppendTextColumn(_("Byte"), wxDATAVIEW_CELL_EDITABLE);
      datavw->AppendTextColumn(_("Value"), wxDATAVIEW_CELL_EDITABLE);

      wxBoxSizer *tblnm_sz = new wxBoxSizer(wxHORIZONTAL);
      wxStaticText *flnmhd = new wxStaticText(this, wxID_ANY, _("Name "));
      wxTextCtrl *flnm = new wxTextCtrl(this, MonkeyTable_FileName);
      wxBitmapButton *browse = new wxBitmapButton(this, MonkeyTable_SaveTable, imgs.GetBitmap(MonkeyBmp_SaveFile));

      browse->SetDefault();

      tblnm_sz->Add(flnmhd, wxSizerFlags().Border(wxRIGHT, 5).Border(wxTOP, 4));
      tblnm_sz->Add(flnm, wxSizerFlags(1).Expand().Border(wxRIGHT, 5));
      tblnm_sz->Add(browse);

      wxBoxSizer *tblopt_sz = new wxBoxSizer(wxHORIZONTAL);
      wxStaticText *flfmthd = new wxStaticText(this, wxID_ANY, _("Format "));
      wxChoice *flfmt = new wxChoice(this, MonkeyTable_FileFmt);
      wxStaticText *flenchd = new wxStaticText(this, wxID_ANY, _("Encoding "));
      wxChoice *flenc = new wxChoice(this, MonkeyTable_FileEnc);

      flfmt->AppendString(_("Thingy table file (*.tbl)"));
      flfmt->SetSelection(0);

      flenc->AppendString(_("ANSI (ISO-8859-1)"));
      flenc->AppendString(_("Unicode (UTF-8)"));
      flenc->AppendString(_("Unicode (UTF-16)"));
      //flenc->AppendString(_("Shift-JIS (SJIS)"));
      flenc->SetSelection(1);

      tblopt_sz->Add(flfmthd, wxSizerFlags().Border(wxRIGHT, 5).Border(wxTOP, 4));
      tblopt_sz->Add(flfmt, wxSizerFlags().Border(wxRIGHT, 5));
      tblopt_sz->AddStretchSpacer(1);
      tblopt_sz->Add(flenchd, wxSizerFlags().Border(wxRIGHT, 5).Border(wxTOP, 4).Right());
      tblopt_sz->Add(flenc, wxSizerFlags().Right());

      global_sz->Add(header, wxSizerFlags().Border(wxTOP | wxLEFT | wxRIGHT, 10));
      global_sz->Add(datavw, wxSizerFlags(1).Expand().Border(wxALL, 10));
      global_sz->Add(tblnm_sz, wxSizerFlags().Expand().Border(wxRIGHT | wxLEFT, 10));
      global_sz->Add(tblopt_sz, wxSizerFlags().Expand().Border(wxALL, 10));
      SetSizer(global_sz);
   }
Beispiel #5
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)
                     );
    }
}
Beispiel #6
0
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);
	}
}
/*! \brief Get the image list.
 *
 * \param aImageList wxImageList&
 * \return void
 *
 */
void wxsImageList::GetImageList(wxImageList &aImageList)
{
    aImageList.RemoveAll();
    wxsImageListEditorDlg::ArrayToImageList(m_ImageData, aImageList);
}