Code::Blocks  SVN r11506
printdlg.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3  * http://www.gnu.org/licenses/gpl-3.0.html
4  *
5  * $Revision: 10912 $
6  * $Id: printdlg.cpp 10912 2016-09-25 16:10:13Z fuscated $
7  * $HeadURL: https://svn.code.sf.net/p/codeblocks/code/trunk/src/src/printdlg.cpp $
8  */
9 
10 #include "sdk.h"
11 #ifndef CB_PRECOMP
12  #include <wx/button.h>
13  #include <wx/intl.h>
14  #include <wx/checkbox.h>
15  #include <wx/radiobox.h>
16  #include <wx/string.h>
17  #include <wx/xrc/xmlres.h>
18  #include "cbeditor.h"
19  #include "configmanager.h"
20  #include "editormanager.h"
21  #include "manager.h"
22 #endif
23 #include "cbstyledtextctrl.h"
24 
25 #include "printdlg.h"
26 
28 {
29  //ctor
30  wxXmlResource::Get()->LoadObject(this, parent, _T("dlgPrint"),_T("wxScrollingDialog"));
31  XRCCTRL(*this, "wxID_OK", wxButton)->SetDefault();
32 
34  if (ed)
35  {
36  bool hasSel = ed->GetControl()->GetSelectedText().Length();
37  XRCCTRL(*this, "rbScope", wxRadioBox)->SetSelection(hasSel ? 0 : 1);
38  }
39  else
40  XRCCTRL(*this, "rbScope", wxRadioBox)->SetSelection(1);
41 
42  int mode = Manager::Get()->GetConfigManager(_T("app"))->ReadInt(_T("/print_mode"), 1);
43  XRCCTRL(*this, "rbColourMode", wxRadioBox)->SetSelection(mode);
44  bool print_line_numbers = Manager::Get()->GetConfigManager(_T("app"))->ReadBool(_T("/print_line_numbers"), true);
45  XRCCTRL(*this, "chkLineNumbers", wxCheckBox)->SetValue(print_line_numbers);
46 }
47 
49 {
50  //dtor
51 }
52 
54 {
55  return (PrintScope)XRCCTRL(*this, "rbScope", wxRadioBox)->GetSelection();
56 }
57 
59 {
60  return (PrintColourMode)XRCCTRL(*this, "rbColourMode", wxRadioBox)->GetSelection();
61 }
62 
64 {
65  return XRCCTRL(*this, "chkLineNumbers", wxCheckBox)->GetValue();
66 }
67 
68 void PrintDialog::EndModal(int retCode)
69 {
70  if (retCode == wxID_OK)
71  {
72  int mode = XRCCTRL(*this, "rbColourMode", wxRadioBox)->GetSelection();
73  Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/print_mode"), (int)mode);
74  Manager::Get()->GetConfigManager(_T("app"))->Write(_T("/print_line_numbers"), GetPrintLineNumbers());
75  }
76  return wxScrollingDialog::EndModal(retCode);
77 }
void EndModal(int retCode)
Definition: sc_dialog.cpp:112
ConfigManager * GetConfigManager(const wxString &name_space) const
Definition: manager.cpp:474
int ReadInt(const wxString &name, int defaultVal=0)
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
Definition: manager.cpp:182
PrintDialog(wxWindow *parent)
Definition: printdlg.cpp:27
PrintColourMode
bool ReadBool(const wxString &name, bool defaultVal=false)
size_t Length() const
#define _T(string)
EditorManager * GetEditorManager() const
Definition: manager.cpp:434
wxString GetSelectedText()
Retrieve the selected text.
void Write(const wxString &name, const wxString &value, bool ignoreEmpty=false)
cbStyledTextCtrl * GetControl() const
Returns a pointer to the underlying cbStyledTextCtrl object (which itself is the wxWindows implementa...
Definition: cbeditor.cpp:842
PrintScope GetPrintScope() const
Definition: printdlg.cpp:53
cbEditor * GetBuiltinActiveEditor()
Definition: editormanager.h:95
PrintScope
virtual ~PrintDialog()
Definition: printdlg.cpp:48
A file editor.
Definition: cbeditor.h:43
static wxXmlResource * Get()
PrintColourMode GetPrintColourMode() const
Definition: printdlg.cpp:58
bool GetPrintLineNumbers() const
Definition: printdlg.cpp:63
virtual void EndModal(int retCode)
Definition: printdlg.cpp:68
wxObject * LoadObject(wxWindow *parent, const wxString &name, const wxString &classname)