AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[module] TVX - Tree View eXtension

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Tue May 08, 2007 9:53 am    Post subject: [module] TVX - Tree View eXtension Reply with quote

TVX is extension for TreeView control to support moving, inserting and deleting. Once you call TVX function your tree view will become extended.


Key Bindings :
Code:
         INSERT        - add new item
   SHIFT INSERT        - add new group
         DELETE        - delete item or group
   SHIFT   UP          - move item up   
   SHIFT  DOWN         - move item down


Current API is as follows (documentation currently in the source):

Code:
TVX  - Initialisation function. Mandatory to call before you show the TreeView.

Walk - Walk the menu and rise events. Check out Save button in Example
Move - Moves tree view item up or down

Copy - Copies menu item or group to another location. Exists in the code as TVX_CopyItem, but still not documented and properly interfaced.




Basic Example:
Code:
   Gui, Add, TreeView, h400 w300 vMyTree

   root  := TV_Add("Root", "" , "Expand")
   loop, 10
      P     := TV_Add(A_Index, root)

   TVX("MyTree", "Handler", "HasRoot CollapseOnMove ")
   Gui, Show,  autosize
return


Handler:
return

#include TVX.ahk   


Check out Walk example here

Documentation
Code:
;----------------------------------------------------------------------------------------
; Function:     TVX
;               Initialisation function. Mandatory to call before you show the TreeView.
;
; Parameters:
;               pTree       - AHK name of the TreeView control
;               pSub        - Subroutine for TreeViewX, the same rules as in g.
;               pOptions    - String containing space delimited options for setting up TreeViewX
;               pUserData   - Base name of the array holding user data.
;                             This array is indexed using tree view item handles.
;           
; Options:
;               HasRoot     - TreeViewX has root item - the one containing all other items.
;                             Root item can't be moved, edited or delited, and items can not
;                             be moved or created outside of it. This option need to be set
;                             after root is already added to the menu, as TreeViewX need to
;                             know the root menu handle.
;                         
;           CollapseOnMove  - When moving item out of of its container, this option makes container collapse
;           EditOnInsert    - Automaticaly enters edit mode upon insertion of new item
;
; Example:
;>
;>          TVX("MyTree", "Handler", "HasRoot CollapseOnMove")
;>
;----------------------------------------------------------------------------------------
; Function:     Walk
;               Walk the menu and rise events
;
; Parameters:
;               root        - menu to iterate, can be simple item also
;               label       - event handler
;               event_type  - event argument 1 - Event type
;               event_param - event argument 2 - Item upon which event is rised
;           
;
;                  Type                       Param
;
;           +  - Iteration start,           root handle
;           M  - Menu item,                 menu handle
;           I  - Item,                      item handle
;           E  - End of menu                menu handle         (pseudo item)
;           -  - Iteration end              root handle         (pseudo item)
;
;----------------------------------------------------------------------------------------------
; Function:     Move
;               Moves tree view item up or down
;
; Parameters:
;               item        -   Handle of the item to move
;               direction   -   "u" or "d" (Up & Down)
;
; Returns:
;               Handle of the item
;
; Remarks:
;               Item to be moved is copied to the new place then source item is deleted. This
;               creates new handle for the moved item. New handle will be returned by the function.
;

_________________


Last edited by majkinetor on Fri Aug 03, 2007 1:08 pm; edited 8 times in total
Back to top
View user's profile Send private message MSN Messenger
Rabiator



Joined: 17 Apr 2005
Posts: 260
Location: Sauerland

PostPosted: Tue May 08, 2007 1:21 pm    Post subject: Re: TVX - Tree Viex eXtension Reply with quote

majkinetor, nice work!! Cool
Now I'll retry a script that I discarded exactly because these modifying possibilities were missing.

Thanks for this facility!
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Tue May 08, 2007 1:44 pm    Post subject: Reply with quote

This is Walk example. It will save entire tree in the text file on button click.
Walk handler is called for every item in the treeview and few more times for pseudo items (end of menu, end of iteration). Events specify some points of general interest. You can use Walk for whatever kind of processing you need upon treeview enteries, while being informed about hierarchy details.


Code:
OnBtnClick:
   TVX_Walk(root, "SaveHandler", Event, Item)
return

SaveHandler:
    TV_GetText(txt, Item)                   
    if Event = +                                ;start of iteration, called only for root
    {
        FileDelete, _out.txt
        FileAppend %txt%`n, _out.txt
        line := "|-"
    }

    if Event = E
        StringTrimRight, line, line, 2          ;end of group
   
    if Event in I,M                             ;I=simple item, M=group item 
        FileAppend %line%%txt%, _out.txt


    if Event = M                                ;start of group
        line .= "--"
   
    if Event = -                                ;end of iteration
        Msgbox, TVX saved in _out.txt
return


_________________
Back to top
View user's profile Send private message MSN Messenger
Rajat



Joined: 28 Mar 2004
Posts: 1715

PostPosted: Tue May 08, 2007 4:14 pm    Post subject: Reply with quote

cool additions to TView control... I did similar additions from scratch in a couple of my scripts but never coaxed myself into writing a function. thanks for doing it! Smile
_________________
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10450

PostPosted: Fri May 11, 2007 1:17 am    Post subject: Reply with quote

Great extension and presentation. I've linked to this topic from the remarks section of the TreeView page.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1715

PostPosted: Fri May 11, 2007 10:17 am    Post subject: Reply with quote

what do you use to make these demo gifs?
thanks
_________________
Back to top
View user's profile Send private message
majkinetor



Joined: 24 May 2006
Posts: 3544
Location: Belgrade

PostPosted: Fri May 11, 2007 10:26 am    Post subject: Reply with quote

Different stuff.

- Camstudio (freeware, portable)
Makes a video of what you do in region you specify. You have hotkeys to pause recording so you can pause when you want to add anotations. You also have hotkey "next anotation" so if you order then chronologicaly you can just record and press this hotkey when you want. This will generaly give you about 60MB avi.

- GIF Movie Gear (shareware, can be portable)
Then, you load this video here. It will show frames, so you can remove frames you don't like. After that you optimise gif with this tool so it becomes very small (optimisation means that only picture differences will be kept, so if you have several static frames, only 1 will be saved, if dot moved on 4th frame, only that dot will saved..). Then you save it as gif animation which gives you 300KB for longer gifs.

- Bannershop GIF Animator (shareware, can be portable)
You can create here banners , like the one in your signature. You can save short bunners and insert them at frame location using GIF Movie Gear. This allows you more proffesional presentation, with transitions etc..
For instance, take first frame of your movie and save it as a picture. Load this picture in Banner Animator and create fade in. Save this gif and load it at the start of your movie in GIF Movie Gear. This joines transitional gif and large gif into single one.


Don't create gifs larger then 300KB. Although they work nice standalone, they usualy crash all browsers or make local CPU burn. 300KB is generaly enough for 2 minutes of presentation. This depends on contenst of your presentation. If frames are "too moving" optimisation will be less effective and you will have larger gif.
_________________
Back to top
View user's profile Send private message MSN Messenger
Rajat



Joined: 28 Mar 2004
Posts: 1715

PostPosted: Fri May 11, 2007 11:19 am    Post subject: Reply with quote

that's really useful explanation... thanks for the info.
i'll copy this to my notes program, i'm sure this'll come in handy. Smile
_________________
Back to top
View user's profile Send private message
T800



Joined: 15 Oct 2006
Posts: 31
Location: Croatia

PostPosted: Sat Jun 02, 2007 8:34 pm    Post subject: Make it native! Reply with quote

This really should be integrated into ahk runtime.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group