Exemple #1
0
    void
gui_make_popup(char_u *path_name, int mouse_pos)
{
    vimmenu_T	*menu = gui_find_menu(path_name);

    if (menu != NULL)
    {
	/* Find the position of the current cursor */
	DWORD	temp_p;
	POINT	p;
	temp_p = GetDCOrg(s_hdc);
	p.x = LOWORD(temp_p);
	p.y = HIWORD(temp_p);
	if (mouse_pos)
	{
	    int	mx, my;

	    gui_mch_getmouse(&mx, &my);
	    p.x += mx;
	    p.y += my;
	}
	else if (curwin != NULL)
	{
	    p.x += TEXT_X(W_WINCOL(curwin) + curwin->w_wcol + 1);
	    p.y += TEXT_Y(W_WINROW(curwin) + curwin->w_wrow + 1);
	}
	msg_scroll = FALSE;
	gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
    }
}
Exemple #2
0
static int boot_menu(void)
{
    const char* strings[] = {"Boot Rockbox", "Boot OF", "USB mode", "Reset Rockbox configuration"};
    int button, touch, poweroff_repeat = 0;
    unsigned int i;

    verbose = true;
    adc_init();

redraw:
    lcd_clear_display();
    for(i=0; i<ARRAYLEN(strings); i++)
    {
        lcd_drawrect(RECT_X, RECT_Y(i), RECT_WIDTH, RECT_HEIGHT);
        lcd_putsxy(TEXT_X(i), TEXT_Y(i), strings[i]);
    }
    lcd_update();

    while(1)
    {
        button = button_get_w_tmo(HZ/4);
        if(button & BUTTON_TOUCHSCREEN)
        {
            touch = button_get_data();
            unsigned int x = touch & 0xFFFF, y = touch >> 16;
            int found = -1;
            for(i=0; i<ARRAYLEN(strings); i++)
            {
                if(x > RECT_X && x < RECT_X+RECT_WIDTH &&
                   y > RECT_Y(i) && y < RECT_Y(i)+RECT_HEIGHT)
                {
                    found = i;
                    break;
                }
            }

            switch(found)
            {
                case 0:
                    reset_screen();
                    boot_rockbox();
                    break;
                case 1:
                    reset_screen();
                    boot_of();
                    break;
                case 2:
                    usb_mode();
                    break;
                case 3:
                    reset_configuration();
                    break;
            }

            if(found != -1)
                goto redraw;
        }
        else if(button & BUTTON_POWER)
Exemple #3
0
static gboolean
bst_canvas_source_build_async (gpointer data)
{
  GnomeCanvasItem *item = GNOME_CANVAS_ITEM (data);
  if (gnome_canvas_item_check_undisposed (item))
    {
      BstCanvasSource *csource = BST_CANVAS_SOURCE (item);
      GnomeCanvasGroup *group = GNOME_CANVAS_GROUP (csource);
      
      /* keep in mind, that creation order affects stacking */

      /* add input and output channel items */
      if (!csource->built_ichannels)
        {
          csource->built_ichannels = TRUE;
          bst_canvas_source_build_channels (csource,
                                            TRUE,               /* input channels */
                                            0xffff00, 0x808000,	/* ichannels */
                                            0x00afff, 0x005880, /* jchannels */
                                            TRUE, FALSE);
          return TRUE;
        }
      if (!csource->built_ochannels)
        {
          csource->built_ochannels = TRUE;
          bst_canvas_source_build_channels (csource,
                                            FALSE,              /* output channels */
                                            0xff0000, 0x800000, /* ochannels */
                                            0, 0,               /* unused */
                                            TRUE, FALSE);
          return TRUE;
        }

      /* add icon to group */
      if (!csource->icon_item)
        {
          csource->icon_item = g_object_connect (gnome_canvas_item_new (group,
                                                                        GNOME_TYPE_CANVAS_PIXBUF,
                                                                        "x", ICON_X (csource),
                                                                        "y", ICON_Y (csource),
                                                                        "width", ICON_WIDTH (csource),
                                                                        "height", ICON_HEIGHT (csource),
                                                                        NULL),
                                                 "signal::destroy", gtk_widget_destroyed, &csource->icon_item,
                                                 "swapped_signal::event", bst_canvas_source_child_event, csource,
                                                 NULL);
          source_icon_changed (csource);
          return TRUE;
        }
      
      if (!csource->text)
        {
          /* add text item, invoke name_changed callback to setup the text value */
          guint ocolor = csource->source && bse_item_internal (csource->source) ? RGBA_INTERNAL : RGBA_BLACK;
          csource->text = gnome_canvas_item_new (group,
                                                 GNOME_TYPE_CANVAS_TEXT,
                                                 "fill_color_rgba", ocolor,
                                                 "anchor", GTK_ANCHOR_NORTH,
                                                 "justification", GTK_JUSTIFY_CENTER,
                                                 "x", TEXT_X (csource),
                                                 "y", TEXT_Y (csource),
                                                 "font", TEXT_FONT,
                                                 NULL);
          g_object_connect (csource->text,
                            "signal::destroy", gtk_widget_destroyed, &csource->text,
                            "swapped_signal::event", bst_canvas_source_child_event, csource,
                            NULL);
          gnome_canvas_text_set_zoom_size (GNOME_CANVAS_TEXT (csource->text), FONT_HEIGHT);
          source_name_changed (csource);
          return TRUE;
        }

      /* add input and output channel hints */
      if (!csource->built_ihints)
        {
          csource->built_ihints = TRUE;
          bst_canvas_source_build_channels (csource,
                                            TRUE,               /* input channels */
                                            0xffff00, 0x808000,	/* ichannels */
                                            0x00afff, 0x005880, /* jchannels */
                                            FALSE, TRUE);
          return TRUE;
        }
      if (!csource->built_ohints)
        {
          csource->built_ohints = TRUE;
          bst_canvas_source_build_channels (csource,
                                            FALSE,              /* output channels */
                                            0xff0000, 0x800000, /* ochannels */
                                            0, 0,               /* unused */
                                            FALSE, TRUE);
          return TRUE;
        }
    }
  GnomeCanvas *canvas = g_object_steal_data (item, "bst-workaround-canvas-ref");
  g_object_unref (item);
  if (canvas)
    g_object_unref (canvas);      /* canvases don't properly protect their items */
  return FALSE;
}
Exemple #4
0
    void
gui_mch_draw_string(
    int		row,
    int		col,
    char_u	*text,
    int		len,
    int		flags)
{
#ifndef MSWIN16_FASTTEXT
    static int	*padding = NULL;
    static int	pad_size = 0;
    int		i;
#endif
    HPEN	hpen, old_pen;
    int		y;

#ifndef MSWIN16_FASTTEXT
    /*
     * Italic and bold text seems to have an extra row of pixels at the bottom
     * (below where the bottom of the character should be).  If we draw the
     * characters with a solid background, the top row of pixels in the
     * character below will be overwritten.  We can fix this by filling in the
     * background ourselves, to the correct character proportions, and then
     * writing the character in transparent mode.  Still have a problem when
     * the character is "_", which gets written on to the character below.
     * New fix: set gui.char_ascent to -1.  This shifts all characters up one
     * pixel in their slots, which fixes the problem with the bottom row of
     * pixels.	We still need this code because otherwise the top row of pixels
     * becomes a problem. - webb.
     */
    HBRUSH	hbr;
    RECT	rc;

    if (!(flags & DRAW_TRANSP))
    {
	/*
	 * Clear background first.
	 * Note: FillRect() excludes right and bottom of rectangle.
	 */
	rc.left = FILL_X(col);
	rc.top = FILL_Y(row);
#ifdef FEAT_MBYTE
	if (has_mbyte)
	{
	    /* Compute the length in display cells. */
	    rc.right = FILL_X(col + mb_string2cells(text, len));
	}
	else
#endif
	    rc.right = FILL_X(col + len);
	rc.bottom = FILL_Y(row + 1);
	hbr = CreateSolidBrush(gui.currBgColor);
	FillRect(s_hdc, &rc, hbr);
	DeleteBrush(hbr);

	SetBkMode(s_hdc, TRANSPARENT);

	/*
	 * When drawing block cursor, prevent inverted character spilling
	 * over character cell (can happen with bold/italic)
	 */
	if (flags & DRAW_CURSOR)
	{
	    pcliprect = &rc;
	    foptions = ETO_CLIPPED;
	}
    }
#else
    /*
     * Alternative: write the characters in opaque mode, since we have blocked
     * bold or italic fonts.
     */
    /* The OPAQUE mode and backcolour have already been set */
#endif
    /* The forecolor and font have already been set */

#ifndef MSWIN16_FASTTEXT

    if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
    {
	vim_free(padding);
	pad_size = Columns;

	padding = (int *)alloc(pad_size * sizeof(int));
	if (padding != NULL)
	    for (i = 0; i < pad_size; i++)
		padding[i] = gui.char_width;
    }
#endif

    /*
     * We have to provide the padding argument because italic and bold versions
     * of fixed-width fonts are often one pixel or so wider than their normal
     * versions.
     * No check for DRAW_BOLD, Windows will have done it already.
     */
#ifndef MSWIN16_FASTTEXT
    ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row), 0, NULL,
						     (char *)text, len, padding);
#else
    TextOut(s_hdc, TEXT_X(col), TEXT_Y(row), (char *)text, len);
#endif

    if (flags & DRAW_UNDERL)
    {
	hpen = CreatePen(PS_SOLID, 1, gui.currFgColor);
	old_pen = SelectObject(s_hdc, hpen);
	/* When p_linespace is 0, overwrite the bottom row of pixels.
	 * Otherwise put the line just below the character. */
	y = FILL_Y(row + 1) - 1;
#ifndef MSWIN16_FASTTEXT
	if (p_linespace > 1)
	    y -= p_linespace - 1;
#endif
	MoveToEx(s_hdc, FILL_X(col), y, NULL);
	/* Note: LineTo() excludes the last pixel in the line. */
	LineTo(s_hdc, FILL_X(col + len), y);
	DeleteObject(SelectObject(s_hdc, old_pen));
    }
}