Opened 22 months ago

Closed 22 months ago

Last modified 22 months ago

#14781 closed defect (fixed)

wxTextMeasure fix

Reported by: mmarsan Owned by: vadz
Priority: normal Milestone:
Component: GUI-all Version: stable-latest
Keywords: wxTextMeasure Cc:
Blocked By: Blocking:
Patch: yes

Description

Fixes broken first implementation of wxTextMeasure.

Attachments (1)

textmeasure_fix.patch download (11.9 KB) - added by mmarsan 22 months ago.

Download all attachments as: .zip

Change History (8)

Changed 22 months ago by mmarsan

comment:1 follow-up: Changed 22 months ago by vadz

  • Owner set to vadz
  • Status changed from new to accepted

I'm not sure I understand the logic of the patch for GTK+3/wxGCDC checks. AFAICS we can never use "own GTE" in wxGTK3 currently. And in wxGTK2 wxGCDCImpl never derives from wxWindowDCImpl. Or am I missing something?

I also think m_useOwnGTE is very cryptic so I'll rename it. Please check the updated version of the patch to be committed soon and let me know if it has any problems. TIA!

comment:2 Changed 22 months ago by VZ

(In [72799]) Just fix header comments of wxTextMeasure-related files, no real changes.

See #14781.

comment:3 Changed 22 months ago by VZ

(In [72801]) Allow wxTextMeasure to work with non-native wxDC objects too.

Just forward back to wxDC itself in this case instead of using the
platform-specific code in wxTextMeasure that only works with native DCs.

See #14781.

comment:4 Changed 22 months ago by VZ

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [72802]) Allow using wxTextMeasure::GetLargestStringExtent() with wxArrayString.

Change the signature of this method to take the number of strings and the
pointer to the first of them instead of wxVector<wxString> as this allows it
to be used with all of wxVector<wxString>, wxArrayString and raw arrays of
wxStrings.

Also return the computed size from it instead of filling output parameters.

Closes #14781.

comment:5 in reply to: ↑ 1 ; follow-up: Changed 22 months ago by mmarsan

Replying to vadz:

I'm not sure I understand the logic of the patch for GTK+3/wxGCDC checks. AFAICS we can never use "own GTE" in wxGTK3 currently. And in wxGTK2 wxGCDCImpl never derives from wxWindowDCImpl. Or am I missing something?

For GTK+2 wxWindowDCImpl derives from wxGTKDCImpl, which derives from wxDCImpl.
For GTK+3 wxWindowDCImpl derives from wxGTKCairoDCImpl, which derives from wxGCDCImpl.

I haven't tested your changes. They seem good, except for src/gtk/textemeasure.cpp.
In GTK+2 wxGraphicsContext can be used, so wxGCDCImpl is "on" instead of wxDCImpl.
So, #ifndef __WXGTK3__ is not enough.

comment:6 in reply to: ↑ 5 ; follow-up: Changed 22 months ago by vadz

Replying to mmarsan:

I haven't tested your changes.

Could you please test them with GTK+3? I still don't have it here...

They seem good, except for src/gtk/textemeasure.cpp.
In GTK+2 wxGraphicsContext can be used, so wxGCDCImpl is "on" instead of wxDCImpl.
So, #ifndef __WXGTK3__ is not enough.

Sorry, I still don't see why. AFAICS we can never use wxGTK2 code with wxDC in wxGTK3. Or can we? If so, when?

comment:7 in reply to: ↑ 6 Changed 22 months ago by mmarsan

Could you please test them with GTK+3? I still don't have it here...

Combo and richtext samples work fine in GTK+3.

In GTK+2 wxGraphicsContext can be used, so wxGCDCImpl is "on" instead of wxDCImpl.
So, #ifndef __WXGTK3__ is not enough.

Sorry, I still don't see why. AFAICS we can never use wxGTK2 code with wxDC in wxGTK3. Or can we? If so, when?

My fault, I missed that wxGraphicsContext does *not* derive from any wxDC (its name confused me).
I was thinking on something like:

wxGraphicsContext *gc = wxGraphicsContext::Create( dc );
wxSize size = gc->GetMultiLineExtent(text);

would use wxTextMeasure::GetMultiLineExtent(), and CallGetTextExtent() would be called with the wrong m_useDCImpl value.

Neither wxGraphicsContext derives from wxDC nor it has GetMultiLineExtent() member. No issues then.

Note: See TracTickets for help on using tickets.