Example #1
1
void CJoinDialog::MoveSelectedItems(wxListBox& From, wxListBox& To)
{
	int i;
	wxString s;

	if (From.GetSelection() == -1) 
	{
		wxMessageBox(_("Nothing selected."),_T(""),wxICON_EXCLAMATION | wxOK);
	}
	for (i = 0; i < (int)From.GetCount(); ++i) 
	{
		if (From.IsSelected(i))
		{
			s = From.GetString(i);
			To.Append(s);
		}
	}
	for (i = (int)From.GetCount() - 1; i >= 0; --i) 
	{
		if (From.IsSelected(i)) 
		{
			From.Delete(i);
		}
	}
}
Example #2
0
void ListBoxTestCase::ClickEvents()
{
#if wxUSE_UIACTIONSIMULATOR
    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
                                              wxTestableFrame);

    EventCounter selected(frame, wxEVT_LISTBOX);
    EventCounter dclicked(frame, wxEVT_LISTBOX_DCLICK);

    wxUIActionSimulator sim;

    wxArrayString testitems;
    testitems.Add("item 0");
    testitems.Add("item 1");
    testitems.Add("item 2");

    m_list->Append(testitems);

    m_list->Update();
    m_list->Refresh();

    sim.MouseMove(m_list->ClientToScreen(wxPoint(10, 10)));
    wxYield();

    sim.MouseClick();
    wxYield();

    CPPUNIT_ASSERT_EQUAL(1, selected.GetCount());

    sim.MouseDblClick();
    wxYield();

    CPPUNIT_ASSERT_EQUAL(1, dclicked.GetCount());
#endif
}
Example #3
0
	luNewProjTemplatePage(wxWizard* parent) : wxWizardPageSimple(parent)
	{
		this->SetSizeHints( wxDefaultSize, wxDefaultSize );

		wxFlexGridSizer* fgSizer10;
		fgSizer10 = new wxFlexGridSizer( 3, 2, 0, 10 );
		fgSizer10->AddGrowableCol( 1 );
		fgSizer10->SetFlexibleDirection( wxBOTH );
		fgSizer10->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

		m_staticText5 = new wxStaticText( this, wxID_ANY, wxT("Project Templates"), wxDefaultPosition, wxDefaultSize, 0 );
		m_staticText5->Wrap( -1 );
		fgSizer10->Add( m_staticText5, 0, wxALL, 5 );

		m_textTitle = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
		fgSizer10->Add( m_textTitle, 0, wxALL, 5 );

		m_listTemplate = new wxListBox( this, ID_WIZARD_TEMPL_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
		fgSizer10->Add( m_listTemplate, 0, wxALL, 5 );

		m_imgPreview = new wxStaticBitmap( this, wxID_ANY, wxBitmap("Data/Empty.xpm", wxBITMAP_TYPE_ANY),
			wxDefaultPosition, wxDefaultSize, 0 );
		fgSizer10->Add( m_imgPreview, 0, wxALL, 5 );

		m_staticText6 = new wxStaticText( this, wxID_ANY, wxT("Description"), wxDefaultPosition, wxDefaultSize, 0 );
		m_staticText6->Wrap( -1 );
		fgSizer10->Add( m_staticText6, 0, wxALL, 5 );

		m_textDesc = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY );
		fgSizer10->Add( m_textDesc, 0, wxALL|wxEXPAND, 5 );


		this->SetSizer( fgSizer10 );
		this->Layout();

		this->Centre( wxBOTH );

		//--

		luProjTempList *ptlist = getLuApp()->getProjTempList(); GK_ASSERT(ptlist);
		for (size_t i = 0; i < ptlist->size(); i++)
		{
			const luProjTemplate& templ = (*ptlist)[i];
			m_listTemplate->Append(templ.name);
		}

		m_projTempList = ptlist;

		m_listTemplate->Connect(  wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( luNewProjTemplatePage::OnListItemSelected ), NULL, this );

		m_listTemplate->SetSelection(0);

        wxCommandEvent evt(wxEVT_NULL, wxEVT_COMMAND_LISTBOX_SELECTED);
		OnListItemSelected(evt);


		SetSizerAndFit(fgSizer10);
	}
