diff --git a/utils/Install/builder/makefile.vc b/utils/Install/builder/makefile.vc index af02a4b4bd..5c17461960 100644 --- a/utils/Install/builder/makefile.vc +++ b/utils/Install/builder/makefile.vc @@ -4,7 +4,7 @@ # Set WXDIR for your system WXDIR = $(WXWIN) -PROGRAM=toolbar +PROGRAM=wxib OBJECTS = $(PROGRAM).obj !include $(WXDIR)\src\makeprog.vc diff --git a/utils/Install/builder/wxib.RES b/utils/Install/builder/wxib.RES deleted file mode 100644 index 10bb972535..0000000000 Binary files a/utils/Install/builder/wxib.RES and /dev/null differ diff --git a/utils/Install/builder/wxib.cpp.1 b/utils/Install/builder/wxib.cpp.1 deleted file mode 100644 index 9eb863643b..0000000000 --- a/utils/Install/builder/wxib.cpp.1 +++ /dev/null @@ -1,500 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wxib.cpp -// Purpose: wxInstall Builder -// Author: Julian Smart -// Author: Brian Smith -// Modified by: -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx/wx.h". -#include - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP - #include -#endif - -#include -#include -#include - -// define this to 1 to use wxToolBarSimple instead of the native one -#define USE_GENERIC_TBAR 0 - -#if USE_GENERIC_TBAR - #if !wxUSE_TOOLBAR_SIMPLE - #error wxToolBarSimple is not compiled in, set wxUSE_TOOLBAR_SIMPLE \ - to 1 in setup.h and recompile the library. - #else - #include - #endif -#endif // USE_GENERIC_TBAR - -// ---------------------------------------------------------------------------- -// resources -// ---------------------------------------------------------------------------- - -#if defined(__WXGTK__) || defined(__WXMOTIF__) - #include "mondrian.xpm" - #include "bitmaps/new.xpm" - #include "bitmaps/open.xpm" - #include "bitmaps/save.xpm" - #include "bitmaps/copy.xpm" - #include "bitmaps/cut.xpm" - #include "bitmaps/preview.xpm" // paste XPM - #include "bitmaps/print.xpm" - #include "bitmaps/help.xpm" -#endif // GTK or Motif - -// ---------------------------------------------------------------------------- -// classes -// ---------------------------------------------------------------------------- - -// Define a new application -class MyApp : public wxApp -{ -public: - bool OnInit(); -}; - -// Define a new frame -class MyFrame: public wxFrame -{ -public: - MyFrame(wxFrame *parent, - wxWindowID id = -1, - const wxString& title = "wxInstall Builder", - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE); - - void RecreateToolbar(); - - void OnQuit(wxCommandEvent& event); - void OnAbout(wxCommandEvent& event); - - void OnToggleToolbarSize(wxCommandEvent& event); - void OnToggleToolbarOrient(wxCommandEvent& event); - void OnToggleToolbarRows(wxCommandEvent& event); - - void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); } - void OnDeletePrint(wxCommandEvent& WXUNUSED(event)) { DoDeletePrint(); } - void OnInsertPrint(wxCommandEvent& event); - void OnToggleHelp(wxCommandEvent& WXUNUSED(event)) { DoToggleHelp(); } - - void OnToolLeftClick(wxCommandEvent& event); - void OnListBoxDoubleClick(wxCommandEvent& event); - - void OnCombo(wxCommandEvent& event); - - void OnUpdateCopyAndCut(wxUpdateUIEvent& event); - -#if USE_GENERIC_TBAR - virtual wxToolBar *OnCreateToolBar(long style, - wxWindowID id, - const wxString& name ); -#endif // USE_GENERIC_TBAR - -private: - void DoEnablePrint(); - void DoDeletePrint(); - void DoToggleHelp(); - - bool m_smallToolbar, - m_horzToolbar; - size_t m_rows; // 1 or 2 only - - wxTextCtrl* m_textWindow; - wxListBox* m_listBox; - - DECLARE_EVENT_TABLE() -}; - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -const int ID_TOOLBAR = 500; - -enum -{ - IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200, - IDM_TOOLBAR_TOGGLETOOLBARORIENT, - IDM_TOOLBAR_TOGGLETOOLBARROWS, - IDM_TOOLBAR_ENABLEPRINT, - IDM_TOOLBAR_DELETEPRINT, - IDM_TOOLBAR_INSERTPRINT, - IDM_TOOLBAR_TOGGLEHELP, - - ID_COMBO = 1000, - ID_LISTBOX -}; - -// ---------------------------------------------------------------------------- -// event tables -// ---------------------------------------------------------------------------- - -// Notice that wxID_HELP will be processed for the 'About' menu and the toolbar -// help button. - -BEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_MENU(wxID_EXIT, MyFrame::OnQuit) - EVT_MENU(wxID_HELP, MyFrame::OnAbout) - - EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize) - EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient) - EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows) - - EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint) - EVT_MENU(IDM_TOOLBAR_DELETEPRINT, MyFrame::OnDeletePrint) - EVT_MENU(IDM_TOOLBAR_INSERTPRINT, MyFrame::OnInsertPrint) - EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp) - - EVT_MENU(-1, MyFrame::OnToolLeftClick) - - EVT_LISTBOX_DCLICK(ID_LISTBOX, MyFrame::OnListBoxDoubleClick) - EVT_COMBOBOX(ID_COMBO, MyFrame::OnCombo) - - EVT_UPDATE_UI(wxID_COPY, MyFrame::OnUpdateCopyAndCut) - EVT_UPDATE_UI(wxID_CUT, MyFrame::OnUpdateCopyAndCut) -END_EVENT_TABLE() - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// MyApp -// ---------------------------------------------------------------------------- - -IMPLEMENT_APP(MyApp) - -// The `main program' equivalent, creating the windows and returning the -// main frame -bool MyApp::OnInit() -{ - // Create the main frame window - MyFrame* frame = new MyFrame((wxFrame *) NULL, -1, - "wxInstall Builder", - wxPoint(100, 100), wxSize(450, 300)); - - frame->SetAutoLayout(TRUE); - - frame->Show(TRUE); - - frame->SetStatusText("Welcome to wxWindows Install Builder"); - - SetTopWindow(frame); - - return TRUE; -} - -void MyFrame::RecreateToolbar() -{ - // delete and recreate the toolbar - wxToolBarBase *toolBar = GetToolBar(); - delete toolBar; - - SetToolBar(NULL); - - long style = wxNO_BORDER | wxTB_FLAT | wxTB_DOCKABLE; - style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL; - - toolBar = CreateToolBar(style, ID_TOOLBAR); - toolBar->SetMargins( 4, 4 ); - - // Set up toolbar - wxBitmap toolBarBitmaps[8]; - - toolBarBitmaps[0] = wxBITMAP(new); - toolBarBitmaps[1] = wxBITMAP(open); - toolBarBitmaps[2] = wxBITMAP(save); - toolBarBitmaps[3] = wxBITMAP(copy); - toolBarBitmaps[4] = wxBITMAP(cut); - toolBarBitmaps[5] = wxBITMAP(paste); - toolBarBitmaps[6] = wxBITMAP(print); - toolBarBitmaps[7] = wxBITMAP(help); - - if ( !m_smallToolbar ) - { - int w = 2*toolBarBitmaps[0].GetWidth(), - h = 2*toolBarBitmaps[0].GetHeight(); - for ( size_t n = 0; n < WXSIZEOF(toolBarBitmaps); n++ ) - { - toolBarBitmaps[n] = - wxImage(toolBarBitmaps[n]).Scale(w, h).ConvertToBitmap(); - } - - toolBar->SetToolBitmapSize(wxSize(w, h)); - } - -#ifdef __WXMSW__ - int width = 24; -#else - int width = 16; -#endif - - int currentX = 5; - - toolBar->AddTool(wxID_NEW, toolBarBitmaps[0], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New script"); - currentX += width + 5; - toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open script"); - - // neither the generic nor Motif native toolbars really support this - currentX += width + 5; - toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Save script"); - currentX += width + 5; - toolBar->AddTool(wxID_COPY, toolBarBitmaps[3], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Copy"); - currentX += width + 5; - toolBar->AddTool(wxID_CUT, toolBarBitmaps[4], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Cut"); - currentX += width + 5; - toolBar->AddTool(wxID_PASTE, toolBarBitmaps[5], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste"); - currentX += width + 5; - toolBar->AddSeparator(); - toolBar->AddTool(wxID_HELP, toolBarBitmaps[7], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help button"); - - // after adding the buttons to the toolbar, must call Realize() to reflect - // the changes - toolBar->Realize(); - - toolBar->SetRows(m_horzToolbar ? m_rows : 10 / m_rows); -} - -// ---------------------------------------------------------------------------- -// MyFrame -// ---------------------------------------------------------------------------- - -// Define my frame constructor -MyFrame::MyFrame(wxFrame* parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style) - : wxFrame(parent, id, title, pos, size, style) -{ - m_listBox = new wxListBox(this, ID_LISTBOX, wxPoint(0,0), wxSize(-1, -1)); - - m_listBox->Append("loadwxr"); - m_listBox->Append("closeold"); - m_listBox->Append("mleview"); - m_listBox->Append("setbutton"); - m_listBox->Append("getcheck"); - m_listBox->Append("message"); - m_listBox->Append("disable"); - m_listBox->Append("settext"); - m_listBox->Append("gettext"); - m_listBox->Append("grabfile"); - m_listBox->Append("remove"); - m_listBox->Append("system"); - m_listBox->Append("startinst"); - - wxLayoutConstraints *b1 = new wxLayoutConstraints; - b1->left.SameAs (this, wxLeft, 0); - b1->top.SameAs (this, wxTop, 0); - b1->width.PercentOf (this, wxWidth, 20); - b1->bottom.SameAs (this, wxBottom, 0); - m_listBox->SetConstraints(b1); - - m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0,0), wxSize(-1, -1), wxTE_MULTILINE); - - wxLayoutConstraints *b2 = new wxLayoutConstraints; - b2->top.SameAs (this, wxTop, 0); - b2->left.SameAs (m_listBox, wxRight, 0); - b2->width.PercentOf (this, wxWidth, 80); - b2->bottom.SameAs (this, wxBottom, 0); - m_textWindow->SetConstraints(b2); - - m_smallToolbar = TRUE; - m_horzToolbar = TRUE; - m_rows = 1; - - // Give it a status line - CreateStatusBar(); - - // Give it an icon - SetIcon(wxICON(mondrian)); - - wxMenu *fileMenu = new wxMenu; - fileMenu->Append(500, "&New Script", "New wxInstall Script" ); - fileMenu->Append(501, "&Save Script", "Save wxInstall Script" ); - fileMenu->Append(502, "&Open Script", "Open wxInstall Script" ); - fileMenu->AppendSeparator(); - fileMenu->Append(503, "N&ew Project", "New wxInstall Project" ); - fileMenu->Append(504, "S&ave Project", "Save wxInstall Project" ); - fileMenu->Append(505, "O&pen Project", "Open wxInstall Project" ); - fileMenu->AppendSeparator(); - fileMenu->Append(wxID_EXIT, "E&xit", "Quit wxInstall Builder" ); - - wxMenu *helpMenu = new wxMenu; - helpMenu->Append(wxID_HELP, "&About", "About wxInstall Builder"); - - wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE ); - - menuBar->Append(fileMenu, "&File"); - menuBar->Append(helpMenu, "&Help"); - - // Associate the menu bar with the frame - SetMenuBar(menuBar); - - // Create the toolbar - RecreateToolbar(); -} - -#if USE_GENERIC_TBAR - -wxToolBar* MyFrame::OnCreateToolBar(long style, - wxWindowID id, - const wxString& name) -{ - return (wxToolBar *)new wxToolBarSimple(this, id, - wxDefaultPosition, wxDefaultSize, - style, name); -} - -#endif // USE_GENERIC_TBAR - -void MyFrame::OnToggleToolbarSize(wxCommandEvent& WXUNUSED(event)) -{ - m_smallToolbar = !m_smallToolbar; - - RecreateToolbar(); -} - -void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event)) -{ - // m_rows may be only 1 or 2 - m_rows = 3 - m_rows; - - GetToolBar()->SetRows(m_horzToolbar ? m_rows : 10 / m_rows); - - //RecreateToolbar(); -- this is unneeded -} - -void MyFrame::OnToggleToolbarOrient(wxCommandEvent& WXUNUSED(event)) -{ - m_horzToolbar = !m_horzToolbar; - - RecreateToolbar(); -} - -void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) -{ - Close(TRUE); -} - -void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) -{ - (void)wxMessageBox("wxInstall Builder by Brian Smith", "About wxInstall Builder"); -} - -void MyFrame::OnToolLeftClick(wxCommandEvent& event) -{ - /*wxString str; - str.Printf( _T("Clicked on tool %d\n"), event.GetId()); - m_textWindow->WriteText( str ); - - if (event.GetId() == wxID_HELP) - { - if ( event.GetExtraLong() != 0 ) - m_textWindow->WriteText( _T("Help button down now.\n") ); - else - m_textWindow->WriteText( _T("Help button up now.\n") ); - } - - if (event.GetId() == wxID_COPY) - { - DoEnablePrint(); - } - - if (event.GetId() == wxID_CUT) - { - DoToggleHelp(); - } - - if (event.GetId() == wxID_PRINT) - { - DoDeletePrint(); - } */ -} - -void MyFrame::OnCombo(wxCommandEvent& event) -{ - wxLogStatus(_T("Combobox string '%s' selected"), event.GetString().c_str()); -} - -void MyFrame::DoEnablePrint() -{ - wxToolBarBase *tb = GetToolBar(); - if (tb->GetToolEnabled(wxID_PRINT)) - tb->EnableTool( wxID_PRINT, FALSE ); - else - tb->EnableTool( wxID_PRINT, TRUE ); -} - -void MyFrame::DoDeletePrint() -{ - wxToolBarBase *tb = GetToolBar(); - - tb->DeleteTool( wxID_PRINT ); -} - -void MyFrame::DoToggleHelp() -{ - wxToolBarBase *tb = GetToolBar(); - tb->ToggleTool( wxID_HELP, !tb->GetToolState( wxID_HELP ) ); -} - -void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent& event) -{ - /*event.Enable( m_textWindow->CanCopy() );*/ -} - -void MyFrame::OnInsertPrint(wxCommandEvent& WXUNUSED(event)) -{ - wxBitmap bmp = wxBITMAP(print); - - GetToolBar()->InsertTool(0, wxID_PRINT, bmp, wxNullBitmap, - FALSE, (wxObject *) NULL, - "Delete this tool", - "This button was inserted into the toolbar"); - - GetToolBar()->Realize(); -} - -void MyFrame::OnListBoxDoubleClick( wxCommandEvent &event ) -{ - wxString str = event.GetString(); - if(strcmp(str, "closeold")==0) - { - m_textWindow->AppendText("closeold\n"); - } - else if(strcmp(str, "system")==0) - { - wxTextEntryDialog dialog2(this, - "Please enter the command to execute", - "wxInstall Builder", - "", - wxOK | wxCANCEL); - - if (dialog2.ShowModal() == wxID_OK) - { - m_textWindow->AppendText("system,"); - m_textWindow->AppendText(dialog2.GetValue()); - m_textWindow->AppendText("\n"); - } - } - -}