Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Program of the Week PW5 Page 1 This week the Notepad program will be finished. This week is going to add a 'File Save' option allowing selection of a file to write the wxTextCtrl into a file. The...

1 answer below »
Program of the Week PW5 Page 1
This week the Notepad program will be finished.
This week is going to add a 'File Save' option allowing selection of a file to write the wxTextCtrl into a
file.
The existing wxEditor program (PW4) will be further modified to include a save file dialog according
to the following instructions.
Modifications to the wxEditor project code.
Header file: In wxEditorMain.h is the wxEditorFrame class declaration
1. A declaration for a wxFileDialog pointer has to be added just below the wxTextCtrl pointer
declaration:
wxFileDialog* saveDialog
2. there is an enum list declaring ID items as follows:
enum
{
XXXXXXXXXXidMenuQuit = 1000,
XXXXXXXXXXID_TextBox,
XXXXXXXXXXidMenuOpen,
XXXXXXXXXXidMenuAbout
};
add another ID entry for file save: idMenuSave
3. there is the following list for menu items
XXXXXXXXXXvoid OnClose(wxCloseEvent& event);
XXXXXXXXXXvoid OnQuit(wxCommandEvent& event);
XXXXXXXXXXvoid OnAbout(wxCommandEvent& event);
add another item for OnSave command event.
Code file: In wxEditorMain.cpp are pieces which constitute the Frame components of the program.
4. There is the event table connecting event ID's to member functions of the wxEditorFrame
BEGIN_EVENT_TABLE(wxHelloWorld2Frame, wxFrame)
EVT_CLOSE(wxHelloWorld2Frame::OnClose)
EVT_MENU(idMenuQuit, wxHelloWorld2Frame::OnQuit)
EVT_MENU(idMenuAbout, wxHelloWorld2Frame::OnAbout)
EVT_MENU(idMenuOpen, wxHelloWorld2Frame::OnOpen)
END_EVENT_TABLE()
Add an event table item connecting idMenuSave with OnSave function
Program of the Week PW5 Page 2
5. Part of the wxEditorFrame constructor is code to create the menu ba

create a menu ba
wxMenuBar* mbar = new wxMenuBar();
wxMenu* fileMenu = new wxMenu(_T(""));
fileMenu->Append(idMenuOpen, _("&Open\tAlt-F5"), _("Open a file"));
fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application"));
mbar->Append(fileMenu, _("&File"));
Add a ‘Save’ fileMenu item to save a file. Append the item 'Save', with explanatory text 'Save a file'
connecting the idMenuSave event.
6. Add a member function which actually create a File Dialog instance. 'File Save' code is added to
open/load a selected file.
void wxHelloWorldFrame::OnSave(wxCommandEvent &event)
{
}
This is the code which will do those 4 items. The intention is that you study these 4 lines of code and
develop an understanding of what they are doing.
1. Create an instance of the wxFileDialog
wxFileDialog *saveDialog = new wxFileDialog(this, wxT("Choose a file"), wxT(""), wxT(""),
wxT("Text Files (*.txt)|*.txt|C++ Files (*.cpp)|*.cpp|Header Files (*.h)|*.h"),
wxFD_SAVE );
To get the file save dialog, wxFD_OPEN style is replaced with wxFD_SAVE
2. Cause the instance to 'pop-up' (ShowModal)
int response = saveDialog->ShowModal();
get response from the dialog
3. Check if the response is 'OK'’. Save the wxTextCtrl inside the wxFrame to the selected file
if(response == wxID_OK)
{
if response ok, then load contents into textControl
XXXXXXXXXXthis->textControl->SaveFile(saveDialog->GetPath());
}
Build and run the finished program. Turn in a screen copy with the file save dialog activated and the
Application Frame with the Time and Date in the Status Ba
See below:
Program of the Week PW5 Page 3

Homework 6
Make sure you add the time and date to your work when completed so it can be seen when reviewed
Containers:
For each of the containers below, give a 2 or 3 sentence description of how it works. Additionally,
give an example of the constructors (default and overloaded). There are usually 3 or 4 of these. All
the information is available through a reference site like the one below. This includes examples of
the constructors as actual code
www.cplusplus.com
1. vecto
2. list
3. queue
4. stack
5. set
6. map
7. multiset
8. multimap
Algorithms
For the algorithms below, give a 2 or 3 sentence description of how it works and what the calling
arguments are. Give an example of how the algorithm is called
9. find
10. search
11. copy
12. move
13. swap
14. sort
15. max
Answered 1 days After Oct 18, 2021

Solution

Karthi answered on Oct 20 2021
120 Votes
88_cpp_94036
esource.rc
aaaa ICON "wx/msw/std.ico"
#include "wx/msw/wx.rc"
88_cpp_94036/wxEditorApp.cpp
88_cpp_94036/wxEditorApp.cpp
#ifdef WX_PRECOMP
#include "wx_pch.h"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
#endif 
__BORLANDC__
#include "wxEditorApp.h"
#include "wxEditorMain.h"
IMPLEMENT_APP(wxEditorApp);
ool wxEditorApp::OnInit()
{
    wxEditorFrame* frame = new wxEditorFrame(0L, _("wxWidgets Application Template"));
    frame->SetIcon(wxICON(aaaa)); 
 To Set App Icon
    frame->Show();
    
    return true;
}
88_cpp_94036/wxEditorApp.h
#ifndef WXEDITORAPP_H
#define WXEDITORAPP_H
#include class wxEditorApp : public wxApp
{
public:
virtual bool OnInit();
};
#endif
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here