Example #4
0
void CfgPanel::Change()
{
    wxString c = channel->GetStringSelection();
    wxString l = logger->GetStringSelection();
    filename->Enable(LogManager::Get()->FilenameRequired(l));

    if (l.at(0) == _T('<'))  // "<application default>"
        l.Empty();

//  blah... do something, update the maps according to what is selected
}
Example #5
0
void CJoinDialog::MoveAllItems(wxListBox& From, wxListBox& To)
{
	int i;
	wxString s;

	for (i = 0; i < (int)From.GetCount(); ++i) 
	{
		s = From.GetString(i);
		To.Append(s);
	}
	From.Clear();
}
Example #6
0
void ListBoxTestCase::Sort()
{
#ifndef __WXOSX__
    wxDELETE(m_list);
    m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
                            wxDefaultPosition, wxDefaultSize, 0, 0,
                            wxLB_SORT);

    wxArrayString testitems;
    testitems.Add("aaa");
    testitems.Add("Aaa");
    testitems.Add("aba");
    testitems.Add("aaab");
    testitems.Add("aab");
    testitems.Add("AAA");

    m_list->Append(testitems);

    CPPUNIT_ASSERT_EQUAL("AAA", m_list->GetString(0));
    CPPUNIT_ASSERT_EQUAL("Aaa", m_list->GetString(1));
    CPPUNIT_ASSERT_EQUAL("aaa", m_list->GetString(2));
    CPPUNIT_ASSERT_EQUAL("aaab", m_list->GetString(3));
    CPPUNIT_ASSERT_EQUAL("aab", m_list->GetString(4));
    CPPUNIT_ASSERT_EQUAL("aba", m_list->GetString(5));

    m_list->Append("a", wxUIntToPtr(1));

    CPPUNIT_ASSERT_EQUAL("a", m_list->GetString(0));
    CPPUNIT_ASSERT_EQUAL(wxUIntToPtr(1), m_list->GetClientData(0));
