NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
wxTermContainer.cpp
Go to the documentation of this file.
1
2// Name: wxTermContainer.cpp
3// Purpose:
4// Author:
5// Modified by:
6// Created: 03/18/04 01:08:08
7// RCS-ID:
8// Copyright:
9// Licence:
11
12#ifdef __GNUG__
13#pragma implementation "wxTermContainer.cpp"
14#endif
15
16// For compilers that support precompilation, includes "wx/wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20#pragma hdrstop
21#endif
22
24#include "wx/wx.h"
25#include "wx/scrolbar.h"
27
28#include "wxTermContainer.h"
29#include "../terminal/terminal.hpp"
30
31
33
35
40IMPLEMENT_CLASS( wxTermContainer, wxPanel )
41
42
46BEGIN_EVENT_TABLE( wxTermContainer, wxPanel )
47
48
49 EVT_COMMAND_SCROLL_LINEUP( ID_SCROLLBAR, wxTermContainer::OnScrollbarScrollLineUp )
50 EVT_COMMAND_SCROLL_LINEDOWN( ID_SCROLLBAR, wxTermContainer::OnScrollbarScrollLineDown )
51 EVT_COMMAND_SCROLL_PAGEUP( ID_SCROLLBAR, wxTermContainer::OnScrollbarScrollPageUp )
52 EVT_COMMAND_SCROLL_PAGEDOWN( ID_SCROLLBAR, wxTermContainer::OnScrollbarScrollPageDown )
53 EVT_COMMAND_SCROLL_THUMBTRACK( ID_SCROLLBAR, wxTermContainer::OnScrollbarScrollThumbtrack )
54 EVT_MOUSEWHEEL(wxTermContainer::OnWheelScroll)
55
56
57
58 //EVT_SIZE (wxTermContainer::OnSize)
60
62
63
67wxTermContainer::wxTermContainer( ) : m_terminal(nullptr), m_scrollbar(nullptr), m_lastThumbPosition(0), m_sizer(nullptr), m_lastLinesReceived(0)
68{
69}
70
71wxTermContainer::wxTermContainer( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
72: m_terminal(nullptr)
73{
74 Create(parent, id, pos, size, style);
75
78
79}
80
85bool wxTermContainer::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
86{
89
90
92 wxPanel::Create( parent, id, pos, size, style );
93
95 Centre();
97 return TRUE;
98}
99
105{
107
108 wxTermContainer* item1 = this;
109
110 wxBoxSizer* item2 = new wxBoxSizer(wxHORIZONTAL);
111 m_sizer = item2;
112 item1->SetSizer(item2);
113 item1->SetAutoLayout(TRUE);
114
115 /*
116 wxTerm* item3 = new wxTerm( item1, ID_PANEL, wxDefaultPosition, wxSize(379, 80), wxNO_BORDER|wxTAB_TRAVERSAL );
117 m_terminal = item3;
118 item2->Add(item3, 1, wxGROW, 5);
119 */
120
121 //item2->Add(m_terminal, 1, wxGROW, 0);
122
123 wxScrollBar* item4 = new wxScrollBar( item1, ID_SCROLLBAR, wxPoint(this->GetSize().GetX() - 18, 0), wxSize(18, -1), wxSB_VERTICAL );
124 m_scrollbar = item4;
125 item4->SetScrollbar(90, 10, 300, 10);
126 item2->Add(item4, 0, wxGROW, 5);
127
129}
130
131
141{
143}
144
145
161{
162 event.Skip();
163
164 //wxLogDebug("OnScrollbarScrollPageUp()");
165 m_terminal->ScrollTerminal(1, true);
167}
168
169void wxTermContainer::OnWheelScroll(wxMouseEvent& event)
170{
171 m_terminal->ScrollTerminal(3, (event.GetWheelRotation() > 0));
173}
174
190{
191 event.Skip();
192 m_terminal->ScrollTerminal(1, false);
194}
195
211{
212 event.Skip();
215}
216
232{
233 event.Skip();
236}
237
253{
254 event.Skip();
255 //wxLogDebug("Scroll event. Value: %d", event.GetPosition());
256
257 int newThumbPosition = event.GetPosition();
258
259 int linesToScroll;
260 bool scrollUp = (newThumbPosition < m_lastThumbPosition);
261
262 if(scrollUp)
263 {
264 linesToScroll = m_lastThumbPosition - newThumbPosition;
265 }
266 else
267 {
268 linesToScroll = newThumbPosition - m_lastThumbPosition;
269 }
270
271 m_lastThumbPosition = newThumbPosition;
272
273 m_terminal->ScrollTerminal(linesToScroll, scrollUp);
274}
275
281{
282 return TRUE;
283}
284
296{
297 m_terminal = terminal;
298
299 m_sizer->Prepend(m_terminal, 1, wxGROW, 0);
300
301 int termHeight = m_terminal->Height();
302 m_scrollbar->SetScrollbar(100 - termHeight, termHeight, 100, termHeight);
303}
304
305
313void wxTermContainer::OnSize(wxSizeEvent &event)
314{
315 event.Skip();
316}
317
328void wxTermContainer::OnUpdateUI(wxUpdateUIEvent &event)
329{
330 int scrollHeight = m_terminal->GetScrollHeight();
331
332 int thumbSize = m_terminal->Height();
333
334 if (scrollHeight <= thumbSize)
335 {
336 m_scrollbar->Disable();
337 return;
338 }
339
340 m_scrollbar->Enable();
341
342 int thumbPosition = scrollHeight - thumbSize - m_terminal->GetScrollPosition();
343
344 if (scrollHeight != m_lastLinesReceived)
345 {
346 //wxLogDebug("linesReceived: %d, thumbSize: %d, thumbPosition: %d", scrollHeight, thumbSize, thumbPosition);
347 m_lastLinesReceived = scrollHeight;
348 m_lastThumbPosition = thumbPosition;
349 }
350
351 if (thumbPosition < 0)
352 thumbPosition = 0;
353
354 event.Enable(true);
355 m_scrollbar->SetScrollbar(thumbPosition, thumbSize, scrollHeight, thumbSize);
356}
357
358
368{
370}
371
372
382{
384}
385
int GetScrollHeight()
Definition: gterm.cpp:312
void SetTerminalHistory(int size)
Set the terminal buffer size (not the length of the input history). The length of the history (i....
Definition: gterm.cpp:348
int GetScrollPosition()
Returns the current scroll position.
Definition: gterm.cpp:331
int Height() const
Definition: gterm.hpp:156
The terminal class for the GUI. It's a specialisation of the GenericTerminal.
Definition: terminal.hpp:46
void ScrollTerminal(int numLines, bool scrollUp=true)
Definition: terminal.cpp:2247
void SetCursorBlinkRate(int rate)
Definition: terminal.cpp:866
wxTermContainer()
Constructors.
wxScrollBar * m_scrollbar
wxBoxSizer * m_sizer
void OnScrollbarScrollLineDown(wxScrollEvent &event)
wxEVT_SCROLL_LINEDOWN event handler for ID_SCROLLBAR
void OnWheelScroll(wxMouseEvent &event)
wxEVT_MOUSEWHEEL event handler
void OnScrollbarScrollPageUp(wxScrollEvent &event)
wxEVT_SCROLL_PAGEUP event handler for ID_SCROLLBAR
void OnScrollbarScrollLineUp(wxScrollEvent &event)
wxEVT_SCROLL_LINEUP event handler for ID_SCROLLBAR
NumeReTerminal * m_terminal
bool Create(wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxBORDER_STATIC)
Creation.
static bool ShowToolTips()
Should we show tooltips?
void SetTerminal(NumeReTerminal *terminal)
void updateThumbPosition()
Updates the thumb position after every scroll operation except of the click-drag scrolling.
void CreateControls()
Creates the controls and sizers.
void OnScrollbarScrollPageDown(wxScrollEvent &event)
wxEVT_SCROLL_PAGEDOWN event handler for ID_SCROLLBAR
void SetTerminalHistory(int newSize)
Changes the size of the terminal history buffer.
void SetCaretBlinkTime(int newTime)
Changes the blinking duration of the terminal caret.
void OnScrollbarScrollThumbtrack(wxScrollEvent &event)
wxEVT_SCROLL_THUMBTRACK event handler for ID_SCROLLBAR
void OnSize(wxSizeEvent &event)
Empty OnSize event handler.
void OnUpdateUI(wxUpdateUIEvent &event)
#define TRUE
Definition: resampler.cpp:38
END_EVENT_TABLE()
#define ID_SCROLLBAR