larrybtoys
Full Member
Retired Part Time IT Professional
Posts: 244
|
Post by larrybtoys on Apr 5, 2023 23:57:07 GMT 1
Has anyone had this issue and if so is there a fix for it. It is a bug in GFA Basic 32. When clipping a portion of the screen containing centered text and placing the clipped area somewhere else, the centered text that is contained in the clipped portion will no longer be centered. This should be impossible. Whatever is on the screen in the clipped portion should be clipped unchanged. See example which is also attached: Auto Black%, Clipped_Text$, Gray%, MY_HEIGHT%, MY_WIDTH% Auto scnmaxx%, scnmaxy%, White% ' scnmaxx% = _X scnmaxy% = _Y MY_WIDTH% = 1000 : MY_HEIGHT% = 600 ' OpenW # 1, (scnmaxx% - MY_WIDTH%) / 2, (scnmaxy% - MY_HEIGHT%) / 2, MY_WIDTH% + 7, MY_HEIGHT% + 30, 16 + 32 Win_1.AutoRedraw = 1 TopW # 1 Win # 1 GraphMode R2_COPYPEN, OPAQUE 'OverWright mode SetFont 16 'Proportional Font Mode Date "/" ' us date and us print using Mode StrSpace 0 'NO Space before the STR command ' Black% = RGB(0, 0, 0) Gray% = RGB(128, 128, 128) White% = RGB(255, 255, 255) ' Cls Color Black%, Black% PBox 0, 1, 1000, 600 ' Color Gray%, Gray% PBox 0, 200, 1000, 240 ' 'This example does not work properly Color White%, Gray% ~SetTextAlign(Win_1.hDC, 6) SetFont "times", 16 Text 500, 210, "Hello, This is a TEST" ~SetTextAlign(Win_1.hDC, 0) ' Get 450, 200, 550, 240, Clipped_Text$ Put 450, 260, Clipped_Text$ ' ' 'This example works fine but cannot use the CENTER TEXT function Color Gray%, Gray% PBox 0, 400, 1000, 440 ' Color White%, Gray% SetFont "times", 16 Text 412, 410, "Hello, This is a TEST" ' Get 450, 400, 550, 440, Clipped_Text$ Put 450, 460, Clipped_Text$ ' Do Loop Until MouseK ' GraphMode 1 CloseW # 1 End ' ' ' ' ' ' Attachments:Example.G32 (1.6 KB)
|
|
|
Post by (X) on Apr 6, 2023 15:20:17 GMT 1
if you change autoredraw to 0 then it appears to work as expected.
or
If you want autoredraw = 1
then target hDC2 instead of hDC:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' This example works if hDC2 is targeted ' Color White%, Gray% ~SetTextAlign(Win_1.hDC2, 6) SetFont "times", 16 Text 500, 210, "Hello, This is a TEST"
~SetTextAlign(Win_1.hDC2, 0)
' Get 450, 200, 550, 240, Clipped_Text$ Put 450, 260, Clipped_Text$
Win_1.InvalidateAll AutoRedraw = 0 only has one hDC, AutoRdraw = 1 has two: hDC and hDC2 (the back buffer)
You can "draw" to the back buffer "silently" and make the back buffer "appear" (be copied to the front buffer hDC) with the Invalidate command and its other variations: InvalidateAll, Invalidate x,y,w,h.
|
|
webu
Full Member
Posts: 140
|
Post by webu on Apr 6, 2023 15:52:00 GMT 1
Maybe one more little thing. So you can open windows centered:
OpenW 1, , , 640, 400 // with width and height, but without x and y
or
OpenW 1, , ,
Just omit x and y. But the commas are important and necessary.
|
|
larrybtoys
Full Member
Retired Part Time IT Professional
Posts: 244
|
Post by larrybtoys on Apr 6, 2023 22:59:38 GMT 1
Not sure if this is proper but it worked when I center both HDC and HDC2 like this:
~SetTextAlign(Win_1.hDC, 6) ~SetTextAlign(Win_1.hDC2, 6) SetFont "times", 16 Text 500, 210, "Hello, This is a TEST" ~SetTextAlign(Win_1.hDC2, 0) ~SetTextAlign(Win_1.hDC, 0)
|
|
|
Post by (X) on Apr 7, 2023 12:47:32 GMT 1
I may be wrong, but, I don't see any difference if I include hDC and hDC2 or just target hDC2. (Apparently, in this case, you don't even need to use the Invalidate command.)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Initialisations ' Dim Black%, Clipped_Text$, Gray%, MY_HEIGHT% = 600, MY_WIDTH% = 1000 Dim scnmaxx% = _X, scnmaxy% = _Y, White%, cx! Dim DC_Target1%, DC_Target2%
Dim Include_DC1? = False ' OpenW # 1, (scnmaxx% - MY_WIDTH%) / 2, (scnmaxy% - MY_HEIGHT%) / 2, MY_WIDTH% + 7, MY_HEIGHT% + 30, 16 + 32 Win_1.AutoRedraw = 1 TopW # 1 Win # 1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Environment and Variable declarations ' DC_Target1% = Win_1.hDC DC_Target2% = Win_1.hDC2 cx! = Win_1.ScaleWidth / 2 GraphMode R2_COPYPEN, OPAQUE 'OverWright mode SetFont 16 'Proportional Font Mode Date "/" ' us date and us print using Mode StrSpace 0 'NO Space before the STR command
' Black% = RGB(0, 0, 0) Gray% = RGB(128, 128, 128) White% = RGB(255, 255, 255)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Paint some filled rectangles ' Cls Color Black%, Black% 'PBox 0, 1, 1000, 600 ' Color Gray%, Gray% 'PBox 0, 200, 1000, 240
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' This example does not work properly ' Color White%, Gray% SetFont "times", 16 If Include_DC1? ~SetTextAlign(DC_Target1, 6) ~SetTextAlign(DC_Target2, 6) Text cx, 210, "Hello, This is a TEST" If Include_DC1? ~SetTextAlign(DC_Target1, 0) ~SetTextAlign(DC_Target2, 0) ' Get cx, 200, cx + 100, 240, Clipped_Text$ Put cx, 260, Clipped_Text$
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' This example works fine but cannot use the CENTER TEXT function ' Color Gray%, Gray% 'PBox 0, 400, 1000, 440 ' Color White%, Gray% SetFont "times", 16 If Include_DC1? ~SetTextAlign(DC_Target1, 6) ~SetTextAlign(DC_Target2, 6) Text cx, 410, "Hello, This is a TEST" If Include_DC1? ~SetTextAlign(DC_Target1, 0) ~SetTextAlign(DC_Target2, 0) ' Get cx, 400, cx + 100, 440, Clipped_Text$ Put cx, 460, Clipped_Text$
Win_1.InvalidateAll Do Sleep Loop Until Win_1 Is Nothing ' GraphMode 1 CloseW # 1
|
|