It is currently Mon Aug 10, 2020 4:57 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 86 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Re: Canvas based Grid gadget
PostPosted: Fri Mar 29, 2013 4:36 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Apr 24, 2012 5:08 pm
Posts: 542
Location: Ontario, Canada
RichardL wrote:
When designing a grid to be used as a data entry mechanism it is a good idea to imagine yourself as a super fast typist** who would much rather enter a new line of data without taking a hand away from the keyboard to use the mouse.


Good point, and something that should be considered for any application.

Over the past 30 years we've developed various strategies for allowing our applications to be controlled entirely from the keyboard, as well as with the more normal mouse-oriented approach. Our customers find they can get from 5 to 10 times the throughput, compared to using a mouse/keyboard.

In effect, our programs are state machines that dynamically change the functions of keys to suit the situation. The idea is to maximize performance with a minimum of hand movement.

_________________
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Sun Jul 07, 2013 9:35 am 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
This Canvas based Grid gadget is very nicely done.

If someone needs column names to reflect more "traditional" naming convention (A, B, C.....AA, AB, AC... AAA, AAB, AAC... ZZZ) here is my version of the MyGrid_Reset() procedure:
Code:
; needed for MyGrid_Reset()
#ColumnText = 65 ; "A"
#ColumnSpan = 26 ; "A" to "Z"

