summaryrefslogtreecommitdiffstats
path: root/installerbuilder/libinstaller/3rdparty/p7zip_9.04/unix/CPP/7zip/UI/FileManager/FM_rc.cpp
blob: 53d242c6a891f384b51c0ddd7fd80c90590740a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
#include "StdAfx.h"

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif

#include "wx/mimetype.h"
#include "wx/artprov.h"
#include "wx/imaglist.h"

#include "resource.h"

#include "App.h"

#include "Windows/Control/DialogImpl.h"
#include "Windows/Control/ListView.h"
#include "Windows/Control/Window2.h"

// FIXME
#undef IDCLOSE
#define IDCLOSE wxID_EXIT

#define static const
#include "../GUI/p7zip_32.xpm"
#undef static

extern HWND g_HWND;

#define BASE_ID_PANEL_1 (1000 + 100 * 0)
#define BASE_ID_PANEL_2 (1000 + 100 * 1)

////////////////////////////////////// Tool bar images
#include "res/AddPNG.h"
#include "res/Add2PNG.h"
#include "res/ExtractPNG.h"
#include "res/Extract2PNG.h"
#include "res/TestPNG.h"
#include "res/Test2PNG.h"
#include "res/CopyPNG.h"
#include "res/Copy2PNG.h"
#include "res/MovePNG.h"
#include "res/Move2PNG.h"
#include "res/DeletePNG.h"
#include "res/Delete2PNG.h"
#include "res/InfoPNG.h"
#include "res/Info2PNG.h"

#include <wx/mstream.h>
#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name ## _png, sizeof(name ## _png))

static inline wxBitmap _wxGetBitmapFromMemory(const unsigned char *data, int length) {
	wxMemoryInputStream is(data, length);
	return wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1);
}

///////////////////////////////////// SevenZipPanel.h /////////////////////

#include <wx/listctrl.h>

typedef wxListCtrl CExplorerListCtrl;

class MyFrame;

class SevenZipPanel : public wxPanel
{
	static int count;

	CExplorerListCtrl *m_pListCtrlExplorer;
	NWindows::NControl::CWindow2 *_wList;
	

	wxBitmapButton *m_pBmpButtonParentFolder;
	wxComboBox *m_pComboBoxPath;
	wxStatusBar *m_pStatusBar;

	MyFrame *m_frame;

	wxImageList imgList;

	int _panelIndex;

	// wxString m_currentDirectory;

	// int m_nbDirs;

	// wxString m_prompt;

public:
	SevenZipPanel(MyFrame *frame, wxWindow *parent,int id,int panelIndex);

	void registerWindow2(NWindows::NControl::CWindow2 *w)
	{
		_wList = w;
		_wList->OnMessage(WM_CREATE,0,0);
	}
		
	void OnAnyButton( wxCommandEvent &event );
	void OnSelected(wxListEvent& event);
	void OnDeselected(wxListEvent& event);
	void OnActivated(wxListEvent& event);
	void OnFocused(wxListEvent& event);
	void OnLeftDownBeginDrag(wxListEvent& event);
	void OnRightClick(wxListEvent& event);
	void OnColumnClick(wxListEvent& event);

	void OnLeftDown(wxMouseEvent &event );
	void OnRightDown(wxMouseEvent &event );

        void WriteText(const wxString& text) {
		printf("DEBUG : %ls\n",(const wchar_t *)text);
        }

	/* Don't work ...
	void OnCloseWindow(wxCloseEvent& WXUNUSED(event)) {
		_wList->OnDestroy();
	}
	*/

	void evt_destroy() {
		_wList->OnDestroy();
	}


private:
		DECLARE_EVENT_TABLE()
};



///////////////////////////////////// SevenZipPanel.h /////////////////////



class MyFrame: public wxFrame
{
public:
    // ctor
 MyFrame(void (*fct)(HWND),wxFrame *frame, const wxString& title, int x, int y, int w, int h);
    // virtual ~MyFrame();

	void registerWindow2(int baseID,NWindows::NControl::CWindow2 *w)
	{
		printf("MyFrame::registerWindow2(%d,%p)\n",baseID,w);
		switch (baseID)
		{
			case BASE_ID_PANEL_1: _panel1->registerWindow2(w); break;
			case BASE_ID_PANEL_2: _panel2->registerWindow2(w); break;
			default: printf("FIXME - MyFrame::registerWindow2\n");
		}
	}

	void PopulateToolbar(wxToolBar* toolBar);
	void RecreateToolbar();


protected:
	// callbacks
	void OnWorkerEvent(wxCommandEvent& event);
	void OnAnyMenu(wxCommandEvent& event)
	{
		extern bool OnMenuCommand(HWND hWnd, int id);
		extern void ExecuteCommand(UINT commandID);

		int wmId = event.GetId();

		if (wmId >= kToolbarStartID)
		{
			ExecuteCommand(wmId);
			return ; // 0;
		}
		OnMenuCommand(this, wmId);
	}
	void OnCloseWindow(wxCloseEvent& WXUNUSED(event))
	{
		if (_panel1) _panel1->evt_destroy();
		if (_panel2) _panel2->evt_destroy();

		extern void main_WM_DESTROY();
		main_WM_DESTROY();
		Destroy();
	}
private:
	SevenZipPanel * _panel1;
	SevenZipPanel * _panel2;
    DECLARE_EVENT_TABLE()
};

