changeset 19:868ccd73e238 v2.2dev

directory viewer
author pyon@macmini
date Tue, 25 Oct 2011 07:48:39 +0900
parents f3463815c2c9
children d10eafafe31f
files include/common.h include/dirview.h src/dirview.cpp
diffstat 3 files changed, 136 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/include/common.h	Sun Oct 23 21:42:01 2011 +0900
+++ b/include/common.h	Tue Oct 25 07:48:39 2011 +0900
@@ -1,5 +1,5 @@
 // Filename   : common.h
-// Last Change: 23-Oct-2011.
+// Last Change: 24-Oct-2011.
 //
 #ifndef __COMMON__
 #define __COMMON__
@@ -60,6 +60,10 @@
 
     // param
 
+    // dirview
+    ID_LISTCTRLALL,
+    ID_LISTCTRLTHUMB,
+    ID_BITMAPPREVIEW,
 };
 
 #if defined(__WXMSW__)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/dirview.h	Tue Oct 25 07:48:39 2011 +0900
@@ -0,0 +1,29 @@
+// Filename   : dirview.h
+// Last Change: 24-Oct-2011.
+//
+
+#ifndef __dirview__
+#define __dirview__
+
+#include "common.h"
+
+class DirViewFrame : public wxFrame 
+{
+	private:
+	
+	protected:
+		wxListCtrl*     m_listCtrlAll;
+		wxListCtrl*     m_listCtrlThumbnail;
+		wxStaticBitmap* m_bitmapPreview;
+	
+	public:
+		
+		DirViewFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
+		~DirViewFrame();
+	
+        void DirViewFrame::OnThumbnail(wxListEvent& event);
+        void DirViewFrame::OnThumbnail(wxListEvent& event);
+};
+
+#endif //__dirview__
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dirview.cpp	Tue Oct 25 07:48:39 2011 +0900
@@ -0,0 +1,102 @@
+
+// Filename   : dirview.cpp
+// Last Change: 24-Oct-2011.
+//
+
+#include "dirview.h"
+
+// frame constructor
+DirViewFrame::DirViewFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
+{
+	this->SetSizeHints( wxDefaultSize, wxDefaultSize );
+    this->SetBackgroundColour( wxColour(wxT("WHEAT")) );
+	
+	wxBoxSizer* bSizer;
+	bSizer = new wxBoxSizer( wxHORIZONTAL );
+	
+	m_listCtrlAll = new wxListCtrl( this, ID_LISTCTRLALL, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxLC_SINGLE_SEL );
+    itemCol.SetText( wxT("$BDLHV(B") );
+    m_listCtrlAll->InsertColumn( 0, itemCol );
+    m_listCtrlAll->SetColumnWidth( 0, 100 );
+    itemCol.SetText( wxT("$BHoJ]81<THV9f(B") );
+    m_listCtrlAll->InsertColumn( 1, itemCol );
+    m_listCtrlAll->SetColumnWidth( 1, 180 );
+    itemCol.SetText( wxT("$B%U%!%$%k?t(B") );
+    m_listCtrlAll->InsertColumn( 2, itemCol );
+    m_listCtrlAll->SetColumnWidth( 1, 100 );
+	bSizer->Add( m_listCtrlAll, 0, wxALL|wxEXPAND, 5 );
+	
+	m_listCtrlThumbnail = new wxListCtrl( this, ID_LISTCTRLTHUMB, wxDefaultPosition, wxDefaultSize, wxLC_ICON );
+	bSizer->Add( m_listCtrlThumbnail, 0, wxALL|wxEXPAND, 5 );
+	
+	m_bitmapPreview = new wxStaticBitmap( this, ID_BITMAPPREVIEW, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
+	bSizer->Add( m_bitmapPreview, 1, wxALL|wxEXPAND, 5 );
+	
+	this->SetSizer( bSizer );
+	this->Layout();
+	
+	this->Centre( wxBOTH );
+}
+
+// destructor
+DirViewFrame::~DirViewFrame()
+{
+}
+
+// Event Table
+BEGIN_EVENT_TABLE( MyFrame, wxFrame )
+    EVT_LIST_ITEM_SELECTED( ID_LISTCTRLALL,   DirViewFrame::OnThumbnail )
+    EVT_LIST_ITEM_SELECTED( ID_LISTCTRLTHUMB, DirViewFrame::OnPreview   )
+END_EVENT_TABLE()
+
+// Event Handlers
+void DirViewFrame::OnThumbnail(wxListEvent& event)
+{
+    m_listCtrlThumbnail->DeleteAllItems();
+    /*
+    m_imageList->RemoveAll();
+    wxDir dir(m_dir);
+    wxString filename;
+    if ( !dir.IsOpened() ) return;
+
+    bool cout = dir.GetFirst( &filename, wxT("*.jpg"), wxDIR_FILES );
+
+    int i=0;
+    wxListItem item;
+    while ( cout ) {
+        wxString f = m_dir + wxFILE_SEP_PATH + filename;
+        wxFile file( f );
+        long len = file.Length();
+        if ( !m_checkBox->IsChecked() && len > 150000 ) { 
+            cout = dir.GetNext( &filename );
+            continue;
+        }
+
+        item.SetId(i);
+        item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT|wxLIST_MASK_IMAGE);
+        item.SetStateMask(wxLIST_STATE_SELECTED);
+        item.SetState(wxLIST_STATE_SELECTED);
+        item.SetImage(i);
+        item.SetText(filename);
+        m_listCtrl->InsertItem( item );
+        m_listCtrl->SetItem( item );
+
+        wxImage img( f, wxBITMAP_TYPE_JPEG );
+        wxBitmap bmp( img.Scale( 63, 89, wxIMAGE_QUALITY_HIGH ) );
+        m_imageList->Add( bmp );
+        cout = dir.GetNext( &filename );
+        i++;
+    }
+    */
+
+    return;
+} 
+
+void DirViewFrame::OnPreview(wxListEvent& event)
+{
+}
+
+// Functions
+void DirViewFrame::ListAll(void)
+{
+}