#endif
}
Example #7
0
void CfgPanel::Create(wxWindow* parent)
{
    wxPanel::Create(parent,-1);

    wxArrayString channelStrings;

    int slot = 0;
    while (slot < LogManager::max_logs)
    {
        const wxString t = LogManager::Get()->Slot(slot).title;

        if (!!t)
            channelStrings.Add(t);

        ++slot;
    }

    wxArrayString loggerStrings = LogManager::Get()->ListAvailable();
    loggerStrings.Insert(_T("<application default>"), 0);

    wxFlexGridSizer* flex = new wxFlexGridSizer(2, 2, 0, 0);
    flex->AddGrowableRow(1);
    flex->AddGrowableCol(0);
    flex->AddGrowableCol(1);

    wxStaticText* txt;
    txt = new wxStaticText(this, wxID_STATIC, _("Log Source"));
    flex->Add(txt, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5);
    txt = new wxStaticText(this, wxID_STATIC, _("Associated Logger"));
    flex->Add(txt, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP, 5);

    channel = new wxListBox(this, id_channel, wxDefaultPosition, wxDefaultSize, channelStrings, wxLB_SINGLE );
    logger  = new wxListBox(this, id_logger,  wxDefaultPosition, wxDefaultSize, loggerStrings,  wxLB_SINGLE );
    flex->Add(channel, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
    flex->Add(logger,  0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    channel->SetSelection(0);
    logger->SetSelection(0);

    // spacer
    flex->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    filename = new wxTextCtrl(this, id_text);
    flex->Add(filename, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);

    SetSizer(flex);
}
Example #8
0
void ListBoxTestCase::HitTest()
{
    wxArrayString testitems;
    testitems.Add("item 0");
    testitems.Add("item 1");
    testitems.Add("item 2");

    m_list->Append(testitems);

#ifdef __WXGTK__
    // The control needs to be realized for HitTest() to work.
    wxYield();
#endif

    CPPUNIT_ASSERT_EQUAL( 0, m_list->HitTest(5, 5) );

    CPPUNIT_ASSERT_EQUAL( wxNOT_FOUND, m_list->HitTest(290, 190) );
}
Example #9
0
void ListBoxTestCase::ClickNotOnItem()
{
#if wxUSE_UIACTIONSIMULATOR
    wxTestableFrame* frame = wxStaticCast(wxTheApp->GetTopWindow(),
                                              wxTestableFrame);

    EventCounter selected(frame, wxEVT_LISTBOX);
    EventCounter dclicked(frame, wxEVT_LISTBOX_DCLICK);

    wxUIActionSimulator sim;

    wxArrayString testitems;
    testitems.Add("item 0");
    testitems.Add("item 1");
    testitems.Add("item 2");

    m_list->Append(testitems);

    // It is important to set a valid selection: if the control doesn't have
    // any, clicking anywhere in it, even outside of any item, selects the
    // first item in the control under GTK resulting in a selection changed
    // event. This is not a wx bug, just the native platform behaviour so
    // simply avoid it by starting with a valid selection.
    m_list->SetSelection(0);

    m_list->Update();
    m_list->Refresh();

    sim.MouseMove(m_list->ClientToScreen(wxPoint(m_list->GetSize().x - 10, m_list->GetSize().y - 10)));
    wxYield();

    sim.MouseClick();
    wxYield();

    sim.MouseDblClick();
    wxYield();

    //If we are not clicking on an item we shouldn't have any events
    CPPUNIT_ASSERT_EQUAL(0, selected.GetCount());
    CPPUNIT_ASSERT_EQUAL(0, dclicked.GetCount());
#endif
}
Example #10
0
bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
{
    size_t nFiles = filenames.GetCount();
    wxString str;
    str.Printf( _T("%d files dropped"), (int)nFiles);
    m_pOwner->Append(str);

	UStringVector archivePaths;

    for ( size_t n = 0; n < nFiles; n++ )
    {
       // m_pOwner->Append(filenames[n]);
/*
        if (wxFile::Exists(filenames[n]))
            m_pOwner->Append(wxT("  This file exists.") );
        else
            m_pOwner->Append(wxT("  This file doesn't exist.") );
*/
		// cmd = cmd + _T(" \"") + filenames[n] + _T("\"");
		const wchar_t * wx = 	filenames[n].wc_str ();
		archivePaths.Add(wx);
    }

	/*
	m_pOwner->Append(cmd);


	long pid = 0;

	pid = wxExecute(cmd, wxEXEC_ASYNC);
	 */

	TestArchives(archivePaths);

    return true;
}
Example #11
0
void ListBoxClick(wxListBox &list,wxEvent &)
{
  ((t_File*)list.GetParent())->SetSelection();
}
Example #12
0
void ListBoxTestCase::MultipleSelect()
{
    wxDELETE(m_list);
    m_list = new wxListBox(wxTheApp->GetTopWindow(), wxID_ANY,
                            wxDefaultPosition, wxDefaultSize, 0, 0,
                            wxLB_MULTIPLE);

    wxArrayString testitems;
    testitems.Add("item 0");
    testitems.Add("item 1");
    testitems.Add("item 2");
    testitems.Add("item 3");

    m_list->Append(testitems);

    m_list->SetSelection(0);

    wxArrayInt selected;
    m_list->GetSelections(selected);

    CPPUNIT_ASSERT_EQUAL(1, selected.Count());
    CPPUNIT_ASSERT_EQUAL(0, selected.Item(0));

    m_list->SetSelection(2);

    m_list->GetSelections(selected);

    CPPUNIT_ASSERT_EQUAL(2, selected.Count());
    CPPUNIT_ASSERT_EQUAL(2, selected.Item(1));

    m_list->Deselect(0);

    m_list->GetSelections(selected);

    CPPUNIT_ASSERT_EQUAL(1, selected.Count());
    CPPUNIT_ASSERT_EQUAL(2, selected.Item(0));

    CPPUNIT_ASSERT(!m_list->IsSelected(0));
    CPPUNIT_ASSERT(!m_list->IsSelected(1));
    CPPUNIT_ASSERT(m_list->IsSelected(2));
    CPPUNIT_ASSERT(!m_list->IsSelected(3));

    m_list->SetSelection(0);
    m_list->SetSelection(wxNOT_FOUND);

    m_list->GetSelections(selected);
    CPPUNIT_ASSERT_EQUAL(0, selected.Count());
}
Example #13
-1
	void OnListItemSelected(wxCommandEvent& event)
	{
		int sel = m_listTemplate->GetSelection();
		if (sel < 0 || sel >= (int)m_projTempList->size())
		{
			m_curSel = -1;
			return;
		}

		m_curSel = sel;

		const luProjTemplate& templ = (*m_projTempList)[sel];

		m_imgPreview->SetBitmap(wxBitmap(templ.preview, wxBITMAP_TYPE_ANY));
		m_textDesc->SetLabelText(templ.desc);
		m_textTitle->SetLabelText(templ.title);

		//gkPrintf("%d", sel);
	}