enum {
    WORKER_EVENT=100    // this one gets sent from the worker thread
};
    
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
	EVT_MENU(WORKER_EVENT, MyFrame::OnWorkerEvent)
	EVT_MENU(wxID_ANY, MyFrame::OnAnyMenu)
	EVT_CLOSE(MyFrame::OnCloseWindow)
END_EVENT_TABLE()

// My frame constructor
MyFrame::MyFrame(void (*wm_create)(HWND),wxFrame *frame, const wxString& title,
                 int x, int y, int w, int h)
       : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
{
printf("===MyFrame::MyFrame===BEGIN===\n");

	this->SetIcon(wxICON(p7zip_32));
	
	g_HWND = this; // FIXME
	
	wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );

	_panel1 = new SevenZipPanel(this,this,BASE_ID_PANEL_1,0);  // FIXME panelIndex = 0
	_panel2 = 0;
	topsizer->Add(
		_panel1,
		1,            // make vertically stretchable
		wxEXPAND |    // make horizontally stretchable
		wxALL,        //   and make border all around
		0 );         // set border width to 10

	// Create the toolbar
	// FIXME RecreateToolbar();
printf("===MyFrame::MyFrame===WM_CREATE===\n");
       wm_create(this);

       // Create the toolbar // FIXME
	RecreateToolbar();


printf("===MyFrame::MyFrame===SIZER===\n");

	SetSizer( topsizer );      // use the sizer for layout

	topsizer->SetSizeHints( this );   // set size hints to honour minimum size
printf("===MyFrame::MyFrame===END===\n");
}

void myCreateHandle(int n);
void MyFrame::OnWorkerEvent(wxCommandEvent& event)
{
	int n = event.GetInt();
	myCreateHandle(n);
}

wxWindow * g_window=0;
HWND myCreateAndShowMainWindow(LPCTSTR title,void (*fct)(HWND))
{
    MyFrame *frame = new MyFrame(fct,(wxFrame *)NULL, title, 50, 50, 450, 340);
   // Don't Show the frame !
   frame->Show(true); // FIXME

   // FIXME : SetTopWindow(g_HWND);

   g_window = frame;

   return frame;
}


class myToolBar
{
	wxToolBar * m_toolbar;

	bool m_bShowText;

public:
	myToolBar(wxToolBar * toolbar,bool bShowText ) : m_toolbar(toolbar), m_bShowText(bShowText)  { }

	myToolBar* AddTool(int toolId, const wxString& label, const wxBitmap& bitmap1, const wxString& shortHelpString = _T(""), wxItemKind kind = wxITEM_NORMAL)
	{
		wxString text = wxEmptyString;
		if (m_bShowText) text = label;

		wxSize tb_size = m_toolbar->GetToolBitmapSize();
		int tb_witdh = tb_size.GetWidth();
		int tb_height = tb_size.GetHeight();

		if ((bitmap1.GetWidth() > tb_witdh) || ( bitmap1.GetHeight()> tb_height))
		{
			wxBitmap bmp(bitmap1.ConvertToImage().Scale(tb_witdh, tb_height));
			m_toolbar->AddTool(toolId,text,bmp,shortHelpString,kind);
		}
		else
		{
			m_toolbar->AddTool(toolId,text,bitmap1,shortHelpString,kind);
		}

		return this;
	}

	void SetToolBitmapSize(const wxSize& size)
	{
		m_toolbar->SetToolBitmapSize(size);
	}

	bool Realize()
	{
		return m_toolbar->Realize();
	}

	void AddSeparator() { m_toolbar->AddSeparator(); }
};