Procedure.i _MyGrid_Reset(*mg._MyGrid_Type, Rows, Cols)
    ; Reset everything so Grid can receive/show new data
    Protected i, factor.i, bigfactor.i
   
    If rows <= 0 : rows =1 : EndIf
    If cols <= 0 : cols =1 : EndIf
   
    *mg\Rows = rows          : Dim *mg\RowHeight(rows)
    *mg\Cols = cols          : Dim *mg\ColWidth(cols) :  Dim *mg\ColID(cols)
   
    *mg\LastIndex = (rows+1) * (cols+1) - 1
    Dim *mg\gData(*mg\LastIndex)
    If ArraySize(*mg\gData()) < 0
        Debug "failed to allocate memory for the grid data !... "
        ProcedureReturn
    EndIf
   
    ; initializations
    *mg\TopRow          = 1
    *mg\TopCol          = 1
    *mg\Row             = 1
    *mg\Col             = 1
   
    ;- set column name like a real spread sheet...
    For i=#ColumnText To #ColumnText + cols
      If i < (#ColumnText + #ColumnSpan)
        ; A to Z -> total of 26 columns... enough for small stuff.
        _MyGrid_SetCellText(*mg, 0, i - (#ColumnText -1), Chr(i))
      ElseIf i < (#ColumnText + #ColumnSpan + (#ColumnSpan * #ColumnSpan))
        ; AA to ZZ  -> 676 columns -> total of 702 columns... nice size.
        factor = Int((i - (#ColumnText + #ColumnSpan)) / #ColumnSpan)
        Debug factor
        _MyGrid_SetCellText(*mg, 0, i - (#ColumnText -1), Chr(#ColumnText + factor) + Chr(i - #ColumnSpan * (factor + 1)))
     ElseIf i < (#ColumnText + #ColumnSpan + (#ColumnSpan * #ColumnSpan) + (#ColumnSpan * #ColumnSpan * #ColumnSpan))
        ; AAA to ZZZ  -> 17576 columns -> total of 18278 columns... that's a lot!
        factor = Int((i - (#ColumnText + #ColumnSpan)) / #ColumnSpan)
        bigfactor = Int((i - (#ColumnText + (#ColumnSpan * #ColumnSpan) + #ColumnSpan)) / (#ColumnSpan * #ColumnSpan))
        Debug Str(factor) + " : " + Str(bigfactor)
        _MyGrid_SetCellText(*mg, 0, i - (#ColumnText -1), Chr(#ColumnText + bigfactor) + Chr(#ColumnText + factor - (#ColumnSpan * (bigfactor + 1))) + Chr(i - #ColumnSpan * (factor + 1)))
      Else
        ; AAAA to ZZZZ -> 456976 columns -> total of 475254 columns... who needs that?
        ; out of range; or bigger than 18278 columns
        _MyGrid_SetCellText(*mg, 0, i - (#ColumnText -1), "...")
      EndIf
    Next
   
    For i=1 To rows
        _MyGrid_SetCellText(*mg, i, 0, Str(i))
    Next
   
    _MyGrid_ChangeColWidth(*mg, #MyGrid_RC_Any, #MyGrid_Default_ColWidth)
    _MyGrid_ChangeRowHeight(*mg, #MyGrid_RC_Any, #MyGrid_Default_RowHeight)
   
    *mg\FrozenCol           = 0
    *mg\FrozenRow           = 0
   
    *mg\MoveStatus          = #MyGrid_MouseMove_Nothing
    *mg\PreviousX           = 0
    *mg\PreviousY           = 0
   
    *mg\NoRedraw            = #False
   
    *mg\Color_Line          = $CCCCCC
    *mg\Color_BlockBack     = $FFFFBB
    *mg\Color_Background    = $808080
    *mg\Color_FocusBack     = $DBF0E0
    *mg\Color_FocusBorder   = $009AB6
   
    *mg\WrapText            = #True
   
    ; adding the 4 default styles : data-cell/frozen-cells/col-header/row-header
    ClearList( *mg\LstStyle() )
    ClearMap(  *mg\DicStyle() )
   
    AddElement(*mg\LstStyle())      ; data area
    _MyGrid_DefineCurrentStyle(*mg, #MyGrid_Align_Center, $FFFFFF, $000000, Font_A8, 0, 1)
   
    AddElement(*mg\LstStyle())      ; frozen-data area
    _MyGrid_DefineCurrentStyle(*mg, #MyGrid_Align_Center, $D7EBFA, $000000, Font_A8, 0, 1)
   
    AddElement(*mg\LstStyle())      ; col-headers
    _MyGrid_DefineCurrentStyle(*mg, #MyGrid_Align_Center, $EB9E85, $FFFFFF, Font_A8, 0, 0)
   
    AddElement(*mg\LstStyle())      ; row-headers
    _MyGrid_DefineCurrentStyle(*mg, #MyGrid_Align_Center, $EB9E85, $FFFFFF, Font_A8, 0, 0)
   
    ; set min/max/page of scrolls
    _MyGrid_AdjustScrolls(*mg)
   
EndProcedure


For now the code covers 18278 columns...

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Sun Jul 07, 2013 7:32 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 14, 2011 6:07 pm
Posts: 342
@fsw: thanks for your addition (nice tip)

For those who are interested in this gadget, it has gone thru a lot of improvement since last update ... now with block selection and combo-cell ... I am just waiting for the final 5.20 to incorporate live scrolling (using BindEvent() ...) and shall soon upload inshAllah the final update!

Said


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Thu Aug 22, 2013 5:07 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6255
Location: Wales, UK
WinXP x86 PB5.20 Beta12

Hi Said

Few random things I have noticed while playing with your excellent gadget.

[1] MyGrid_SetColorAttribute():

#MyGrid_Color_FocusBack and #MyGrid_Color_FocusBorder are reversed in the *mg structure values

Would it make sense to include the default cell colours?

[2] .... you can put tick-box cells in Column 0 but they do not work.

[3] MyGrid_Col_Freeze()/MyGrid_Row_Freeze() does not?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Thu Aug 22, 2013 7:07 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6255
Location: Wales, UK
#PB_Shortcut_Prior is now #PB_Shorcut_PageUp (corrected by Bisonte)
#PB_Shortcut_Next is now #PB_Shorcut_PageDown (corrected by Bisonte)

Edit:
.... I need to work out how to change the cell edit a little bit. If the User types in some text, it shouldn't only require a Return Key hit to confirm (I know most avid keyboard Users would probably be happy, but it's confusing for those that mostly use the mouse - mouse focus on another cell should trigger acceptance of input in previous cell).

#MyGrid_Align_Right works fine with a single line of text, but if the text wraps in the cell to two or more lines, it gets aligned left.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Last edited by IdeasVacuum on Thu Aug 22, 2013 7:41 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Thu Aug 22, 2013 7:28 am 
Offline
Addict
Addict
User avatar

Joined: Tue Oct 09, 2007 2:15 am
Posts: 1131
Quote:
Renamed: #PB_Shorcut_Prior to #PB_Shorcut_PageUp and #PB_Shorcut_Next to #PB_Shorcut_PageDown

_________________
PureBasic 5.72 LTS (Windows x86/x64) | Windows10 Pro x64 | Z370 Extreme4 | i7 8770k | 32GB RAM | iChill GeForce RTX 2080 Super | HAF XF Evo​​
English is not my native language... (I often use DeepL to translate my texts.)


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Thu Aug 22, 2013 7:37 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6255
Location: Wales, UK
Thanks Bisonte :)

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Thu Aug 22, 2013 7:47 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6255
Location: Wales, UK
Another question - how to define the Grid Gadget without scroll bars?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget (revised for PB5.20)
PostPosted: Fri Aug 23, 2013 4:43 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 14, 2011 6:07 pm
Posts: 342
Hi All,

I have updated this gadget ... see first post. It is now compatible with PB 5.20 and has many new features ....

Hi IdeasVaccum
Quote:
Few random things I have noticed while playing with your excellent gadget.

[1] MyGrid_SetColorAttribute():

#MyGrid_Color_FocusBack and #MyGrid_Color_FocusBorder are reversed in the *mg structure values

Would it make sense to include the default cell colours?

[2] .... you can put tick-box cells in Column 0 but they do not work.

[3] MyGrid_Col_Freeze()/MyGrid_Row_Freeze() does not?


1. You are right, that was in old version - fixed
2. Yes Col 0 and Row 0 are hearers, you cant access them! However you can still hide them and use Col 1/Row 1 which can be editable ...
3. What is your question ? MyGrid_Col_Freeze(gadget, col) defines the col to freeze on ...

Quote:
Another question - how to define the Grid Gadget without scroll bars?


While defining the grid via MyGrid_New() you can request not to add scrolls.

See notes included with MyGrid_PB520.PBI for more details about editing cells

Best,
Said


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget (revised for PB5.20)
PostPosted: Fri Aug 23, 2013 1:32 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6255
Location: Wales, UK
Thanks Said!

Concerning the freezing, it was not working (XP x86, PB5.2 Beta12).

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget (revised for PB5.20)
PostPosted: Fri Aug 23, 2013 3:33 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 1136
Location: Amphibios 9
said wrote:
I have updated this gadget

thanks a lot! Image

Greetings ... Kiffi

_________________
Can't decide if i need a hug, an XXL coffee, 6 shots of vodka or 2 weeks of sleep.


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Sat Aug 01, 2015 2:24 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 14, 2011 6:07 pm
Posts: 342
Hi All,

After 2 years! Some people are still interested in that gadget ... :D :D

Here is a slight update of the same old version (allowing to hide Focus rectangle) and moved the includes to GitHub

* MyGrid_01Aug2015.PBI
* MyGrid_PB520.PBI (the same old release of aug-2013)

Both files can be downloaded here:

https://github.com/said7/PureBasic/tree/master


First post updated as well

Said


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Sat Aug 01, 2015 7:08 pm 
Offline
Enthusiast
Enthusiast

Joined: Sun Apr 06, 2008 12:54 pm
Posts: 392
Location: Brisbane, Qld, Australia
Many thanks, Said. Hiding the focus rectangle works perfectly!

_________________
Mike
www.showcuesystems.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Fri Aug 14, 2015 10:48 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Jun 06, 2003 2:41 pm
Posts: 177
Location: Belgium
Great work ! Thanks Said!

Maybe this gadget can be added to the official Purebasic distribution ?

_________________

LuckyLuke


Top
 Profile  
Reply with quote  
 Post subject: Re: Canvas based Grid gadget
PostPosted: Fri Aug 14, 2015 12:04 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 14065
Location: France
It's a nice work.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 86 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 21 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