1 /*
2 * This file is part of the FortranProject plugin for Code::Blocks IDE
3 * and licensed under the GNU General Public License, version 3
4 * http://www.gnu.org/licenses/gpl-3.0.html
5 *
6 * Author: Darius Markauskas
7 *
8 */
9 #include "finfowindow.h"
10
11 #include <sdk.h>
12 #ifndef CB_PRECOMP
13 #include <configmanager.h>
14 #include <manager.h>
15 #include <editorcolourset.h>
16 #include <cbeditor.h>
17 #include <wx/sizer.h>
18 #endif
19
FInfoWindow()20 FInfoWindow::FInfoWindow()
21 :wxPanel(Manager::Get()->GetAppWindow())
22 {
23 //ctor
24 m_pView = new cbStyledTextCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(1,1));
25 wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
26 sizer->Add(m_pView, 1, wxEXPAND, 0);
27 SetSizer(sizer);
28 sizer->Fit(this);
29 sizer->SetSizeHints(this);
30
31 m_pView->SetReadOnly(true);
32
33 // Colorize
34 cbEditor::ApplyStyles(m_pView);
35 EditorColourSet edColSet;
36 edColSet.Apply(edColSet.GetLanguageForFilename(_T("name.f90")), m_pView, false, true);
37 SetFoldingIndicator();
38
39 // Creates log image
40 const int uiSize = Manager::Get()->GetImageSize(Manager::UIComponent::InfoPaneNotebooks);
41 const int uiScaleFactor = Manager::Get()->GetUIScaleFactor(Manager::UIComponent::InfoPaneNotebooks);
42 const wxString imgFile = ConfigManager::GetDataFolder()
43 + wxString::Format(_T("/FortranProject.zip#zip:/images/%dx%d/info_f.png"),
44 uiSize, uiSize);
45 wxBitmap* bmp = new wxBitmap(cbLoadBitmapScaled(imgFile, wxBITMAP_TYPE_PNG,
46 uiScaleFactor));
47
48 CodeBlocksLogEvent evtAdd(cbEVT_ADD_LOG_WINDOW, this, _("Fortran info"), bmp);
49 Manager::Get()->ProcessEvent(evtAdd);
50 }
51
~FInfoWindow()52 FInfoWindow::~FInfoWindow()
53 {
54 //dtor
55 }
56
RemoveFromNotebook()57 void FInfoWindow::RemoveFromNotebook()
58 {
59 if(Manager::Get()->GetLogManager())
60 {
61 CodeBlocksLogEvent evt(cbEVT_REMOVE_LOG_WINDOW, this);
62 Manager::Get()->ProcessEvent(evt);
63 }
64 }
65
WriteToInfoWindow(const wxString & text)66 void FInfoWindow::WriteToInfoWindow(const wxString& text)
67 {
68 m_pView->Enable(false);
69 m_pView->SetReadOnly(false);
70
71 m_pView->SetText(text);
72
73 m_pView->SetReadOnly(true);
74 m_pView->Enable(true);
75 }
76
SetMarkerStyle(int marker,int markerType,wxColor fore,wxColor back)77 void FInfoWindow::SetMarkerStyle(int marker, int markerType, wxColor fore, wxColor back)
78 {
79 m_pView->MarkerDefine(marker, markerType);
80 m_pView->MarkerSetForeground(marker, fore);
81 m_pView->MarkerSetBackground(marker, back);
82 }
83
SetFoldingIndicator()84 void FInfoWindow::SetFoldingIndicator()
85 {
86 //simple style
87 SetMarkerStyle(wxSCI_MARKNUM_FOLDEROPEN, wxSCI_MARK_MINUS, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
88 SetMarkerStyle(wxSCI_MARKNUM_FOLDER, wxSCI_MARK_PLUS, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
89 SetMarkerStyle(wxSCI_MARKNUM_FOLDERSUB, wxSCI_MARK_BACKGROUND, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
90 SetMarkerStyle(wxSCI_MARKNUM_FOLDERTAIL, wxSCI_MARK_BACKGROUND, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
91 SetMarkerStyle(wxSCI_MARKNUM_FOLDEREND, wxSCI_MARK_PLUS, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
92 SetMarkerStyle(wxSCI_MARKNUM_FOLDEROPENMID, wxSCI_MARK_MINUS, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
93 SetMarkerStyle(wxSCI_MARKNUM_FOLDERMIDTAIL, wxSCI_MARK_BACKGROUND, wxColor(0xff, 0xff, 0xff), wxColor(0x80, 0x80, 0x80));
94 }
95
96