void MyFrame::PopulateToolbar(wxToolBar* p_toolBar)
{/*
 toolBar->AddTool(wxID_NEW, _T("New"),toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_NORMAL,
 _T("New file"), _T("This is help for new file tool"));
 */
	myToolBar toolBar(p_toolBar,true);

	const int kWidth  = 24;
	const int kHeight = 24;

	// FIXME toolBar->SetToolBitmapSize(wxSize(24,24));
	toolBar.SetToolBitmapSize(wxSize(kWidth,kHeight));
	toolBar.AddTool(kAddCommand, wxT("Add"), wxGetBitmapFromMemory(ADD2));
	toolBar.AddTool(kExtractCommand,wxT("Extract"), wxGetBitmapFromMemory(EXTRACT2));
	toolBar.AddTool(kTestCommand, wxT("Test"), wxGetBitmapFromMemory(TEST2));

	toolBar.AddSeparator();

	toolBar.AddTool(IDM_COPY_TO, wxT("Copy"), wxGetBitmapFromMemory(COPY2));
	toolBar.AddTool(IDM_MOVE_TO, wxT("Move"), wxGetBitmapFromMemory(MOVE2));
	toolBar.AddTool(IDM_DELETE, wxT("Delete"), wxGetBitmapFromMemory(DELETE2));
	toolBar.AddTool(IDM_FILE_PROPERTIES, wxT("Info"), wxGetBitmapFromMemory(INFO2));

	////////////////////////////////////////////////////////

	/* FIXME
	if (g_mimeDatabase)
	{
		toolBar.AddSeparator();

		TryMime(&toolBar, _T("txt"));
		TryMime(&toolBar, _T("rar"));
		TryMime(&toolBar, _T("7z"));
	}

	toolBar.AddSeparator();

	wxIcon i_plus = wxArtProvider::GetIcon(wxART_ADD_BOOKMARK    , wxART_TOOLBAR  , wxSize(kWidth,kHeight));
	toolBar.AddTool(wxID_ANY, wxT("Add Bookmark"), i_plus);

	wxIcon i_go_up_dir = wxArtProvider::GetIcon(wxART_GO_DIR_UP   , wxART_TOOLBAR  , wxSize(kWidth,kHeight));
	toolBar.AddTool(wxID_ANY, wxT("Go up dir"), i_go_up_dir);

	wxIcon i_folder = wxArtProvider::GetIcon(wxART_FOLDER   , wxART_TOOLBAR  , wxSize(kWidth,kHeight));
	toolBar.AddTool(wxID_ANY, wxT("Folder"), i_folder);

	wxIcon i_missing_image = wxArtProvider::GetIcon(wxART_MISSING_IMAGE   , wxART_TOOLBAR  , wxSize(kWidth,kHeight));
	toolBar.AddTool(wxID_ANY, wxT("missing image"), i_missing_image);
	*/

	///////////////////////////////////////////////////////

	toolBar.Realize();

	// toolBar->SetRows(!(toolBar->IsVertical()) ? m_rows : 10 / m_rows);
}
void MyFrame::RecreateToolbar()
{
	// delete and recreate the toolbar
	wxToolBar *toolBar = GetToolBar();
	// long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;

	SetToolBar(NULL);

	delete toolBar;
	/*
	style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT);
	switch( m_toolbarPosition )
	{
	case TOOLBAR_LEFT:style |= wxTB_LEFT; break;
	case TOOLBAR_TOP: style |= wxTB_TOP;break;
	case TOOLBAR_RIGHT:style |= wxTB_RIGHT;break;
	case TOOLBAR_BOTTOM:style |= wxTB_BOTTOM;break;
	}
	*/
	long style = wxTB_FLAT | wxTB_NODIVIDER | wxTB_TEXT; // TOOLBAR_STYLE | wxTB_TOP;
	/*
	if ( m_showTooltips ) style &= ~wxTB_NO_TOOLTIPS;
	else                  style |= wxTB_NO_TOOLTIPS;

	if ( style & wxTB_TEXT && !(style & wxTB_NOICONS) && m_horzText ) style |= wxTB_HORZ_LAYOUT;
	*/
	toolBar = CreateToolBar(style, wxID_ANY);

	PopulateToolbar(toolBar);
}

void registerWindow2(int baseID,NWindows::NControl::CWindow2 *w)
{
	MyFrame * f = (MyFrame *) g_HWND;
	f->registerWindow2(baseID,w);
	
}


/////////////////////////////////////////////////////////
#include "LangUtils.h"

static const UINT kOpenBookmarkMenuID = 730;  // FIXME / duplicate
static const UINT kSetBookmarkMenuID = 740;


