menu.priv.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /****************************************************************************
  2. * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc. *
  3. * *
  4. * Permission is hereby granted, free of charge, to any person obtaining a *
  5. * copy of this software and associated documentation files (the *
  6. * "Software"), to deal in the Software without restriction, including *
  7. * without limitation the rights to use, copy, modify, merge, publish, *
  8. * distribute, distribute with modifications, sublicense, and/or sell *
  9. * copies of the Software, and to permit persons to whom the Software is *
  10. * furnished to do so, subject to the following conditions: *
  11. * *
  12. * The above copyright notice and this permission notice shall be included *
  13. * in all copies or substantial portions of the Software. *
  14. * *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
  16. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
  18. * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
  19. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
  20. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
  21. * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
  22. * *
  23. * Except as contained in this notice, the name(s) of the above copyright *
  24. * holders shall not be used in advertising or otherwise to promote the *
  25. * sale, use or other dealings in this Software without prior written *
  26. * authorization. *
  27. ****************************************************************************/
  28. /****************************************************************************
  29. * Author: Juergen Pfeifer, 1995,1997 *
  30. ****************************************************************************/
  31. /* $Id: menu.priv.h,v 1.22 2005/01/16 01:02:23 tom Exp $ */
  32. /***************************************************************************
  33. * Module menu.priv.h *
  34. * Top level private header file for all libnmenu modules *
  35. ***************************************************************************/
  36. #ifndef MENU_PRIV_H_incl
  37. #define MENU_PRIV_H_incl 1
  38. #include "curses.priv.h"
  39. #include "mf_common.h"
  40. #include "menu.h"
  41. /* Backspace code */
  42. #define BS (8)
  43. extern NCURSES_EXPORT_VAR(ITEM) _nc_Default_Item;
  44. extern NCURSES_EXPORT_VAR(MENU) _nc_Default_Menu;
  45. /* Normalize item to default if none was given */
  46. #define Normalize_Item( item ) ((item)=(item)?(item):&_nc_Default_Item)
  47. /* Normalize menu to default if none was given */
  48. #define Normalize_Menu( menu ) ((menu)=(menu)?(menu):&_nc_Default_Menu)
  49. /* Get the user defined (framing) window of the menu */
  50. #define Get_Menu_UserWin(menu) ((menu)->userwin ? (menu)->userwin : stdscr)
  51. /* Normalize menu window */
  52. #define Get_Menu_Window( menu ) \
  53. ((menu)->usersub ? (menu)->usersub : Get_Menu_UserWin(menu))
  54. /* menu specific status flags */
  55. #define _LINK_NEEDED (0x04)
  56. #define _MARK_ALLOCATED (0x08)
  57. #define ALL_MENU_OPTS ( \
  58. O_ONEVALUE | \
  59. O_SHOWDESC | \
  60. O_ROWMAJOR | \
  61. O_IGNORECASE | \
  62. O_SHOWMATCH | \
  63. O_NONCYCLIC )
  64. #define ALL_ITEM_OPTS (O_SELECTABLE)
  65. /* Move to the window position of an item and draw it */
  66. #define Move_And_Post_Item(menu,item) \
  67. {wmove((menu)->win,(menu)->spc_rows*(item)->y,((menu)->itemlen+(menu)->spc_cols)*(item)->x);\
  68. _nc_Post_Item((menu),(item));}
  69. #define Move_To_Current_Item(menu,item) \
  70. if ( (item) != (menu)->curitem)\
  71. {\
  72. Move_And_Post_Item(menu,item);\
  73. Move_And_Post_Item(menu,(menu)->curitem);\
  74. }
  75. /* This macro ensures, that the item becomes visible, if possible with the
  76. specified row as the top row of the window. If this is not possible,
  77. the top row will be adjusted and the value is stored in the row argument.
  78. */
  79. #define Adjust_Current_Item(menu,row,item) \
  80. { if ((item)->y < row) \
  81. row = (item)->y;\
  82. if ( (item)->y >= (row + (menu)->arows) )\
  83. row = ( (item)->y < ((menu)->rows - row) ) ? \
  84. (item)->y : (menu)->rows - (menu)->arows;\
  85. _nc_New_TopRow_and_CurrentItem(menu,row,item); }
  86. /* Reset the match pattern buffer */
  87. #define Reset_Pattern(menu) \
  88. { (menu)->pindex = 0; \
  89. (menu)->pattern[0] = '\0'; }
  90. #define UChar(c) ((unsigned char)(c))
  91. /* Internal functions. */
  92. extern NCURSES_EXPORT(void) _nc_Draw_Menu (const MENU *);
  93. extern NCURSES_EXPORT(void) _nc_Show_Menu (const MENU *);
  94. extern NCURSES_EXPORT(void) _nc_Calculate_Item_Length_and_Width (MENU *);
  95. extern NCURSES_EXPORT(int) _nc_Calculate_Text_Width(const TEXT *);
  96. extern NCURSES_EXPORT(void) _nc_Post_Item (const MENU *, const ITEM *);
  97. extern NCURSES_EXPORT(bool) _nc_Connect_Items (MENU *, ITEM **);
  98. extern NCURSES_EXPORT(void) _nc_Disconnect_Items (MENU *);
  99. extern NCURSES_EXPORT(void) _nc_New_TopRow_and_CurrentItem (MENU *,int, ITEM *);
  100. extern NCURSES_EXPORT(void) _nc_Link_Items (MENU *);
  101. extern NCURSES_EXPORT(int) _nc_Match_Next_Character_In_Item_Name (MENU*,int,ITEM**);
  102. extern NCURSES_EXPORT(int) _nc_menu_cursor_pos (const MENU* menu, const ITEM* item,
  103. int* pY, int* pX);
  104. #ifdef TRACE
  105. #define returnItem(code) TRACE_RETURN(code,item)
  106. #define returnItemPtr(code) TRACE_RETURN(code,item_ptr)
  107. #define returnItemOpts(code) TRACE_RETURN(code,item_opts)
  108. #define returnMenu(code) TRACE_RETURN(code,menu)
  109. #define returnMenuHook(code) TRACE_RETURN(code,menu_hook)
  110. #define returnMenuOpts(code) TRACE_RETURN(code,menu_opts)
  111. extern NCURSES_EXPORT(ITEM *) _nc_retrace_item (ITEM *);
  112. extern NCURSES_EXPORT(ITEM **) _nc_retrace_item_ptr (ITEM **);
  113. extern NCURSES_EXPORT(Item_Options) _nc_retrace_item_opts (Item_Options);
  114. extern NCURSES_EXPORT(MENU *) _nc_retrace_menu (MENU *);
  115. extern NCURSES_EXPORT(Menu_Hook) _nc_retrace_menu_hook (Menu_Hook);
  116. extern NCURSES_EXPORT(Menu_Options) _nc_retrace_menu_opts (Menu_Options);
  117. #else /* !TRACE */
  118. #define returnItem(code) return code
  119. #define returnItemPtr(code) return code
  120. #define returnItemOpts(code) return code
  121. #define returnMenu(code) return code
  122. #define returnMenuHook(code) return code
  123. #define returnMenuOpts(code) return code
  124. #endif /* TRACE/!TRACE */
  125. #endif /* MENU_PRIV_H_incl */