Collapsible/Expandable Menus

Discussion in 'OT Technology' started by mstinawu, Mar 21, 2005.

  1. mstinawu

    mstinawu i like being spanked

    Joined:
    Apr 11, 2001
    Messages:
    3,212
    Likes Received:
    0
    Location:
    Torrance, CA
    I need some ideas on what structure(s) could be best used to implement a collapsible/expandable type menuing system. The menus would go at most 3-4 levels deep and I would like as little structural overhead as possible.

    I know this is a very general question, but I just need some ideas to brainstorm with. Googling data structure and algorithms for these kind of things usually bring me no results.

    Thanks in advance.
     
  2. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    what is this for? do you want an html example, or is this for a program? What language?

    Anyway, I would think of it in terms of a table:

    *UID* - *Parent* - *Name*
    1 - 0 - Top Menu 1
    2 - 1 - Sub Menu 1a
    3 - 1 - Sub Menu 1b
    4 - 3 - Sub Menu 1b1
    5 - 3 - Sub Menu 1b2
    6 - 3 - Sub Menu 1b3
    7 - 1 - Sub Menu 1c
    8 - 0 - Top Menu 2
    9 - 8 - Sub Menu 2a
    10 - 0 - Top Menu 3

    Where a "Parent" of 0 means it's a top menu, and then all submenus use the main menu's UID as it's "Parent"

    make sense?
     
  3. Jake!

    Jake! Guest

    If it is HTTP dreamweaver's layering is pretty easy
     
  4. mstinawu

    mstinawu i like being spanked

    Joined:
    Apr 11, 2001
    Messages:
    3,212
    Likes Received:
    0
    Location:
    Torrance, CA
    I would just like to know in an object oriented sense. I don't need a direct implementation, just a general idea of what structure I could make use of. I'm programming in C++ if you must know and this is for a relatively small list of menu items (probably 200 max).
     
  5. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    then use what I gave ya.
     
  6. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    A tree is the natural choice for something like this. Each top-level menu is a tree (root node), with each sub-item being a subtree, and each menu item with no children being a leaf node. Or, you could have the top level not really represent anything (represent the menu bar or whatever), and have the first level of subtrees be the menus. Either way makes pretty good sense.
     
  7. mstinawu

    mstinawu i like being spanked

    Joined:
    Apr 11, 2001
    Messages:
    3,212
    Likes Received:
    0
    Location:
    Torrance, CA
    Thanks all. I'm going w/ a similar idea using a pointer to an array of pointers and keeping track of the parent "node". Arrays are just less costly. Arrays are great. yay
     

Share This Page