Page 1 of 1
Displaying a gadget partially outside its window
Posted: Sun Nov 07, 2010 8:49 pm
by merendo
Hello fellow freaks!
I have a problem, which is as follows: I want to display a ListViewGadget, but it is larger than the window which it is assigned to. I would like the gadget to extend outside this window and the part that is outside the window should still be displayed instead of just being cropped.
Is there a way to do this? Searching these forums as well as the purearea.net code archive hasn't turned up anything.
Thanks for any help!!!
merendo
Re: Displaying a gadget partially outside its window
Posted: Sun Nov 07, 2010 9:45 pm
by PureLust
merendo wrote:I want to display a ListViewGadget, but it is larger than the window which it is assigned to. I would like the gadget to extend outside this window and the part that is outside the window should still be displayed instead of just being cropped.

what exactly do you mean?
Showing parts of the Gadget outside the Window, or be able to scroll inside the window to view the rest of the ListViewGadget()?
If you want the 2nd thing (scrolling within the Window), ScrollAreaGadget() is your fiend.
Re: Displaying a gadget partially outside its window
Posted: Mon Nov 08, 2010 12:07 am
by Vera
Hello merendo,
I'm also unsure if you want the impossible
Why not make the window resizable ?
or use tootips that exceed the window by themselfs ?
or make your ListView a separate childwindow ?
Re: Displaying a gadget partially outside its window
Posted: Mon Nov 08, 2010 9:21 am
by merendo
Here's what I want:
Code: Select all
If OpenWindow(0, 0, 0, 270, 140, "ListViewGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ListViewGadget(0, 10, 10, 250, 200)
For a = 1 To 12
AddGadgetItem (0, -1, "Item " + Str(a) + " of the Listview") ; define listview content
Next
SetGadgetState(0, 9) ; set (beginning with 0) the tenth item as the active one
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
But I would like the ListViewGadget to be fully visible, ie to extend outside the window boundaries. Right now, it's just being cropped. Is there a way to do this?
Re: Displaying a gadget partially outside its window
Posted: Sun Nov 14, 2010 10:08 pm
by DoubleDutch
You can't extend out of the window, but see PureLust's post:
If you want the 2nd thing (scrolling within the Window), ScrollAreaGadget() is your fiend.
That is a BIG clue on how to get pretty much what you want...
Re: Displaying a gadget partially outside its window
Posted: Sun Nov 14, 2010 10:33 pm
by TomS
By far not perfect, but maybe it's enough for you to work with.
Code: Select all
OpenWindow(0, 0, 0, 270, 140, "Main", #PB_Window_SystemMenu)
ButtonGadget(0, 5, 5, 200, 50, "button")
OpenWindow(1, 100, 100, 250, 200, "", #PB_Window_BorderLess)
ListViewGadget(1, 0, 0, 250, 200)
For a=1 To 10
AddGadgetItem(1, 0, Str(a))
Next
Repeat
event = WaitWindowEvent(20)
Select event
Case #PB_Event_MoveWindow
If EventWindow()=0
ResizeWindow(1, WindowX(0)+100, WindowY(0)+100, #PB_Ignore, #PB_Ignore )
SetActiveWindow(1)
EndIf
Default
SetActiveWindow(1)
EndSelect
Until event=#PB_Event_CloseWindow
End
Re: Displaying a gadget partially outside its window
Posted: Fri Nov 19, 2010 8:58 am
by merendo
Yes, that's how I've solved the problem now. I am still not entirely satisfied, as it creates a weird look when the parent window is moved, but I guess it'll have to do. Thanks for your code anyway.
Re: Displaying a gadget partially outside its window
Posted: Fri Nov 19, 2010 4:34 pm
by einander
Hi Merendo:
With a callback you can avoid the weird look when the parent window is moved.
Code: Select all
Procedure WinCB1(hWnd, Msg, wParam, lParam)
Select msg
Case #WM_MOVE,#WM_MOVING
If EventWindow()=0
ResizeWindow(1, WindowX(0)+120, WindowY(0)+50, #PB_Ignore, #PB_Ignore )
EndIf
Default
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow(0, 0, 0, 270, 60, "Main", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
BtnShowHide=ButtonGadget(-1, 5, 5, 100, 20, "Show Gad",#PB_Button_Toggle)
BtnClose=ButtonGadget(-1, 5, 35, 100, 20, "Quit")
OpenWindow(1, WindowX(0)+120, WindowY(0)+50, 250, 200, "", #PB_Window_BorderLess|#PB_Window_Invisible)
StickyWindow(1,1)
ListViewGadget(1, 0, 0, 250, 200)
For a=1 To 10
AddGadgetItem(1, 0, Str(a))
Next
SetWindowCallback(@WinCb1())
Repeat
If GetAsyncKeyState_(27)&$8000 : End : EndIf
ev = WaitWindowEvent(1)
Select ev
Case #PB_Event_Gadget
Select EventGadget()
Case BtnClose:Break
Case BtnShowHide
HideWindow(1, GetGadgetState(BtnShowHide)!1)
EndSelect
EndSelect
Until ev=#PB_Event_CloseWindow
End
Cheers!