void rc_MyLoadMenu(HWND hWnd)
{
	wxFrame *hwnd = (wxFrame *)hWnd;
	wxMenu *m;
	wxMenu *m_file = m = new wxMenu;
	{
		m->Append(IDM_FILE_OPEN, _T("&Open\tEnter"));
		m->Append(IDM_FILE_OPEN_INSIDE,_T("Open &Inside\tCtrl+PgDn"));
		m->Append(IDM_FILE_OPEN_OUTSIDE,_T("Open O&utside\tShift+Enter"));
		m->Append(IDM_FILE_EDIT,_T("&Edit\tF4"));
		m->AppendSeparator();
		m->Append(IDM_RENAME,_T("Rena&me\tF2"));
		m->Append(IDM_COPY_TO,_T("&Copy To...\tF5"));
		m->Append(IDM_MOVE_TO,_T("&Move To...\tF6"));
		m->Append(IDM_DELETE,_T("&Delete\tDel"));
		m->AppendSeparator();
		m->Append(IDM_FILE_SPLIT,_T("&Split file..."));
		m->Append(IDM_FILE_COMBINE,_T("Com&bine files..."));
		m->AppendSeparator();
		m->Append(IDM_FILE_PROPERTIES,_T("P&roperties\tAlt+Enter"));
		m->Append(IDM_FILE_COMMENT,_T("Comme&nt\tCtrl+Z"));
		m->Append(IDM_FILE_CRC,_T("Calculate checksum"));
		m->AppendSeparator();
		m->Append(IDM_CREATE_FOLDER,_T("Create Folder\tF7"));
		m->Append(IDM_CREATE_FILE,_T("Create File\tCtrl+N"));
		m->AppendSeparator();
		m->Append(IDCLOSE,_T("E&xit\tAlt+F4"));   
	}
	wxMenu *m_edit = m = new wxMenu;
	{
		m->Append(IDM_EDIT_CUT, _T("Cu&t\tCtrl+X"))->Enable(true);              // GRAYED
		// m->Enable(IDM_EDIT_CUT, false);
		m->Append(IDM_EDIT_COPY, _T("&Copy\tCtrl+C"))->Enable(true);            // GRAYED
		m->Append(IDM_EDIT_PASTE, _T("&Paste\tCtrl+V"))->Enable(true);          // GRAYED
		m->AppendSeparator();
		m->Append(IDM_SELECT_ALL, _T("Select &All\tShift+[Grey +]")); 
		m->Append(IDM_DESELECT_ALL, _T("Deselect All\tShift+[Grey -]")); 
		m->Append(IDM_INVERT_SELECTION, _T("&Invert Selection\tGrey *"));   
		m->Append(IDM_SELECT, _T("Select...\tGrey +"));           
		m->Append(IDM_DESELECT, _T("Deselect...\tGrey -"));        
		m->Append(IDM_SELECT_BY_TYPE, _T("Select by Type\tAlt+[Grey+]")); 
		m->Append(IDM_DESELECT_BY_TYPE, _T("Deselect by Type\tAlt+[Grey -]")); 
	}
	wxMenu *m_view = m = new wxMenu;
	{
		m->AppendRadioItem(IDM_VIEW_LARGE_ICONS, _T("Lar&ge Icons\tCtrl+1"));        
		m->AppendRadioItem(IDM_VIEW_SMALL_ICONS, _T("S&mall Icons\tCtrl+2"));      
		m->AppendRadioItem(IDM_VIEW_LIST, _T("&List\tCtrl+3"));             
		m->AppendRadioItem(IDM_VIEW_DETAILS, _T("&Details\tCtrl+4"))->Check(true);  // CHECKED
		m->AppendSeparator();
		m->Append(IDM_VIEW_ARANGE_BY_NAME, _T("Name\tCtrl+F3"));               
		m->Append(IDM_VIEW_ARANGE_BY_TYPE, _T("Type\tCtrl+F4"));             
		m->Append(IDM_VIEW_ARANGE_BY_DATE, _T("Date\tCtrl+F5"));             
		m->Append(IDM_VIEW_ARANGE_BY_SIZE, _T("Size\tCtrl+F6"));               
		m->Append(IDM_VIEW_ARANGE_NO_SORT, _T("Unsorted\tCtrl+F7"));           
		m->AppendSeparator();
		m->AppendCheckItem(IDM_VIEW_FLAT_VIEW, _T("Flat View"));                   
		m->AppendCheckItem(IDM_VIEW_TWO_PANELS, _T("&2 Panels\tF9")); 

		{
			wxMenu* subMenu = new wxMenu;
			subMenu->AppendCheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, _T("Archive Toolbar"));            
			subMenu->AppendCheckItem(IDM_VIEW_STANDARD_TOOLBAR, _T("Standard Toolbar"));            
			subMenu->AppendSeparator();
			subMenu->AppendCheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, _T("Large Buttons"));               
			subMenu->AppendCheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, _T("Show Buttons Text"));           
			m->Append(12112, _T("Toolbars"), subMenu); // FIXME ID ?
		}
		m->AppendSeparator();
		m->Append(IDM_OPEN_ROOT_FOLDER, _T("Open Root Folder\t" STRING_PATH_SEPARATOR));        
		m->Append(IDM_OPEN_PARENT_FOLDER, _T("Up One Level\tBackspace"));
		m->Append(IDM_FOLDERS_HISTORY, _T("Folders History...\tAlt+F12"));
		m->AppendSeparator();
		m->Append(IDM_VIEW_REFRESH, _T("&Refresh\tCtrl+R"));
	}
	wxMenu *m_favorites = m = new wxMenu;
	{
		{
			wxMenu* subMenu = new wxMenu;
			for (int i = 0; i < 10; i++)
			{
				UString s = LangString(IDS_BOOKMARK, 0x03000720);
				s += L" ";
				wchar_t c = (wchar_t)(L'0' + i);
				s += c;
				s += L"\tAlt+Shift+";
				s += c;
				subMenu->Append( kSetBookmarkMenuID + i, wxString(s));
			}

			m->Append(12111, _T("&Add folder to Favorites as"), subMenu); // FIXME ID ?
		}
		m->AppendSeparator();
		for (int i = 0; i < 10; i++)
		{
			UString path = g_App.AppState.FastFolders.GetString(i);
			const int kMaxSize = 100;
			const int kFirstPartSize = kMaxSize / 2;
			if (path.Length() > kMaxSize)
			{
				path = path.Left(kFirstPartSize) + UString(L" ... ") +
					path.Right(kMaxSize - kFirstPartSize);
			}
			UString s = path;
			if (s.IsEmpty())
				s = L"-";
			s += L"\tAlt+";
			s += (wchar_t)(L'0' + i);
			// menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
			m->Append( kOpenBookmarkMenuID + i, wxString(s));
		}
		
	}
	wxMenu *m_tools = m = new wxMenu;
	{
		m->Append(IDM_OPTIONS, _T("&Options..."));
		m->Append(IDM_BENCHMARK, _T("&Benchmark"));
	}
	wxMenu *m_help = m = new wxMenu;
	{
		m->Append(IDM_HELP_CONTENTS, _T("&Contents...\tF1"));
		m->AppendSeparator();
		m->Append(IDM_ABOUT, _T("&About 7-Zip..."));
	}

	wxMenuBar *menuBar = new wxMenuBar;

	menuBar->Append(m_file, _T("&File"));
	menuBar->Append(m_edit, _T("&Edit"));
	menuBar->Append(m_view, _T("&View"));
	menuBar->Append(m_favorites, _T("F&avorites"));
	menuBar->Append(m_tools, _T("&Tools"));
	menuBar->Append(m_help, _T("&Help"));
	hwnd->SetMenuBar(menuBar);
}

