I may suggest a workaround for this - using of ownerdrawn label
...
@ 20,10 SAY cText SIZE 260, 22 STYLE SS_OWNERDRAW ON PAINT {|o,p|FPaint(o,p)}
...
FUNCTION FPaint( o, lpDis )
But it is better to use the new BOARD control, because the code is absolutely the same under Windows and Linux GTK:
...
@ 20, 20 BOARD oBoa SIZE 80, 26 ON PAINT {|o,h|FPaint(o,h)}
oBoa:title := "Input"
...
FUNCTION FPaint( o, h )
IF o:oFont != Nil
hwg_Selectobject( h, o:oFont:handle )
ENDIF
hwg_Rectangle( h,0, 0, o:nWidth-1, o:nHeight-1 )
IF o:tcolor != NIL
hwg_Settextcolor( h, o:tcolor )
ENDIF
Now 2 problem with that BOARD code:
1) control:Title := "xxx" do not update screen
2) adding control:refresh() draw over previous text, never clear old text
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, you need to call :Refresh() to update the control.
What about the second punkt, I just added the TRANSPARENT flag to HBoard command. If it is used, the old text will be erased while refreshing.
Or you may add hwg_fillrect() call to FPaint() to fill the background with desired color.
Regards, Alexander.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've made some changes in HBoard fynctionality to improve and simplify its architecture, the TRANSPARENT clause is removed.
you may add to the code above a line:
oBoa:extStyle := WS_EX_TRANSPARENT
or replace all the code with the following:
@ 20, 20 BOARD oBoa SIZE 80, 26
@ 0, 0 DRAWN oSay SIZE 80, 26 TEXT "Input"
oSay:tBorderColor := 0 // Set the border color
To change the label text you can with the:
oSay:Settext("new_text")
I may suggest a workaround for this - using of ownerdrawn label
...
@ 20,10 SAY cText SIZE 260, 22 STYLE SS_OWNERDRAW ON PAINT {|o,p|FPaint(o,p)}
...
FUNCTION FPaint( o, lpDis )
LOCAL drawInfo := hwg_Getdrawiteminfo( lpDis )
LOCAL hDC := drawInfo[ 3 ], x1 := drawInfo[ 4 ], y1 := drawInfo[ 5 ], x2 := drawInfo[ 6 ], y2 := drawInfo[ 7 ]
IF o:oFont != Nil
hwg_Selectobject( hDC, o:oFont:handle )
ENDIF
IF o:tcolor != NIL
hwg_Settextcolor( hDC, o:tcolor )
ENDIF
hwg_Rectangle( hDC, x1, y1, x2-1, y2-1 ) // Drawing a border
hwg_Settransparentmode( hDC, .T. )
hwg_Drawtext( hDC, o:title, x1+2, y1+2, x2, y2, o:nStyleDraw )
hwg_Settransparentmode( hDC, .F. )
RETURN NIL
You may create a pen of any color and thickness to draw the border, or you may draw a rounded border with hwg_Roundrect().
Regards, Alexander
But it is better to use the new BOARD control, because the code is absolutely the same under Windows and Linux GTK:
...
@ 20, 20 BOARD oBoa SIZE 80, 26 ON PAINT {|o,h|FPaint(o,h)}
oBoa:title := "Input"
...
FUNCTION FPaint( o, h )
IF o:oFont != Nil
hwg_Selectobject( h, o:oFont:handle )
ENDIF
hwg_Rectangle( h,0, 0, o:nWidth-1, o:nHeight-1 )
IF o:tcolor != NIL
hwg_Settextcolor( h, o:tcolor )
ENDIF
hwg_Settransparentmode( h, .T. )
hwg_Drawtext( h, o:title, 2, 2, o:nWidth, o:nHeight )
hwg_Settransparentmode( h, .F. )
RETURN NIL
Last edit: Alexander S.Kresin 2023-08-17
I use BOARD solution
Thanks.
Now 2 problem with that BOARD code:
1) control:Title := "xxx" do not update screen
2) adding control:refresh() draw over previous text, never clear old text
Yes, you need to call :Refresh() to update the control.
What about the second punkt, I just added the TRANSPARENT flag to HBoard command. If it is used, the old text will be erased while refreshing.
Or you may add hwg_fillrect() call to FPaint() to fill the background with desired color.
Regards, Alexander.
Using latest SVN version ok
Thanks
Note: attachment is before latest SVN
I've made some changes in HBoard fynctionality to improve and simplify its architecture, the TRANSPARENT clause is removed.
you may add to the code above a line:
oBoa:extStyle := WS_EX_TRANSPARENT
or replace all the code with the following:
@ 20, 20 BOARD oBoa SIZE 80, 26
@ 0, 0 DRAWN oSay SIZE 80, 26 TEXT "Input"
oSay:tBorderColor := 0 // Set the border color
To change the label text you can with the:
oSay:Settext("new_text")
BTW, a short explanation of HBoard and HDrawn is here: http://www.kresin.ru/notes/index_en.php?b=blog_en&n=6
Last edit: Alexander S.Kresin 2023-11-02