OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::Search::SearchItem Class Reference

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

Inheritance diagram for Slic3r::Search::SearchItem:
Collaboration diagram for Slic3r::Search::SearchItem:

Public Member Functions

 SearchItem (wxWindow *parent, wxString text, int index, SearchDialog *sdialog=nullptr, SearchObjectDialog *search_dialog=nullptr, wxString tooltip="")
 ~SearchItem ()
wxSize DrawTextString (wxDC &dc, const wxString &text, const wxPoint &pt, bool bold)
void OnPaint (wxPaintEvent &event)
void on_mouse_enter (wxMouseEvent &evt)
void on_mouse_leave (wxMouseEvent &evt)
void on_mouse_left_down (wxMouseEvent &evt)
void on_mouse_left_up (wxMouseEvent &evt)

Public Attributes

wxString m_text
int m_index
SearchDialog * m_sdialog { nullptr }
SearchObjectDialog * m_search_object_dialog { nullptr }
GUI::ObjectDataViewModelNode * m_item { nullptr }

Detailed Description

Constructor & Destructor Documentation

◆ SearchItem()

Slic3r::Search::SearchItem::SearchItem ( wxWindow * parent,
wxString text,
int index,
SearchDialog * sdialog = nullptr,
SearchObjectDialog * search_dialog = nullptr,
wxString tooltip = "" )
300 : wxWindow(parent, wxID_ANY, wxDefaultPosition, wxSize(parent->GetSize().GetWidth(), 3 * GUI::wxGetApp().em_unit()))
301{
302 m_sdialog = sdialog;
303 m_search_object_dialog = search_dialog;
304 m_text = text;
305 m_index = index;
306
307 this->SetToolTip(tooltip);
308
309 SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#FFFFFF")));
310 Bind(wxEVT_ENTER_WINDOW, &SearchItem::on_mouse_enter, this);
311 Bind(wxEVT_LEAVE_WINDOW, &SearchItem::on_mouse_leave, this);
312 Bind(wxEVT_LEFT_DOWN, &SearchItem::on_mouse_left_down, this);
313 Bind(wxEVT_LEFT_UP, &SearchItem::on_mouse_left_up, this);
314 Bind(wxEVT_PAINT, &SearchItem::OnPaint, this);
315}
wxString m_text
Definition Search.hpp:130
void on_mouse_enter(wxMouseEvent &evt)
Definition Search.cpp:396
void on_mouse_leave(wxMouseEvent &evt)
Definition Search.cpp:402
void on_mouse_left_up(wxMouseEvent &evt)
Definition Search.cpp:414
SearchDialog * m_sdialog
Definition Search.hpp:132
void on_mouse_left_down(wxMouseEvent &evt)
Definition Search.cpp:408
void OnPaint(wxPaintEvent &event)
Definition Search.cpp:331
SearchObjectDialog * m_search_object_dialog
Definition Search.hpp:133
int m_index
Definition Search.hpp:131
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219

References StateColor::darkModeColorFor(), em_unit(), m_index, m_sdialog, m_search_object_dialog, m_text, on_mouse_enter(), on_mouse_leave(), on_mouse_left_down(), on_mouse_left_up(), and OnPaint().

Here is the call graph for this function:

◆ ~SearchItem()

Slic3r::Search::SearchItem::~SearchItem ( )
inline
137{};

Member Function Documentation

◆ DrawTextString()

wxSize Slic3r::Search::SearchItem::DrawTextString ( wxDC & dc,
const wxString & text,
const wxPoint & pt,
bool bold )
318{
319 if (bold) {
320 dc.SetFont(Label::Head_14);
321 } else {
322 dc.SetFont(Label::Body_14);
323 }
324
325 dc.SetBackgroundMode(wxTRANSPARENT);
326 dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#323A3C")));
327 dc.DrawText(text, pt);
328 return dc.GetTextExtent(text);
329}
static wxFont Head_14
Definition Label.hpp:45
static wxFont Body_14
Definition Label.hpp:53

References Label::Body_14, StateColor::darkModeColorFor(), and Label::Head_14.

Referenced by OnPaint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_mouse_enter()

void Slic3r::Search::SearchItem::on_mouse_enter ( wxMouseEvent & evt)
397{
398 SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#BFE1DE"))); // ORCA color with %25 opacity
399 Refresh();
400}

References StateColor::darkModeColorFor().

Referenced by SearchItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_mouse_leave()

void Slic3r::Search::SearchItem::on_mouse_leave ( wxMouseEvent & evt)
403{
404 SetBackgroundColour(StateColor::darkModeColorFor(wxColour(255, 255, 255)));
405 Refresh();
406}

References StateColor::darkModeColorFor().

Referenced by SearchItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_mouse_left_down()

void Slic3r::Search::SearchItem::on_mouse_left_down ( wxMouseEvent & evt)
409{
410 SetBackgroundColour(StateColor::darkModeColorFor(wxColour("#BFE1DE"))); // ORCA color with %25 opacity
411 Refresh();
412}

References StateColor::darkModeColorFor().

Referenced by SearchItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_mouse_left_up()

void Slic3r::Search::SearchItem::on_mouse_left_up ( wxMouseEvent & evt)
415{
416
417 //if (m_sdialog->prevent_list_events) return;
418 // if (wxGetMouseState().LeftIsDown())
419 if (m_sdialog) {
420 m_sdialog->Die();
421 wxCommandEvent event(wxCUSTOMEVT_JUMP_TO_OPTION);
422 event.SetInt(m_index);
423 wxPostEvent(GUI::wxGetApp().plater(), event);
424 }
425
428 wxCommandEvent event(wxCUSTOMEVT_JUMP_TO_OBJECT);
429 event.SetClientData(m_item);
430 wxPostEvent(GUI::wxGetApp().plater(), event);
431 }
432}
GUI::ObjectDataViewModelNode * m_item
Definition Search.hpp:134

References m_index, m_item, m_sdialog, and m_search_object_dialog.

Referenced by SearchItem().

Here is the caller graph for this function:

◆ OnPaint()

void Slic3r::Search::SearchItem::OnPaint ( wxPaintEvent & event)
332{
333 wxPaintDC dc(this);
334 auto top = 5;
335 int left = 20;
336
337 auto bold_pair = std::vector<std::pair<int, int>>();
338
339 auto index = 0;
340
341 auto b_first_list = std::vector<int>();
342 auto b_second_list = std::vector<int>();
343
344 auto position = 0;
345 while ((position = m_text.find("<b>", position)) != wxString::npos) {
346 b_first_list.push_back(position);
347 position++;
348 }
349
350 position = 0;
351 while ((position = m_text.find("</b>", position)) != wxString::npos) {
352 b_second_list.push_back(position + 3);
353 position++;
354 }
355
356 if (b_first_list.size() != b_second_list.size()) { return; }
357
358 for (auto i = 0; i < b_first_list.size(); i++) {
359 auto pair = std::make_pair(b_first_list[i], b_second_list[i]);
360 bold_pair.push_back(pair);
361 }
362
363 //DrawTextString(dc, m_text, wxPoint(left, top), false);
364 /*if (bold_pair.size() <= 0) {
365 DrawTextString(dc, m_text, wxPoint(left, top), false);
366 } else {
367 auto index = 0;
368 for (auto i = 0; i < bold_pair.size(); i++) { DrawTextString(dc, m_text.SubString(index, bold_pair[i].second), wxPoint(left, top), true); }
369 }*/
370 auto str = wxString("");
371 for (auto c = 0; c < m_text.length(); c++) {
372 str = m_text[c];
373
374 auto inset = false;
375 auto pair_index = 0;
376 for (auto o = 0; o < bold_pair.size(); o++) {
377 if (c >= bold_pair[o].first && c <= bold_pair[o].second) {
378 pair_index = o;
379 inset = true;
380 break;
381 }
382 }
383
384 if (!inset) {
385 left += DrawTextString(dc, str, wxPoint(left, top), false).GetWidth();
386 } else {
387 //str = str.erase(bold_pair[pair_index].first, 3);
388 //str = str.erase(bold_pair[pair_index].second, 4);
389 if (c - bold_pair[pair_index].first >= 3 && bold_pair[pair_index].second - c > 3) {
390 left += DrawTextString(dc, str, wxPoint(left, top), true).GetWidth();
391 }
392 }
393 }
394}
wxSize DrawTextString(wxDC &dc, const wxString &text, const wxPoint &pt, bool bold)
Definition Search.cpp:317
BoundingBox inset(BoundingBox box, const Point &by)
Definition IMEXArrange.cpp:38
@ left
Definition MarchingSquares.hpp:188

References DrawTextString(), and m_text.

Referenced by SearchItem().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_index

int Slic3r::Search::SearchItem::m_index

Referenced by SearchItem(), and on_mouse_left_up().

◆ m_item

GUI::ObjectDataViewModelNode* Slic3r::Search::SearchItem::m_item { nullptr }
134{ nullptr };

Referenced by on_mouse_left_up().

◆ m_sdialog

SearchDialog* Slic3r::Search::SearchItem::m_sdialog { nullptr }
132{ nullptr };

Referenced by SearchItem(), and on_mouse_left_up().

◆ m_search_object_dialog

SearchObjectDialog* Slic3r::Search::SearchItem::m_search_object_dialog { nullptr }
133{ nullptr };

Referenced by SearchItem(), and on_mouse_left_up().

◆ m_text

wxString Slic3r::Search::SearchItem::m_text

Referenced by SearchItem(), and OnPaint().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Search.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Search.cpp