Loading ...
Sorry, an error occurred while loading the content.

47031RE: Spreadsheet control[s]

Expand Messages
  • rod_bird001
    Sep 21 9:24 AM
    • 0 Attachment

      Richard has tweaked the code to include scrolling, tis is a link to the discussion on the alternative support forum. http://libertybasic.conforums.com/index.cgi?board=LB3&action=display&num=1379780644&start= 



      --- In libertybasic@yahoogroups.com, <rodbird@...> wrote:

      Richard's advice is to use LOCATE, rather than the undocumented feature that controls follow the original variable values on refresh.

       

      So corrected code, 

       

      'Original code by KCDan with help from Janet and Brent.
      'Richard advice is to use LOCATE
      'Any other bugs are my own

      nomainwin

      'Calculate how much space windows borders will take

      'Anatoly's tip

      WindowWidth = 200

      WindowHeight = 200

      open "Ajusting..." for graphics_nf_nsb as #1

      #1 "home ; down ; posxy w h"

      themeW=200-2*w : themeH = 200-2*h

      'themeW and themeH now contain the number of pixels

      'the Windows theme takes out of the graphics area

      close #1

      nomainwin

      'set up a 5x15 cell sheet

      numCols=5 'x

      numRows=15 'y

      cellW=120 'cell width in pixels

      cellH=25 'cell height in pixels

      cellColor$="black"

      cellBackcolor$="white"

      dim cell$(numCols,numRows)

      'fill the sheet's array with data

      for C=1 to numCols

      for R=1 to numRows

      cell$(C,R)=str$(C)+":"+str$(R)

      next R

      next C

      'textbox offsets in cell

      txtW=95

      txtH=25

      txtX=-81

      txtY=-26

      'checkbox offsets in cell

      okW=20

      okH=24

      okX=-25

      okY=-25

      'open a graphicbox inside a window_nf but first

      'calculate how much space Windows will take

      'Anatoly's tip

      WindowWidth = 200

      WindowHeight = 200

      open "Ajusting..." for graphics_nf_nsb as #1

      #1 "home ; down ; posxy w h"

      themeW=200-2*w : themeH = 200-2*h

      'themeW and themeH now contain the number of pixels

      'the Windows theme takes out of the graphics area

      close #1

      WindowWidth =numCols*cellW+themeW

      WindowHeight =numRows*cellH+themeH

      UpperLeftX=(DisplayWidth-WindowWidth)/2

      UpperLeftY=(DisplayHeight-WindowHeight)/2

       

      graphicbox #main.g,0,0,numCols*cellW+2,numRows*cellH+2

      checkbox #main.ok,"",[okclicked],[okclicked],okX,okY,okW,okH

      textbox #main.txt, txtX, txtY, txtW, txtH

      open "Grid Tool" for window_nf as #main

      print #main, "font ms_sans_serif 10 bold"

      print #main, "trapclose [quit]"

      print #main.g, "down;fill buttonface;flush"

       

      print #main.g, "when leftButtonMove [cellclicked]"

      print #main.g, "when leftButtonDown [cellclicked]"

      goto [redraw]

      wait

      [cellclicked]

      'capture the cell coordinates and set the

      'textbox and checkbox offsets

      'then refresh to draw the controls at the cell location

      curx=int(MouseX/120)+1

      cury=int(MouseY/25)+1

      if curx<1 or curx>numCols then curx=0

      if cury<1 or cury>numRows then cury=0

      txtX=(curx-1)*120+1

      txtY=(cury-1)*25+1

      okX=(curx-1)*120+100

      okY=(cury-1)*25+2

      #main.txt "!locate ";txtX;" ";txtY;" ";txtW;" ";txtH

      #main.ok "locate ";okX;" ";okY;" ";okW;" ";okH

      #main "refresh"

      'show the original contents
      '#main.txt cell$(curx,cury)

       

      #main.txt "!setfocus"

      goto [redraw]

       

      [okclicked]

      'move the text and checkbox controls off screen and save the changes

      txtX=-100

      txtY=-100

      okX=-100

      okY=-100

      #main.txt "!locate ";txtX;" ";txtY;" ";txtW;" ";txtH

      #main.ok "locate ";okX;" ";okY;" ";okW;" ";okH

      #main "refresh"

      #main.txt "!contents? t$"

      cell$(curx,cury)=t$

      #main.txt ""

      #main.ok "reset"

       

      [redraw]

      'delete the last segment, redraw all cells and flush

      #main.g "delsegment t"

      #main.g "color ";cellColor$;";backcolor ";cellBackcolor$

      for C=1 to numCols

      for R=1 to numRows

      #main.g "place ";(C-1)*120;" ";(R-1)*25

      #main.g "boxfilled ";C*120+1;" ";R*25+1

      #main.g "place ";(C-1)*120+2;" ";((R-1)*25)+18;";|";cell$(C,R)

      next R

      next C

      #main.g "flush t"

      wait

      [quit]

      close #main

      end

       



      --- In libertybasic@yahoogroups.com, <rodbird@...> wrote:

      I see I have the window theme size code in twice, the top block can be deleted. 



      --- In libertybasic@yahoogroups.com, <libertybasic@yahoogroups.com> wrote:

      I found some code from KCDan and tweaked it a little, it sets out the data in a graphicbox and uses a moving textbox and checkbox to take input.

       

              'Original code by KCDan with help from Janet and Brent.
              'Any bugs are my own
              nomainwin

              'Calculate how much space windows borders will take
              'Anatoly's tip
              WindowWidth = 200
              WindowHeight = 200
              open "Ajusting..." for graphics_nf_nsb as #1
              #1, "home ; down ; posxy w h"
              themeW=200-2*w : themeH = 200-2*h
              'themeW and themeH now contain the number of pixels
              'the Windows theme takes out of the graphics area
              close #1

              nomainwin
              'set up a 5x15 cell sheet
              numCols=5   'x
              numRows=15  'y
              cellW=120   'cell width in pixels
              cellH=25    'cell height in pixels
              cellColor$="black"
              cellBackcolor$="white"
              dim cell$(numCols,numRows)

              'fill the sheet's array with data
              for C=1 to numCols
                  for R=1 to numRows
                      cell$(C,R)=str$(C)+":"+str$(R)
                  next R
              next C

              'textbox offsets in cell
              txtW=95
              txtH=25
              txtX=-81
              txtY=-26

              'checkbox offsets in cell
              okW=20
              okH=24
              okX=-25
              okY=-25

              'open a graphicbox inside a window_nf but first
              'calculate how much space Windows will take
              'Anatoly's tip
              WindowWidth = 200
              WindowHeight = 200
              open "Ajusting..." for graphics_nf_nsb as #1
              #1, "home ; down ; posxy w h"
              themeW=200-2*w : themeH = 200-2*h
              'themeW and themeH now contain the number of pixels
              'the Windows theme takes out of the graphics area
              close #1

              WindowWidth =numCols*cellW+themeW
              WindowHeight =numRows*cellH+themeH
              UpperLeftX=(DisplayWidth-WindowWidth)/2
              UpperLeftY=(DisplayHeight-WindowHeight)/2


              graphicbox #main.g,0,0,numCols*cellW+2,numRows*cellH+2
              checkbox #main.ok,"",[okclicked],[okclicked],okX,okY,okW,okH
              textbox #main.txt, txtX,  txtY, txtW, txtH

              open "SpreadSheet" for window_nf as #main

              print #main, "font ms_sans_serif 10 bold"
              print #main, "trapclose [quit]"
              print #main.g, "down;fill buttonface;flush"


              print #main.g, "when leftButtonMove [cellclicked]"
              print #main.g, "when leftButtonDown [cellclicked]"
              goto [redraw]
              wait

              [cellclicked]
              'capture the cell coordinates and set the
              'textbox and checkbox offsets
              'then refresh to draw the controls at the cell location
              curx=int(MouseX/120)+1
              cury=int(MouseY/25)+1
              if curx<1 or curx>numCols then curx=0
              if cury<1 or cury>numRows then cury=0
              txtX=(curx-1)*120+1
              txtY=(cury-1)*25+1
              okX=(curx-1)*120+100
              okY=(cury-1)*25+2
              #main, "refresh"
              #main.txt, cell$(curx,cury)
              #main.txt "!setfocus"
              goto [redraw]


              [okclicked]
              'move the text and checkbox controls off screen and save the changes
              txtX=-100
              txtY=-100
              okX=-100
              okY=-100
              #main, "refresh"
              #main.txt, "!contents? t$"
              cell$(curx,cury)=t$
              #main.txt, ""
              #main.ok,"reset"


              [redraw]
              'delete the last segment, redraw all cells and flush
              #main.g, "delsegment t"
              #main.g, "color ";cellColor$;";backcolor ";cellBackcolor$
              for C=1 to numCols
                  for R=1 to numRows
                      #main.g, "place ";(C-1)*120;" ";(R-1)*25
                      #main.g, "boxfilled ";C*120+1;" ";R*25+1
                      #main.g, "place ";(C-1)*120+2;" ";((R-1)*25)+18;";|";cell$(C,R)
                  next R
              next C
              #main.g, "flush t"
              wait

              [quit]
              close #main
              end


       



      --- In libertybasic@yahoogroups.com, <larryrl@...> wrote:

      That's ok, you gotta do what works for you.

      Larry Lowe

      --- In libertybasic@yahoogroups.com, Fred Jensen <k6dgw@...> wrote:
      >
      > On 9/16/2013 7:08 PM, Larry Lowe wrote:
      > > There is a program called bills, which uses regular buttons and you
      > > click them to edit the text. Could you make a scrollable graphics window
      > > and put buttons on there to act as the cells? If so you could make the
      > > text the caption on the button. Just a thought since you said no
      > > calculations we needed.
      >
      > Thanks for the lead Larry, I looked at it and I don't think that's what
      > I'm really looking for. Since this is just columnar data and posted R/O
      > to the texteditor window, I think I'll just format it. Done that
      > before, I can do it again.
      >
      > Best Regards,
      >
      > Fred
      > Auburn CA
      >
    • Show all 10 messages in this topic