Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Gradient Fill on VOGUI ShellWindow 07 Nov 2022 07:59 #24344

  • Chris
  • Chris's Avatar
  • Topic Author


  • Posts: 3750
  • Hi all,

    I received a request about providing a way to draw a VOGUI ShellWindow background with a gradient text, similar to XIDE's background. Of course XIDE uses windows forms and GDI+, but to my surprise the same code (almost) works for the VOGUI, too, see below. Only problem is that unfortunately the Expose() callback seems not to be called when moving a window over the shell window, so the text is not being redrawn in this case. Now it's been a lot of years since I last dealt with similar things in the VOGUI, and before I spend too much time looking into this, maybe one of you VOGUI/Win32 gurus can have a quick look and adjust the following code to make it work better?

    METHOD Expose(oExposeEvent) // CLASS StandardShellWindow
    	SUPER:Expose(oExposeEvent)
    	SELF:DrawGradient()
    RETURN NIL
    
    METHOD DrawGradient() AS VOID
    	LOCAL cText := "Text to print" AS STRING
    	
    	LOCAL oFont AS System.Drawing.Font
    	oFont := System.Drawing.Font{"Arial" , REAL4(SELF:Size:Width/9.0) , System.Drawing.FontStyle.Bold}
    
    	LOCAL oSF AS System.Drawing.StringFormat
    	oSF := System.Drawing.StringFormat{}
    	oSF:LineAlignment:= System.Drawing.StringAlignment.Center
    	oSF:Alignment := System.Drawing.StringAlignment.Center
    	
    	LOCAL oBrush AS System.Drawing.Brush
    	oBrush := System.Drawing.Drawing2D.LinearGradientBrush{System.Drawing.Point{0,0} , System.Drawing.Point{SELF:Size:Width,SELF:Size:Height} , System.Drawing.Color.Blue , System.Drawing.Color.Yellow}
    
    	LOCAL oRect AS System.Drawing.Rectangle
    	oRect := System.Drawing.Rectangle{3 , 3 , SELF:Size:Width , SELF:Size:Height}
    
    	LOCAL g AS System.Drawing.Graphics
    	g := System.Drawing.Graphics.FromHwnd(SELF:Handle(4))
    	g:DrawString(cText , oFont , System.Drawing.Brushes.Gray , oRect , oSF) // this is for the "shadow"
    	oRect := System.Drawing.Rectangle{0 , 0 , SELF:Size:Width , SELF:Size:Height}
    	g:DrawString(cText , oFont , oBrush , oRect , oSF)
    	g:Dispose()
    RETURN
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Last edit: by Chris.

    Gradient Fill on VOGUI ShellWindow 07 Nov 2022 08:44 #24345

    • ecos
    • ecos's Avatar


  • Posts: 40
  • Hi Chris,
    things are not so easy with the VO-GUI... You can't simply call your drawing stuff from the expose-method. I attach a simple example how this can be done. Hope this helps a little...

    Karl
    Attachments:

    Please Log in or Create an account to join the conversation.

    Gradient Fill on VOGUI ShellWindow 07 Nov 2022 17:10 #24352

    • Chris
    • Chris's Avatar
    • Topic Author


  • Posts: 3750
  • Hi Karl,

    Thanks a lot, looking good! Although it also has some problems when resizing, like when making it half size so the text is half visible and then enlarge it again. After that, also moving a window over the shell, does not repaint the background.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Gradient Fill on VOGUI ShellWindow 08 Nov 2022 08:22 #24359

    • ecos
    • ecos's Avatar


  • Posts: 40
  • Same behaviour here in my x#-application. Vo-application works fine for many, many years.

    This should help:
    METHOD dispatch(uEvent)	// class StandardShellWindow
    LOCAL liRt		AS INT
    LOCAL oEvent	AS @@Event
    
    oEvent	:= uEvent
    
    DO CASE
    
    CASE oEvent:message = WM_PAINT
    	SELF:BkPaint(SELF:handle(4))	
    	liRt := SUPER:dispatch(oEvent)
    
    
    OTHERWISE
    	liRt := SUPER:dispatch(oEvent)
    ENDCASE
    
    RETURN liRt

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1