view src/testframe.cpp @ 23:a2dd16b70c08 v2.2dev

apply vivid-coloured image for selected item.
author pyon@macmini
date Tue, 01 Nov 2011 22:26:41 +0900
parents 7bf900d47e9e
children
line wrap: on
line source

// Filename   : testframe.cpp
// Last Change: 08-Oct-2011.
//
#include "common.h"

class TestFrame : public wxFrame 
{
    DECLARE_EVENT_TABLE()
    private:
        wxListCtrl* m_listCtrl;

	public:
		TestFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLOSE_BOX );
		~TestFrame();

        void OnMessage(wxListEvent&);
};

// constructor
TestFrame::TestFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) 
    : wxFrame( parent, id, title, pos, size, style )
{
	this->SetSize( 400, 600 );
    this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
	
	wxBoxSizer* bSizer;
	bSizer = new wxBoxSizer( wxVERTICAL );
	
	m_listCtrl = new wxListCtrl( this, ID_LSWHITE, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
    wxListItem itemCol;
    itemCol.SetText( wxT("通番") );
    m_listCtrl->InsertColumn( 0, itemCol );
    m_listCtrl->SetColumnWidth( 0, 100 );
    itemCol.SetText( wxT("被保険者番号") );
    m_listCtrl->InsertColumn( 1, itemCol );
    m_listCtrl->SetColumnWidth( 1, 180 );
    itemCol.SetText( wxT("ファイル数") );
    m_listCtrl->InsertColumn( 2, itemCol );
    m_listCtrl->SetColumnWidth( 1, 100 );
	bSizer->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );

	this->SetSizer( bSizer );
	this->Layout();
	
	this->Centre( wxBOTH );

    m_listCtrl->InsertItem( 1, wxT("aaa") );
    m_listCtrl->SetItem( 0, 1, wxT("bbb"), -1 );
    m_listCtrl->InsertItem( 1, wxT("aa2") );
    m_listCtrl->SetItem( 1, 1, wxT("bb2"), -1 );
}

// destructor
TestFrame::~TestFrame()
{
}

// Event Table
BEGIN_EVENT_TABLE( TestFrame, wxFrame )
    EVT_LIST_ITEM_ACTIVATED( ID_LSWHITE, TestFrame::OnMessage )
END_EVENT_TABLE()

// Event Handlers
void TestFrame::OnMessage(wxListEvent& event)
{
    wxListItem item = event.GetItem();
    item.SetColumn(1);
    item.SetMask(wxLIST_MASK_TEXT);
    //int n = item.GetColumn();
    //wxString msg_n = wxString::Format(wxT("%d"),n);
    //wxMessageBox( msg_n );
    m_listCtrl->GetItem( item );
    wxString msg   = item.GetText();
    wxMessageBox( msg );
}