Esempio n. 1
0
File: radio.c Progetto: LubkaB/mc
WRadio *
radio_new (int y, int x, int count, const char **texts)
{
    WRadio *r;
    Widget *w;
    int i, wmax = 0;

    r = g_new (WRadio, 1);
    w = WIDGET (r);

    /* Compute the longest string */
    r->texts = g_new (hotkey_t, count);

    for (i = 0; i < count; i++)
    {
        int width;

        r->texts[i] = parse_hotkey (texts[i]);
        width = hotkey_width (r->texts[i]);
        wmax = max (width, wmax);
    }

    widget_init (w, y, x, count, 4 + wmax, radio_callback, radio_event);
    /* 4 is width of "(*) " */
    r->state = 1;
    r->pos = 0;
    r->sel = 0;
    r->count = count;
    widget_want_hotkey (w, TRUE);

    return r;
}
Esempio n. 2
0
void label_init(label_ptr l)
{
    widget_init((widget_ptr) l);
    l->text = NULL;
    l->img = NULL;
    l->widget.update = label_update;
}
Esempio n. 3
0
void menuitem_init(menuitem_ptr m)
{
    widget_init((widget_ptr) m);
    m->text = NULL;
    m->img = NULL;
    m->submenu = NULL;
}
Esempio n. 4
0
void menubar_init(menubar_ptr m)
{
    widget_init((widget_ptr) m);
    m->widget.update = menubar_update;
    m->item_count = 0;
    m->widget.handle_click = menubar_handle_click;
}
Esempio n. 5
0
mcview_t *
mcview_new (int y, int x, int lines, int cols, gboolean is_panel)
{
    mcview_t *view;

    view = g_new0 (mcview_t, 1);
    widget_init (WIDGET (view), y, x, lines, cols, mcview_callback, mcview_event);

    view->hex_mode = FALSE;
    view->hexedit_mode = FALSE;
    view->locked = FALSE;
    view->hexview_in_text = FALSE;
    view->text_nroff_mode = FALSE;
    view->text_wrap_mode = FALSE;
    view->magic_mode = FALSE;

    view->dpy_frame_size = is_panel ? 1 : 0;
    view->converter = str_cnv_from_term;

    mcview_init (view);

    if (mcview_default_hex_mode)
        mcview_toggle_hex_mode (view);
    if (mcview_default_nroff_flag)
        mcview_toggle_nroff_mode (view);
    if (mcview_global_wrap_mode)
        mcview_toggle_wrap_mode (view);
    if (mcview_default_magic_flag)
        mcview_toggle_magic_mode (view);

    return view;
}
Esempio n. 6
0
WDialog *
dlg_create (gboolean modal, int y1, int x1, int lines, int cols, widget_pos_flags_t pos_flags,
            gboolean compact, const int *colors, widget_cb_fn callback,
            widget_mouse_cb_fn mouse_callback, const char *help_ctx, const char *title)
{
    WDialog *new_d;
    Widget *w;

    new_d = g_new0 (WDialog, 1);
    w = WIDGET (new_d);
    dlg_adjust_position (pos_flags, &y1, &x1, &lines, &cols);
    widget_init (w, y1, x1, lines, cols, (callback != NULL) ? callback : dlg_default_callback,
                 mouse_callback);
    w->pos_flags = pos_flags;
    w->options |= WOP_SELECTABLE | WOP_TOP_SELECT;

    w->state |= WST_CONSTRUCT | WST_FOCUSED;
    if (modal)
        w->state |= WST_MODAL;

    new_d->color = colors;
    new_d->help_ctx = help_ctx;
    new_d->compact = compact;
    new_d->data = NULL;

    new_d->mouse_status = MOU_UNHANDLED;

    dlg_set_title (new_d, title);

    /* unique name of event group for this dialog */
    new_d->event_group = g_strdup_printf ("%s_%p", MCEVENT_GROUP_DIALOG, (void *) new_d);

    return new_d;
}
Esempio n. 7
0
bool init_button(button_t *btn, widget_t *parent,
    const char *caption, uint16_t points, pixel_t background, pixel_t foreground)
{
	widget_init(&btn->widget, parent);

	btn->widget.destroy = button_destroy;
	btn->widget.reconfigure = button_reconfigure;
	btn->widget.rearrange = button_rearrange;
	btn->widget.repaint = button_repaint;
	btn->widget.handle_keyboard_event = button_handle_keyboard_event;
	btn->widget.handle_position_event = button_handle_position_event;

	source_init(&btn->background);
	source_set_color(&btn->background, background);
	source_init(&btn->foreground);
	source_set_color(&btn->foreground, foreground);

	if (caption == NULL) {
		btn->caption = NULL;
	} else {
		btn->caption = str_dup(caption);
	}
	font_init(&btn->font, FONT_DECODER_EMBEDDED, NULL, points);

	sysarg_t cpt_width;
	sysarg_t cpt_height;
	font_get_box(&btn->font, btn->caption, &cpt_width, &cpt_height);
	btn->widget.width_min = cpt_width + 8;
	btn->widget.height_min = cpt_height + 8;
	btn->widget.width_ideal = cpt_width + 28;
	btn->widget.height_ideal = cpt_height + 8;

	return true;
}
Esempio n. 8
0
WTree *
tree_new (int y, int x, int lines, int cols, gboolean is_panel)
{
    WTree *tree;
    Widget *w;

    tree = g_new (WTree, 1);
    w = WIDGET (tree);

    widget_init (w, y, x, lines, cols, tree_callback, tree_event);
    tree->is_panel = is_panel;
    tree->selected_ptr = 0;

    tree->store = tree_store_get ();
    tree_store_add_entry_remove_hook (remove_callback, tree);
    tree->tree_shown = 0;
    tree->search_buffer[0] = 0;
    tree->topdiff = w->lines / 2;
    tree->searching = 0;
    tree->active = 0;

    /* We do not want to keep the cursor */
    widget_want_cursor (w, FALSE);
    load_tree (tree);
    return tree;
}
Esempio n. 9
0
void button_init(button_ptr b)
{
    widget_init((widget_ptr) b);
    b->text = NULL;
    b->img = NULL;
    b->widget.update = button_update;
    b->widget.handle_click = button_handle_click;
}
Esempio n. 10
0
Widget *
widget_new (Canvas   *canvas)
{
  Widget *widget = g_malloc0 (sizeof (Widget));

  widget_init (widget, canvas);
  return widget;
}
Esempio n. 11
0
static Widget *
mousedispatch_new (int y, int x, int yl, int xl)
{
    Widget *w;

    w = g_new (Widget, 1);
    widget_init (w, y, x, yl, xl, md_callback, help_event);
    return w;
}
Esempio n. 12
0
static Widget *
mousedispatch_new (int y, int x, int yl, int xl)
{
    Widget *w;

    w = g_new0 (Widget, 1);
    widget_init (w, y, x, yl, xl, md_callback, help_mouse_callback);
    w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR;

    return w;
}
Esempio n. 13
0
static Widget *
mousedispatch_new (int y, int x, int yl, int xl)
{
    Widget *w;

    w = g_new0 (Widget, 1);
    widget_init (w, y, x, yl, xl, md_callback, help_mouse_callback);
    widget_want_cursor (w, TRUE);

    return w;
}
Esempio n. 14
0
void
setup ()
{
  root_widget = widget_init (xwidth, xheight);

  attr_init ();
  read_pixmaps ();
  read_adigit_pixmap ();
  read_bdigit_pixmap ();
  pai2pix_init ();
  auto_init ();
}
static void create(void)
{
	static const char title[] = " AlsaMixer v" SND_UTIL_VERSION_STR " ";

	widget_init(&mixer_widget, screen_lines, screen_cols, 0, 0,
		    attr_mixer_frame, WIDGET_BORDER);
	if (screen_cols >= (sizeof(title) - 1) + 2) {
		wattrset(mixer_widget.window, attr_mixer_active);
		mvwaddstr(mixer_widget.window, 0, (screen_cols - (sizeof(title) - 1)) / 2, title);
	}
	init_mixer_layout();
	display_card_info();
	set_view_mode(view_mode);
}
Esempio n. 16
0
WGroupbox *
groupbox_new (int y, int x, int height, int width, const char *title)
{
    WGroupbox *g;
    Widget *w;

    g = g_new (WGroupbox, 1);
    w = WIDGET (g);
    widget_init (w, y, x, height, width, groupbox_callback, NULL);

    g->title = NULL;
    groupbox_set_title (g, title);

    return g;
}
Esempio n. 17
0
WMenuBar *
menubar_new (int y, int x, int cols, GList * menu, gboolean visible)
{
    WMenuBar *menubar;
    Widget *w;

    menubar = g_new0 (WMenuBar, 1);
    w = WIDGET (menubar);
    widget_init (w, y, x, 1, cols, menubar_callback, menubar_event);

    menubar->is_visible = visible;
    widget_want_cursor (w, FALSE);
    menubar_set_menu (menubar, menu);

    return menubar;
}
Esempio n. 18
0
bool init_minimal(minimal_t *min, widget_t *parent, pixel_t a, pixel_t b)
{
	widget_init(&min->widget, parent);

	min->widget.destroy = minimal_destroy;
	min->widget.reconfigure = minimal_reconfigure;
	min->widget.rearrange = minimal_rearrange;
	min->widget.repaint = minimal_repaint;
	min->widget.handle_keyboard_event = minimal_handle_keyboard_event;
	min->widget.handle_position_event = minimal_handle_position_event;

	min->pix_a = a;
	min->pix_b = b;

	return true;
}
Esempio n. 19
0
WButtonBar *
buttonbar_new (gboolean visible)
{
    WButtonBar *bb;
    Widget *w;

    bb = g_new0 (WButtonBar, 1);
    w = WIDGET (bb);
    widget_init (w, LINES - 1, 0, 1, COLS, buttonbar_callback, buttonbar_event);

    w->pos_flags = WPOS_KEEP_HORZ | WPOS_KEEP_BOTTOM;
    bb->visible = visible;
    widget_want_hotkey (w, TRUE);
    widget_want_cursor (w, FALSE);

    return bb;
}
Esempio n. 20
0
WCheck *
check_new (int y, int x, int state, const char *text)
{
    WCheck *c;
    Widget *w;

    c = g_new (WCheck, 1);
    w = WIDGET (c);
    c->text = parse_hotkey (text);
    /* 4 is width of "[X] " */
    widget_init (w, y, x, 1, 4 + hotkey_width (c->text), check_callback, check_mouse_callback);
    c->state = state ? C_BOOL : 0;
    widget_want_cursor (w, TRUE);
    widget_want_hotkey (w, TRUE);

    return c;
}
Esempio n. 21
0
listview *listview_create ( const char *name, listview_update_callback cb, void *udata, unsigned int eh, gboolean reverse )
{
    listview *lv  = g_malloc0 ( sizeof ( listview ) );
    gchar    *box = g_strjoin ( ".", name, "box", NULL );
    widget_init ( WIDGET ( lv ), box );
    g_free ( box );
    lv->listview_name             = g_strdup ( name );
    lv->widget.free               = listview_free;
    lv->widget.resize             = listview_resize;
    lv->widget.draw               = listview_draw;
    lv->widget.clicked            = listview_clicked;
    lv->widget.motion_notify      = listview_motion_notify;
    lv->widget.get_desired_height = listview_get_desired_height;
    lv->widget.enabled            = TRUE;
    lv->eh                        = eh;

    char *n = g_strjoin ( ".", lv->listview_name, "scrollbar", NULL );
    lv->scrollbar = scrollbar_create ( n );
    // Default position on right.
    lv->scrollbar->widget.index = rofi_theme_get_integer_exact ( WIDGET ( lv->scrollbar ), "index", 1 );
    g_free ( n );
    widget_set_clicked_handler ( WIDGET ( lv->scrollbar ), listview_scrollbar_clicked, lv );
    lv->scrollbar->widget.parent = WIDGET ( lv );
    // Calculate height of an element.
    //
    char    *tb_name = g_strjoin ( ".", lv->listview_name, "element", NULL );
    textbox *tb      = textbox_create ( tb_name, 0, NORMAL, "" );
    lv->element_height = textbox_get_estimated_height ( tb, lv->eh );
    g_free ( tb_name );
    widget_free ( WIDGET ( tb ) );

    lv->callback = cb;
    lv->udata    = udata;

    // Some settings.
    lv->spacing         = rofi_theme_get_distance ( WIDGET ( lv ), "spacing", DEFAULT_SPACING );
    lv->menu_columns    = rofi_theme_get_integer  ( WIDGET ( lv ), "columns", config.menu_columns );
    lv->fixed_num_lines = rofi_theme_get_boolean  ( WIDGET ( lv ), "fixed-height", config.fixed_num_lines );
    lv->dynamic         = rofi_theme_get_boolean  ( WIDGET ( lv ), "dynamic", TRUE );
    lv->reverse         = rofi_theme_get_boolean  ( WIDGET ( lv ), "reverse", reverse );
    listview_set_show_scrollbar ( lv, rofi_theme_get_boolean ( WIDGET ( lv ), "scrollbar", !config.hide_scrollbar ) );
    lv->cycle = rofi_theme_get_boolean ( WIDGET ( lv ), "cycle", config.cycle );

    return lv;
}
Esempio n. 22
0
WHLine *
hline_new (int y, int x, int width)
{
    WHLine *l;
    Widget *w;
    int lines = 1;

    l = g_new (WHLine, 1);
    w = WIDGET (l);
    widget_init (w, y, x, lines, width < 0 ? 1 : width, hline_callback, NULL);
    l->text = NULL;
    l->auto_adjust_cols = (width < 0);
    l->transparent = FALSE;
    widget_want_cursor (w, FALSE);
    widget_want_hotkey (w, FALSE);

    return l;
}
Esempio n. 23
0
WDialog *
dlg_create (gboolean modal, int y1, int x1, int lines, int cols,
            const int *colors, widget_cb_fn callback, mouse_h mouse_handler,
            const char *help_ctx, const char *title, dlg_flags_t flags)
{
    WDialog *new_d;
    Widget *w;

    new_d = g_new0 (WDialog, 1);
    w = WIDGET (new_d);
    widget_init (w, y1, x1, lines, cols, (callback != NULL) ? callback : dlg_default_callback,
                 mouse_handler);
    widget_want_cursor (w, FALSE);

    new_d->state = DLG_CONSTRUCT;
    new_d->modal = modal;
    if (colors != NULL)
        memmove (new_d->color, colors, sizeof (dlg_colors_t));
    new_d->help_ctx = help_ctx;
    new_d->flags = flags;
    new_d->data = NULL;

    dlg_set_size (new_d, lines, cols);
    new_d->fullscreen = (w->x == 0 && w->y == 0 && w->cols == COLS && w->lines == LINES);

    new_d->mouse_status = MOU_UNHANDLED;

    /* Strip existing spaces, add one space before and after the title */
    if (title != NULL && *title != '\0')
    {
        char *t;

        t = g_strstrip (g_strdup (title));
        if (*t != '\0')
            new_d->title = g_strdup_printf (" %s ", t);
        g_free (t);
    }

    /* unique name got event group for this dialog */
    new_d->event_group = g_strdup_printf ("%s_%p", MCEVENT_GROUP_DIALOG, (void *) new_d);

    return new_d;
}
static bool create(void)
{
	const char *title;

	if (screen_lines < 6 || screen_cols < 36) {
		form_widget.close();
		beep();
		return FALSE;
	}
	widget_init(&form_widget,
		    6, 36, SCREEN_CENTER, SCREEN_CENTER,
		    attr_textbox, WIDGET_BORDER | WIDGET_SUBWINDOW | WIDGET_CURSOR_VISIBLE);
	title = _("Sound Card");
	mvwprintw(form_widget.window, 0, (36 - 2 - get_mbs_width(title)) / 2, " %s ", title);

	set_form_win(form, form_widget.window);
	set_form_sub(form, form_widget.subwindow);
	return TRUE;
}
Esempio n. 25
0
File: box.c Progetto: yusiwen/rofi
box * box_create ( widget *parent, const char *name, RofiOrientation type )
{
    box *b = g_malloc0 ( sizeof ( box ) );
    // Initialize widget.
    widget_init ( WIDGET ( b ), parent, WIDGET_TYPE_UNKNOWN, name );
    b->type                      = type;
    b->widget.draw               = box_draw;
    b->widget.free               = box_free;
    b->widget.resize             = box_resize;
    b->widget.update             = box_update;
    b->widget.find_mouse_target  = box_find_mouse_target;
    b->widget.get_desired_height = box_get_desired_height;
    b->widget.get_desired_width  = box_get_desired_width;

    b->type = rofi_theme_get_orientation ( WIDGET ( b ), "orientation", b->type );

    b->spacing = rofi_theme_get_distance ( WIDGET ( b ), "spacing", DEFAULT_SPACING );
    return b;
}
Esempio n. 26
0
WGauge *
gauge_new (int y, int x, int cols, gboolean shown, int max, int current)
{
    WGauge *g;
    Widget *w;

    g = g_new (WGauge, 1);
    w = WIDGET (g);
    widget_init (w, y, x, 1, cols, gauge_callback, NULL);
    widget_want_cursor (w, FALSE);
    widget_want_hotkey (w, FALSE);

    g->shown = shown;
    if (max == 0)
        max = 1;                /* I do not like division by zero :) */
    g->max = max;
    g->current = current;
    g->from_left_to_right = TRUE;

    return g;
}
Esempio n. 27
0
textbox* textbox_create ( const char *name, TextboxFlags flags, TextBoxFontType tbft, const char *text )
{
    textbox *tb = g_slice_new0 ( textbox );

    widget_init ( WIDGET ( tb ), name );

    tb->widget.draw               = textbox_draw;
    tb->widget.free               = textbox_free;
    tb->widget.resize             = textbox_resize;
    tb->widget.get_width          = textbox_get_width;
    tb->widget.get_height         = _textbox_get_height;
    tb->widget.get_desired_height = textbox_get_desired_height;
    tb->flags                     = flags;

    tb->changed = FALSE;

    tb->main_surface = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, tb->widget.w, tb->widget.h );
    tb->main_draw    = cairo_create ( tb->main_surface );
    tb->layout       = pango_layout_new ( p_context );
    textbox_font ( tb, tbft );

    if ( ( flags & TB_WRAP ) == TB_WRAP ) {
        pango_layout_set_wrap ( tb->layout, PANGO_WRAP_WORD_CHAR );
    }
    textbox_text ( tb, text ? text : "" );
    textbox_cursor_end ( tb );

    // auto height/width modes get handled here
    textbox_moveresize ( tb, tb->widget.x, tb->widget.y, tb->widget.w, tb->widget.h );

    tb->blink_timeout = 0;
    tb->blink         = 1;
    if ( ( flags & TB_EDITABLE ) == TB_EDITABLE ) {
        tb->blink_timeout = g_timeout_add ( 1200, textbox_blink, tb );
    }

    // Enabled by default
    tb->widget.enabled = TRUE;
    return tb;
}
Esempio n. 28
0
File: app.c Progetto: postgetme/crco
static bsp_init (void)
{
	rg_led_init ();

	g_led (0);

	#if FS_EN == 1
		fs_init ();
	#endif

	#if SHELL_EN == 1
 		shell_init ();
	#endif

	

	#if TCP_EN == 1
		init_TcpNet ();
	#endif
				
	#if KEY_EN == 1
 		key_init ();
	#endif
	
	#if RESET_KEY_EN == 1
		reset_key_init ();
	#endif

	#if GUI_EN == 1
		lcd_init (); 
		lcd_write_led (0);	  
		widget_init ();
	#endif

	I2CInit(0);

	#if RTC_EN == 1
		pcf8563_init ();
	#endif
}
Esempio n. 29
0
WListbox *
listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn callback)
{
    WListbox *l;
    Widget *w;

    if (height <= 0)
        height = 1;

    l = g_new (WListbox, 1);
    w = WIDGET (l);
    widget_init (w, y, x, height, width, listbox_callback, listbox_mouse_callback);
    w->options |= WOP_SELECTABLE | WOP_WANT_HOTKEY;

    l->list = NULL;
    l->top = l->pos = 0;
    l->deletable = deletable;
    l->callback = callback;
    l->allow_duplicates = TRUE;
    l->scrollbar = !mc_global.tty.slow_terminal;

    return l;
}
Esempio n. 30
0
scrollbar *scrollbar_create ( widget *parent, const char *name )
{
    scrollbar *sb = g_malloc0 ( sizeof ( scrollbar ) );
    widget_init ( WIDGET ( sb ), parent, WIDGET_TYPE_SCROLLBAR, name );
    sb->widget.x = 0;
    sb->widget.y = 0;
    sb->width    = rofi_theme_get_distance ( WIDGET ( sb ), "handle-width", DEFAULT_SCROLLBAR_WIDTH );
    int width = distance_get_pixel ( sb->width, ROFI_ORIENTATION_HORIZONTAL );
    sb->widget.w = widget_padding_get_padding_width ( WIDGET ( sb ) ) + width;
    sb->widget.h = widget_padding_get_padding_height ( WIDGET ( sb ) );

    sb->widget.draw               = scrollbar_draw;
    sb->widget.free               = scrollbar_free;
    sb->widget.trigger_action     = scrollbar_trigger_action;
    sb->widget.motion_notify      = scrollbar_motion_notify;
    sb->widget.get_desired_height = scrollbar_get_desired_height;

    sb->length     = 10;
    sb->pos        = 0;
    sb->pos_length = 4;

    return sb;
}