OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
ScrolledWindow Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Widgets/ScrolledWindow.hpp>

Inheritance diagram for ScrolledWindow:
Collaboration diagram for ScrolledWindow:

Public Member Functions

 ScrolledWindow (wxWindow *parent, wxWindowID id, wxPoint position, wxSize size, long style, int marginWidth=0, int scrollbarWidth=4, int tipLength=0)
void OnMouseWheel (wxMouseEvent &event)
void SetTipColor (wxColour color)
bool SetBackgroundColour (const wxColour &color) override
void SetMarginColor (wxColour color)
void SetScrollbarColor (wxColour color)
void SetScrollbarTip (int len)
virtual void SetVirtualSize (int x, int y)
virtual void SetVirtualSize (wxSize &size)
wxPanel * GetPanel ()
bool IsBothDirections ()
virtual void SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, int noUnitsX, int noUnitsY, int xPos=0, int yPos=0, bool noRefresh=false) override

Private Member Functions

void OnSize (wxSizeEvent &WXUNUSED(event))
void OnScroll (wxScrollWinEvent &event)

Private Attributes

wxPanel * m_userPanel
wxWindow * m_scroll_win
MyScrollbar * m_rightScrollbar
MyScrollbar * m_bottomScrollbar
wxWindow * m_verticalSplitter
wxSplitterWindow * m_horizontalSplitter
int m_marginWidth
bool m_bothDirections

Detailed Description

Constructor & Destructor Documentation

◆ ScrolledWindow()

ScrolledWindow::ScrolledWindow ( wxWindow * parent,
wxWindowID id,
wxPoint position,
wxSize size,
long style,
int marginWidth = 0,
int scrollbarWidth = 4,
int tipLength = 0 )
18 : wxScrolled<wxWindow>(parent, id, position, size, style)
19{
20 bool bVertical = (style & wxVSCROLL) != 0;
21 bool bHorizontal = (style & wxHSCROLL) != 0;
22 m_bothDirections = bVertical & bHorizontal;
23 EnableScrolling(bHorizontal, bVertical);
24 ShowScrollbars(wxSHOW_SB_NEVER, wxSHOW_SB_NEVER);
25
26 m_rightScrollbar = NULL;
27 m_bottomScrollbar = NULL;
28 m_verticalSplitter = NULL;
30 m_userPanel = NULL;
31 m_scroll_win = NULL;
32
33 m_marginWidth = marginWidth;
34
35 wxSize hsSize = size;
36 hsSize.SetWidth(hsSize.GetWidth() - marginWidth);
37 hsSize.SetHeight(hsSize.GetHeight() - marginWidth);
38
39 wxSize vsSize = size;
40 vsSize.SetWidth(vsSize.GetWidth() - marginWidth);
41
42
43 if (bVertical) {
44 m_verticalSplitter = new wxWindow(this, -1, position, vsSize);
45 m_userPanel = new wxPanel(m_verticalSplitter, -1, wxPoint(0, 0), wxSize(size.GetWidth() - marginWidth, size.GetHeight()));
46 m_scroll_win = new wxWindow(m_verticalSplitter, -1, wxPoint(size.GetWidth() - marginWidth, 0), wxSize(marginWidth, size.GetHeight()));
47 m_rightScrollbar = new MyScrollbar(m_scroll_win, -1, wxPoint(0, 0), wxSize(scrollbarWidth, size.GetHeight()), this, wxVSCROLL, scrollbarWidth, tipLength);
48 } else if (bHorizontal) {
49 m_horizontalSplitter = new wxSplitterWindow(this, -1, position, hsSize);
50 m_userPanel = new wxPanel(m_horizontalSplitter, -1, wxPoint(0, 0), wxSize(size.GetWidth() - marginWidth, size.GetHeight() - marginWidth));
51 m_userPanel->SetBackgroundColour(parent->GetBackgroundColour());
52
53 m_bottomScrollbar = new MyScrollbar(m_horizontalSplitter, -1, wxPoint(0, 0), wxSize(size.GetWidth() - marginWidth, marginWidth), this, wxHSCROLL, scrollbarWidth,
54 tipLength);
55 m_horizontalSplitter->SplitHorizontally(m_userPanel, m_bottomScrollbar, -marginWidth);
56 m_horizontalSplitter->SetSashInvisible();
57 }
58
59 SetTargetWindow(m_userPanel); // very very important line
60
61 Bind(wxEVT_SIZE, &ScrolledWindow::OnSize, this);
62 Bind(wxEVT_SCROLLWIN_TOP, &ScrolledWindow::OnScroll, this);
63 Bind(wxEVT_SCROLLWIN_BOTTOM, &ScrolledWindow::OnScroll, this);
64 Bind(wxEVT_SCROLLWIN_LINEUP, &ScrolledWindow::OnScroll, this);
65 Bind(wxEVT_SCROLLWIN_LINEDOWN, &ScrolledWindow::OnScroll, this);
66 Bind(wxEVT_SCROLLWIN_PAGEUP, &ScrolledWindow::OnScroll, this);
67 Bind(wxEVT_SCROLLWIN_PAGEDOWN, &ScrolledWindow::OnScroll, this);
68 Bind(wxEVT_SCROLLWIN_THUMBTRACK, &ScrolledWindow::OnScroll, this);
69 Bind(wxEVT_SCROLLWIN_THUMBRELEASE, &ScrolledWindow::OnScroll, this);
70 Bind(wxEVT_MOUSEWHEEL, &ScrolledWindow::OnMouseWheel, this);
71}
#define style
Definition WipeTowerDialog.cpp:101
wxPanel * m_userPanel
Definition ScrolledWindow.hpp:43
void OnScroll(wxScrollWinEvent &event)
Definition ScrolledWindow.cpp:213
MyScrollbar * m_rightScrollbar
Definition ScrolledWindow.hpp:45
void OnMouseWheel(wxMouseEvent &event)
Definition ScrolledWindow.cpp:73
wxWindow * m_scroll_win
Definition ScrolledWindow.hpp:44
wxWindow * m_verticalSplitter
Definition ScrolledWindow.hpp:48
MyScrollbar * m_bottomScrollbar
Definition ScrolledWindow.hpp:46
int m_marginWidth
Definition ScrolledWindow.hpp:50
void OnSize(wxSizeEvent &WXUNUSED(event))
Definition ScrolledWindow.cpp:160
bool m_bothDirections
Definition ScrolledWindow.hpp:51
wxSplitterWindow * m_horizontalSplitter
Definition ScrolledWindow.hpp:49

References m_bothDirections, m_bottomScrollbar, m_horizontalSplitter, m_marginWidth, m_rightScrollbar, m_scroll_win, m_userPanel, m_verticalSplitter, OnMouseWheel(), OnScroll(), OnSize(), and style.

Here is the call graph for this function:

Member Function Documentation

◆ GetPanel()

wxPanel * ScrolledWindow::GetPanel ( )
inline
36{ return m_userPanel; }

References m_userPanel.

◆ IsBothDirections()

bool ScrolledWindow::IsBothDirections ( )
inline
39{ return m_bothDirections; }

References m_bothDirections.

◆ OnMouseWheel()

void ScrolledWindow::OnMouseWheel ( wxMouseEvent & event)
74{
75 m_rightScrollbar->GetEventHandler()->ProcessEvent(event);
76
77 // int dMotion, actualDim;
78 // if (event.GetWheelRotation() > 0)
79 // dMotion = -m_pixelsPerUnit;
80 // else
81 // dMotion = m_pixelsPerUnit;
82 // m_previousMouse += dMotion;
83 // actualDim = m_actualDim;
84
85 // if (m_direction == wxVSCROLL) {
86 // m_viewStartInPixels += (dMotion * m_virtualDim) / (float) actualDim + 0.5; // in pixels
87
88 // if (m_viewStartInPixels < 0)
89 // m_viewStartInPixels = 0;
90 // else if (m_viewStartInPixels + actualDim >= m_virtualDim)
91 // m_viewStartInPixels = m_virtualDim - actualDim;
92
93 // m_viewStartInScrollUnits = m_viewStartInPixels / (float) m_pixelsPerUnit + 0.5; // in scroll units
94 // m_scrolledWindow->Scroll(-1, m_viewStartInScrollUnits); // -1 means no change in this direction
95 // SetViewStart(m_viewStartInScrollUnits);
96 //} else {
97 // dMotion = -dMotion;
98 // if (m_scrolledWindow->IsBothDirections()) actualDim -= m_marginWidth; // must take into account the right margin
99
100 // m_viewStartInPixels += (dMotion * m_virtualDim) / (float) actualDim + 0.5; // in pixels
101
102 // if (m_viewStartInPixels < 0)
103 // m_viewStartInPixels = 0;
104 // else if (m_viewStartInPixels + actualDim >= m_virtualDim)
105 // m_viewStartInPixels = m_virtualDim - actualDim;
106
107 // m_viewStartInScrollUnits = m_viewStartInPixels / (float) m_pixelsPerUnit + 0.5; // in scroll units
108 // m_scrolledWindow->Scroll(m_viewStartInScrollUnits, -1); // -1 means no change in this direction
109 // SetViewStart(m_viewStartInScrollUnits);
110 //}
111 // Refresh();
112 // Update();
113}

References m_rightScrollbar.

Referenced by ScrolledWindow().

Here is the caller graph for this function:

◆ OnScroll()

void ScrolledWindow::OnScroll ( wxScrollWinEvent & event)
private
214{
215 int startX, startY;
216 GetViewStart(&startX, &startY);
217 if (m_rightScrollbar) {
218 m_rightScrollbar->SetViewStart(startY);
219 m_rightScrollbar->Refresh();
220 m_rightScrollbar->Update();
221 }
222 if (m_bottomScrollbar) {
223 m_bottomScrollbar->SetViewStart(startX);
224 m_bottomScrollbar->Refresh();
225 m_bottomScrollbar->Update();
226 }
227 // event.Skip(); // then do the regular process // uncomment if you want to use the mouse and the trackpad in the scrolled panel
228}

References m_bottomScrollbar, and m_rightScrollbar.

Referenced by ScrolledWindow().

Here is the caller graph for this function:

◆ OnSize()

void ScrolledWindow::OnSize ( wxSizeEvent & WXUNUSEDevent)
private
161{
162 int startX, startY, virtX, virtY, clientW, clientH;
163
165
166 GetViewStart(&startX, &startY);
167 GetVirtualSize(&virtX, &virtY);
168 GetClientSize(&clientW, &clientH);
169
170 // trace / log in the output / console window
171 // wxString str; str.sprintf("Actual=(%d,%d). Virtual=(%d,%d)\n", clientW, clientH, virtX, virtY); OutputDebugString(str);
172 if (m_verticalSplitter) m_verticalSplitter->SetSize(clientW, clientH);
173 if (m_horizontalSplitter) m_horizontalSplitter->SetSize(clientW, clientH);
174
175 if (m_rightScrollbar) {
176 if (clientH >= virtY) // hide the scrollbar by enlarging the user panel
177 {
178 // m_verticalSplitter->SetSashPosition(clientW);
179 m_userPanel->SetSize(GetClientSize());
180 m_rightScrollbar->SetSize(0, clientH);
181 m_userPanel->Refresh();
182 m_userPanel->Update();
183 } else {
184 // m_verticalSplitter->SetSashPosition(clientW - m_marginWidth); // resize the splitter panes
185 }
186 m_rightScrollbar->SetViewStart(startY);
187 m_rightScrollbar->Refresh();
188 m_rightScrollbar->Update(); // we want to repaint
189 }
190 if (m_bottomScrollbar) {
191 if (clientW >= virtX) // hide the scrollbar by enlarging the user panel
192 {
193 m_horizontalSplitter->SetSashPosition(clientH); // we don't need horizontal scrollbar
195 m_userPanel->SetSize(clientW - m_marginWidth, clientH); // don't hide the vertical scrollbar
196 else
197 m_userPanel->SetSize(GetClientSize());
198
199 m_bottomScrollbar->SetSize(clientW, 0);
200 m_userPanel->Refresh();
201 m_userPanel->Update();
202 } else {
203 m_horizontalSplitter->SetSashPosition(clientH - m_marginWidth); // resize the splitter panes
204 }
205 m_bottomScrollbar->SetViewStart(startX);
206 m_bottomScrollbar->Refresh();
207 m_bottomScrollbar->Update(); // we want to repaint even if the panel gets smaller
208 }
209 Layout();
210 AdjustScrollbars();
211}

References m_bottomScrollbar, m_horizontalSplitter, m_marginWidth, m_rightScrollbar, m_userPanel, and m_verticalSplitter.

Referenced by ScrolledWindow().

Here is the caller graph for this function:

◆ SetBackgroundColour()

bool ScrolledWindow::SetBackgroundColour ( const wxColour & color)
override
122{
123 const bool result = wxWindow::SetBackgroundColour(color);
124 m_verticalSplitter->SetBackgroundColour(color);
125 m_userPanel->SetBackgroundColour(color);
126 m_scroll_win->SetBackgroundColour(color);
127 return result;
128}

References m_scroll_win, m_userPanel, and m_verticalSplitter.

◆ SetMarginColor()

void ScrolledWindow::SetMarginColor ( wxColour color)
131{
132 if (m_rightScrollbar) m_rightScrollbar->SetMarginColor(color);
133 if (m_bottomScrollbar) m_bottomScrollbar->SetMarginColor(color);
134}

References m_bottomScrollbar, and m_rightScrollbar.

◆ SetScrollbarColor()

void ScrolledWindow::SetScrollbarColor ( wxColour color)
137{
138 if (m_rightScrollbar) m_rightScrollbar->SetScrollbarColor(color);
139 if (m_bottomScrollbar) m_bottomScrollbar->SetScrollbarColor(color);
140}

References m_bottomScrollbar, and m_rightScrollbar.

◆ SetScrollbars()

void ScrolledWindow::SetScrollbars ( int pixelsPerUnitX,
int pixelsPerUnitY,
int noUnitsX,
int noUnitsY,
int xPos = 0,
int yPos = 0,
bool noRefresh = false )
overridevirtual
153{
154 wxScrolled<wxWindow>::SetScrollbars(pixelsPerUnitX, pixelsPerUnitY, noUnitsX, noUnitsY, xPos, yPos, noRefresh);
155 wxScrolled<wxWindow>::SetVirtualSize(pixelsPerUnitX * noUnitsX, pixelsPerUnitY * noUnitsY); // So that GetVirtualSize gives good values
156 if (m_rightScrollbar) m_rightScrollbar->SetVirtualDim(pixelsPerUnitY, noUnitsY);
157 if (m_bottomScrollbar) m_bottomScrollbar->SetVirtualDim(pixelsPerUnitX, noUnitsX);
158}

References m_bottomScrollbar, and m_rightScrollbar.

Referenced by SetVirtualSize(), and SetVirtualSize().

Here is the caller graph for this function:

◆ SetScrollbarTip()

void ScrolledWindow::SetScrollbarTip ( int len)
143{
144 if (m_rightScrollbar) m_rightScrollbar->SetScrollbarTip(len);
145 if (m_bottomScrollbar) m_bottomScrollbar->SetScrollbarTip(len);
146}

References m_bottomScrollbar, and m_rightScrollbar.

◆ SetTipColor()

void ScrolledWindow::SetTipColor ( wxColour color)
116{
117 if (m_rightScrollbar) m_rightScrollbar->SetTipColor(color);
118 if (m_bottomScrollbar) m_bottomScrollbar->SetTipColor(color);
119}

References m_bottomScrollbar, and m_rightScrollbar.

◆ SetVirtualSize() [1/2]

void ScrolledWindow::SetVirtualSize ( int x,
int y )
virtual
148{ SetScrollbars(1, 1, x, y); }
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, int noUnitsX, int noUnitsY, int xPos=0, int yPos=0, bool noRefresh=false) override
Definition ScrolledWindow.cpp:152

References SetScrollbars().

Here is the call graph for this function:

◆ SetVirtualSize() [2/2]

void ScrolledWindow::SetVirtualSize ( wxSize & size)
virtual
150{ SetScrollbars(1, 1, size.GetWidth(), size.GetHeight()); }

References SetScrollbars().

Here is the call graph for this function:

Member Data Documentation

◆ m_bothDirections

bool ScrolledWindow::m_bothDirections
private

Referenced by ScrolledWindow(), and IsBothDirections().

◆ m_bottomScrollbar

◆ m_horizontalSplitter

wxSplitterWindow* ScrolledWindow::m_horizontalSplitter
private

Referenced by ScrolledWindow(), and OnSize().

◆ m_marginWidth

int ScrolledWindow::m_marginWidth
private

Referenced by ScrolledWindow(), and OnSize().

◆ m_rightScrollbar

◆ m_scroll_win

wxWindow* ScrolledWindow::m_scroll_win
private

◆ m_userPanel

wxPanel* ScrolledWindow::m_userPanel
private

◆ m_verticalSplitter

wxWindow* ScrolledWindow::m_verticalSplitter
private

The documentation for this class was generated from the following files: