comparison src/ui_utils.cpp @ 2:23d0d9319a00

Update Also converted everything to LF from CRLF
author Paper <mrpapersonic@gmail.com>
date Sat, 12 Aug 2023 03:16:26 -0400
parents 1ae666fdf9e2
children 1d82f6e04d7d
comparison
equal deleted inserted replaced
1:1ae666fdf9e2 2:23d0d9319a00
1 #include "window.h" 1 #include "window.h"
2 #include "ui_utils.h" 2 #include "ui_utils.h"
3 #ifdef MACOSX
4 #include "sys/osx/dark_theme.h"
5 #else
6 #include "sys/win32/dark_theme.h"
7 #endif
3 8
4 void UiUtils::CreateTextHeader(wxWindow* parent, const wchar_t* title, int width, int x, int y) { 9 bool UiUtils::IsInDarkMode() {
5 wxStaticText* static_text_title = new wxStaticText(parent, wxID_ANY, title, wxPoint(x, y), wxSize(width, 15), wxALIGN_LEFT); 10 if (session.config.theme != OS)
6 wxFont font = static_text_title->GetFont(); 11 return (session.config.theme == DARK);
7 font.SetWeight(wxFONTWEIGHT_BOLD); 12 #ifdef MACOSX
8 static_text_title->SetFont(font); 13 if (osx::DarkThemeAvailable()) {
9 //wxStaticLine* line = new wxStaticLine(parent, wxID_ANY, wxPoint(x,y+15), wxSize(width, 2), wxLI_HORIZONTAL); 14 if (osx::IsInDarkTheme()) {
10 wxClientDC dc(parent); 15 return true;
11 dc.DrawRectangle(x, y+15, width, 2); 16 } else {
17 return false;
18 }
19 }
20 #elif defined(WIN32)
21 if (win32::DarkThemeAvailable()) {
22 if (win32::IsInDarkTheme()) {
23 return true;
24 } else {
25 return false;
26 }
27 }
28 #endif
29 return (session.config.theme == DARK);
12 } 30 }
13 31
14 wxStaticText* UiUtils::CreateTextParagraph(wxWindow* parent, const wchar_t* title, const wchar_t* data, int width, int height, int x, int y) { 32 void UiUtils::CreateTextHeader(QWidget* parent, QString title, QPoint point, QSize size) {
15 CreateTextHeader(parent, title, width, x, y); 33 QLabel* static_text_title = new QLabel(title, parent);
16 return new wxStaticText(parent, wxID_ANY, data, wxPoint(x+23, y+30), wxSize(width-23, height), wxALIGN_LEFT); 34 static_text_title->setTextFormat(Qt::PlainText);
35 static_text_title->setStyleSheet("font-weight: bold");
36 static_text_title->move(point.x(), point.y());
37 static_text_title->resize(size.width(), 16);
38
39 QFrame* static_text_line = new QFrame(parent);
40 static_text_line->setFrameShape(QFrame::HLine);
41 static_text_line->setFrameShadow(QFrame::Sunken);
42 static_text_line->resize(size.width(), 2);
43 static_text_line->move(point.x(), point.y()+18);
17 } 44 }
18 45
19 wxStaticText* UiUtils::CreateTextParagraphWithLabels(wxWindow* parent, const wchar_t* title, const wchar_t* label, const wchar_t* data, int width, int height, int x, int y) { 46 QPlainTextEdit* UiUtils::CreateTextParagraph(QWidget* parent, QString title, QString data, QPoint point, QSize size) {
20 CreateTextHeader(parent, title, width, x, y); 47 CreateTextHeader(parent, title, point, size);
21 new wxStaticText(parent, wxID_ANY, label, wxPoint(x+23, y+30), wxSize(width-23, height), wxALIGN_LEFT); 48
22 return new wxStaticText(parent, wxID_ANY, data, wxPoint(x+157, y+30), wxSize(width-157, height), wxALIGN_LEFT); 49 QPlainTextEdit* paragraph = new QPlainTextEdit(data, parent);
50 paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
51 paragraph->setWordWrapMode(QTextOption::NoWrap);
52 paragraph->setFrameShape(QFrame::NoFrame);
53 paragraph->move(point.x()+12, point.y()+32);
54 paragraph->resize(size.width()-12, size.height()-32);
55 return paragraph;
56 }
57
58 QPlainTextEdit* UiUtils::CreateTextParagraphWithLabels(QWidget* parent, QString title, QString label, QString data, QPoint point, QSize size) {
59 CreateTextHeader(parent, title, point, size);
60
61 QPlainTextEdit* label_t = new QPlainTextEdit(label, parent);
62 label_t->setTextInteractionFlags(Qt::NoTextInteraction);
63 label_t->setWordWrapMode(QTextOption::NoWrap);
64 label_t->setFrameShape(QFrame::NoFrame);
65 label_t->move(point.x()+12, point.y()+32);
66 label_t->resize(90, size.height()-32);
67
68 QPlainTextEdit* paragraph = new QPlainTextEdit(data, parent);
69 paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
70 paragraph->setWordWrapMode(QTextOption::NoWrap);
71 paragraph->setFrameShape(QFrame::NoFrame);
72 paragraph->move(point.x()+102, point.y()+32);
73 paragraph->resize(size.width()-102, size.height()-32);
74 return paragraph;
23 } 75 }
24 76
25 /* As far as I can tell, this is identical to the way Taiga implements it. 77 /* As far as I can tell, this is identical to the way Taiga implements it.
26 Kind of cool, I didn't even look into the source code for it :p */ 78 Kind of cool, I didn't even look into the source code for it :p */
27 wxTextCtrl* UiUtils::CreateSelectableTextParagraph(wxWindow* parent, const wchar_t* title, const wchar_t* data, int width, int height, int x, int y) { 79 QPlainTextEdit* UiUtils::CreateSelectableTextParagraph(QWidget* parent, QString title, QString data, QPoint point, QSize size) {
28 CreateTextHeader(parent, title, width, x, y); 80 CreateTextHeader(parent, title, point, size);
29 wxTextCtrl* textctrl = new wxTextCtrl(parent, wxID_ANY, "", wxPoint(x+23, y+30), wxSize(width-23, height), wxTE_LEFT | wxBORDER_NONE | wxTE_BESTWRAP | wxTE_READONLY | wxTE_MULTILINE | wxTE_NO_VSCROLL); 81
30 (*textctrl) << data; 82 QPlainTextEdit* text_edit = new QPlainTextEdit(data, parent);
31 return textctrl; 83 text_edit->setReadOnly(true);
84 text_edit->setFrameShape(QFrame::NoFrame);
85 text_edit->move(point.x()+12, point.y()+32);
86 text_edit->resize(size.width()-12, size.height()-32);
87 return text_edit;
32 } 88 }