A
all
Hi,
This isn't a C question more of a programming question, so I hope it's
ok to post here (I will be coding it in C!)
I've been racking my brains about this little problem and can't see
wood for the trees...
I have to write a c module that gives the user a menu interface to
various options. Dependant on the user, some/most/all menus can be
'turned off'. Rather than have a 'dead-end' if the user navigates to
an 'off' item they should only be able to see the menu options they
can alter.
Example:
FULL MENU
-------------
A-------------------------B
| |
a.1 - a.2 b.1 - b.2
| | | |
x a.2.1 - a.2.2 x x
| |
x x
ALLOWED MENU for user John
==================
A.1----------------------B
| |
x b.1 - b.2
| |
x x
x = function, i.e. do something such as set screen orientation
A, a.1 = menu option eg A is "Screen", and a.1 is "Orientation"
So for Johns menu a.2 and subordinates are not allowed. To keep the
menu structure 'tidy' I have to promote the a.1 option to where A was
as this is only option available on this branch now.
Now the menu must not be 'hard-coded' to allow for
expansion/alteration, so I have created a link-list that points to the
items partner left and right and up and down. I *think* the best way
for me to handle menu items being on or off is to 'fix' the link list
to the full menu structure and have a option within each linked-list
to say if it's off or on.
Is this 'sensible'? I wonder because I can't see an 'easy' way of
dealing with menu items being promoted to higher levels within the
code.
Any help greatly appreciated.
This isn't a C question more of a programming question, so I hope it's
ok to post here (I will be coding it in C!)
I've been racking my brains about this little problem and can't see
wood for the trees...
I have to write a c module that gives the user a menu interface to
various options. Dependant on the user, some/most/all menus can be
'turned off'. Rather than have a 'dead-end' if the user navigates to
an 'off' item they should only be able to see the menu options they
can alter.
Example:
FULL MENU
-------------
A-------------------------B
| |
a.1 - a.2 b.1 - b.2
| | | |
x a.2.1 - a.2.2 x x
| |
x x
ALLOWED MENU for user John
==================
A.1----------------------B
| |
x b.1 - b.2
| |
x x
x = function, i.e. do something such as set screen orientation
A, a.1 = menu option eg A is "Screen", and a.1 is "Orientation"
So for Johns menu a.2 and subordinates are not allowed. To keep the
menu structure 'tidy' I have to promote the a.1 option to where A was
as this is only option available on this branch now.
Now the menu must not be 'hard-coded' to allow for
expansion/alteration, so I have created a link-list that points to the
items partner left and right and up and down. I *think* the best way
for me to handle menu items being on or off is to 'fix' the link list
to the full menu structure and have a option within each linked-list
to say if it's off or on.
Is this 'sensible'? I wonder because I can't see an 'easy' way of
dealing with menu items being promoted to higher levels within the
code.
Any help greatly appreciated.