//////////////////////////////////////////////////////////////////


static CStringTable g_stringTable[] =
{
  /* resource.rc */	  
  /***************/
	{ IDS_APP_TITLE, L"7-Zip File Manager" },

	{ IDS_COPY                , L"Copy" },
	{ IDS_MOVE                , L"Move" },
	{ IDS_COPY_TO             , L"Copy to:" },
	{ IDS_MOVE_TO             , L"Move to:" },
	{ IDS_COPYING             , L"Copying..." },
	{ IDS_MOVING              , L"Moving..." },
	{ IDS_CANNOT_COPY         , L"You cannot move or copy items for such folders." },
	{ IDS_SPLITTING           , L"Splitting..." },
	{ IDS_SPLIT_CONFIRM_TITLE , L"Confirm Splitting" },
	{ IDS_SPLIT_CONFIRM_MESSAGE , L"Are you sure you want to split file into {0} volumes?" },
	{ IDS_SPLIT_VOL_MUST_BE_SMALLER , L"Volume size must be smaller than size of original file" },

	{ IDS_COMBINE             , L"Combine Files" },
	{ IDS_COMBINE_TO          , L"&Combine to:" },
	{ IDS_COMBINING           , L"Combining..." },
	{ IDS_COMBINE_SELECT_ONE_FILE , L"Select only first file" },

	{ IDS_CHECKSUM_CALCULATING , L"Checksum calculating..." },
	{ IDS_CHECKSUM_INFORMATION , L"Checksum information" },
	{ IDS_CHECKSUM_CRC_DATA     , L"CRC checksum for data:" },
	{ IDS_CHECKSUM_CRC_DATA_NAMES , L"CRC checksum for data and names:" },

	{ IDS_SCANNING , L"Scanning..." },

	{ IDS_PROPERTIES , L"Properties" },

	{ IDS_OPERATION_IS_NOT_SUPPORTED , L"Operation is not supported." },
  
	{ IDS_CONFIRM_FILE_DELETE , L"Confirm File Delete" },
	{ IDS_CONFIRM_FOLDER_DELETE , L"Confirm Folder Delete" },
	{ IDS_CONFIRM_ITEMS_DELETE , L"Confirm Multiple File Delete" },
	{ IDS_WANT_TO_DELETE_FILE , L"Are you sure you want to delete '{0}'?" },
	{ IDS_WANT_TO_DELETE_FOLDER , L"Are you sure you want to delete the folder '{0}' and all its contents?" },
	{ IDS_WANT_TO_DELETE_ITEMS  , L"Are you sure you want to delete these {0} items?" },
	{ IDS_DELETING            , L"Deleting..." },
	{ IDS_ERROR_DELETING      , L"Error Deleting File or Folder" },
	{ IDS_RENAMING            , L"Renaming..." },
	{ IDS_ERROR_RENAMING      , L"Error Renaming File or Folder" },
	{ IDS_CONFIRM_FILE_COPY   , L"Confirm File Copy" },
	{ IDS_WANT_TO_COPY_FILES  , L"Are you sure you want to copy files to archive" },
  
	{ IDS_CREATE_FOLDER       , L"Create Folder" },
	{ IDS_CREATE_FOLDER_NAME  , L"Folder name:" },
	{ IDS_CREATE_FOLDER_DEFAULT_NAME , L"New Folder" },
	{ IDS_CREATE_FOLDER_ERROR , L"Error Creating Folder" },
	{ IDS_CREATE_FILE         , L"Create File" },
	{ IDS_CREATE_FILE_NAME    , L"File Name:" },
	{ IDS_CREATE_FILE_DEFAULT_NAME , L"New File" },
	{ IDS_CREATE_FILE_ERROR   , L"Error Creating File" },
	{ IDS_SELECT              , L"Select" },
	{ IDS_DESELECT            , L"Deselect" },
	{ IDS_SELECT_MASK         , L"Mask:" },
	{ IDS_FOLDERS_HISTORY     , L"Folders History" },
	{ IDS_N_SELECTED_ITEMS    , L"{0} object(s) selected" },
	{ IDS_FILES_COLON         , L"Files:" },
	{ IDS_FOLDERS_COLON       , L"Folders:" },
	{ IDS_SIZE_COLON          , L"Size:" },

	{ IDS_PROP_TOTAL_SIZE     , L"Total Size" },
	{ IDS_PROP_FREE_SPACE     , L"Free Space" },
	{ IDS_PROP_CLUSTER_SIZE   , L"Cluster Size" },
	{ IDS_PROP_VOLUME_NAME    , L"Label" },
	{ IDS_PROP_LOCAL_NAME     , L"Local Name" },
	{ IDS_PROP_PROVIDER       , L"Provider" },
	{ IDS_OPTIONS             , L"Options" },
	{ IDS_COMMENT             , L"Comment" },
	{ IDS_COMMENT2            , L"&Comment:" },
	{ IDS_SYSTEM              , L"System" },
	{ IDS_TOO_MANY_ITEMS      , L"Too many items" },
	{ IDS_WANT_UPDATE_MODIFIED_FILE , L"File '{0}' was modified.\nDo you want to update it in the archive?" },
	{ IDS_CANNOT_UPDATE_FILE  , L"Can not update file\n'{0}'" },
	{ IDS_CANNOT_START_EDITOR , L"Cannot start editor." },
	{ IDS_OPENNING            , L"Opening..." },
	{ IDS_ADD                 , L"Add" },
	{ IDS_EXTRACT             , L"Extract" },
	{ IDS_TEST                , L"Test" },
	{ IDS_BUTTON_COPY         , L"Copy" },
	{ IDS_BUTTON_MOVE         , L"Move" },
	{ IDS_BUTTON_DELETE       , L"Delete" },
	{ IDS_BUTTON_INFO         , L"Info" },
	{ IDS_BOOKMARK            , L"Bookmark" },
	{ IDS_COMPUTER            , L"Computer" },
	{ IDS_NETWORK             , L"Network" },

	{ IDS_PROGRESS_TESTING    , L"Testing" },
	{ IDS_MESSAGE_NO_ERRORS   , L"There are no errors" },
 
	{ 0 , 0 }
};

