ScriptUO

Official ScriptUO EasyUO Scripts => Script Library => Script development tools => Topic started by: TrailMyx on March 12, 2010, 09:51:06 PM

Title: TrailMyx's Tab Control and List Handler
Post by: TrailMyx on March 12, 2010, 09:51:06 PM
Code: [Select]
;=================================================================
; Script Name: TrailMyx's Tab List Handling Subs
; Author: TrailMyx
; Version: 0.20
; Shard OSI / FS: OSI / FS OK
; Revision Date: 3/12/2010
; Purpose: Allows the scripter to create cool Tab lists like you'll find in scripts like the CLAw
;          autolooter found at ScriptUO.com --> http://www.scriptuo.com/index.php?topic=17.0
;
; Subroutines included:
;   TM_CreateTabControl - Creates a new tab control instance
;   TM_HandleTabs - Button handler for each tab control.  One handler is required for each control
;   TM_AddTab - Add a tab to a tab control
;   TM_HideTabControl - Hides the whole control
;   TM_ShowTabControl - Makes the tab control visible
;   TM_HideTabByName - hides a tab by name
;   TM_ShowTabByName - makes a tab visible by name
;
; Requirements:
;   Requires TM List functions.
;   http://www.scriptuo.com/index.php?topic=21.msg21#msg21
; Locals/Globals:
;   TMTABS_ , %2 (local)
;
; Special Thanks:
;
;=================================================================

(http://www.scriptuo.com/Pictures/tab_control2.PNG)

So if you've ever used my CLAw user interface, you may have apprecated the "Tabs" that are created to allow you to change the view of the various ListBoxes.  However, it's a pain to implement by hand until now.  Utilizing my list handler subs, I created a new set of tools to help make your user interfaces more pretty.

Subs to come, but here's some sample code to see how easy it is:

Code: easyuo
  1. ;-----------------------------------------------------------------
  2. ;  Start of test code ----->
  3. set %list_functions c:\tool_listhandler29.txt ; required if you will be "calling" the list handler subs.
  4. set %font_arial MS , #SPC , Ariel
  5. set %called #FALSE ; assumes that functions are included in this file.  #TRUE to "call" them instead
  6. gosub showEUOMenu1
  7. gosub TM_CreateTabControl TabControl1 10 30 170 150 White WindowText %font_arial 8
  8. gosub TM_AddTab TabControl1 Fruit Fruit #TRUE ; #TRUE = hidden, #FALSE = visible
  9. gosub TM_AddTab TabControl1 Vegies Vegies #FALSE TestFunction
  10. gosub TM_AddTab TabControl1 FastFood FastFood #FALSE
  11. gosub TM_AddTab TabControl1 Planets Planets #FALSE
  12. gosub TM_AddToList TabControl1_Fruit bananna TAG
  13. gosub TM_AddToList TabControl1_Fruit apple TAG
  14. gosub TM_AddToList TabControl1_Fruit kiwi TAG
  15. gosub TM_AddToList TabControl1_Fruit grapes TAG
  16. gosub TM_AddToList TabControl1_Vegies carrot TAG
  17. gosub TM_AddToList TabControl1_Vegies onions TAG
  18. gosub TM_AddToList TabControl1_Vegies tomato TAG
  19. gosub TM_AddToList TabControl1_FastFood Windys TAG
  20. gosub TM_AddToList TabControl1_FastFood Burger , #SPC , King TAG
  21. gosub TM_AddToList TabControl1_FastFood Carls , #SPC , Jr. TAG
  22. gosub TM_AddToList TabControl1_Planets Mars
  23. gosub TM_AddToList TabControl1_Planets Uranus
  24. gosub TM_AddToList TabControl1_Planets Neptune
  25. gosub TM_AddToList TabControl1_Planets Jupiter
  26.  
  27. gosub TM_CreateTabControl TabControl2 200 30 170 150 White WindowText %font_arial 8
  28. gosub TM_AddTab TabControl2 Tab1 Tab1 #FALSE
  29. gosub TM_AddTab TabControl2 Tab2 Tab2 #FALSE
  30. gosub TM_AddTab TabControl2 Tab3 Tab3 #FALSE
  31. gosub TM_AddTab TabControl2 Tab4 Tab4 #FALSE
  32.  
  33. gosub TM_CreateTabControl TabControl3 30 220 150 150 White WindowText %font_arial 8
  34. gosub TM_AddTab TabControl3 Tab1 Tab1 #FALSE
  35. gosub TM_AddTab TabControl3 Tab2 Tab2 #FALSE
  36. gosub TM_AddTab TabControl3 Tab3 Tab3 #FALSE
  37. gosub TM_AddTab TabControl3 Tab4 Tab4 #FALSE
  38.  
  39. ; Lists are addressed as TabControl4_Tab1, 2, 3, 4
  40. gosub TM_CreateTabControl TabControl4 200 220 150 150 White WindowText %font_arial 8
  41. gosub TM_AddTab TabControl4 Tab1 Tab1 #FALSE
  42. gosub TM_AddTab TabControl4 Tab2 Tab2 #FALSE
  43. gosub TM_AddTab TabControl4 Tab3 Tab3 #FALSE
  44. gosub TM_AddTab TabControl4 Tab4 Tab4 #FALSE
  45.  
  46. gosub TM_HideTabControl TabControl3 ; hide the whole tab control
  47. gosub TM_ShowTabControl TabControl3 ; show the whole tab control, remembers what tabs where hidden
  48.  
  49. gosub TM_HideTabByName TabControl1 Planets
  50. gosub TM_ShowTabByName TabControl1 Fruit
  51.  
  52. gosub TM_CopyAllItemsInList TabControl1_Planets TabControl2_Tab2 #FALSE #FALSE
  53. gosub TM_CopyAllItemsInList TabControl1_Planets TabControl3_Tab3 #FALSE #FALSE
  54. gosub TM_CopyAllItemsInList TabControl1_Planets TabControl4_Tab4 #FALSE #FALSE
  55.  
  56. gosub TM_SelectTabByName TabControl2 Tab2
  57. gosub TM_SelectTabByName TabControl3 Tab3
  58.  
  59. repeat
  60.   gosub TM_HandleTabs TabControl1
  61.   gosub TM_HandleTabs TabControl2
  62.   gosub TM_HandleTabs TabControl3
  63.   gosub TM_HandleTabs TabControl4
  64. until #FALSE
  65.  
  66. sub TestFunction
  67.   display ok Function Called!
  68. return
  69. stop
  70. ;  <------ End of test code
  71.  

And see the attached picture to see the results.  Notice the TM_HandleTabs automatically handles the view change between tabs for each tab control.  A tab control is a grouping of tabs much like you see in a normal Windows program.
Title: Re: TrailMyx's Tab List Handler
Post by: Scrripty on March 12, 2010, 10:07:00 PM
You are a steely eyed missle man.  NEW TOYS! :)  Merry Christmas to Twinkle McNugget!
Title: Re: TrailMyx's Tab List Handler
Post by: TrailMyx on March 12, 2010, 10:34:30 PM
You are a steely eyed missle man.  NEW TOYS! :)  Merry Christmas to Twinkle McNugget!


This is one I've wanted to write for a long time.  The basics are working pretty well.  Just adding some features.  Since the underlying code is from the list handlers, you can easily copy information from one tab control to another.  It's kinda hard-coded in the CLAw, but these are very generic and pretty easy to use.
Title: Re: TrailMyx's Tab List Handler
Post by: TrailMyx on March 12, 2010, 10:38:19 PM
I'll even have a handler that you can program and run a routine of your own choosing when the tab button is pressed and the tab contents are redrawn.  It'll be pretty cool.
Title: Re: TrailMyx's Tab List Handler
Post by: Scrripty on March 12, 2010, 11:37:15 PM
I'll even have a handler that you can program and run a routine of your own choosing when the tab button is pressed and the tab contents are redrawn.  It'll be pretty cool.

What's that mean?  You're the one writing it. :)  Handler I can program to run what kind of routing?  OH like click a tab and run one of your list subs?  OOOOooooo heh
Title: Re: TrailMyx's Tab List Handler
Post by: TrailMyx on March 13, 2010, 12:17:54 AM
Right now, I handle the button click for each tab control to switch out the lists and draw them.  However, if you want to include a function that's run at the button press, you can just include that as one of the arguments in the TM_AddTab.  I've got the first version ready to go and will post it right now.
Title: Re: TrailMyx's Tab List Handler
Post by: Scrripty on March 13, 2010, 12:40:25 AM
Right now, I handle the button click for each tab control to switch out the lists and draw them.  However, if you want to include a function that's run at the button press, you can just include that as one of the arguments in the TM_AddTab.  I've got the first version ready to go and will post it right now.

Is it as fast as the list subs?  Cause honestly when you get 200+ names in the lists... it gets a little combersome to arrange/save.  Loading is still pretty snappy tho. :)
Title: Re: TrailMyx's Tab List Handler
Post by: TrailMyx on March 13, 2010, 12:46:58 AM
Should be the same really.  Subs aren't slow, just EUO is slow iterating all that stuff.

Now that these subs are out of the way, it'll pave the way for my new file system.
Title: Re: TrailMyx's Tab List Handler
Post by: Scrripty on March 13, 2010, 10:33:21 AM
Should be the same really.  Subs aren't slow, just EUO is slow iterating all that stuff.

Now that these subs are out of the way, it'll pave the way for my new file system.

I'm trying to come up with a neat way to implement this in the targetter.  But honestly I think the list subs give it just enough functionality.  Wait... can't you select multiple items in a list?  Is there a way to setup a list to be that way?  Maybe a flag to set it so one list in a tab can be normal, and the next can be "flagged" so that you can select multiple items in a list, and when you scan them, it will find EACH item is #true for selection and shows blue like it's selected?  I'm pretty sure I remember selecting multiple items in a list, I just tried in yours and couldn't tho.
Title: Re: TrailMyx's Tab List Handler
Post by: TrailMyx on March 13, 2010, 11:59:54 AM
You can't select multiple items in an EUO list anyhow.  EUO limitation again.  With Windows Forms, you can set up a ListBox to allow for multiple selections, but EUO doesn't pass that through to the scripter.

So there's nothing I can do for you.
Title: Re: TrailMyx's Tab List Handler
Post by: TrailMyx on March 13, 2010, 01:18:54 PM
I'm not going to be changing the base functions as implemented so far.  Probably going to add a few other functions.  I realized I didn't add a "DeleteTab" function.  You can hide tabs,  just not delete them yet.

So if you wanted to play a bit with these, I doubt the base code will change that much.  I only started these yesterday, so they are pretty new and not tested other than my sample code.  But their functionality greatly comes from the list handling subs which have some usage.
Title: Re: TrailMyx's Tab Control and List Handler
Post by: Endless Night on March 23, 2010, 06:02:54 AM
Another Nice one
Your releaseing  some great bits of code lately TM

:)


Title: Re: TrailMyx's Tab Control and List Handler
Post by: TrailMyx on March 23, 2010, 08:28:08 AM
Same to you; everyone is being pretty creative lately so I thought I would jump on the bandwagon.  ;)

These will get really interesting when I fuse it with my new advanced filesystem.
Title: Re: TrailMyx's Tab Control and List Handler
Post by: Scrripty on March 23, 2010, 08:35:10 AM
I've been looking for a way to incorporate this into my current personal project, once the filesystem is done, I'll try to add this and if it works out I'll send it to you and see what ya think. :)  I got a pretty great idea for it. heh
Title: Re: TrailMyx's Tab Control and List Handler
Post by: TrailMyx on March 23, 2010, 08:37:34 AM
I have a few more features to add to this as well.  I thought of a few nice additions.
Title: Re: TrailMyx's Tab Control and List Handler
Post by: Scrripty on June 28, 2010, 09:29:12 AM
Just throwing this out there.  I'd love these to use NGFS too. :)  When you get time... heh
Title: Re: TrailMyx's Tab Control and List Handler
Post by: Scrripty on May 10, 2011, 01:42:09 AM
Just dug into these, would have been very nice to read the first post that says how to address these.  And after playing with it for a bit, I thought DUH.  Then I just wrote my own sub to pull the currently visible list from the tab control.  I named it, TM_GetVisibleListFromControl.  If you're interested in more people using this, that would probly be a helpfull sub to add. :)  Unless I'm missing it, and you have it hiding somewhere I don't know about.  There's only one reference to how the actual lists are addressed, even tho, if you think about it, it should be pretty obvious.  But it threw me for a good 10 minutes until I really paid attention to what I was doing cause I was annoyed with it. :)
Title: Re: TrailMyx's Tab Control and List Handler
Post by: TrailMyx on May 10, 2011, 05:18:49 AM
I added that a while back in my internal version.  Ya, it's a necessary one for sure.  I write a mass of tools, but it's only when you dig into actually using them in a project that you notice all those other little subs you need.

