Opened 3 months ago

Closed 2 months ago

Last modified 2 months ago

#16406 closed enhancement (fixed)

New wxNativeRenderer method DrawGauge for native progress display style in custom controls

Reported by: TcT Owned by: VZ
Priority: normal Milestone:
Component: base Version: dev-latest
Keywords: msw, osx Cc:
Blocked By: Blocking:
Patch: yes

Description

In various scenarios a wxGauge like progress display is required in another control like in wxDataViewProgressRenderer.

I've attached a patch that implements a ::DrawGauge method to wxNativeRenderer.

I've implemented the function for MSW (XP theme and legacy), OSX and generic. I've also modified wxDataViewProgressRenderer to use wxNativeRenderer::DrawGauge. A screenshot of the wxDataView sample with the patch applied is attached.

New method is modeled like the existing wxNativeRenderer methods:

virtual void DrawGauge(wxWindow* win,
                       wxDC& dc,
                       const wxRect& rect,
                       int value,
                       int max,
                       int flags = 0) = 0;
  • value current progress value
  • max maximum progress value
  • flags currently unused

Attachments (2)

wxWidgets-gauge_native_renderer.patch download (9.5 KB) - added by TcT 3 months ago.
Patch based on r77018
DrawGauge_sample.jpg download (116.6 KB) - added by TcT 3 months ago.
Sample screenshot

Download all attachments as: .zip

Change History (5)

Changed 3 months ago by TcT

Patch based on r77018

Changed 3 months ago by TcT

Sample screenshot

comment:1 Changed 2 months ago by vadz

Thanks for the nice patch! Applying it with just some minor style changes and the addition of the documentation to source:wxWidgets/trunk/interface/wx/renderer.h.

I looked at how this could be implemented for wxGTK, but this doesn't look trivial, there is no standard function to do it and the closes I could find was gtk_cell_renderer_progress_render() used by GtkCellRendererProgress but it's rather longish... Still, ideally we should do something like this to match the themed look for wxGTK.

comment:2 Changed 2 months ago by VZ

  • Owner set to VZ
  • Resolution set to fixed
  • Status changed from new to closed

In 77023:

Add wxRendererNative::DrawGauge() method.

Add the method with the native implementations for MSW and OS X and a generic
version fallback.

Closes #16406.

comment:3 Changed 2 months ago by VZ

In 77024:

wxOSX compilation fix after the last commit.

Add the missing wx/time.h header required for using wxGetLocalTimeMillis().

Also add WXUNUSED() around the unused parameters of DrawGauge().

See #16406.

Note: See TracTickets for help on using tickets.