Page 1 of 2

[460 Final] How to transparent container on canvas gadget ??

Posted: Mon Dec 05, 2011 1:17 pm
by marc_256
Hello everyone,

My PureCAD 2D/3D, drawing and modeling software is going the good direction now...

Image
my first test here... fixed with GIMP :mrgreen: :mrgreen:

The next step is to draw a transparent container (toolbar) on/over canvas gadget (drawing).
I found a lot of Window transparency on this forum, but not what I need for this.

Is there a way to draw transparent container on a canvas gadget ??

Thanks,
Marc

Re: [460 Final] How to transparent container on canvas gadge

Posted: Mon Dec 05, 2011 3:16 pm
by Danilo
It is easy with normal PB Windows and transparency. So you can use gadgets etc.
Drawback: The main window looses focus if you use the toolwindow.

Code: Select all

Procedure drawCanvasBackground(canvas)
    Dim color(1)
    color(0)=RGB($40,$40,$40)
    color(1)=RGB($AA,$AA,$AA)

    width  = GadgetWidth(canvas)
    height = GadgetHeight(canvas)
    For y = 0 To height Step 40
        For x = 0 To width Step 40
            c!1
            Box(x,y,40,40,color(c))
        Next
    Next
EndProcedure

Procedure WinCallback(hWnd, uMsg, wParam, lParam) 
    If uMsg = #WM_MOVE And IsWindow(0) And hWnd = WindowID(0)
        If IsWindow(1)
            ResizeWindow(1,WindowX(0)+110,WindowY(0)+110,#PB_Ignore,#PB_Ignore)
            ;ProcedureReturn 0
        EndIf
    ElseIf uMsg = #WM_ACTIVATE And IsWindow(1) And hWnd = WindowID(1)
        ;SetActiveWindow(0)
        ;ProcedureReturn 0
    EndIf
  
    ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure 

If OpenWindow(0, 0, 0, 800, 500, "CanvasGadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
    CanvasGadget(1,0,0,800,500)
    If StartDrawing(CanvasOutput(1))
        drawCanvasBackground(1)
        StopDrawing()
    EndIf

    OpenWindow(1,WindowX(0)+110,WindowY(0)+110,500,60,"Inner",#PB_Window_BorderLess|#PB_Window_Invisible,WindowID(0))
    SetWindowLong_(WindowID(1),#GWL_EXSTYLE,GetWindowLong_(WindowID(1),#GWL_EXSTYLE)|#WS_EX_LAYERED)
    SetLayeredWindowAttributes_(WindowID(1),0,$80,#LWA_ALPHA)
    SetWindowColor(1,RGB($00,$00,$FF))

    SetWindowCallback(@WinCallback())

    ComboBoxGadget(2,10,10,100,20)
    For i=0 To 100
        AddGadgetItem(2,-1,"Item "+Str(i))
    Next
    SetGadgetState(2,20)

    HideWindow(0,0)
    HideWindow(1,0)

    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
    
    CloseWindow(1)
    CloseWindow(0)
EndIf
Second option: draw everything yourself, make your own gadgets with images.

Code: Select all

Structure s_CanvasImage
    img.i
    x.i
    y.i
EndStructure

Global NewList CanvasImages.s_CanvasImage()

Procedure drawCanvasBackground(canvas)
    Dim color(1)
    color(0)=RGB($40,$40,$40)
    color(1)=RGB($AA,$AA,$AA)

    width  = GadgetWidth(canvas)
    height = GadgetHeight(canvas)
    For y = 0 To height Step 40
        For x = 0 To width Step 40
            c!1
            Box(x,y,40,40,color(c))
        Next
    Next
EndProcedure

Procedure redrawCanvas(canvas)
    If StartDrawing(CanvasOutput(canvas))
        drawCanvasBackground(canvas)
        DrawingMode(#PB_2DDrawing_AlphaBlend)
        ForEach CanvasImages()
            DrawImage(ImageID(CanvasImages()\img),CanvasImages()\x,CanvasImages()\y)
        Next
        StopDrawing()
    EndIf
EndProcedure

Procedure canvasEvents(canvas, eventType)
    Select eventType
    EndSelect
EndProcedure

Procedure addCanvasImage(img,x,y)
    LastElement(CanvasImages())
    If AddElement(CanvasImages())
        CanvasImages()\img = img
        CanvasImages()\x   = x
        CanvasImages()\y   = y
    EndIf
EndProcedure

Procedure createCanvasToolbar(width,height)
    img = CreateImage(#PB_Any,width,height,32|#PB_Image_Transparent)
    If img And StartDrawing(ImageOutput(img))
        DrawingMode(#PB_2DDrawing_AlphaBlend)
        RoundBox(0,0,width,height,8,8,RGBA($00,$00,$FF,$80))
        LineXY(width-20,0,width-20,height,RGBA($FF,$FF,$FF,$FF))
        FillArea(width-10,2,-1,RGBA($00,$00,$FF,$80))
        DrawingMode(#PB_2DDrawing_Outlined)
        RoundBox(0,0,width,height,8,8,RGBA($FF,$FF,$FF,$FF))
        DrawingMode(#PB_2DDrawing_Transparent)
        DrawText(5,5,"Canvas Toolbar",RGBA($FF,$FF,$FF,$FF))
        StopDrawing()
    EndIf
    ProcedureReturn img
EndProcedure

If OpenWindow(0, 0, 0, 800, 500, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CanvasGadget(0,0,0,800,500)

    tb = createCanvasToolbar(500,60)
    addCanvasImage(tb,110,110)
    redrawCanvas(0)
    
    Repeat
      Event = WaitWindowEvent()
          
      If Event = #PB_Event_Gadget And EventGadget() = 0
            canvasEvents(0,EventType())
      EndIf    
      
    Until Event = #PB_Event_CloseWindow
EndIf

Re: [460 Final] How to transparent container on canvas gadge

Posted: Mon Dec 05, 2011 6:44 pm
by marc_256
Hi Danilo,

Thanks for the replay

The first one I found also,
but the problem is that the focus of the main window is lost,
and I have to click again for having focus.

The second solution is a very fine one,
just what I need, but I need mode than 50 toolbars, with images, buttons, combo boxes, ets...
So, I'm some time busy ... ??!!


Thanks,
Marc

Re: [460 Final] How to transparent container on canvas gadge

Posted: Mon Dec 05, 2011 7:02 pm
by Ramihyn_
marc_256 wrote:The first one I found also,
but the problem is that the focus of the main window is lost,
and I have to click again for having focus.
Can't you just use "SetActiveWindow()" to switch the focus back to your main window each time you notice that the tool window got the focus? I did that for a test last year and it worked good enough for me, the users didnt even notice.

Of cause that doesnt work well with all types of gadgets. For example a text input field wouldnt work, but buttons and others do.

A combobox/popup for example would be a special case gadget where you have to do it based on the type of event.

Re: [460 Final] How to transparent container on canvas gadge

Posted: Mon Dec 05, 2011 7:04 pm
by netmaestro
You can overcome the focus problem by skinning your main window. This way Windows has no caption bar to dim and if your toolbar window is borderless you can switch back and forth seamlessly.

Re: [460 Final] How to transparent container on canvas gadge

Posted: Mon Dec 05, 2011 7:17 pm
by netmaestro
Also, there is another option that may appeal to you. Without skinning the whole window, you can simply ownerdraw the frames, then the OS isn't responsible for drawing them and it won't dim them. This has the added advantage of leaving your window resizable if that's important:

http://www.purebasic.fr/english/viewtop ... 83#p232983

Re: [460 Final] How to transparent container on canvas gadge

Posted: Mon Dec 05, 2011 8:57 pm
by RASHAD
A fake transparent container on a canvas gadget

Code: Select all


#CAPTUREBLT = $40000000

Procedure drawCanvasBackground(canvas)
    Dim color(1)
    color(0)=RGB($40,$40,$40)
    color(1)=RGB($AA,$AA,$AA)

    width  = GadgetWidth(canvas)
    height = GadgetHeight(canvas)
    For y = 0 To height Step 40
        For x = 0 To width Step 40
            c!1
            Box(x,y,40,40,color(c))
        Next
    Next
EndProcedure


If OpenWindow(0, 0, 0, 800, 500, "CanvasGadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered);|#PB_Window_Invisible)
CanvasGadget(1,0,0,800,500)
If StartDrawing(CanvasOutput(1))
    drawCanvasBackground(1)
    StopDrawing()
EndIf

SetWindowLongPtr_(GadgetID(1), #GWL_STYLE, GetWindowLongPtr_(GadgetID(1), #GWL_STYLE) | #WS_CLIPSIBLINGS)
;SetWindowPos_(GadgetID(1), #HWND_BOTTOM, -1, -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE)

hBitmap = CreateImage(10,780, 50)
hdc = StartDrawing(ImageOutput(10))
SelectObject_(hdc, hBitmap)
BitBlt_(hdc, 0,0,780, 50, GetWindowDC_(GadgetID(1)), 10, 10, #SRCCOPY | #CAPTUREBLT)StopDrawing()

CreateImage(20,780, 50)
StartDrawing(ImageOutput(20))
  DrawAlphaImage(ImageID(10),0,0,160)
StopDrawing()

hBrush = CreatePatternBrush_(ImageID(20))

ContainerGadget(2, 10,10,780,50) 

    ComboBoxGadget(3,10,10,100,20)
    For i=0 To 100
        AddGadgetItem(3,-1,"Item "+Str(i))
    Next
   
CloseGadgetList()
BringWindowToTop_(GadgetID(2))

SetClassLongPtr_(GadgetID(2), #GCL_HBRBACKGROUND, hBrush)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
    
;    CloseWindow(1)
;    CloseWindow(0)
EndIf


Re: [460 Final] How to transparent container on canvas gadge

Posted: Tue Dec 06, 2011 3:27 pm
by marc_256
Hi,

thanks for helping me here, :)
I did some tests and the problem is still there,
when I want to open a Container or Window over my drawing area (canvas)
I do not see then at all.
They flicker once and disappears.

So, I have to find an other work around. :cry:

Thanks,
marc

Re: [460 Final] How to transparent container on canvas gadge

Posted: Tue Dec 06, 2011 6:15 pm
by RASHAD
marc_256 Hi

Usually for this kind of software they use MDI for ToolBars and alike
But we still can help if you post some code to see the problems

Keep the spirit

Re: [460 Final] How to transparent container on canvas gadge

Posted: Tue Dec 06, 2011 8:28 pm
by Danilo
RASHAD wrote:Usually for this kind of software they use MDI for ToolBars and alike
Floating Toolwindows would also work.

Code: Select all

Procedure drawCanvasBackground(canvas)
    Dim color(1)
    color(0)=RGB($40,$40,$40)
    color(1)=RGB($AA,$AA,$AA)

    width  = GadgetWidth(canvas)
    height = GadgetHeight(canvas)
    For y = 0 To height Step 40
        For x = 0 To width Step 40
            c!1
            Box(x,y,40,40,color(c))
        Next
    Next
EndProcedure

If OpenWindow(0, 0, 0, 800, 500, "CanvasGadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible)
    CanvasGadget(1,0,0,800,500)
    If StartDrawing(CanvasOutput(1))
        drawCanvasBackground(1)
        StopDrawing()
    EndIf

    OpenWindow(1,WindowX(0)+110,WindowY(0)+110,500,60,"Inner",#PB_Window_Tool|#PB_Window_Invisible,WindowID(0))
    ;SetWindowLong_(WindowID(1),#GWL_EXSTYLE,GetWindowLong_(WindowID(1),#GWL_EXSTYLE)|#WS_EX_LAYERED)
    ;SetLayeredWindowAttributes_(WindowID(1),0,$80,#LWA_ALPHA)
    SetWindowColor(1,RGB($00,$00,$FF))

    ComboBoxGadget(2,10,10,100,20)
    For i=0 To 100
        AddGadgetItem(2,-1,"Item "+Str(i))
    Next
    SetGadgetState(2,20)

    HideWindow(0,0)
    HideWindow(1,0)

    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: [460 Final] How to transparent container on canvas gadge

Posted: Tue Dec 06, 2011 9:06 pm
by RASHAD
I do agree with all the options
You gave him 2
NM gave him 1
I gave him another one
So what is left ? :P


BTW:Yours still have the drawback(lost focus)

Re: [460 Final] How to transparent container on canvas gadge

Posted: Tue Dec 06, 2011 10:05 pm
by marc_256
Hi guys,

thanks for the help here,
the problem is more complex than it is...
I did also some tests,

1) I loved to make it transparent if not in use by the user.
2) Movable over the screen
3) Borderless like in the drawing (first post).
4) MDI
5) Focus still on drawing gadget after use.

My test:
you need this images in the same folder...

http://www.marc-systems.be/PureBasic/Line_Tool.bmp

http://www.marc-systems.be/PureBasic/LineStandard.bmp
http://www.marc-systems.be/PureBasic/LineDotted.bmp
http://www.marc-systems.be/PureBasic/LineDashed.bmp

http://www.marc-systems.be/PureBasic/Mo ... n_Gray.bmp
http://www.marc-systems.be/PureBasic/Mo ... _Green.bmp

http://www.marc-systems.be/PureBasic/Cl ... n_Gray.bmp
http://www.marc-systems.be/PureBasic/Cl ... on_Red.bmp

Code: Select all

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-==================================================================================================
;- PVG_CAD - 2D/3D
;---------------------------------------------------------------------------------------------------
;- Pajot Valley Graphics
;- Marc
;- 06/12/2011 - 19:10:00
;-==================================================================================================

;---------------------------------------------------------------------------------------------------
;- LOAD IMAGES
;---------------------------------------------------------------------------------------------------
		LoadImage(20, "Move_Button_Gray.bmp")
		LoadImage(21, "Move_Button_Green.bmp")

		LoadImage(25, "Close_Button_Gray.bmp")
		LoadImage(26, "Close_Button_Red.bmp")

		LoadImage(29, "Line_Tool.bmp")

		LoadImage(30, "LineStandard.bmp")
		LoadImage(31, "LineDotted.bmp")
		LoadImage(32, "LineDashed.bmp")

;---------------------------------------------------------------------------------------------------
;- SETUP WINDOW
;---------------------------------------------------------------------------------------------------
	OpenWindow(0, 50, 50, 800, 600, " - PVG 3d Studio - Lines, Arrows... - ", #PB_Window_SystemMenu)

;---------------------------------------------------------------------------------------------------
;- CREATE USER ZONE
;---------------------------------------------------------------------------------------------------
		MDIGadget(39, 0, 0, 800, 600, 0, 0, #PB_MDI_BorderLess | #PB_MDI_NoScrollBars)



;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-==================================================================================================
;---------------------------------------------------------------------------------------------------
;- CREATE DRAWING ZONE
;---------------------------------------------------------------------------------------------------
	If OpenWindow(1, 10, 10, 800, 600, "Drawing Zone", #PB_Window_BorderLess, 0)
		AddGadgetItem(39, 1, "", #PB_Ignore, #PB_Window_Tool)		;#PB_Window_BorderLess)

		CanvasGadget(2, 0, 0, 800, 600, #PB_Canvas_Keyboard)
			StartDrawing(CanvasOutput(2))
				Box(0, 0, 800, 600, RGB(200, 250, 100))
			StopDrawing()
	EndIf


;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-==================================================================================================
;---------------------------------------------------------------------------------------------------
;- CREATE TOOLBAR - LINE SELECTION
;---------------------------------------------------------------------------------------------------
PVG_CAD_Create_Toolbar_Lines:

	If OpenWindow(3, 10, 50, 600, 24, "Line Selection", #PB_Window_BorderLess, 0)
		AddGadgetItem(39, 3, "", #PB_Ignore, #PB_Window_Tool)		;#PB_Window_BorderLess)
;		SetParent_(WindowID(2), WindowID(0))
		ResizeWindow(3, 10, 50, 600, 24)

		ContainerGadget(4, 0, 0, 600, 24, #PB_Container_BorderLess)
			SetGadgetColor(4, #PB_Gadget_BackColor, RGB(150, 150, 150))
			GadgetToolTip(4, "Line Selection Toolbar")

			CanvasGadget(5, 0, 0, 16, 24, #PB_Canvas_Keyboard)
				StartDrawing(CanvasOutput(5))
					DrawImage(ImageID(20), 0, 0, 16, 24)
				StopDrawing()

			ImageGadget(6, 20, 1, 26, 22, ImageID(29))

			ComboBoxGadget(7, 50, 2, 150, 20)
				AddGadgetItem(7, 0, "Standard")
				AddGadgetItem(7, 1, "Dotted")
				AddGadgetItem(7, 2, "Dashed")
				SetGadgetState(7, 0)

			ImageGadget(8, 205, 2, 50, 20, ImageID(30))

			CanvasGadget(9, 584, 0, 16, 24, #PB_Canvas_Keyboard)
				StartDrawing(CanvasOutput(9))
					DrawImage(ImageID(25), 0, 0, 16, 24)
				StopDrawing()

		CloseGadgetList()

	EndIf

		SetWindowLongPtr_(WindowID(3), #GWL_EXSTYLE, #WS_EX_LAYERED)
		SetLayeredWindowAttributes_(WindowID(3), 0, 185, #LWA_ALPHA)


;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-==================================================================================================
;---------------------------------------------------------------------------------------------------
;- CREATE TOOLBAR - POINT SELECTION
;---------------------------------------------------------------------------------------------------
PVG_CAD_Create_Toolbar_Points:

	If OpenWindow(10, 100, 50, 400, 24, "Point Selection", #PB_Window_BorderLess, 0)
		AddGadgetItem(39, 10, "", #PB_Ignore, #PB_Window_Tool)						;#PB_Window_BorderLess)
;		SetParent_(WindowID(10), WindowID(1))
		ResizeWindow(10, 100, 50, 400, 24)

	EndIf







;-==================================================================================================
;- DO LOOP
;---------------------------------------------------------------------------------------------------
Repeat
		Event = WaitWindowEvent()
		Select Event
			Case #PB_Event_Gadget
				Select EventGadget()

;-[CANVAS - DRAWING ZONE]---------------------------------------------------------------------------
;					Case 1
;						EventType = EventType()
;						Select EventType
;							Case #PB_EventType_MouseMove

;;								PVG_CAD_Mouse_PosX_New = GetGadgetAttribute(PVG_CAD_Canvas_Num, #PB_Canvas_MouseX)
;;								PVG_CAD_Mouse_PosY_New = GetGadgetAttribute(PVG_CAD_Canvas_Num, #PB_Canvas_MouseY)

;;								PVG_CAD_Mouse_DeltaX = PVG_CAD_Mouse_PosX_Old - PVG_CAD_Mouse_PosX_New
;;								PVG_CAD_Mouse_DeltaY = PVG_CAD_Mouse_PosY_Old - PVG_CAD_Mouse_PosY_New
;						EndSelect


;-[CANVAS - TOOLBAR - LINE SELECTION ZONE]----------------------------------------------------------
					Case 5
						EventType = EventType()
						Select EventType

							Case #PB_EventType_LeftButtonDown
								Mouse_LeftButton_Status.b = 1
								Mouse_Gadget_PosX.w = GetGadgetAttribute(5, #PB_Canvas_MouseX)
								Mouse_Gadget_PosY.w = GetGadgetAttribute(5, #PB_Canvas_MouseY)
;								Mouse_Gadget_PosX.w = WindowMouseX(0)
;								Mouse_Gadget_PosY.w = WindowMouseX(0)

							Case #PB_EventType_LeftButtonUp
								Mouse_LeftButton_Status = 0

							Case #PB_EventType_MouseEnter
								StartDrawing(CanvasOutput(5))
									DrawImage(ImageID(21), 0, 0, 16, 24)
								StopDrawing()

							Case #PB_EventType_MouseLeave
								StartDrawing(CanvasOutput(5))
									DrawImage(ImageID(20), 0, 0, 16, 24)
								StopDrawing()

							Case #PB_EventType_MouseMove
								If Mouse_LeftButton_Status = 1

									Mouse_PosX_New.w = WindowMouseX(0)
									Mouse_PosY_New.w = WindowMouseY(0)

									If Mouse_PosX_New < 0
										Gadget_PosX.w = Mouse_Gadget_PosX
									Else
										Gadget_PosX.w = Mouse_PosX_New - Mouse_Gadget_PosX
									EndIf

									If Mouse_PosY_New < 0
										Gadget_PosY.w = Mouse_PosY_New
									Else
										Gadget_PosY.w = Mouse_PosY_New - Mouse_Gadget_PosY
									EndIf

									ResizeWindow(3, Gadget_PosX, Gadget_PosY, #PB_Ignore, #PB_Ignore)
								EndIf
						EndSelect

;-[CANVAS - TOOLBAR - LINE SELECTION ZONE]----------------------------------------------------------
					Case 9
						EventType = EventType()
						Select EventType

							Case #PB_EventType_MouseEnter
								StartDrawing(CanvasOutput(9))
									DrawImage(ImageID(26), 0, 0, 16, 24)
								StopDrawing()

							Case #PB_EventType_MouseLeave
								StartDrawing(CanvasOutput(9))
									DrawImage(ImageID(25), 0, 0, 16, 24)
								StopDrawing()

						EndSelect

;- [COMBO BOX GADGET]-------------------------------------------------------------------------------
					Case 7
						EventType = EventType()
						Select EventType
							Case #PB_EventType_Change
								Select GetGadgetState(7)
									Case 0
										SetGadgetState(8, ImageID(30))
									Case 1
										SetGadgetState(8, ImageID(31))
									Case 2
										SetGadgetState(8, ImageID(32))
								EndSelect
						EndSelect


				EndSelect
			Case #PB_Event_CloseWindow
				Quit = 1
		EndSelect
Until Quit = 1
End

;-==================================================================================================
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

The problem:
Can not make this borderless ??
Transparent ??



Thanks
Marc,

Sorry, I'm just a 3D designer... :oops:

EDITED: 06/12/2011 - 22:10

Re: [460 Final] How to transparent container on canvas gadge

Posted: Tue Dec 06, 2011 10:20 pm
by marc_256
Thats what I like to have as result but inside my MDI on a Canvas gadget...

Code: Select all

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-==================================================================================================
;- PVG_CAD - 2D/3D
;---------------------------------------------------------------------------------------------------
;- Pajot Valley Graphics
;- Marc
;- 06/12/2011 - 19:10:00
;-==================================================================================================

;---------------------------------------------------------------------------------------------------
;- LOAD IMAGES
;---------------------------------------------------------------------------------------------------
		LoadImage(20, "Move_Button_Gray.bmp")
		LoadImage(21, "Move_Button_Green.bmp")

		LoadImage(25, "Close_Button_Gray.bmp")
		LoadImage(26, "Close_Button_Red.bmp")

		LoadImage(29, "Line_Tool.bmp")

		LoadImage(30, "LineStandard.bmp")
		LoadImage(31, "LineDotted.bmp")
		LoadImage(32, "LineDashed.bmp")

;---------------------------------------------------------------------------------------------------
;- SETUP WINDOW
;---------------------------------------------------------------------------------------------------
	OpenWindow(0, 50, 50, 800, 600, " - PVG 3d Studio - Lines, Arrows... - ", #PB_Window_SystemMenu)

;---------------------------------------------------------------------------------------------------
;- CREATE USER ZONE
;---------------------------------------------------------------------------------------------------
		MDIGadget(39, 0, 0, 800, 600, 0, 0, #PB_MDI_BorderLess | #PB_MDI_NoScrollBars)



;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-==================================================================================================
;---------------------------------------------------------------------------------------------------
;- CREATE DRAWING ZONE
;---------------------------------------------------------------------------------------------------
	If OpenWindow(1, 10, 10, 800, 600, "Drawing Zone", #PB_Window_BorderLess, 0)
		AddGadgetItem(39, 1, "", #PB_Ignore, #PB_Window_Tool)		;#PB_Window_BorderLess)

		CanvasGadget(2, 0, 0, 800, 600, #PB_Canvas_Keyboard)
			StartDrawing(CanvasOutput(2))
				Box(0, 0, 800, 600, RGB(200, 250, 100))
			StopDrawing()
	EndIf


;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-==================================================================================================
;---------------------------------------------------------------------------------------------------
;- CREATE TOOLBAR - LINE SELECTION
;---------------------------------------------------------------------------------------------------
PVG_CAD_Create_Toolbar_Lines:

	If OpenWindow(3, 10, 50, 600, 24, "Line Selection", #PB_Window_BorderLess, WindowID(0))
;		AddGadgetItem(39, 3, "", #PB_Ignore, #PB_Window_Tool)		;#PB_Window_BorderLess)
;		SetParent_(WindowID(2), WindowID(0))
		ResizeWindow(3, 10, 50, 600, 24)

		ContainerGadget(4, 0, 0, 600, 24, #PB_Container_BorderLess)
			SetGadgetColor(4, #PB_Gadget_BackColor, RGB(150, 150, 150))
			GadgetToolTip(4, "Line Selection Toolbar")

			CanvasGadget(5, 0, 0, 16, 24, #PB_Canvas_Keyboard)
				StartDrawing(CanvasOutput(5))
					DrawImage(ImageID(20), 0, 0, 16, 24)
				StopDrawing()

			ImageGadget(6, 20, 1, 26, 22, ImageID(29))

			ComboBoxGadget(7, 50, 2, 150, 20)
				AddGadgetItem(7, 0, "Standard")
				AddGadgetItem(7, 1, "Dotted")
				AddGadgetItem(7, 2, "Dashed")
				SetGadgetState(7, 0)

			ImageGadget(8, 205, 2, 50, 20, ImageID(30))

			CanvasGadget(9, 584, 0, 16, 24, #PB_Canvas_Keyboard)
				StartDrawing(CanvasOutput(9))
					DrawImage(ImageID(25), 0, 0, 16, 24)
				StopDrawing()

		CloseGadgetList()

	EndIf

		SetWindowLongPtr_(WindowID(3), #GWL_EXSTYLE, #WS_EX_LAYERED)
		SetLayeredWindowAttributes_(WindowID(3), 0, 185, #LWA_ALPHA)


;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;-==================================================================================================
;---------------------------------------------------------------------------------------------------
;- CREATE TOOLBAR - POINT SELECTION
;---------------------------------------------------------------------------------------------------
PVG_CAD_Create_Toolbar_Points:

	If OpenWindow(10, 100, 50, 400, 24, "Point Selection", #PB_Window_BorderLess, WindowID(0))
		AddGadgetItem(39, 10, "", #PB_Ignore, #PB_Window_Tool)						;#PB_Window_BorderLess)
;		SetParent_(WindowID(10), WindowID(1))
		ResizeWindow(10, 100, 50, 400, 24)

	EndIf

	SetWindowLong_(WindowID(10), #GWL_EXSTYLE, GetWindowLong_(WindowID(10), #GWL_EXSTYLE) | #WS_EX_LAYERED)
	SetLayeredWindowAttributes_(WindowID(10), 0, $80, #LWA_ALPHA)






;-==================================================================================================
;- DO LOOP
;---------------------------------------------------------------------------------------------------
Repeat
		Event = WaitWindowEvent()
		Select Event
			Case #PB_Event_Gadget
				Select EventGadget()

;-[CANVAS - DRAWING ZONE]---------------------------------------------------------------------------
;					Case 1
;						EventType = EventType()
;						Select EventType
;							Case #PB_EventType_MouseMove

;;								PVG_CAD_Mouse_PosX_New = GetGadgetAttribute(PVG_CAD_Canvas_Num, #PB_Canvas_MouseX)
;;								PVG_CAD_Mouse_PosY_New = GetGadgetAttribute(PVG_CAD_Canvas_Num, #PB_Canvas_MouseY)

;;								PVG_CAD_Mouse_DeltaX = PVG_CAD_Mouse_PosX_Old - PVG_CAD_Mouse_PosX_New
;;								PVG_CAD_Mouse_DeltaY = PVG_CAD_Mouse_PosY_Old - PVG_CAD_Mouse_PosY_New
;						EndSelect


;-[CANVAS - TOOLBAR - LINE SELECTION ZONE]----------------------------------------------------------
					Case 5
						EventType = EventType()
						Select EventType

							Case #PB_EventType_LeftButtonDown
								Mouse_LeftButton_Status.b = 1
								Mouse_Gadget_PosX.w = GetGadgetAttribute(5, #PB_Canvas_MouseX)
								Mouse_Gadget_PosY.w = GetGadgetAttribute(5, #PB_Canvas_MouseY)
;								Mouse_Gadget_PosX.w = WindowMouseX(0)
;								Mouse_Gadget_PosY.w = WindowMouseX(0)

							Case #PB_EventType_LeftButtonUp
								Mouse_LeftButton_Status = 0

							Case #PB_EventType_MouseEnter
								StartDrawing(CanvasOutput(5))
									DrawImage(ImageID(21), 0, 0, 16, 24)
								StopDrawing()

							Case #PB_EventType_MouseLeave
								StartDrawing(CanvasOutput(5))
									DrawImage(ImageID(20), 0, 0, 16, 24)
								StopDrawing()

							Case #PB_EventType_MouseMove
								If Mouse_LeftButton_Status = 1

;									Mouse_PosX_New.w = WindowMouseX(0)
;									Mouse_PosY_New.w = WindowMouseY(0)

									Mouse_PosX_New.w = DesktopMouseX()
									Mouse_PosY_New.w = DesktopMouseY()

									If Mouse_PosX_New < 0
										Gadget_PosX.w = Mouse_Gadget_PosX
									Else
										Gadget_PosX.w = Mouse_PosX_New - Mouse_Gadget_PosX
									EndIf

									If Mouse_PosY_New < 0
										Gadget_PosY.w = Mouse_PosY_New
									Else
										Gadget_PosY.w = Mouse_PosY_New - Mouse_Gadget_PosY
									EndIf

									ResizeWindow(3, Gadget_PosX, Gadget_PosY, #PB_Ignore, #PB_Ignore)
								EndIf
						EndSelect

;-[CANVAS - TOOLBAR - LINE SELECTION ZONE]----------------------------------------------------------
					Case 9
						EventType = EventType()
						Select EventType

							Case #PB_EventType_MouseEnter
								StartDrawing(CanvasOutput(9))
									DrawImage(ImageID(26), 0, 0, 16, 24)
								StopDrawing()

							Case #PB_EventType_MouseLeave
								StartDrawing(CanvasOutput(9))
									DrawImage(ImageID(25), 0, 0, 16, 24)
								StopDrawing()

						EndSelect

;- [COMBO BOX GADGET]-------------------------------------------------------------------------------
					Case 7
						EventType = EventType()
						Select EventType
							Case #PB_EventType_Change
								Select GetGadgetState(7)
									Case 0
										SetGadgetState(8, ImageID(30))
									Case 1
										SetGadgetState(8, ImageID(31))
									Case 2
										SetGadgetState(8, ImageID(32))
								EndSelect
						EndSelect


				EndSelect
			Case #PB_Event_CloseWindow
				Quit = 1
		EndSelect
Until Quit = 1
End

;-==================================================================================================
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<o>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Re: [460 Final] How to transparent container on canvas gadge

Posted: Tue Dec 06, 2011 10:24 pm
by netmaestro
Image dl links aren't working here.

Re: [460 Final] How to transparent container on canvas gadge

Posted: Tue Dec 06, 2011 10:37 pm
by marc_256
Image dl links aren't working here.
Hi netmaestro,

I just try here, all works OK.
Did you try Copy/Past ?

Image

Image
Image
Image

Image
Image

Image
Image


Marc,