(Continued) AIX Simulation SCO UNIX Menu Drive
Wang Guanghong
Static void start_line (menu * m)
{
IF (M-> Curitem-> Index
&& M-> Curitem-> Index> M-> Toprow) return;
IF (m-> Nitems> = m-> height m-> Curitem-> index) {
IF (M-> Toprow> = M-> Curitem-> Index)
M-> Toprow = m-> Curitem-> Index;
Else
M-> TOPROW = M-> cols;
}
Else {
M-> TOPROW = M-> Nitems - M-> HEIGHT
}
}
Static int compute_seat (menu * m)
{
INT N, Y, X, T;
FOR (n = 0; n
T = N-1;
IF (t <0) m-> items [n] -> left = m-> items [m-> nitems-1];
Else M-> items [n] -> left = m-> items [t];
T = N 1;
IF (t> = m-> nitems) m-> items [n] -> right = m-> items [0];
Else M-> Items [n] -> Right = m-> items [t];
T = N - m-> cols;
IF (t <0) m-> items [n] -> UP = m-> items [m-> NItems-1];
Else M-> Items [n] -> UP = m-> items [t];
T = n m-> cols;
IF (T> = m-> Nitems) m-> items [n] -> down = m-> items [0];
Else M-> items [n] -> down = m-> items [t];
}
}
INT POST_MENU (Menu * M)
{
Touch_menu (m);
Wrefresh (M-> Sub);
}
INT TOUCH_MENU (Menu * M)
{
INT Y, X, S, CY, CX;
Char * lable;
Chtype attrs;
IF (m == null) return -1;
IF (M-> Sub == Null) Return -2;
UNPOST_MENU (M);
START_LINE (M);
For (s = m-> TOPROW, Y = 0; y
FOR (x = 0; x
Lable = menu_LABLE (S, M);
IF (s == m-> Curitem-> index) {
Attrs = m-> Sub - >_ attrs;
WattRset (M-> Sub, A_REVERSE | M-> SUB -> _ Attrs);
Mvwprintw (M-> Sub, Y, X * (M-> Itemlen), "% S% S", M-> Mark, Lable);
CY = Y, CX = x * (m-> itemlen);
WattRset (M-> Sub, Attrs);
}
Else
Mvwprintw (M-> Sub, Y, X * (M-> itemlen) M-> Marklen, Lable);
S ;
}
WMOVE (M-> Sub, CY, CX);
WMOVE (M-> WIN, CY 1, CX 1);
Compute_seat (m);
}
INT UNPOST_MENU (Menu * M)
{
Werase (M-> Sub);
Wrefresh (m-> win);
}
Item ** menu_items (menu * m)
{
Return M-> item;
}
Item * current_item (menu * m)
{
Return M-> Curitem;
}
INT ITEM_INDEX (item * i)
{
Return I-> Index;
}
INT Free_Item (item * i)
{
Free (i);
Return 0;
}
INT free_menu (menu * m)
{
Free (m);
Return 0;
}
INT MENU_DRIVER (Menu * M, INT C)
{
Switch (c) {
Case REQ_LEFT_ITEM:
IF (M-> Curitem-> Left) {
M-> Curitem = m-> Curitem-> Left;
Touch_menu (m);
}
Break;
Case Req_right_Item:
IF (M-> Curitem-> Right) {
M-> Curitem = m-> Curitem-> Right;
Touch_menu (m);
}
Break;
Case Req_up_Item:
IF (M-> Curitem-> Up) {
M-> Curitem = M-> Curitem-> Up;
Touch_menu (m);
}
Break;
Case Req_down_Item:
IF (M-> Curitem-> down) {
M-> Curitem = m-> Curitem-> Down;
Touch_menu (m);
}
Break;
Case REQ_SCR_ULINE:
Case Req_SCR_DLINE:
Case Req_SCR_DPAGE:
Case REQ_SCR_UPAGE:
Case Req_First_Item:
M-> Curitem = m-> items [0];
Touch_menu (m);
Break;
Case Req_last_Item:
Break;
Case Req_next_Item:
IF (M-> Curitem-> Index
M-> Curitem = m-> items [m-> Curitem-> INDEX 1];
Else
M-> Curitem = m-> items [0];
Touch_menu (m);
Break;
Case Req_PREV_ITEM:
IF (M-> Curitem-> INDEX> 0)
M-> Curitem = M-> Items [M-> Curitem-> INDEX - 1];
Else
M-> Curitem = m-> items [m-> nitems-1];
Touch_menu (m);
Break;
Case Req_Toggle_Item:
Case Req_clear_pattern:
Case REQ_BACK_PATTERN: CASE REQ_NEXT_MATCH:
Case Req_PREV_MATCH:
Break;
}
Wrefresh (M-> Sub);
Return E_OK;
}