diff options
Diffstat (limited to 'wx+')
-rw-r--r-- | wx+/bitmap_button.h | 32 | ||||
-rw-r--r-- | wx+/dc.h | 8 | ||||
-rw-r--r-- | wx+/graph.cpp | 2 | ||||
-rw-r--r-- | wx+/image_tools.cpp | 45 | ||||
-rw-r--r-- | wx+/image_tools.h | 2 | ||||
-rw-r--r-- | wx+/popup_dlg.cpp | 15 | ||||
-rw-r--r-- | wx+/popup_dlg.h | 4 | ||||
-rw-r--r-- | wx+/tooltip.cpp | 2 |
8 files changed, 82 insertions, 28 deletions
diff --git a/wx+/bitmap_button.h b/wx+/bitmap_button.h index 70f161d2..188ee607 100644 --- a/wx+/bitmap_button.h +++ b/wx+/bitmap_button.h @@ -42,8 +42,10 @@ void setBitmapTextLabel(wxBitmapButton& btn, const wxImage& img, const wxString& void setImage(wxAnyButton& button, const wxImage& bmp); void setImage(wxStaticBitmap& staticBmp, const wxImage& img); -wxBitmap renderSelectedButton(const wxSize& sz); -wxBitmap renderPressedButton(const wxSize& sz); +wxImage renderPressedButton(const wxSize& sz); + +inline wxColor getColorToggleButtonBorder(){ return {0x79, 0xbc, 0xed}; } //medium blue +inline wxColor getColorToggleButtonFill (){ return {0xcc, 0xe4, 0xf8}; } //light blue @@ -100,25 +102,14 @@ void setImage(wxStaticBitmap& staticBmp, const wxImage& img) } -inline -wxBitmap renderSelectedButton(const wxSize& sz) -{ - wxBitmap bmp(sz); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes - bmp.SetScaleFactor(getDisplayScaleFactor()); - { - wxMemoryDC dc(bmp); - - const wxColor borderCol(0x79, 0xbc, 0xed); //medium blue - const wxColor innerCol (0xcc, 0xe4, 0xf8); //light blue - drawInsetRectangle(dc, wxRect(bmp.GetSize()), fastFromDIP(1), borderCol, innerCol); - } - return bmp; -} - inline -wxBitmap renderPressedButton(const wxSize& sz) +wxImage generatePressedButtonBack(const wxSize& sz) { +#if 1 + return rectangleImage(sz, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW), {0x11, 0x79, 0xfe} /*light blue*/, fastFromDIP(2)); + +#else //rectangle border with gradient as background wxBitmap bmp(sz); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes bmp.SetScaleFactor(getDisplayScaleFactor()); { @@ -145,7 +136,10 @@ wxBitmap renderPressedButton(const wxSize& sz) dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); dc.DrawRectangle(rect); } - return bmp; + wxImage img = bmp.ConvertToImage(); + convertToVanillaImage(img); + return img; +#endif } } @@ -13,7 +13,7 @@ #include <wx/dcbuffer.h> //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER #include <wx/dcscreen.h> #include <wx/bmpbndl.h> -// #include <gtk/gtk.h> + // #include <gtk/gtk.h> namespace zen @@ -50,12 +50,12 @@ void clearArea(wxDC& dc, const wxRect& rect, const wxColor& col) //properly draw rectangle respecting high DPI (and avoiding wxPen position fuzzyness) inline -void drawInsetRectangle(wxDC& dc, wxRect rect, int borderWidth, const wxColor& borderCol, const wxColor& innerCol) +void drawFilledRectangle(wxDC& dc, wxRect rect, const wxColor& innerCol, const wxColor& borderCol, int borderWidth) { if (rect.width > 0 && rect.height > 0) { - assert(borderCol.IsSolid() && innerCol.IsSolid()); + assert(innerCol.IsSolid() && borderCol.IsSolid()); wxDCPenChanger rectPen (dc, *wxTRANSPARENT_PEN); wxDCBrushChanger rectBrush(dc, borderCol); dc.DrawRectangle(rect); @@ -68,7 +68,7 @@ void drawInsetRectangle(wxDC& dc, wxRect rect, int borderWidth, const wxColor& b inline -void drawInsetRectangle(wxDC& dc, const wxRect& rect, int borderWidth, const wxColor& col) +void drawRectangleBorder(wxDC& dc, const wxRect& rect, const wxColor& col, int borderWidth) { if (rect.width > 0 && rect.height > 0) diff --git a/wx+/graph.cpp b/wx+/graph.cpp index 07268f34..d755a839 100644 --- a/wx+/graph.cpp +++ b/wx+/graph.cpp @@ -576,7 +576,7 @@ void Graph2D::render(wxDC& dc) const assert(attr_.yLabelpos == YLabelPos::none || attr_.labelFmtY); //paint graph background (excluding label area) - drawInsetRectangle(dc, graphArea, fastFromDIP(1), getBorderColor(), attr_.colorBack); + drawFilledRectangle(dc, graphArea, attr_.colorBack, getBorderColor(), fastFromDIP(1)); graphArea.Deflate(fastFromDIP(1)); //set label areas respecting graph area border! diff --git a/wx+/image_tools.cpp b/wx+/image_tools.cpp index 72c7dc74..04f7f7ff 100644 --- a/wx+/image_tools.cpp +++ b/wx+/image_tools.cpp @@ -397,7 +397,7 @@ void zen::convertToVanillaImage(wxImage& img) const unsigned char* rgb = img.GetData(); const int pixelCount = width * height; - for (int i = 0; i < pixelCount; ++ i) + for (int i = 0; i < pixelCount; ++i) { const unsigned char r = *rgb++; const unsigned char g = *rgb++; @@ -415,3 +415,46 @@ void zen::convertToVanillaImage(wxImage& img) assert(!img.HasMask()); } } + +wxImage zen::rectangleImage(wxSize size, const wxColor& col) +{ + assert(col.IsSolid()); + wxImage img(size); + + unsigned char* rgb = img.GetData(); + const int pixelCount = size.GetWidth() * size.GetHeight(); + for (int i = 0; i < pixelCount; ++i) + { + *rgb++ = col.GetRed(); + *rgb++ = col.GetGreen(); + *rgb++ = col.GetBlue(); + } + convertToVanillaImage(img); + return img; +} + + +wxImage zen::rectangleImage(wxSize size, const wxColor& innerCol, const wxColor& borderCol, int borderWidth) +{ + assert(innerCol.IsSolid() && borderCol.IsSolid()); + wxImage img = rectangleImage(size, borderCol); + + const int heightInner = size.GetHeight() - 2 * borderWidth; + const int widthInner = size.GetWidth () - 2 * borderWidth; + + if (widthInner > 0 && heightInner > 0 && innerCol != borderCol) + //copyImageLayover(rectangleImage({widthInner, heightInner}, innerCol), img, {borderWidth, borderWidth}); => inline: + for (int y = 0; y < heightInner; ++y) + { + unsigned char* rgb = img.GetData () + 3 * (borderWidth + (borderWidth + y) * size.GetWidth()); + + for (int x = 0; x < widthInner; ++x) + { + *rgb++ = innerCol.GetRed(); + *rgb++ = innerCol.GetGreen(); + *rgb++ = innerCol.GetBlue(); + } + } + + return img; +} diff --git a/wx+/image_tools.h b/wx+/image_tools.h index bfd107d0..79b15e3a 100644 --- a/wx+/image_tools.h +++ b/wx+/image_tools.h @@ -58,6 +58,8 @@ inline wxImage shrinkImage(const wxImage& img, int maxSize) { return shrinkImage wxImage resizeCanvas(const wxImage& img, wxSize newSize, int alignment); +wxImage rectangleImage(wxSize size, const wxColor& col); +wxImage rectangleImage(wxSize size, const wxColor& innerCol, const wxColor& borderCol, int borderWidth); diff --git a/wx+/popup_dlg.cpp b/wx+/popup_dlg.cpp index b5a194ad..9f29badc 100644 --- a/wx+/popup_dlg.cpp +++ b/wx+/popup_dlg.cpp @@ -91,6 +91,17 @@ void setBestInitialSize(wxRichTextCtrl& ctrl, const wxString& text, wxSize maxSi } +int zen::getTextCtrlHeight(wxTextCtrl& ctrl, double rowCount) +{ + const int rowHeight = + ctrl.GetTextExtent(L"X").GetHeight(); + + return std::round( + 2 + + rowHeight * rowCount); +} + + class zen::StandardPopupDialog : public PopupDialogGenerated { public: @@ -277,8 +288,8 @@ public: GetSizer()->SetSizeHints(this); //~=Fit() + SetMinSize() #ifdef __WXGTK3__ - Show(); //GTK3 size calculation requires visible window: https://github.com/wxWidgets/wxWidgets/issues/16088 - Hide(); //avoid old position flash when Center() moves window (asynchronously?) + Show(); //GTK3 size calculation requires visible window: https://github.com/wxWidgets/wxWidgets/issues/16088 + Hide(); //avoid old position flash when Center() moves window (asynchronously?) #endif Center(); //needs to be re-applied after a dialog size change! diff --git a/wx+/popup_dlg.h b/wx+/popup_dlg.h index ca4a7591..cabf13f5 100644 --- a/wx+/popup_dlg.h +++ b/wx+/popup_dlg.h @@ -13,6 +13,7 @@ #include <wx/window.h> #include <wx/bitmap.h> #include <wx/string.h> +#include <wx/textctrl.h> namespace zen @@ -94,6 +95,9 @@ private: wxString checkBoxLabel; ConfirmationButton3 buttonToDisableWhenChecked = ConfirmationButton3::cancel; }; + + +int getTextCtrlHeight(wxTextCtrl& ctrl, double rowCount); } #endif //POPUP_DLG_H_820780154723456 diff --git a/wx+/tooltip.cpp b/wx+/tooltip.cpp index f8d23c5d..86b9ec8d 100644 --- a/wx+/tooltip.cpp +++ b/wx+/tooltip.cpp @@ -13,7 +13,7 @@ #include "image_tools.h" #include "bitmap_button.h" #include "dc.h" -#include <gtk/gtk.h> + #include <gtk/gtk.h> using namespace zen; |