REGISTER_STRINGTABLE(g_stringTable)

/////////////////////////////////////////////////////

#include "res/ParentFolder.h"

	SevenZipPanel::SevenZipPanel(MyFrame *frame, wxWindow *parent,int id,int panelIndex) :
	       	wxPanel(parent,id) , m_frame(frame), _wList(0)
	{
		_panelIndex = panelIndex;

		int _baseID = id; // FIXME
		int _listID = _baseID + 1;
		int _comboBoxID = _baseID + 3;
		int _statusBarID = _comboBoxID + 1;
		int kParentFolderID = 100; // FIXME Panel.h


		///Sizer for adding the controls created by users
		wxBoxSizer* pMainSizer = new wxBoxSizer(wxVERTICAL);
		int sizes[] = {150, 250, 350, -1};
		wxArrayString pathArray;
		wxBoxSizer *pPathSizer = new wxBoxSizer(wxHORIZONTAL);
		m_pBmpButtonParentFolder = new wxBitmapButton(this, kParentFolderID, wxGetBitmapFromMemory(PARENT_FOLDER), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW);
		m_pComboBoxPath = new wxComboBox(this, _comboBoxID, wxEmptyString, wxDefaultPosition, wxSize(300,-1), pathArray, wxCB_DROPDOWN | wxCB_SORT );
		pPathSizer->Add(m_pBmpButtonParentFolder, 0, wxALL|wxEXPAND, 0);
		pPathSizer->Add(m_pComboBoxPath, 1, wxALL|wxEXPAND, 5);

		m_pListCtrlExplorer = new CExplorerListCtrl(this,_listID,wxDefaultPosition, wxSize(300,300),
			wxLC_REPORT |
			wxSUNKEN_BORDER | wxLC_EDIT_LABELS);

		printf("DEBUG : new CExplorerListCtrl(id=%d) => %p\n",_listID,m_pListCtrlExplorer);

		m_pStatusBar = new wxStatusBar(this, _statusBarID);
		m_pStatusBar->SetFieldsCount(4, sizes);
		pMainSizer->Add(pPathSizer, 0, wxALL|wxEXPAND, 0);
		pMainSizer->Add(m_pListCtrlExplorer, 1, wxALL|wxEXPAND, 0);
		pMainSizer->Add(m_pStatusBar, 0, wxALL|wxEXPAND, 0);
		SetSizer(pMainSizer);
		SetAutoLayout (true);
		Layout();

		
		// m_pListCtrlExplorer->SetDropTarget(new DnDFile(this));

	}

	void SevenZipPanel::OnAnyButton( wxCommandEvent &event )
	{
		count++;

		int id = event.GetId();

		wxString msg = wxString::Format(_T("P %d : button %d \n"), count,id);

		WriteText(msg);

		_wList->OnMessage(WM_COMMAND , id , 0);
	}

	void SevenZipPanel::OnSelected(wxListEvent& event)
	{
		const wxListItem & item = event.GetItem();
		count++;

		wxString msg = wxString::Format(_T("P %d : OnSelected %d \n"), count,event.GetId());

		WriteText(msg);

		NMLISTVIEW info;
		info.hdr.hwndFrom = m_pListCtrlExplorer;
		info.hdr.code     = LVN_ITEMCHANGED;
		info.uOldState    = 0;
		info.uNewState    = LVIS_SELECTED;
		info.lParam       = item.GetData(); // event.GetIndex(); // FIXME ? event.GetData();
		_wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
		/*
		if ( GetWindowStyle() & wxLC_REPORT )
		{
		wxListItem info;
		info.m_itemId = event.m_itemIndex;
		info.m_col = 1;
		info.m_mask = wxLIST_MASK_TEXT;
		if ( GetItem(info) )
		{
		wxLogMessage(wxT("Value of the 2nd field of the selected item: %s"),
		info.m_text.c_str());
		}
		else
		{
		wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
		}
		}
		*/
	}

	void SevenZipPanel::OnDeselected(wxListEvent& event)
	{
		const wxListItem & item = event.GetItem();
		count++;
		wxString msg = wxString::Format(_T("P %d : OnDeselected %d \n"), count,event.GetId());
		WriteText(msg);

		NMLISTVIEW info;
		info.hdr.hwndFrom = m_pListCtrlExplorer;
		info.hdr.code     = LVN_ITEMCHANGED;
		info.uOldState    = LVIS_SELECTED;
		info.uNewState    = 0;
		info.lParam       = item.GetData(); // event.GetIndex(); // FIXME ? event.GetData();
		_wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
	}

	void SevenZipPanel::OnColumnClick(wxListEvent& event)
	{
		count++;
		wxString msg = wxString::Format(_T("P %d : OnColumnClick %d col=%d\n"), count,event.GetId(),event.GetColumn());
		WriteText(msg);

		NMLISTVIEW info;
		info.hdr.hwndFrom = m_pListCtrlExplorer;
		info.hdr.code     = LVN_COLUMNCLICK;
		info.iSubItem     = event.GetColumn();
		_wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);

	}


	void SevenZipPanel::OnActivated(wxListEvent& event)
	{
		count++;

		int ind = event.GetIndex();

		NMHDR info;
		info.hwndFrom = m_pListCtrlExplorer;
		info.code     = NM_DBLCLK;
		_wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);

		/*
		if ((ind >= 0) && ( ind < m_nbDirs))
		{
			wxString msg = wxString::Format(_T("P %d : OnActivated %d : DIR = %d\n"), count,event.GetId(),ind);
			WriteText(msg);

			wxString name = m_pListCtrlExplorer->GetItemText(ind);

			wxFileName filename (m_currentDirectory,name);
			BinPath(filename.GetFullPath());

		}
		else
		*/
		{
			wxString msg = wxString::Format(_T("P %d : OnActivated %d : FILE = %d\n"), count,event.GetId(),ind);
			WriteText(msg);
		}


	}

	void SevenZipPanel::OnFocused(wxListEvent& event)
	{
		count++;

		wxString msg = wxString::Format(_T("P %d : OnFocused %d \n"), count,event.GetId());

		WriteText(msg);

		event.Skip();
	}

	void SevenZipPanel::OnLeftDownBeginDrag(wxListEvent& event)
	{
		count++;

		wxString msg = wxString::Format(_T("P %d : OnLeftDownBeginDrag %d \n"), count,event.GetId());
		WriteText(msg);

#if 0		
		if (   m_pListCtrlExplorer->GetSelectedItemCount() < 1) return ;

        // start drag operation
        wxFileDataObject filesData;


	long item = -1;
    for ( ;; )
    {
        item = m_pListCtrlExplorer->GetNextItem(item,
                                     wxLIST_NEXT_ALL,
                                     wxLIST_STATE_SELECTED);
        if ( item == -1 )
            break;

        // this item is selected - do whatever is needed with it
        // wxLogMessage("Item %ld is selected.", item);
		wxString file = m_currentDirectory + _T("/") + m_pListCtrlExplorer->GetItemText(item);

		filesData.AddFile(file);

    }

		msg = wxString::Format(_T("P %d : wxDropSource %d \n"), count,event.GetId());
		WriteText(msg);

        wxDropSource source(filesData, this,
                            wxDROP_ICON(dnd_copy),
                            wxDROP_ICON(dnd_move),
                            wxDROP_ICON(dnd_none));

        int flags = 0;
		/*
        if ( m_moveByDefault )
            flags |= wxDrag_DefaultMove;
        else if ( m_moveAllow )
            flags |= wxDrag_AllowMove;
			*/
		flags |= wxDrag_AllowMove;

		msg = wxString::Format(_T("P %d : DoDragDrop %d \n"), count,event.GetId());
		WriteText(msg);


        wxDragResult result = source.DoDragDrop(flags);


        const wxChar *pc;
        switch ( result )
        {
            case wxDragError:   pc = _T("Error!");    break;
            case wxDragNone:    pc = _T("Nothing");   break;
            case wxDragCopy:    pc = _T("Copied");    break;
            case wxDragMove:    pc = _T("Moved");     break;
            case wxDragCancel:  pc = _T("Cancelled"); break;
            default:            pc = _T("Huh?");      break;
        }

        WriteText(wxString(_T("    Drag result: ")) + pc);
#endif
	}

void SevenZipPanel::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
{
	WriteText(_T("OnLeftDown"));
#if 0
    if ( !m_strText.empty() )
    {
        // start drag operation
        wxTextDataObject textData(m_strText);
        wxDropSource source(textData, this,
                            wxDROP_ICON(dnd_copy),
                            wxDROP_ICON(dnd_move),
                            wxDROP_ICON(dnd_none));

        int flags = 0;
        if ( m_moveByDefault )
            flags |= wxDrag_DefaultMove;
        else if ( m_moveAllow )
            flags |= wxDrag_AllowMove;

        wxDragResult result = source.DoDragDrop(flags);

#if wxUSE_STATUSBAR
        const wxChar *pc;
        switch ( result )
        {
            case wxDragError:   pc = _T("Error!");    break;
            case wxDragNone:    pc = _T("Nothing");   break;
            case wxDragCopy:    pc = _T("Copied");    break;
            case wxDragMove:    pc = _T("Moved");     break;
            case wxDragCancel:  pc = _T("Cancelled"); break;
            default:            pc = _T("Huh?");      break;
        }

        SetStatusText(wxString(_T("Drag result: ")) + pc);
#else
        wxUnusedVar(result);
#endif // wxUSE_STATUSBAR
    }
#endif // wxUSE_DRAG_AND_DROP
}

void SevenZipPanel::OnRightClick(wxListEvent& event)
{
	wxPoint point = event.GetPoint(); 

	WriteText(_T("OnRightClick"));
    wxMenu menu; // (_T("Dnd sample menu"));

    menu.Append(wxID_ANY, _T("&Test drag..."));
    menu.AppendSeparator();
    menu.Append(wxID_ANY, _T("item1"));
    menu.Append(wxID_ANY, _T("item2"));
    menu.Append(wxID_ANY, _T("item3"));
    menu.Append(wxID_ANY, _T("&About"));

    PopupMenu( &menu, point.x, point.y );
}

int SevenZipPanel::count = 0;

BEGIN_EVENT_TABLE(SevenZipPanel, wxPanel)
// EVT_MENU(wxID_ANY, SevenZipPanel::OnAnyMenu)
// EVT_LISTBOX   (wxID_ANY,       MyPanel::OnListBox)
// EVT_LISTBOX_DCLICK(wxID_ANY,          MyPanel::OnAnyListBoxDoubleClick)
EVT_BUTTON    (wxID_ANY,      SevenZipPanel::OnAnyButton)

 // EVT_CLOSE(SevenZipPanel::OnCloseWindow)

/////////////////
EVT_LIST_ITEM_SELECTED(wxID_ANY,   SevenZipPanel::OnSelected)
EVT_LIST_ITEM_DESELECTED(wxID_ANY, SevenZipPanel::OnDeselected)
EVT_LIST_ITEM_ACTIVATED(wxID_ANY,  SevenZipPanel::OnActivated)
EVT_LIST_ITEM_FOCUSED(wxID_ANY,  SevenZipPanel::OnFocused)

EVT_LIST_BEGIN_DRAG(wxID_ANY, SevenZipPanel::OnLeftDownBeginDrag)
EVT_LIST_ITEM_RIGHT_CLICK(wxID_ANY, SevenZipPanel::OnRightClick)

EVT_LIST_COL_CLICK(wxID_ANY, SevenZipPanel::OnColumnClick)

END_EVENT_TABLE()