Opened 3 years ago

Closed 3 years ago

Last modified 3 years 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


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 years ago.
Patch based on r77018
DrawGauge_sample.jpg download (116.6 KB) - added by TcT 3 years ago.
Sample screenshot

Download all attachments as: .zip

Change History (6)

Changed 3 years ago by TcT

Patch based on r77018

Changed 3 years ago by TcT

Sample screenshot

comment:1 Changed 3 years 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 3 years 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 3 years ago by VZ

In 77024:

(The changeset message doesn't reference this ticket)

comment:4 Changed 3 years ago by vadz

For future reference: there was a problem with the initial implementation, see r78278 for the correction.

Note: See TracTickets for help on using tickets.