设为首页 加入收藏

TOP

C指针原理(65)-Ncurses-文本终端的图形
2014-11-23 17:41:17 来源: 作者: 【 】 浏览:13
Tags:指针 原理 -Ncurses- 文本 终端 图形

然后看看隐藏和显示面板

dp@dp:~/cursestest % cat x.c

#include

int main()

{

WINDOW *my_wins[3];

PANEL *my_panels[3];

int lines = 10, cols = 40, y = 2, x = 4, i;

int ch;

initscr();

cbreak();

noecho();

/* 为每个面板创建窗口*/

my_wins[0] = newwin(lines, cols, y, x);

my_wins[1] = newwin(lines, cols, y + 1, x + 5);

my_wins[2] = newwin(lines, cols, y + 2, x + 10);

/* 为窗口添加创建边框以便你能看到面板的效果*/

for(i = 0; i < 3; +++i)

box(my_wins[i], 0, 0);

/* 按自底向上的顺序,为每一个面板关联一个窗口*/

my_panels[0] = new_panel(my_wins[0]);

/* 把面板0 压进栈, 叠放顺序: stdscr0

*/

my_panels[1] = new_panel(my_wins[1]);

/* 把面板1 压进栈, 叠放顺序: stdscr01

*/

my_panels[2] = new_panel(my_wins[2]);

/* 把面板2 压进栈, 叠放顺序: stdscr012*/

/* 更新栈的顺序。把面板2 置于栈顶*/

update_panels();

/* 在屏幕上显示*/

doupdate();

//q退出,按1-3键显示和隐藏对应的面板

int isshow[3]={1,1,1};

while((ch = getch()) !='q')

{ switch(ch)

{

case '1':

if ((++isshow[0])%2) show_panel(my_panels[0]);

else hide_panel (my_panels[0]);

break;

case '2':

if ((++isshow[1])%2) show_panel(my_panels[1]);

else hide_panel (my_panels[1]);

break;

case '3':

if ((++isshow[2])%2) show_panel(my_panels[2]);

else hide_panel (my_panels[2]);

break;

}

update_panels();

doupdate();

}

getch();

endwin();

}

麦好的AI乐园博客所有内容是原创,如果转载请注明来源

http://blog.csdn.net/myhaspl/


执行后

dp@dp:~/cursestest % gcc -lncursesw -lpanel x.c -o mytest

dp@dp:~/cursestest % ./mytest

比如把2号面板隐藏,效果如下


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇A Tool Bar 下一篇C指针原理(64)-Ncurses-文本终端..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: