Re: Drag to Move/Resize Gadgets
Posted: Tue Sep 23, 2014 1:26 pm
Hi,
I tried your code (very good, thank), but I have a problem:
I have to be able to move only the gadget of the text and not the whole container ...
How can I do?
Ps You need to change my image with one of your ...
<<ImmaArena= LoadImage(#PB_Any,"C:\Users\guido\Desktop\Vj3D_CourseDesigner2015\10_FileTemporanei\PerStampa32.png")>>
I tried your code (very good, thank), but I have a problem:
I have to be able to move only the gadget of the text and not the whole container ...
How can I do?
Ps You need to change my image with one of your ...
<<ImmaArena= LoadImage(#PB_Any,"C:\Users\guido\Desktop\Vj3D_CourseDesigner2015\10_FileTemporanei\PerStampa32.png")>>
Code: Select all
UseJPEGImageDecoder()
UseTGAImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()
UseJPEGImageEncoder()
UsePNGImageEncoder()
; ---- FONT ----
FontComitato=0
;---- Gadget ----
GContainer=0
GImageArena=1
GTextComitato=2
; ---- load Font ----
LoadFont(FontComitato, "Palatino linotype",24)
; ---- Dati caricati dall'Editor2D
NomeComitato.s="ASD I Due Leoni"
NomeManifestazione.s="Concorso Ippico Nazionale tipo A***** del 27-28-29/12/2014"
Categoria.s="C140"
Prontuario.s="19 a fasi consequtive - tempo seconda fase"
Velocita.s="350Mt/m"
LunghezzaBase.s="380Mt"
LunghezzaSecondaFase.s="240Mt"
TempoMassimoBase.s="52Sec."
TempoMassimoSecondaFase.s="38Sec."
TempoMassimoBarrage.s=" "
TempoMassimoSecondaMance.s=" "
TempoMassimoTerzoPercorso.s=" "
DirettoreDiCampo.s="Guido"
DataCategoria.s="27/12/2014"
ProntuarioInternazionale.s=" "
ImmaArena= LoadImage(#PB_Any,"C:\Users\guido\Desktop\Vj3D_CourseDesigner2015\10_FileTemporanei\PerStampa32.png")
; ---- Dati foglio cartaceo ----
A4X.f=297.0
A4Y.f=210.0
ProporzioneImma.f=3.0/4.0
Border=1
IntestazioneStandard=1; 1=Standard 2=Personalizzata
Orientamento.s="L" ; L=Landscape P=Portrait
; ---- Calcolo dimensione Desktop
NbDesktops = ExamineDesktops()
SizeWindW.f=DesktopWidth(0)
SizeWindH.f=DesktopHeight(0)
; ---- Calcolo Dpi schermo per dimensione foglio
DPI_X.f = GetDeviceCaps_(GetDC_(GetDesktopWindow_()), #LOGPIXELSX)
DPI_Y.f = GetDeviceCaps_(GetDC_(GetDesktopWindow_()), #LOGPIXELSY)
ContainerX.f=((A4X.f/10.0)*DPI_X.f)/2.54
ContainerY.f=((A4Y.f/10.0)*DPI_Y.f)/2.54
; ---- Calcolo per corretta dimensione dell'immagine nel foglio virtuale
ImmaSizeW=ContainerX.f*ProporzioneImma.f
ImmaSizeH=ContainerY.f*ProporzioneImma.f
ResizeImage(ImmaArena, ImmaSizeW, ImmaSizeH)
; ---- Determina la centratura dell'immagine nel foglio ----
If Border=1
PosImmaX.f=(ContainerX.f-ImmaSizeW)/2.0
EndIf
If Border=2
PosImmaX.f=0
EndIf
If Border=3
PosImmaX.f=ContainerX.f-ImmaSizeW
EndIf
PosImmaY.f=ContainerY.f-ImmaSizeH
; --- Apertura della MainWindow ----
mainWin = OpenWindow(#PB_Any , 0, 0,SizeWindW.f,SizeWindH,"",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
; ---- Calcola la dimensione dei Gadget di Testo in base al font ----
StartDrawing(WindowOutput(mainWin))
DrawingFont(FontID(FontComitato))
DimeFontComitatoW=TextWidth(NomeComitato.s)+2
DimeFontComitatoH=TextHeight(NomeComitato.s)
StopDrawing()
; ---- Crea il Cointainer "Foglio virtuale" e lo dimensiona correttamente + con all'interno i gadget ( arena testi etc etc ) ----
ContainerGadget(GContainer, 0, 0, ContainerX.f, ContainerY.f, #PB_Container_Double)
SetGadgetColor(GContainer, #PB_Gadget_BackColor, RGB(255,255,255))
ImageGadget(GImageArena, PosImmaX.f, PosImmaY.f, ImmaSizeW, ImmaSizeH, ImageID(ImmaArena))
If IntestazioneStandard=1
x=(ContainerX.f-DimeFontComitatoW)/2
y=1
TextGadget(GTextComitato, x, y, DimeFontComitatoW, DimeFontComitatoH, NomeComitato.s,#PB_Text_Center)
SetGadgetFont(GTextComitato, FontID(FontComitato))
SetGadgetColor(GTextComitato, #PB_Gadget_BackColor, RGB(255,255,255))
SetGadgetColor(GTextComitato, #PB_Gadget_FrontColor, RGB(255,0,0))
SetWindowLongPtr_(GadgetID(GTextComitato), #GWL_STYLE, GetWindowLongPtr_(GadgetID(GTextComitato), #GWL_STYLE) | #WS_CLIPSIBLINGS)
EndIf
CloseGadgetList()
Repeat
Event = WaitWindowEvent()
Select event
Case #WM_LBUTTONDOWN
ReleaseCapture_()
GetCursorPos_(cursorpos.POINT)
gadget = WindowFromPoint_(PeekQ(cursorpos))
If GetAsyncKeyState_(#VK_SHIFT) & 32768
SendMessage_(gadget, #WM_NCLBUTTONDOWN, #HTBOTTOMRIGHT, 0) ; #HTRIGHT = stretch width only
Else
SendMessage_(gadget, #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
EndIf
EndSelect
Until Event = #PB_Event_CloseWindow