comparison src/delwhite.cpp @ 2:1ea4f7981ff5

create window.
author pyon@macmini
date Sun, 02 Oct 2011 18:44:03 +0900
parents
children a5bddd859104
comparison
equal deleted inserted replaced
1:214f2908b8e4 2:1ea4f7981ff5
1 // Filename : delwhite.cpp
2 // Last Change: 02-Oct-2011.
3 //
4
5 #include "delwhite.h"
6
7 // for all others, include the necessary headers (this file is usually all you
8 // need because it includes almost all "standard" wxWidgets headers)
9 #ifndef WX_PRECOMP
10 #include "wx/utils.h"
11 #include "wx/dir.h"
12 #include "wx/file.h"
13 #endif
14
15
16 // constructor
17 FrameDelWhite::FrameDelWhite( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
18 {
19 this->SetSize( 1200, 1000 );
20 //this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
21 //this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) );
22
23 wxBoxSizer* bSizer;
24 bSizer = new wxBoxSizer( wxVERTICAL );
25
26 m_listCtrl = new wxListCtrl( this, ID_LSWHITE, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
27 bSizer->Add( m_listCtrl, 1, wxALL|wxEXPAND, 5 );
28 m_imageList = new wxImageList( 105, 148 );
29 m_listCtrl->AssignImageList( m_imageList, wxIMAGE_LIST_NORMAL );
30
31 wxBoxSizer* bSizerBtn;
32 bSizerBtn = new wxBoxSizer( wxHORIZONTAL );
33
34 m_checkBox = new wxCheckBox( this, ID_CHECK, wxT("全ての画像を表示"), wxDefaultPosition, wxDefaultSize, 0 );
35 bSizer->Add( m_checkBox, 0, wxALL, 5 );
36
37 m_staticText = new wxStaticText( this, wxID_ANY, wxT("白紙ファイルを選択し,「削除」ボタンを押してください.") );
38 bSizerBtn->Add( m_staticText, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
39
40 m_buttonDelWhite = new wxButton( this, ID_DELETE, wxT("削除"), wxDefaultPosition, wxDefaultSize, 0 );
41 bSizerBtn->Add( m_buttonDelWhite, 0, wxALL, 5 );
42
43 m_buttonCancel = new wxButton( this, ID_CANCEL, wxT("キャンセル"), wxDefaultPosition, wxDefaultSize, 0 );
44 bSizerBtn->Add( m_buttonCancel, 0, wxALL, 5 );
45
46 bSizer->Add( bSizerBtn, 0, wxEXPAND, 5 );
47
48 this->SetSizer( bSizer );
49 this->Layout();
50
51 this->Centre( wxBOTH );
52 }
53
54 // destructor
55 FrameDelWhite::~FrameDelWhite()
56 {
57 }
58
59 // Event Table
60 BEGIN_EVENT_TABLE( FrameDelWhite, wxFrame )
61 //EVT_LIST_ITEM_SELECTED( ID_LSTCTRL, FramePreview::ChageImage )
62 EVT_BUTTON( ID_DELETE, FrameDelWhite::DeleteImage )
63 EVT_BUTTON( ID_CANCEL, FrameDelWhite::CloseFrame )
64 END_EVENT_TABLE()
65
66 // Event Handlers
67 void FrameDelWhite::DeleteImage(wxCommandEvent& WXUNUSED(event))
68 {
69 return;
70 }
71
72 void FrameDelWhite::CloseFrame(wxCommandEvent& WXUNUSED(event))
73 {
74 this->Close();
75 return;
76 }
77
78 // Functions
79 void FrameDelWhite::LoadImages( void )
80 {
81 wxDir dir(m_dir);
82 wxString filename;
83 if ( !dir.IsOpened() ) return;
84
85 bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES );
86
87 int i=0;
88 wxListItem item;
89 while ( cout ) {
90 wxString f = m_dir + wxFILE_SEP_PATH + filename;
91 wxFile file( f );
92 long len = file.Length();
93 if ( !m_checkBox->IsChecked() && len < 2181468 ) {
94 cout = dir.GetNext( &filename );
95 continue;
96 }
97
98 item.SetId(i);
99 item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT|wxLIST_MASK_IMAGE);
100 item.SetStateMask(wxLIST_STATE_SELECTED);
101 item.SetState(wxLIST_STATE_SELECTED);
102 item.SetImage(i);
103 item.SetText(filename);
104 m_listCtrl->InsertItem( item );
105 m_listCtrl->SetItem( item );
106
107 wxImage img( f, wxBITMAP_TYPE_JPEG );
108 wxBitmap bmp( img.Scale( 105, 148, wxIMAGE_QUALITY_HIGH ) );
109 m_imageList->Add( bmp );
110 cout = dir.GetNext( &filename );
111 i++;
112 }
113
114 return;
115 }
116