annotate src/delwhite.cpp @ 2:1ea4f7981ff5

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