Visual C++ ide style gradient interface?

BlitzMax Forums/BlitzMax Programming/Visual C++ ide style gradient interface?

Is it possible to do cool Visual studio net, nero style gradient guis. sort of like panels but blue tinted. can this be done with soem sort of manifst tool or they special win32 only gadgets maxgui doesn't implement yet?

Like this?


It loads a gradient image as a pixmap on a standard MaxGUI panel and resizes it to fit the window:
Strict

Global window:TGadget = CreateWindow( "", 0,0, 400,300 ) ' global since eventhooked

Global panel:TGadget = CreatePanel( 0,0, 400,300, window ) ' global since eventhooked
SetGadgetLayout panel, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED
Global panelPixmap:TPixmap = ResizePixmap( LoadPixmap( "gradient_blue.png" ),..
                             GadgetWidth( window ), GadgetHeight( window ) )
SetPanelPixmap panel, panelPixmap

Local text:TGadget = CreateTextField( 40,40, 100,20, panel )
SetGadgetLayout text, EDGE_RELATIVE, EDGE_RELATIVE, EDGE_RELATIVE, EDGE_RELATIVE

Local button:TGadget = CreateButton( "button", 40,60, 100,24, panel, BUTTON_PUSH )
SetGadgetLayout button, EDGE_RELATIVE, EDGE_RELATIVE, EDGE_RELATIVE, EDGE_RELATIVE

Function EventHook:Object( iId, tData:Object, tContext:Object )
	Local Event:TEvent = TEvent( tData )
	Select Event.Source
		Case window
			Select Event.id
				Case EVENT_WINDOWSIZE
						panelPixmap = ResizePixmap( panelPixmap,..
						              GadgetWidth( window ), GadgetHeight( window ) )
						SetPanelPixmap panel, panelPixmap
					Return Null ' exit function without passing event through
			End Select ' id
	End Select ' source
	Return Event ' We didn't handle this event, so pass it through
End Function

AddHook EmitEventHook,EventHook

Repeat
	WaitEvent
	Select EventSource()
		Case button
			Select EventID()
				Case EVENT_GADGETACTION
					SetGadgetText text, "button pressed"
			End Select
	End Select
Until ( EventSource() = window ) And ( EventID() = EVENT_WINDOWCLOSE )


gradient_blue.png used by above code, though any image could be used.

A manifest file isn't needed for that, but one is for the XP-look gadgets (I use Faena's utility).

It's working here

but terribly slow when resizing with the lastest update and synco.

You're right about the slowness. Since it doesn't matter if this vertical gradient pixmap tiles horizontally, it can be sped up by replacing "GadgetWidth( window )" with, say, "1" in both calls to ResizePixmap. This wouldn't work with a pixmap that you don't want to tile horizontally, but it does speed things up considerably here.

I also just noticed that the pixmap degrades the more it's resized, so a "virgin" copy needs to be kept. The code below has both of these changes (using the same .PNG):
Strict

Global window:TGadget = CreateWindow( "", 0,0, 400,300 ) ' global since eventhooked

Global panel:TGadget = CreatePanel( 0,0, 400,300, window ) ' global since eventhooked
SetGadgetLayout panel, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED, EDGE_ALIGNED
Global panelVirginPixmap:TPixmap = LoadPixmap( "gradient_blue.png" )
Global panelPixmap:TPixmap = ResizePixmap( panelVirginPixmap,..
                             1, GadgetHeight( window ) )
SetPanelPixmap panel, panelPixmap

Local text:TGadget = CreateTextField( 40,40, 100,20, panel )
SetGadgetLayout text, EDGE_RELATIVE, EDGE_RELATIVE, EDGE_RELATIVE, EDGE_RELATIVE

Local button:TGadget = CreateButton( "button", 40,60, 100,24, panel, BUTTON_PUSH )
SetGadgetLayout button, EDGE_RELATIVE, EDGE_RELATIVE, EDGE_RELATIVE, EDGE_RELATIVE

Function EventHook:Object( iId, tData:Object, tContext:Object )
	Local Event:TEvent = TEvent( tData )
	Select Event.Source
		Case window
			Select Event.id
				Case EVENT_WINDOWSIZE
						panelPixmap = ResizePixmap( panelVirginPixmap,..
						              1, GadgetHeight( window ) )
						SetPanelPixmap panel, panelPixmap
					Return Null ' exit function without passing event through
			End Select ' id
	End Select ' source
	Return Event ' We didn't handle this event, so pass it through
End Function

AddHook EmitEventHook,EventHook

Repeat
	WaitEvent
	Select EventSource()
		Case button
			Select EventID()
				Case EVENT_GADGETACTION
					SetGadgetText text, "button pressed"
			End Select
	End Select
Until ( EventSource() = window ) And ( EventID() = EVENT_WINDOWCLOSE )


But....
there is a problem when you manage a pixmap over a panel, the continuous refresh of the pixmap eats memory.

How do you make labels etc. look right not have a grey box around them?

there is a problem when you manage a pixmap over a panel

OK, seems it isn't a perfect solution... :) Maybe the proper one (instead of this panel workaround) requires some sort of Windows system-level stuff like denzilquixode uses to fix tabbers here.


How do you make labels etc. look right not have a grey box around them?

Sorry, I think you'll have to ask BRL about that one - it seems to be a (hopefully temporary) limitation of MaxGUI. One of my first posts after MaxGUI's release wondered why SetGadgetColor and SetGadgetAlpha often don't do anything.