NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
terminalcalltip.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2022 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include "terminalcalltip.hpp"
20#include <wx/panel.h>
21
22
30TerminalCallTip::TerminalCallTip(wxWindow* parent, const wxSize& s)
31 : wxWindow(parent, wxID_ANY, wxDefaultPosition, s+wxSize(2,2), wxBORDER_SIMPLE | wxCLIP_CHILDREN)
32{
33 SetBackgroundColour(wxColour(245, 245, 245));
34
35 m_text = new wxTextCtrl(this, wxID_ANY, "STANDARDTEXT", wxDefaultPosition, s, wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxBORDER_NONE);
36 m_text->SetBackgroundColour(wxColour(245, 245, 245));
37
38 Hide();
39}
40
41
52void TerminalCallTip::PopUp(const wxPoint& pos, const wxString& text)
53{
54 m_text->Clear();
55 m_text->SetDefaultStyle(wxTextAttr(wxColour(128,128,128)));
56 m_text->AppendText(text);
57 SetPosition(pos-wxPoint(2,0));
58
59 if (!IsShown())
60 Show();
61}
62
63
71{
72 Hide();
73}
74
75
83void TerminalCallTip::Resize(const wxSize& s)
84{
85 SetSize(s+wxSize(4,2));
86 m_text->SetSize(s);
87}
88
89
97void TerminalCallTip::ChangeFont(const wxFont& font)
98{
99 m_text->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, font));
100}
101
102
112void TerminalCallTip::Highlight(size_t start, size_t len)
113{
114 wxString text = m_text->GetValue();
115 m_text->Clear();
116 m_text->SetDefaultStyle(wxTextAttr(wxColour(128, 128, 128)));
117 m_text->AppendText(text.substr(0, start));
118 m_text->SetDefaultStyle(wxTextAttr(*wxBLUE));
119 m_text->AppendText(text.substr(start, len));
120 m_text->SetDefaultStyle(wxTextAttr(wxColour(128, 128, 128)));
121 m_text->AppendText(text.substr(start+len));
122}
123
wxTextCtrl * m_text
void Highlight(size_t start, size_t len)
Hightlight the section of the text in the calltip.
void Resize(const wxSize &s)
Change the calltip's size.
TerminalCallTip(wxWindow *parent, const wxSize &s=wxDefaultSize)
TerminalCallTip constructor.
void Dismiss()
Remove the shown calltip.
void PopUp(const wxPoint &pos, const wxString &text)
Show the calltip at the desired position. This function does not check, whether the calltip is acutal...
void ChangeFont(const wxFont &font)
Changes the font of the calltip.