bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CDK - Multiple Menu's (cdk_menu)


From: Marc Smith
Subject: Re: CDK - Multiple Menu's (cdk_menu)
Date: Wed, 14 Oct 2015 21:28:25 -0400

Here is a quick patch I did to make this work for my project:

--- a/menu.c    2012-03-20 20:05:35.000000000 -0400
+++ a/menu.c    2015-08-10 16:50:49.692629728 -0400
@@ -60,8 +60,22 @@
    {
       int x1 = (menuLocation[x] == LEFT) ? x : rightcount--;
       int x2;
-      int y1 = (menuPos == BOTTOM) ? (ymax - 1) : 0;
-      int y2 = (menuPos == BOTTOM) ? (ymax - subsize[x] - 2) : TITLELINES;
+      int y1, y2;
+      if (menuPos == BOTTOM)
+      {
+         y1 = ymax - 1;
+         y2 = ymax - subsize[x] - 2;
+      }
+      else if (menuPos == TOP)
+      {
+         y1 = 0;
+         y2 = TITLELINES;
+      }
+      else
+      {
+         y1 = menuPos;
+         y2 = menuPos + TITLELINES;
+      }
       int high = subsize[x] + TITLELINES;

       /*
@@ -401,12 +415,17 @@
    if (menu->menuPos == BOTTOM)
    {
       mvwaddch (menu->pullWin[menu->currentTitle],
-               menu->subsize[menu->currentTitle] + 1, 0, ACS_LTEE);
+                menu->subsize[menu->currentTitle] + 1, 0, ACS_LTEE);
    }
-   else
+   else if (menu->menuPos == TOP)
    {
       mvwaddch (menu->pullWin[menu->currentTitle], 0, 0, ACS_LTEE);
    }
+   else
+   {
+      mvwaddch (menu->pullWin[menu->currentTitle],
+                (menu->menuPos == 0) ? 0 : (menu->menuPos - 1), 0, ACS_LTEE);
+   }

    /* Draw the items. */
    for (x = x0; x < x1; x++)


I haven't looked at the recent releases of CDK, the above is against 5.0-20120323... not sure if anything from that chunk in menu.c changed from then.

It does as I described before, allows you to specify either TOP, BOTTOM, or some other row number for menuRowNumber with newCDKMenu(). It could be better -- I'd like to see the menu "fly" up or down based on the position of the row number for the menu location automatically, or even add a parameter to control the direction (up or down) for the menu lists when activated. Right now it always opens downward (except for BOTTOM).

Let me know what you think -- I'd put more work into it if you think this is a worthy inclusion for CDK.


--Marc


On Sat, Sep 5, 2015 at 8:37 PM, Thomas Dickey <address@hidden> wrote:
On Mon, Aug 10, 2015 at 05:05:06PM -0400, Marc Smith wrote:
> Thanks for the reply; I'm not sure that cdk_traverse would do the trick, at
> least I can't think of how that would work right now... and the more I
> think about a second screen, I'm not sure it would look right on the
> display -- I need to think about this one more and how/if I would need to
> refresh multiple screens and how it would look with the menu dropping down
> over the sub screen (maybe the top screen would have focus).
>
> I played around with menu.c a bit and modifying it seems pretty straight
> forward -- would you be open to making menuPos accept the normal constants
> (TOP and BOTTOM) and additional a row number for the position? I could
> produce a patch with your input...

hmm - sorry to be slow.   It sounds as if you want an alternate function
like

       CDKMENU *newerCDKMenu (
                      CDKSCREEN *cdkscreen,
                      const char *menulist[MAX_MENU_ITEMS][MAX_SUB_ITEMS],
                      int menuListLength,
                      int *submenuListLength,
                      int *menuLocation,
                      int menuRowNumber,
                      chtype titleAttribute,
                      chtype subtitleAttribute);

...a patch would help.

> Thanks,
>
> Marc
>
>
>
> On Mon, Aug 10, 2015 at 2:23 PM, Thomas Dickey <address@hidden> wrote:
>
> > On Fri, Aug 07, 2015 at 12:09:17AM -0400, Marc Smith wrote:
> > > Hi,
> > >
> > > Looking for any tips for using multiple CDK menu's on a single screen...
> > I
> > > know that I can use one on the TOP and one on the BOTTOM but I want one
> > on
> > > top of the other (no rows between)... and maybe that is the answer, to
> > not
> > > use a single CDK screen but use multiple? Put one CDK menu on a screen,
> > and
> > > then the second on a different (sub) screen?
> >
> > You might be able to do this with the tab-traversal feature
> > (see the cdk_traverse manpage).
> >
> > If not, separate screens is the way to go.
> >
> > --
> > Thomas E. Dickey <address@hidden>
> > http://invisible-island.net
> > ftp://invisible-island.net
> >
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.10 (GNU/Linux)
> >
> > iEYEARECAAYFAlXI7C8ACgkQcCNT4PfkjtuPUQCfT2O5bRsx9DuKzy5ZMC2Q9/2z
> > HXQAnjRyYWU67J3bibCO851iR1JqMB3Y
> > =gTr4
> > -----END PGP SIGNATURE-----
> >
> >

--
Thomas E. Dickey <address@hidden>
http://invisible-island.net
ftp://invisible-island.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAlXrirYACgkQcCNT4PfkjttCHgCdFdzIGKHPI7qKVGSH5OWU48WB
/fYAoNdkqnX8BxeV59gmM+DbPAAf80ax
=3+xY
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]