On Sat, 13 Mar 2021 10:33:06 +0100 QuentinC wrote:
Q> I'm implementing a custom control where the user can select some part of
Q> the content of the control, with whether the keyboard or the mouse.
Q> The content of the control is drawn using wxGraphicsContext.
Q> I would like to indicate to the user what is currently selected:
Q> 1 - by inverting colors inside the selected region, a.k.a. inverse
Q> video. Something that is normally black should appear white when
Q> selected, and conversely. Something that is blue should appear yellow
Q> when selected, etc.
Q> 2 - Draw the focus rectangle around the selected region, well known for
Q> windows users a.k.a. focus ring. The selection is always rectangle.
Q> For part 1, I don't see any specific method to do it, and don't
Q> understand what kind of brush I'm supposed to use in order to achieve
Q> color inversion.
You can't do it with a crush in modern graphics APIs. The solution is to
use wxOverlay and draw something (e.g. just a semitransparent rectangle) on
top of the normal drawing. This may require some rather important changes
to your existing code, but there is just no way around it.
Q> For part 2, is the specific pen and color normally used for focus
Q> indication under windows documented somewhere ?
The pen colour must correspond to some wxSYS_COLOUR_XXX but I don't know
which one, to be honest.
TT-Solutions: wxWidgets consultancy and technical support