Anyhow, there's several more subs in there.  Just haven't debugged that last version before I stopped scripting.
Title: Re: TrailMyx's Tab Control and List Handler
Post by: Scrripty on May 11, 2011, 05:13:20 AM
I added that a while back in my internal version.  Ya, it's a necessary one for sure.  I write a mass of tools, but it's only when you dig into actually using them in a project that you notice all those other little subs you need.

Anyhow, there's several more subs in there.  Just haven't debugged that last version before I stopped scripting.

If it's not ok to post this sub, just delete. :)  Someone might use it tho besides us.  Could happen.  Not sure this is done the best cause I just browsed your code, but it works every time in my implementation.  So I'm happy.

Code: [Select]
; %1 = Tab Control Name
sub TM_GetListNameFromTabControl
  namespace push
  namespace local TMTABS_ , %1
  set !temp_lpc #LPC
  set #LPC 10000
  if !tab_cnt = 0
  {
    namespace pop
    set #LPC !temp_lpc
    return #false
  }
  for !i 1 !tab_cnt
  {
    if !tab_hidden . !i = #FALSE
    {
      if !i = !selected
      {
        set !temp !tab_name . !i
        set #lpc !temp_lpc
        return !temp
      }
    }
  }
  namespace pop
  set #LPC !temp_lpc
return #false

Title: Re: TrailMyx's Tab Control and List Handler
Post by: TrailMyx on May 11, 2011, 06:54:03 AM
be sure you revert the #LPC back to the initial one, otherwise if you find a match, you'll force the LPC to 10000 for the rest of the execution.
Title: Re: TrailMyx's Tab Control and List Handler
Post by: Scrripty on May 11, 2011, 11:45:23 AM
No wonder it was moving along rather snappily.  Fixed. ehh
Title: Re: TrailMyx's Tab Control and List Handler
Post by: Scrripty on May 11, 2011, 12:25:49 PM
Send me those other subs and I'll bang on them for you. :)  And so I don't have to write them myself.
Title: Re: TrailMyx's Tab Control and List Handler
Post by: altiric on August 05, 2021, 12:56:34 PM
I realize im a bit late to the party, was just wondering if anything ended up continuing with this on someones hard drive they forgot about lol. Been working with list_handler, tab_handler, ngfs, advanced_filesystem and there are a few changes here and there between them as they have gotten upgrades. It seems tabs has everything but ngfs but also has an older version of the list handler in it. I have been getting 90% of where i need to be using them individually but would like to work on getting one file running and was just wondering where the best place to start might be.
Title: Re: TrailMyx's Tab Control and List Handler
Post by: Hitechs on August 05, 2021, 05:55:20 PM
this looks interesting,

I added that a while back in my internal version.  Ya, it's a necessary one for sure.  I write a mass of tools, but it's only when you dig into actually using them in a project that you notice all those other little subs you need.

Anyhow, there's several more subs in there.  Just haven't debugged that last version before I stopped scripting.

If it's not ok to post this sub, just delete. :)  Someone might use it tho besides us.  Could happen.  Not sure this is done the best cause I just browsed your code, but it works every time in my implementation.  So I'm happy.

Code: [Select]
; %1 = Tab Control Name
sub TM_GetListNameFromTabControl
  namespace push
  namespace local TMTABS_ , %1
  set !temp_lpc #LPC
  set #LPC 10000
  if !tab_cnt = 0
  {
    namespace pop
    set #LPC !temp_lpc
    return #false
  }
  for !i 1 !tab_cnt
  {
    if !tab_hidden . !i = #FALSE
    {
      if !i = !selected
      {
        set !temp !tab_name . !i
        set #lpc !temp_lpc
        return !temp
      }
    }
  }
  namespace pop
  set #LPC !temp_lpc
return #false
Title: Re: TrailMyx's Tab Control and List Handler
Post by: altiric on August 05, 2021, 06:27:29 PM
Its what made me ask :)