diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 92e51f82..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: windows-build -on: - # push: - # branches: [master] - workflow_dispatch: - -jobs: - build: - runs-on: windows-latest - defaults: - run: - shell: msys2 {0} - steps: - - uses: actions/checkout@v2 - - uses: msys2/setup-msys2@v2 - with: - msystem: MINGW64 - update: true - install: >- - git - mingw-w64-x86_64-cc - mingw-w64-x86_64-gcc - mingw-w64-x86_64-wxWidgets - mingw-w64-x86_64-boost - mingw-w64-x86_64-hunspell - pacboy: >- - cmake:p - ninja:p - - name: CI-Build - run: | - ls /mingw64/bin/ || true - cmake -G "Ninja" -H. -Bbuild -DVCPKG_TARGET_TRIPLET=x64-windows-static - cmake --build build - - uses: actions/upload-artifact@v3 - with: - name: build - path: | - ./build/magicseteditor* - /mingw64/bin/libhunspell-1.7-0.dll diff --git a/src/gui/util.cpp b/src/gui/util.cpp index 124c60b8..e51b65be 100644 --- a/src/gui/util.cpp +++ b/src/gui/util.cpp @@ -12,9 +12,19 @@ #include #include #include -#include #include +#if wxUSE_UXTHEME && defined(__WXMSW__) + #include + #if defined(HAVE_VSSYM32) + #include + #else + #include + #endif + #include + #include +#endif + // ----------------------------------------------------------------------------- : Window related // Id of the control that has the focus, or -1 if no control has the focus @@ -235,7 +245,13 @@ void set_menu_item_image(wxMenuItem* item, const String& resource) { if (item->GetKind() == wxITEM_CHECK) return; // check items can't have icons #endif Image bitmap = load_resource_tool_image(resource); - item->SetBitmap(bitmap); + #if defined(__WXMSW__) + Image disabled_bitmap = generate_disabled_image(bitmap); + item->SetBitmaps(bitmap, bitmap); + item->SetDisabledBitmap(disabled_bitmap); + #else + item->SetBitmap(bitmap); + #endif } wxMenuItem* make_menu_item(wxMenu* menu, int id, const char* resource, const String& text, const String& help, wxItemKind kind, wxMenu* submenu) { @@ -364,6 +380,18 @@ wxImage load_resource_tool_image(const String& name) { #endif #endif +// ----------------------------------------------------------------------------- : Platform look + +#if wxUSE_UXTHEME && defined(__WXMSW__) +RECT msw_rect(wxRect const& rect, int dl = 0, int dt = 0, int dr = 0, int db=0) { + RECT r; + r.left = rect.x - dl; + r.top = rect.y - dt; + r.right = rect.x + rect.width + dr; + r.bottom = rect.y + rect.height + db; + return r; +} +#endif // Draw a basic 3D border void draw3DBorder(DC& dc, int x1, int y1, int x2, int y2) { @@ -382,13 +410,39 @@ void draw3DBorder(DC& dc, int x1, int y1, int x2, int y2) { } void draw_control_box(Window* win, DC& dc, const wxRect& rect, bool focused, bool enabled) { + #if wxUSE_UXTHEME && defined(__WXMSW__) + RECT r = msw_rect(rect, 1,1,1,1); + if (wxUxThemeIsActive()) { + HTHEME hTheme = (HTHEME)::OpenThemeData(GetHwndOf(win), VSCLASS_EDIT); + if (hTheme) { + ::DrawThemeBackground( + hTheme, + (HDC)dc.GetHDC(), + EP_EDITTEXT, + !enabled ? ETS_DISABLED : focused ? ETS_NORMAL : ETS_NORMAL, + &r, + NULL + ); + return; + } + } + #endif // otherwise, draw a standard border // clear the background dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); dc.DrawRectangle(rect); - // draw a 3D border - draw3DBorder(dc, rect.x - 1, rect.y - 1, rect.x + rect.width, rect.y + rect.height); + // draw the border + #if defined(__WXMSW__) + r.left = rect.x - 2; + r.top = rect.y - 2; + r.right = rect.x + rect.width + 2; + r.bottom = rect.y + rect.height + 2; + DrawEdge((HDC)dc.GetHDC(), &r, EDGE_SUNKEN, BF_RECT); + #else + // draw a 3D border + draw3DBorder(dc, rect.x - 1, rect.y - 1, rect.x + rect.width, rect.y + rect.height); + #endif } void draw_button(Window* win, DC& dc, const wxRect& rect, bool focused, bool down, bool enabled) { @@ -432,6 +486,9 @@ void draw_drop_down_arrow(Window* win, DC& dc, const wxRect& rect, bool active) } void draw_checkbox(const Window* win, DC& dc, const wxRect& rect, bool checked, bool enabled) { + #if defined(__WXMSW__) + if (win == nullptr) win = dc.GetWindow(); + #endif if (win) { wxRendererNative& rn = wxRendererNative::GetDefault(); rn.DrawCheckBox(const_cast(win), dc, rect, (checked ? wxCONTROL_CHECKED : 0) | (enabled ? 0 : wxCONTROL_DISABLED)); @@ -448,6 +505,9 @@ void draw_checkbox(const Window* win, DC& dc, const wxRect& rect, bool checked, } void draw_radiobox(const Window* win, DC& dc, const wxRect& rect, bool checked, bool enabled) { + #if defined(__WXMSW__) + if (win == nullptr) win = dc.GetWindow(); + #endif if (win) { wxRendererNative& rn = wxRendererNative::GetDefault(); rn.DrawRadioBitmap(const_cast(win), dc, rect, (checked ? wxCONTROL_CHECKED : 0) | (enabled ? 0 : wxCONTROL_DISABLED)); @@ -469,9 +529,27 @@ void draw_radiobox(const Window* win, DC& dc, const wxRect& rect, bool checked, } void draw_selection_rectangle(Window* win, DC& dc, const wxRect& rect, bool selected, bool focused, bool hot) { - + #if wxUSE_UXTHEME && defined(__WXMSW__) + HTHEME hTheme = (HTHEME)::OpenThemeData(GetHwndOf(win), VSCLASS_LISTVIEW); + if (hTheme) { + RECT r = msw_rect(rect); + ::DrawThemeBackground( + hTheme, + (HDC)dc.GetHDC(), + LVP_LISTITEM, + hot&&selected ? LISS_HOTSELECTED : hot ? LISS_HOT :selected&&focused ? LISS_SELECTED : selected ? LISS_SELECTEDNOTFOCUS : LISS_NORMAL, + &r, + NULL + ); + return; + } + #endif } void enable_themed_selection_rectangle(Window* win) { - + #if wxUSE_UXTHEME && defined(__WXMSW__) + if (wxUxThemeIsActive()) { + ::SetWindowTheme((HWND)win->GetHWND(), L"Explorer", NULL); + } + #endif } diff --git a/src/gui/value/choice.cpp b/src/gui/value/choice.cpp index 4b946600..1ed5cd0e 100644 --- a/src/gui/value/choice.cpp +++ b/src/gui/value/choice.cpp @@ -58,7 +58,7 @@ void ChoiceThumbnailRequest::store(const Image& img) { if (img.Ok()) { ChoiceThumbnail& thumbnail = style().thumbnails[id]; ChoiceThumbnailLock lock(thumbnail.mutex); - thumbnail.bitmap = wxBitmap(img, -1); + thumbnail.bitmap = img; thumbnail.status = THUMB_OK; } }