It is currently Mon Nov 30, 2020 5:41 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Crossplatform scrollable Canvas Gadget (Win + OSX done)
PostPosted: Mon Jan 02, 2012 10:16 pm 
Offline
Always Here
Always Here

Joined: Mon Sep 22, 2003 6:45 pm
Posts: 7446
Location: Norway
It's possible to use a ScrolledWindow (a kind of container that adds scrollbar to the child): http://developer.gnome.org/gtk/2.24/Gtk ... indow.html

But I'd recommend adding scrollbars separately. The scrolled window is really more like a scrollarea gadget in the sense that it pans around on a big gadget.


Top
 Profile  
Reply with quote  
 Post subject: Re: Crossplatform scrollable Canvas Gadget (Win + OSX done)
PostPosted: Mon Jan 02, 2012 10:44 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5815
Location: Germany
The scrolled window requires support from the contained widget to work properly. Adding ScrollBarGadgets manually is probably the simpler solution.

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
 Post subject: Re: Crossplatform scrollable Canvas Gadget (Win + OSX done)
PostPosted: Mon Jan 02, 2012 11:58 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10589
Location: Beyond the pale...
It's looking like Linux might well be the easiest of the 3 implementations. :) I might dual boot my old desktop with a copy of Ubuntu and have a crack at it after all.

Thanks again.

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject: Re: Crossplatform scrollable Canvas Gadget (Win + OSX done)
PostPosted: Thu May 31, 2012 2:34 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 536
Location: sweden
My schedulegadget does the same but with two (or three) gadgets and all in a list.
http://www.purebasic.fr/english/viewtopic.php?f=12&t=50113


Top
 Profile  
Reply with quote  
 Post subject: Re: Crossplatform scrollable Canvas Gadget (Win + OSX done)
PostPosted: Thu May 31, 2012 4:51 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10589
Location: Beyond the pale...
jesperbrannmark wrote:
My schedulegadget does the same but with two (or three) gadgets and all in a list.
http://www.purebasic.fr/english/viewtopic.php?f=12&t=50113


Not quite, that uses a scrollarea gadget which is not suitable for very large documents because the inner container is limited in size (at least under Windows it is).

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject: Re: Crossplatform scrollable Canvas Gadget (Win + OSX done)
PostPosted: Wed Aug 12, 2020 2:56 pm 
Offline
Addict
Addict

Joined: Fri Aug 28, 2015 6:10 pm
Posts: 1171
Location: Portugal
Needed a scrollable canvas gadget so wrote this. No API.

The canvas is in a container gadget and is simply moved around.

I can get the scroll bars to move the canvas and I can set the start point of the canvas from the main programme.

I can also get the canvas to move with the left mouse button down, the vertical scroll can also be done with the mouse wheel the only thing I cannot get hold of is horizontal movement from say a rollerball or the mac magic mouse.

If anyone looks at this are there any limitations I should be aware of?

First the module ScrollCanvas.pbi

Code:
DeclareModule ScrollCanvas
 
  Declare.i Create(Vx,Vy,Vw,Vh,Cw,Ch)
  Declare ProgScrollx(x.i)
  Declare ProgScrollY(Y.i)
 
EndDeclareModule

