rulergadget test beta

Developed or developing a new product in PureBasic? Tell the world about it.
localmotion34
Enthusiast
Enthusiast
Posts: 665
Joined: Fri Sep 12, 2003 10:40 pm
Location: Tallahassee, Florida

rulergadget test beta

Post by localmotion34 »

here is a gadget i am working on that will extend the functionality of PB drawing image and graphics. not much right now, but i am planning a rulered canvas and rulered imagegadget. this is just a preliminary release to get some input on methods and functionality as well as suggestions. anyone who wants to help is more than welcome.

Code: Select all

#pb_rulerH=$33333333
#pb_rulerV=$33333334
#Pb_rulerL=$33333335

Procedure rulergadget(number,x,y,width,flags)
  If flags=#Pb_rulerL
  LoadFont(2, "test", 7) 
  ruler=CreateImage(#PB_Any,width,33)
  StartDrawing(ImageOutput())
  Box(0,0,width,33,#White)
  DrawingMode(4)
  Box(0,0,width,33,0)
  For c=b+10 To c=b+90 Step 10
    LineXY(c,0,c,6,0)
    LineXY(c,33,c,27,0)
  Next 
  For a=100 To width Step 100
    LineXY(a,0,a,10,0)
    Locate(a-7,11)
    DrawingFont(FontID())
    DrawText(Str(a))
    LineXY(a,33,a,23,0)
    b=a
    For c=b+10 To c=b+90 Step 10
      LineXY(c,0,c,6,0)
      LineXY(c,33,c,27,0)
    Next 
  Next 
  StopDrawing()
  temp=ImageGadget(#PB_Any,x,y,width,33,UseImage(ruler))
  ruler1=CreateImage(#PB_Any,33,width)
  StartDrawing(ImageOutput())
  Box(0,0,33,width,#White)
  DrawingMode(4)
  Box(0,0,33,width,0)
  For a=100 To width Step 100
    LineXY(0,a,7,a)
    Locate(11,a-4)
    DrawingFont(FontID())
    DrawText(Str(a))
    LineXY(33,a,27,a)
    For c=0 To 90 Step 10
      LineXY(0,c,6,c)
      LineXY(33,c,27,c)
    Next 
    b=a
    For c=b+10 To c=b+90 Step 10
      LineXY(0,c,6,c)
      LineXY(33,c,27,c)
    Next 
  Next 
  StopDrawing()
  temp1=ImageGadget(#PB_Any,x-33,y+33,33,width,UseImage(ruler1))
  toggleb=ButtonGadget(#PB_Any,x-33,y,33,33,"",#PB_Button_Toggle)
  ProcedureReturn toggleb 
ElseIf flags=#pb_rulerH
  LoadFont(2, "test", 7) 
  ruler=CreateImage(#PB_Any,width,33)
  StartDrawing(ImageOutput())
  Box(0,0,width,33,#White)
  DrawingMode(4)
  Box(0,0,width,33,0)
  For c=b+10 To c=b+90 Step 10
    LineXY(c,0,c,6,0)
    LineXY(c,33,c,27,0)
  Next 
  For a=100 To width Step 100
    LineXY(a,0,a,10,0)
    Locate(a-7,11)
    DrawingFont(FontID())
    DrawText(Str(a))
    LineXY(a,33,a,23,0)
    b=a
    For c=b+10 To c=b+90 Step 10
      LineXY(c,0,c,6,0)
      LineXY(c,33,c,27,0)
    Next 
  Next 
  StopDrawing()
  temp=ImageGadget(#PB_Any,x,y,width,33,UseImage(ruler))
ElseIf flags=#pb_rulerV
  LoadFont(2, "test", 7)
  ruler1=CreateImage(#PB_Any,33,width)
  StartDrawing(ImageOutput())
  Box(0,0,33,width,#White)
  DrawingMode(4)
  Box(0,0,33,width,0)
  For a=100 To width Step 100
    LineXY(0,a,7,a)
    Locate(11,a-4)
    DrawingFont(FontID())
    DrawText(Str(a))
    LineXY(33,a,27,a)
    For c=0 To 90 Step 10
      LineXY(0,c,6,c)
      LineXY(33,c,27,c)
    Next 
    b=a
    For c=b+10 To c=b+90 Step 10
      LineXY(0,c,6,c)
      LineXY(33,c,27,c)
    Next 
  Next 
  StopDrawing()
  temp1=ImageGadget(#PB_Any,x,y,33,width,UseImage(ruler1))
EndIf 
EndProcedure 

If OpenWindow(0,0,0,645,605,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"RulerGadget") And CreateGadgetList(WindowID(0)) 
  test=rulergadget(1,60,20,550,#Pb_rulerL)
  
  
EndIf 
Repeat 
  event=WaitWindowEvent()
  Select event
    Case #PB_EventGadget
      Select EventGadgetID()
        
      EndSelect
    Case #PB_EventCloseWindow
      End 
  EndSelect 
ForEver 
 
regards.
Last edited by localmotion34 on Fri Dec 10, 2004 11:54 pm, edited 1 time in total.

Code: Select all

!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: rulergadget test beta

Post by PB »

Can't compile: Error at line 113 : CloseGadgetList() without OpenGadgetList()
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

just remove that line

nice btw!!
Post Reply