OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
DropDown.cpp File Reference
#include "DropDown.hpp"
#include "Label.hpp"
#include <cassert>
#include <algorithm>
#include <boost/date_time/posix_time/posix_time_types.hpp>
#include <cstdio>
#include "slic3r/GUI/Widgets/PopupWindow.hpp"
#include <vector>
#include <utility>
#include <iterator>
#include <wx/dc.h>
#include <wx/dcclient.h>
#include <wx/display.h>
#include <wx/dcbuffer.h>
#include <wx/dcgraph.h>
#include <wx/event.h>
#include <wx/popupwin.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/window.h>
#include <wx/utils.h>
#include <set>
#include "slic3r/GUI/Widgets/StateColor.hpp"
#include "slic3r/GUI/Widgets/StateHandler.hpp"
#include "slic3r/GUI/wxExtensions.hpp"
Include dependency graph for DropDown.cpp:

Go to the source code of this file.

Functions

 wxDEFINE_EVENT (EVT_DISMISS, wxCommandEvent)
 wxDEFINE_EVENT (EVT_DROPDOWN_ITEM_ACTION, wxCommandEvent)
static wxSize GetBmpSize (wxBitmap &bmp)
static void _DrawSplitItem (const wxWindow *w, wxDC &dc, wxString split_text, wxPoint start_pt, int item_width, int item_height)

Function Documentation

◆ _DrawSplitItem()

void _DrawSplitItem ( const wxWindow * w,
wxDC & dc,
wxString split_text,
wxPoint start_pt,
int item_width,
int item_height )
static
261{
262 // save dc
263 auto pre_clr = dc.GetTextForeground();
264 auto pre_pen = dc.GetPen();
265 dc.SetTextForeground(wxColour(172, 172, 172));//GRAY 500
266 dc.SetPen(wxColour(166, 169, 170));//GRAY 400
267 // miner font
268 auto font = w->GetFont();
269 font.SetPointSize(font.GetPointSize() - 3);
270 dc.SetFont(font);
271
272 int spacing = w->FromDIP(8);
273
274 if (!split_text.empty())// Paiting: text + spacing + line + spacing
275 {
276 int max_content_width = item_width - start_pt.x - 2 * spacing;
277 wxSize tSize = dc.GetMultiLineTextExtent(split_text);
278 if (tSize.x > max_content_width)
279 {
280 split_text = wxControl::Ellipsize(split_text, dc, wxELLIPSIZE_END, max_content_width);
281 tSize = dc.GetMultiLineTextExtent(split_text);
282 }
283
284 dc.SetFont(font);
285 dc.DrawText(split_text, start_pt);
286
287 int line_width = item_width - start_pt.x - tSize.x - 2 * spacing;
288 int line_y = start_pt.y + (tSize.GetHeight() / 2);
289 dc.DrawLine(start_pt.x + tSize.x + spacing, line_y, start_pt.x + tSize.x + line_width + spacing, line_y);// draw right line
290 }
291 else// Paiting: line + spacing
292 {
293 int line_y = start_pt.y + (item_height / 2);
294 int line_width = item_width - start_pt.x - spacing;
295 dc.DrawLine(start_pt.x, line_y, start_pt.x + line_width, line_y);// draw line
296 }
297
298 // restore dc
299 dc.SetTextForeground(pre_clr);
300 dc.SetPen(pre_pen);
301 dc.SetFont(w->GetFont());
302}

Referenced by DropDown::render().

Here is the caller graph for this function:

◆ GetBmpSize()

wxSize GetBmpSize ( wxBitmap & bmp)
static
237{
238 if (!bmp.IsOk())
239 return wxSize(0, 0);
240#ifdef __APPLE__
241 return bmp.GetScaledSize();
242#else
243 return bmp.GetSize();
244#endif
245}

Referenced by DropDown::messureSize(), and DropDown::render().

Here is the caller graph for this function:

◆ wxDEFINE_EVENT() [1/2]

wxDEFINE_EVENT ( EVT_DISMISS ,
wxCommandEvent  )

◆ wxDEFINE_EVENT() [2/2]

wxDEFINE_EVENT ( EVT_DROPDOWN_ITEM_ACTION ,
wxCommandEvent  )

References DropDown::mouseCaptureLost(), DropDown::mouseDown(), DropDown::mouseMove(), DropDown::mouseReleased(), DropDown::mouseWheelMoved(), and DropDown::paintEvent().

Here is the call graph for this function: