File: TextFileViewer.cpp

package info (click to toggle)
mriconvert 1%3A2.1.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,488 kB
  • sloc: cpp: 17,029; makefile: 11
file content (44 lines) | stat: -rwxr-x--- 1,049 bytes parent folder | download | duplicates (4)
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
/// TextFileViewer.cpp
/**
*/

#include <fstream>
#include <sstream>
#include <string>

#include <wx/wx.h>
#include <wx/wxprec.h>

#include "TextFileViewer.h"
#include "fileformats.h"


TextFileViewer::TextFileViewer(wxWindow* parent, const wxChar* caption)
: wxFrame(parent, -1, wxString(caption, wxConvLocal))
{
  wxBoxSizer* frameSizer = new wxBoxSizer(wxVERTICAL);

  mTextCtrl = new wxTextCtrl(this, -1, _T(""), wxDefaultPosition,
    wxSize(400,400), wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH);

  frameSizer->Add(mTextCtrl, 1, wxEXPAND);

  std::istringstream input(fileformats_h, std::istringstream::in);

  if (!input.good()) {
    (*mTextCtrl) << _("problem opening istringstream::in\n");
  }

  std::string str;
  while (getline(input, str)) {
    (*mTextCtrl) << wxString(str.c_str(), wxConvLocal) << _T("\n");
#ifdef __WXMSW__
    (*mTextCtrl) << _T('\n');
#endif
  }

  // Scroll to the top of the text.
  mTextCtrl->SetInsertionPoint(0);
  SetSizer(frameSizer);
  frameSizer->Fit(this);
}