Module ScrollCanvas
 
  Global ViewHeight.i,ViewWidth.i
  Global Canvas,CanvasWidth.i,CanvasHeight.i
 
  Global VScroll.i,HScroll.i
 
  Global VScrollValue
 
  Procedure HandleVScroll()

    VScrollValue = GetGadgetState(VScroll); - (GetGadgetState(VScroll) * 2)
 
    If VScrollValue < 0
   
      VScrollValue = 0
   
    EndIf

    If VScrollValue > CanvasHeight - ViewHeight

      VScrollValue = CanvasHeight - ViewHeight
   
    EndIf 

    VScrollValue = GetGadgetState(VScroll) - (GetGadgetState(VScroll) * 2)
   
    ResizeGadget(Canvas,#PB_Ignore,VScrollValue,#PB_Ignore,#PB_Ignore)
 
  EndProcedure
 
  Procedure HandleHScroll()

  HScrollValue = GetGadgetState(HScroll); - (GetGadgetState(VScroll) * 2)

  If HScrollValue < 0
   
    HScrollValue = 0
   
  EndIf

  If HScrollValue > CanvasWidth - ViewWidth
 
    HScrollValue = CanvasWidth - ViewWidth
   
  EndIf

  HScrollValue = GetGadgetState(HScroll) - (GetGadgetState(HScroll) * 2)

  ResizeGadget(Canvas,HScrollValue,#PB_Ignore,#PB_Ignore,#PB_Ignore)
 
  EndProcedure
 
  Procedure ProgScrollx(x.i)
   
    ResizeGadget(Canvas,x,#PB_Ignore,#PB_Ignore,#PB_Ignore)
   
    SetGadgetState(HScroll,-x)
   
  EndProcedure
 
  Procedure ProgScrollY(y.i)
   
    ResizeGadget(Canvas,#PB_Ignore,Y,#PB_Ignore,#PB_Ignore)
   
    SetGadgetState(VScroll,-y)
   
  EndProcedure
 
  Procedure.i Create(Vx,Vy,Vw,Vh,Cw,Ch)
   
    CanvasWidth = Cw
    CanvasHeight = Ch
    ViewHeight= Vh - 20
    ViewWidth = Vw - 20

    View = ContainerGadget(#PB_Any, Vx, Vy, ViewWidth, ViewHeight, #PB_Container_Single)
    Canvas = CanvasGadget(#PB_Any, 0, 0, Cw, Ch)
   
    CloseGadgetList()
     HScroll = ScrollBarGadget(#PB_Any, Vx,Vy + ViewHeight,ViewWidth, 20,0, CanvasWidth - ViewWidth,1)
     VScroll = ScrollBarGadget(#PB_Any, Vx + ViewWidth,Vy,20, ViewHeight,0, CanvasHeight - ViewHeight,1)
     
     BindGadgetEvent(VScroll,@HandleVScroll())
     BindGadgetEvent(HScroll,@HandleHScroll())
     
     Debug CanvasHeight - ViewHeight
     Debug CanvasWidth - ViewWidth
     
     
    ProcedureReturn Canvas
   
   
  EndProcedure
 
EndModule


Now a little test programme. ScrollCanvastest.pb

Code:
IncludeFile "ScrollCanvas.pbi"

Global Window_0

Global DrawCanvas.i

Procedure TestDraw()

  StartVectorDrawing(CanvasVectorOutput(DrawCanvas))
 
  MovePathCursor(0,0)
  AddPathLine(800,900)

  MovePathCursor(800,0)
  AddPathLine(0,900)
 
  StrokePath(1)
 
EndProcedure

  Window_0 = OpenWindow(#PB_Any, 0, 0, 850, 450, "Scroll Canvas", #PB_Window_SystemMenu)

  DrawCanvas = ScrollCanvas::Create(20,25,700,400,800,900)

  TestDraw()
 
  ;Show Centre of canvas
  ScrollCanvas::ProgScrollY(-260)
  ScrollCanvas::ProgScrollX(-60) 
 
  Define Event.i
 
Repeat
   
  Event = WaitWindowEvent()
 
  Select event
    Case #PB_Event_CloseWindow
      End

    Case #PB_Event_Menu
      Select EventMenu()
      EndSelect

    Case #PB_Event_Gadget
      Select EventGadget()
      EndSelect
  EndSelect
 
ForEver


Any use?

CD

_________________
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.


Top
 Profile  
Reply with quote  
 Post subject: Re: Crossplatform scrollable Canvas Gadget (Win + OSX done)
PostPosted: Tue Aug 25, 2020 12:57 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Wed Oct 29, 2003 4:35 pm
Posts: 10589
Location: Beyond the pale...
A similar approach to that taken by a ScrollAreaGadget and is limited by the size restrictions placed on a gadget by the OS in question. Windows 7 certainly has such limitations.

_________________
I may look like a mule, but I'm not a complete ass.


Top
 Profile  
Reply with quote  
 Post subject: Re: Crossplatform scrollable Canvas Gadget (Win + OSX done)
PostPosted: Tue Aug 25, 2020 4:45 pm 
Offline
Addict
Addict

Joined: Mon Nov 25, 2013 6:41 am
Posts: 836
How about this?
https://github.com/mestnyi33/Widget/blob/master/examples/scroll/scrollarea(demo).pb


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye