本文整理汇总了C++中draw_header函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_header函数的具体用法?C++ draw_header怎么用?C++ draw_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw_header函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_help_popup
/* render help dialog */
void
load_help_popup (WINDOW * main_win)
{
int c, quit = 1;
size_t i, n;
int y, x, h = HELP_WIN_HEIGHT, w = HELP_WIN_WIDTH;
int w2 = w - 2;
n = ARRAY_SIZE (help_main);
getmaxyx (stdscr, y, x);
WINDOW *win = newwin (h, w, (y - h) / 2, (x - w) / 2);
keypad (win, TRUE);
wborder (win, '|', '|', '-', '-', '+', '+', '+', '+');
/* create a new instance of GMenu and make it selectable */
GMenu *menu = new_gmenu (win, HELP_MENU_HEIGHT, HELP_MENU_WIDTH, HELP_MENU_Y,
HELP_MENU_X);
menu->size = n;
/* add items to GMenu */
menu->items = (GItem *) xcalloc (n, sizeof (GItem));
for (i = 0; i < n; ++i) {
menu->items[i].name = alloc_string (help_main[i]);
menu->items[i].checked = 0;
}
post_gmenu (menu);
draw_header (win, "GoAccess Quick Help", 1, 1, w2, 1);
mvwprintw (win, 2, 2, "[UP/DOWN] to scroll - [q] to quit");
wrefresh (win);
while (quit) {
c = wgetch (stdscr);
switch (c) {
case KEY_DOWN:
gmenu_driver (menu, REQ_DOWN);
draw_header (win, "", 2, 3, HELP_MENU_WIDTH, 0);
break;
case KEY_UP:
gmenu_driver (menu, REQ_UP);
draw_header (win, "", 2, 3, HELP_MENU_WIDTH, 0);
break;
case KEY_RESIZE:
case 'q':
quit = 0;
break;
}
wrefresh (win);
}
/* clean stuff up */
for (i = 0; i < n; ++i)
free (menu->items[i].name);
free (menu->items);
free (menu);
touchwin (main_win);
close_win (win);
wrefresh (main_win);
}
示例2: draw_menu_item
/* render an actual menu item */
static void
draw_menu_item (GMenu * menu, char *s, int x, int y, int w, int color,
int checked)
{
char check, *lbl = NULL;
if (menu->selectable) {
check = checked ? 'x' : ' ';
lbl = xmalloc (snprintf (NULL, 0, "[%c] %s", check, s) + 1);
sprintf (lbl, "[%c] %s", check, s);
draw_header (menu->win, lbl, "%s", y, x, w, color, 0);
free (lbl);
} else {
draw_header (menu->win, s, "%s", y, x, w, color, 0);
}
}
示例3: render_screens
/* render all windows */
static void
render_screens (void)
{
GColors *color = get_color (COLOR_DEFAULT);
int row, col, chg = 0;
getmaxyx (stdscr, row, col);
term_size (main_win);
generate_time ();
chg = logger->processed - logger->offset;
draw_header (stdscr, "", "%s", row - 1, 0, col, color_default);
wattron (stdscr, color->attr | COLOR_PAIR (color->pair->idx));
mvaddstr (row - 1, 1, "[F1]Help [Enter] Exp. Panel");
mvprintw (row - 1, 30, "%d - %s", chg, asctime (now_tm));
mvaddstr (row - 1, col - 21, "[Q]uit GoAccess");
mvprintw (row - 1, col - 5, "%s", GO_VERSION);
wattroff (stdscr, color->attr | COLOR_PAIR (color->pair->idx));
refresh ();
/* call general stats header */
display_general (header_win, conf.ifile, logger);
wrefresh (header_win);
/* display active label based on current module */
update_active_module (header_win, gscroll.current);
display_content (main_win, logger, dash, &gscroll);
}
示例4: render_visitors
/* render dashboard hits */
static void
render_visitors (GDashModule * data, GDashRender render, int *x)
{
WINDOW *win = render.win;
GModule module = data->module;
const GDashStyle *style = module_style;
char *visitors;
int y = render.y, w = render.w, idx = render.idx, sel = render.sel;
int len = data->visitors_len;
if (data->module == HOSTS && data->data[idx].is_subitem)
goto out;
/* selected state */
if (sel) {
visitors = int_to_str (data->data[idx].metrics->visitors);
draw_header (win, visitors, "%*s", y, *x, w, HIGHLIGHT, len);
free (visitors);
}
/* regular state */
else {
wattron (win, A_BOLD | COLOR_PAIR (style[module].color_visitors));
mvwprintw (win, y, *x, "%*d", len, data->data[idx].metrics->visitors);
wattroff (win, A_BOLD | COLOR_PAIR (style[module].color_visitors));
}
out:
*x += len + DASH_SPACE;
}
示例5: render_bandwidth
/* render dashboard bandwidth */
static void
render_bandwidth (GDashModule * data, GDashRender render, int *x)
{
WINDOW *win = render.win;
GModule module = data->module;
const GDashStyle *style = module_style;
int y = render.y, w = render.w, idx = render.idx, sel = render.sel;
char *bw = data->data[idx].metrics->bw.sbw;
if (data->module == HOSTS && data->data[idx].is_subitem)
goto out;
if (style[module].color_bw == -1)
return;
/* selected state */
if (sel) {
draw_header (win, bw, "%11s", y, *x, w, HIGHLIGHT, 0);
}
/* regular state */
else {
wattron (win, A_BOLD | COLOR_PAIR (style[module].color_bw));
mvwprintw (win, y, *x, "%11s", bw);
wattroff (win, A_BOLD | COLOR_PAIR (style[module].color_bw));
}
out:
*x += DASH_BW_LEN + DASH_SPACE;
}
示例6: render_protocol
/* render dashboard request protocol */
static void
render_protocol (GDashModule * data, GDashRender render, int *x)
{
WINDOW *win = render.win;
GModule module = data->module;
const GDashStyle *style = module_style;
int y = render.y, w = render.w, idx = render.idx, sel = render.sel;
char *protocol = data->data[idx].metrics->protocol;
if (style[module].color_protocol == -1)
return;
if (protocol == NULL || *protocol == '\0')
return;
/* selected state */
if (sel) {
draw_header (win, protocol, "%s", y, *x, w, HIGHLIGHT, 0);
}
/* regular state */
else {
wattron (win, A_BOLD | COLOR_PAIR (style[module].color_protocol));
mvwprintw (win, y, *x, "%s", protocol);
wattroff (win, A_BOLD | COLOR_PAIR (style[module].color_protocol));
}
*x += REQ_PROTO_LEN - 1 + DASH_SPACE;
}
示例7: render_screens
/* render all windows */
static void
render_screens (void)
{
int row, col, chg = 0;
getmaxyx (stdscr, row, col);
term_size (main_win);
generate_time ();
chg = logger->process - logger->offset;
draw_header (stdscr, "", "%s", row - 1, 0, col, 0, 0);
wattron (stdscr, COLOR_PAIR (COL_WHITE));
mvaddstr (row - 1, 1, "[F1]Help [O]pen detail view");
mvprintw (row - 1, 30, "%d - %s", chg, asctime (now_tm));
mvaddstr (row - 1, col - 21, "[Q]uit GoAccess");
mvprintw (row - 1, col - 5, "%s", GO_VERSION);
wattroff (stdscr, COLOR_PAIR (COL_WHITE));
refresh ();
/* call general stats header */
display_general (header_win, conf.ifile, logger);
wrefresh (header_win);
/* display active label based on current module */
update_active_module (header_win, gscroll.current);
display_content (main_win, logger, dash, &gscroll);
}
示例8: draw_page_text
static void
draw_page_text (GtkPrintOperation * op, GtkPrintContext * cnt, gint page, gpointer data)
{
cairo_t *cr;
PangoLayout *layout;
gint i, line;
cr = gtk_print_context_get_cairo_context (cnt);
/* create header */
if (options.print_data.headers)
draw_header (cnt, page + 1, npages);
/* add text */
layout = gtk_print_context_create_pango_layout (cnt);
pango_layout_set_font_description (layout, fdesc);
cairo_move_to (cr, 0, HEADER_HEIGHT + HEADER_GAP);
line = page * nlines;
for (i = 0; i < nlines; i++)
{
if (text[line + i] == NULL)
break;
pango_layout_set_text (layout, text[line + i], -1);
pango_cairo_show_layout (cr, layout);
cairo_rel_move_to (cr, 0, FONTSIZE);
}
g_object_unref (layout);
}
示例9: new_mandel_window
// creates a new MandelPod window
void new_mandel_window(void)
{
// get the graphics context
mandel_gc = pz_get_gc(1);
// create the main window
mandel_wid = pz_new_window (0, 21,
screen_info.cols, screen_info.rows - (HEADER_TOPLINE+1),
draw_header, handle_event);
#ifdef MANDELPOD_STATUS
// create the status window
status_wid = pz_new_window (22, 4, 12, 12, draw_idle_status, handle_event);
#endif
// get screen info
GrGetWindowInfo(mandel_wid, &wi);
// select the event types
GrSelectEvents (mandel_wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_TIMER);
// display the window
GrMapWindow (mandel_wid);
#ifdef MANDELPOD_STATUS
GrMapWindow (status_wid);
#endif
// create the timer for the busy status animation
mandel_timer_id = GrCreateTimer (mandel_wid, 250);
// start main app
init_values();
create_status();
draw_header();
calculate_mandel();
}
示例10: new_tunnel_window
// Creates a new tunnel "app" window
void new_tunnel_window(void)
{
tunnel_gc = pz_get_gc(1); /* Get the graphics context */
/* Open the window: */
tunnel_wid = pz_new_window (0,
21,
screen_info.cols,
screen_info.rows - (HEADER_TOPLINE+1),
draw_header,
handle_event);
GrGetWindowInfo(tunnel_wid, &wi); /* Get screen info */
/* Select the types of events you need for your window: */
GrSelectEvents (tunnel_wid, GR_EVENT_MASK_TIMER|GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP);
// set up pixmap
temp_pixmap = GrNewPixmap(screen_info.cols,
(screen_info.rows - (HEADER_TOPLINE + 1)),
NULL);
/* Display the window: */
GrMapWindow (tunnel_wid);
draw_header();
readHighScore();
reset();
}
示例11: reset_board
static void reset_board()
{
int index;
for(index = 0; index < 9; index++)
board[index] = '-';
difficulty = 6;
gameRunning = 1;
currSquare = 0;
draw_header();
/* Clear the window */
GrClearWindow (tictactoe_wid, GR_FALSE);
GrSetGCUseBackground(tictactoe_gc, GR_TRUE);
GrSetGCBackground(tictactoe_gc, WHITE);
GrSetGCForeground(tictactoe_gc, BLACK);
GrLine(tictactoe_wid, tictactoe_gc, wi.width * .90, (wi.height / 2.) - (wi.height / 2. * .33),
wi.width - wi.width * .90, (wi.height / 2.) - (wi.height / 2. * .33));
GrLine(tictactoe_wid, tictactoe_gc, wi.width * .90, (wi.height / 2.) + (wi.height / 2. * .33),
wi.width - wi.width * .90, (wi.height / 2.) + (wi.height / 2. * .33));
GrLine(tictactoe_wid, tictactoe_gc, (wi.width / 2.) - (wi.width / 2. * .33), wi.height * .90,
(wi.width / 2.) - (wi.width / 2. * .33), wi.height - wi.height * .90);
GrLine(tictactoe_wid, tictactoe_gc, (wi.width / 2.) + (wi.width / 2. * .33), wi.height * .90,
(wi.width / 2.) + (wi.width / 2. * .33), wi.height - wi.height * .90);
currSquare = 0;
drawXO(currSquare, GRAY, 'x');
}
示例12: load_confdlg_error
/* Render the help dialog. */
static void
load_confdlg_error (WINDOW * parent_win, char **errors, int nerrors)
{
int c, quit = 1, i = 0;
int y, x, h = ERR_WIN_HEIGHT, w = ERR_WIN_WIDTH;
WINDOW *win;
GMenu *menu;
getmaxyx (stdscr, y, x);
win = newwin (h, w, (y - h) / 2, (x - w) / 2);
keypad (win, TRUE);
wborder (win, '|', '|', '-', '-', '+', '+', '+', '+');
/* create a new instance of GMenu and make it selectable */
menu =
new_gmenu (win, ERR_MENU_HEIGHT, ERR_MENU_WIDTH, ERR_MENU_Y, ERR_MENU_X);
menu->size = nerrors;
/* add items to GMenu */
menu->items = (GItem *) xcalloc (nerrors, sizeof (GItem));
for (i = 0; i < nerrors; ++i) {
menu->items[i].name = alloc_string (errors[i]);
menu->items[i].checked = 0;
free (errors[i]);
}
free (errors);
post_gmenu (menu);
draw_header (win, ERR_HEADER, " %s", 1, 1, w - 2, color_error);
mvwprintw (win, 2, 2, "[UP/DOWN] to scroll - [q] to quit");
wrefresh (win);
while (quit) {
c = wgetch (stdscr);
switch (c) {
case KEY_DOWN:
gmenu_driver (menu, REQ_DOWN);
break;
case KEY_UP:
gmenu_driver (menu, REQ_UP);
break;
case KEY_RESIZE:
case 'q':
quit = 0;
break;
}
wrefresh (win);
}
/* clean stuff up */
for (i = 0; i < nerrors; ++i)
free (menu->items[i].name);
free (menu->items);
free (menu);
touchwin (parent_win);
close_win (win);
wrefresh (parent_win);
}
示例13: render_overall_header
/* Print out (terminal dashboard) the overall statistics header. */
static void
render_overall_header (WINDOW * win, GHolder * h)
{
char *hd = get_overall_header (h);
int col = getmaxx (stdscr);
draw_header (win, hd, " %s", 0, 0, col, color_panel_header);
free (hd);
}
示例14: disabled_panel_msg
static void
disabled_panel_msg (GModule module)
{
const char *lbl = module_to_label (module);
int row, col;
getmaxyx (stdscr, row, col);
draw_header (stdscr, lbl, "'%s' panel is disabled", row - 1, 0, col,
WHITE_RED, 0);
}
示例15: render_data
/* render dashboard data */
static void
render_data (GDashModule * data, GDashRender render, int *x)
{
WINDOW *win = render.win;
GModule module = data->module;
const GDashStyle *style = module_style;
int y = render.y, w = render.w, idx = render.idx, sel = render.sel;
char buf[DATE_LEN];
char *value, *padded_data;
value = substring (data->data[idx].metrics->data, 0, w - *x);
if (module == VISITORS) {
/* verify we have a valid date conversion */
if (convert_date (buf, value, "%Y%m%d", "%d/%b/%Y", DATE_LEN) != 0) {
LOG_DEBUG (("invalid date: %s", value));
xstrncpy (buf, "---", 4);
}
}
if (sel) {
if (data->module == HOSTS && data->data[idx].is_subitem) {
padded_data = left_pad_str (value, *x);
draw_header (win, padded_data, "%s", y, 0, w, HIGHLIGHT, 0);
free (padded_data);
} else {
draw_header (win, module == VISITORS ? buf : value, "%s", y, *x, w,
HIGHLIGHT, 0);
}
} else {
wattron (win, COLOR_PAIR (style[module].color_data));
mvwprintw (win, y, *x, "%s", module == VISITORS ? buf : value);
wattroff (win, COLOR_PAIR (style[module].color_data));
}
*x += module == VISITORS ? DATE_LEN - 1 : data->data_len;
*x += DASH_SPACE;
free (value);
}