OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ProximCmdHistoryWindow Class Reference

#include <ProximCmdHistoryWindow.hh>

Inheritance diagram for ProximCmdHistoryWindow:
Inheritance graph
Collaboration diagram for ProximCmdHistoryWindow:
Collaboration graph

Public Member Functions

 ProximCmdHistoryWindow (ProximMainFrame *parent, wxWindowID id, ProximLineReader &lineReader)
 
virtual ~ProximCmdHistoryWindow ()
 
- Public Member Functions inherited from ProximSimulatorWindow
virtual void reset ()
 

Private Types

enum  { ID_LIST = 10000 , ID_SAVE , ID_CLOSE , ID_LINE }
 

Private Member Functions

void onSimulatorCommand (SimulatorEvent &event)
 
void updateCommandList ()
 
wxSizer * createContents (wxWindow *parent, bool set_sizer, bool call_fit)
 
void onClose (wxCommandEvent &event)
 
void onSave (wxCommandEvent &event)
 
void onCommandDClick (wxCommandEvent &event)
 

Private Attributes

ProximLineReaderlineReader_
 Line reader storing the command history.
 
wxListBox * cmdList_
 ListBox widget displaying the command history.
 

Additional Inherited Members

- Protected Member Functions inherited from ProximSimulatorWindow
 ProximSimulatorWindow (ProximMainFrame *mainFrame, wxWindowID id=-1, wxPoint pos=wxDefaultPosition, wxSize size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
 
virtual ~ProximSimulatorWindow ()
 

Detailed Description

Window for browsing Proxim command history.

Definition at line 47 of file ProximCmdHistoryWindow.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_LIST 
ID_SAVE 
ID_CLOSE 
ID_LINE 

Definition at line 65 of file ProximCmdHistoryWindow.hh.

Constructor & Destructor Documentation

◆ ProximCmdHistoryWindow()

ProximCmdHistoryWindow::ProximCmdHistoryWindow ( ProximMainFrame parent,
wxWindowID  id,
ProximLineReader lineReader 
)

The Constructor.

Parameters
parentProxim main frame.
lineReaderLine reader handling the command history.

Definition at line 58 of file ProximCmdHistoryWindow.cc.

59 :
60 ProximSimulatorWindow(parent, id),
61 lineReader_(lineReader) {
62
63 createContents(this, true, true);
64 cmdList_ = dynamic_cast<wxListBox*>(FindWindow(ID_LIST));
65
67}
wxSizer * createContents(wxWindow *parent, bool set_sizer, bool call_fit)
wxListBox * cmdList_
ListBox widget displaying the command history.
ProximLineReader & lineReader_
Line reader storing the command history.

◆ ~ProximCmdHistoryWindow()

ProximCmdHistoryWindow::~ProximCmdHistoryWindow ( )
virtual

The Destructor.

Definition at line 73 of file ProximCmdHistoryWindow.cc.

73 {
74}

Member Function Documentation

◆ createContents()

wxSizer * ProximCmdHistoryWindow::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the window widgets.

Code generated by wxDesigner. Do not edit manually.

Parameters
parentParent window of the window contents.
call_fitIf true, resize the parent window to fit the created contents.
set_sizerIf true, sets the created sizer as parent window contents.

Definition at line 177 of file ProximCmdHistoryWindow.cc.

178 {
179
180 wxFlexGridSizer *item0 = new wxFlexGridSizer( 1, 0, 0 );
181 item0->AddGrowableCol( 0 );
182 item0->AddGrowableRow( 0 );
183
184 wxString *strs1 = (wxString*) NULL;
185 wxListBox *item1 = new wxListBox( parent, ID_LIST, wxDefaultPosition, wxSize(300,300), 0, strs1, wxLB_SINGLE );
186 item0->Add( item1, 0, wxGROW|wxALL, 5 );
187
188 wxStaticLine *item2 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
189 item0->Add( item2, 0, wxGROW|wxALL, 5 );
190
191 wxBoxSizer *item3 = new wxBoxSizer( wxHORIZONTAL );
192
193 wxButton *item4 = new wxButton( parent, ID_SAVE, wxT("&Save"), wxDefaultPosition, wxDefaultSize, 0 );
194 item3->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
195
196 wxStaticLine *item5 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(-1,20), wxLI_VERTICAL );
197 item3->Add( item5, 0, wxGROW|wxALL, 5 );
198
199 wxButton *item6 = new wxButton( parent, ID_CLOSE, wxT("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
200 item3->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
201
202 item0->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
203
204 if (set_sizer)
205 {
206 parent->SetSizer( item0 );
207 if (call_fit)
208 item0->SetSizeHints( parent );
209 }
210
211 return item0;
212}

References ID_CLOSE, ID_LINE, ID_LIST, and ID_SAVE.

◆ onClose()

void ProximCmdHistoryWindow::onClose ( wxCommandEvent &  event)
private

Handles the Close button events.

Closes the window.

Definition at line 111 of file ProximCmdHistoryWindow.cc.

111 {
112 GetParent()->Close();
113}

◆ onCommandDClick()

void ProximCmdHistoryWindow::onCommandDClick ( wxCommandEvent &  event)
private

Event handler for the command list double clicks.

Sends the double clicked command to the linereader input.

Parameters
eventEvent of the item dclick.

Definition at line 123 of file ProximCmdHistoryWindow.cc.

123 {
124 std::string command = WxConversion::toString(event.GetString());
125 lineReader_.input(command);
126}
void input(std::string command)
static std::string toString(const wxString &source)

References ProximLineReader::input(), lineReader_, and WxConversion::toString().

Here is the call graph for this function:

◆ onSave()

void ProximCmdHistoryWindow::onSave ( wxCommandEvent &  event)
private

Displays dialog for saving command history to a file.

Definition at line 132 of file ProximCmdHistoryWindow.cc.

132 {
133
134 wxString title = _T("Save Command History");
135 wxString filters = _T("Command history logs (*.log)|*.log|All files|*.*");
136 wxFileDialog dialog(
137 this, title, _T(""), _T("commands.log"), filters, wxSAVE);
138
139 if (dialog.ShowModal() == wxID_CANCEL) {
140 return;
141 }
142
143 std::string filename = WxConversion::toString(dialog.GetPath());
144
145 std::ofstream file(filename.c_str());
146 if (file.bad()) {
147 wxString message = _T("Error saving file '.");
148 message.Append(dialog.GetPath());
149 message.Append(_T("'."));
150 ErrorDialog dialog(this, message);
151 dialog.ShowModal();
152 return;
153 }
154
155 size_t cmdCount = lineReader_.inputsInHistory();
156 for (size_t i = 0; i < cmdCount; i++) {
157 std::string command =
158 lineReader_.inputHistoryEntry(cmdCount - 1 - i);
159 file << command << std::endl;
160 }
161
162 file.close();
163}
virtual std::size_t inputsInHistory() const
virtual std::string inputHistoryEntry(std::size_t age) const

References LineReader::inputHistoryEntry(), LineReader::inputsInHistory(), lineReader_, and WxConversion::toString().

Here is the call graph for this function:

◆ onSimulatorCommand()

void ProximCmdHistoryWindow::onSimulatorCommand ( SimulatorEvent event)
private

Calls history list update when a simulator event of a completed command is received.

Definition at line 99 of file ProximCmdHistoryWindow.cc.

99 {
101 event.Skip();
102}

References updateCommandList().

Here is the call graph for this function:

◆ updateCommandList()

void ProximCmdHistoryWindow::updateCommandList ( )
private

Updates the command history list.

Definition at line 81 of file ProximCmdHistoryWindow.cc.

81 {
82 cmdList_->Clear();
83 for (size_t i = 0; i < lineReader_.inputsInHistory(); i++) {
84 std::string command = lineReader_.inputHistoryEntry(i);
85 cmdList_->Insert(WxConversion::toWxString(command), 0);
86 }
87 if (cmdList_->GetCount() > 0) {
88 FindWindow(ID_SAVE)->Enable();
89 } else {
90 FindWindow(ID_SAVE)->Disable();
91 }
92}
static wxString toWxString(const std::string &source)

References cmdList_, ID_SAVE, LineReader::inputHistoryEntry(), LineReader::inputsInHistory(), lineReader_, and WxConversion::toWxString().

Referenced by onSimulatorCommand().

Here is the call graph for this function:

Member Data Documentation

◆ cmdList_

wxListBox* ProximCmdHistoryWindow::cmdList_
private

ListBox widget displaying the command history.

Definition at line 75 of file ProximCmdHistoryWindow.hh.

Referenced by updateCommandList().

◆ lineReader_

ProximLineReader& ProximCmdHistoryWindow::lineReader_
private

Line reader storing the command history.

Definition at line 73 of file ProximCmdHistoryWindow.hh.

Referenced by onCommandDClick(), onSave(), and updateCommandList().


The documentation for this class was generated from the following files: