Exemplo n.º 1
0
void Controls::set_font(string name, string fontface, int fontsize){
    set_font(find(name), fontface, fontsize);
}
Exemplo n.º 2
0
void GraphicGUI::draw_ticks()
{
	int x = canvas->get_x() - 5 - get_text_width(SMALLFONT, "-00");
	int y = canvas->get_y() - 1;
	int x1 = canvas->get_x() - LINE_W3;
	int x2 = canvas->get_x() - LINE_W2;
	int x3 = canvas->get_x() - LINE_W1;
	char string[BCTEXTLEN];

// Amplitude
	set_font(SMALLFONT);
	int major_division = canvas->get_h() / (MAJOR_DIVISIONS - 1);
	for(int i = 0; i < MAJOR_DIVISIONS; i++)
	{
		int current_db = (MAJOR_DIVISIONS - 1 - i) * (MAX_DB - MIN_DB) / (MAJOR_DIVISIONS - 1) + MIN_DB;
		if(current_db == MIN_DB)
			sprintf(string, "oo");
		else
		if(current_db <= 0.0)
			sprintf(string, "%d", current_db);
		else
			sprintf(string, "+%d", current_db);

		set_color(BLACK);
		int y1 = y + 1 + i * canvas->get_h() / (MAJOR_DIVISIONS - 1);
		int x4 = canvas->get_x() - LINE_W4 - get_text_width(SMALLFONT, string);
		draw_text(x4 + 1, y1 + get_text_ascent(SMALLFONT) / 2 + 1, string);
		draw_line(x1 + 1, y1 + 1, x3 + 1, y1 + 1);
		set_color(RED);
		draw_text(x4, y1 + get_text_ascent(SMALLFONT) / 2, string);
		draw_line(x1, y1, x3, y1);


		if(i < MAJOR_DIVISIONS - 1)
		{
			for(int j = 0; j < MINOR_DIVISIONS; j++)
			{
				int y2 = y1 + j * major_division / MINOR_DIVISIONS;
				set_color(BLACK);
				draw_line(x2 + 1, y2 + 1, x3 + 1, y2 + 1);
				set_color(RED);
				draw_line(x2, y2, x3, y2);
			}
		}
	}


// Frequency
	for(int i = 0; i <= MAJOR_DIVISIONS; i++)
	{
		int freq = Freq::tofreq(i * TOTALFREQS / MAJOR_DIVISIONS);
		char string[BCTEXTLEN];
		x1 = canvas->get_x() + i * canvas->get_w() / MAJOR_DIVISIONS;
		int y1 = canvas->get_y() + canvas->get_h() + LINE_W1 - 1;
		sprintf(string, "%d", freq);
		int x2 = x1 - get_text_width(SMALLFONT, string);
		int y2 = canvas->get_y() + canvas->get_h() + LINE_W2 - 1;
		int y3 = canvas->get_y() + canvas->get_h() + LINE_W3 - 1;
		int y4 = canvas->get_y() + canvas->get_h() + get_text_height(SMALLFONT) + LINE_W4 - 1;
		
		set_color(BLACK);
		draw_text(x2 + 1, y4 + 1, string);
		draw_line(x1 + 1, y3 + 1, x1 + 1, y1 + 1);
		
		set_color(RED);
		draw_text(x2, y4, string);
		draw_line(x1, y3, x1, y1);
		
		if(i < MAJOR_DIVISIONS)
		{
			for(int j = 0; j < MINOR_DIVISIONS; j++)
			{
				int x3 = (int)(x1 +
					(canvas->get_w() / MAJOR_DIVISIONS) -
					exp(-(double)j * 0.7) *
					(canvas->get_w() / MAJOR_DIVISIONS));
				set_color(BLACK);
				draw_line(x3 + 1, y2 + 1, x3 + 1, y1 + 1);
				set_color(RED);
				draw_line(x3, y2, x3, y1);
			}
		}
	}
}
Exemplo n.º 3
0
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
	LOGFONT lf={0,};
	CHOOSEFONT cf={sizeof(cf),hwnd,0,&lf,0,
		CF_EFFECTS|CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT,
		0,};
	CHARFORMAT fmt={sizeof(fmt),};
	CHOOSECOLOR cs;

    switch (id)
	{
		case IDM_ABOUT:
			MessageBox(hwnd,"Sex v0.1\n"
				            "Copyright (C) 1998, Nullsoft Inc.","About sex",MB_OK);
		return;
		case IDM_PASTE:
            SendMessage(hwnd_rich, WM_PASTE, 0, 0);
		return;
		case IDM_COPY:
            SendMessage(hwnd_rich, WM_COPY, 0, 0);
        return;
		case IDM_CUT:
            SendMessage(hwnd_rich, WM_CUT, 0, 0);
        return;
		case IDM_CLOSE:
			SendMessage(hwnd,WM_CLOSE,0,0);
		return;
		case IDM_QUIT:
			DestroyWindow(hwnd);
		return;
		case IDM_FONT:
			{
				get_font (&lf, &fmt, &cf);
				
				if (ChooseFont(&cf))
				{
                    set_font (&lf, &fmt, &cf, FALSE, FALSE, FALSE, FALSE, FALSE);
				}
			}
		return;
		case IDM_BGCOLOR:
			{
				if (choose_color(&cs, hwnd))
				{
					config_color=cs.rgbResult;
					config_write();
					SendMessage(hwnd_rich,EM_SETBKGNDCOLOR,FALSE,config_color);
				}
			}
		return;
        case IDM_FGCOLOR:
            {
				get_font (&lf, &fmt, &cf);

				if (choose_color(&cs, hwnd))
				{
                    set_font (&lf, &fmt, &cf, FALSE, FALSE, FALSE, TRUE, cs.rgbResult);
                }
            }
		return;
        case IDM_UNDERLINE:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, FALSE, FALSE, TRUE, FALSE, 0);
            }
		return;
        case IDM_ITALIC:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, FALSE, TRUE, FALSE, FALSE, 0);
            }
		return;
        case IDM_BOLD:
            {
				get_font (&lf, &fmt, &cf);

                set_font (&lf, &fmt, &cf, TRUE, FALSE, FALSE, FALSE, 0);
            }
		return;
        case IDM_WORDWRAP:
            {
                if (word_wrap)
                {
                    ModifyStyle(hwnd_rich, 0 ,WS_HSCROLL|ES_AUTOHSCROLL,  0 );
                    word_wrap = 0;
                }
                else
                {
                    ModifyStyle(hwnd_rich, WS_HSCROLL|ES_AUTOHSCROLL, 0 , 0 );
                    word_wrap = 1;
                }
            }
		return;
        case IDM_REDL:
            {
                if (config_icon != 1)
                {
					choose_icon(1);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLUEL:
            {
                if (config_icon != 2)
                {
					choose_icon(2);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLACKL:
            {
                if (config_icon != 3)
                {
					choose_icon(3);
					change_icon(hwnd);
                }
            }
		return;
        case IDM_BLUER:
            {
                if (config_icon != 4)
                {
					choose_icon(4);
					change_icon(hwnd);
                }
            }
		return;
    }
}
Exemplo n.º 4
0
int main(int argc, char *argv[]) 
{
	GtkWidget *window;
	GtkWidget *canvas;
	GtkWidget *font_button;
	GtkWidget *g_button;
	GtkWidget *d_button;
	GtkWidget *str;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *label1, *label2;
	GtkWidget *spin;
	PangoFontDescription *desc;

        if (argc == 2) {
            if (get_conf (argv[1]))
                printf ("Error reading configuration. Use defaults\n");
        }

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title (GTK_WINDOW(window), "Font converter");

	hbox = gtk_hbox_new (FALSE, 10);
	label1 = gtk_label_new ("Text: ");
	font_button = gtk_font_button_new_with_font (get_fontname());
	d_button = gtk_button_new_with_label ("Draw");
	g_button = gtk_button_new_with_label ("G Code");
	str = gtk_entry_new ();
	gtk_entry_set_max_length (GTK_ENTRY (str), 15);
	gtk_entry_set_text (GTK_ENTRY (str), get_string());
	label2 = gtk_label_new ("Width (inch): ");
	spin = gtk_spin_button_new_with_range (3, 120, 1);
	gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spin), 2);
	gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), (double)10);

	gtk_box_pack_start (GTK_BOX (hbox), label1, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), str, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), font_button, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), d_button, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), g_button, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), label2, FALSE, FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0);

	canvas = gtk_drawing_area_new();
	gtk_widget_set_size_request (canvas, 1200, 600);

	vbox = gtk_vbox_new (FALSE, 5);
	gtk_box_pack_start (GTK_BOX (vbox), canvas, TRUE, TRUE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);

	g_object_set_data (G_OBJECT (g_button), "spin", spin);

	gtk_container_add (GTK_CONTAINER (window), vbox);

	g_signal_connect(window, "destroy",
		G_CALLBACK(gtk_main_quit), NULL);  

	g_signal_connect(G_OBJECT (canvas), "expose_event",
		G_CALLBACK(expose_event), str);  

	g_signal_connect(G_OBJECT (font_button), "font_set",
		G_CALLBACK(font_button_clicked), NULL);  

	g_signal_connect(G_OBJECT (g_button), "clicked",
		G_CALLBACK(g_button_clicked), str);  

	g_signal_connect(G_OBJECT (d_button), "clicked",
		G_CALLBACK(d_button_clicked), canvas);  

	gtk_widget_show_all(window);
	map = pango_ft2_font_map_new ();
	ctx = pango_font_map_create_context (map);
	desc = pango_font_description_from_string (get_fontname());
	set_font (desc);

	gtk_main();

	g_object_unref (map);
	g_object_unref (ctx);
	return 0;
}
Exemplo n.º 5
0
static void init_X() {
    int screenNumber;
    unsigned long foreground, background;
    int screen_width, screen_height;
    Screen *screen;
    XSizeHints hints;
    char **argv = NULL;
    XGCValues gcValues;
    Colormap colormap;
    XColor rgb_color, hw_color;
    Font font;
    //char *FNAME = "hanzigb24st";
    char *FNAME = "-misc-fixed-medium-r-normal--0-0-100-100-c-0-iso10646-1";

    display = XOpenDisplay(NULL);
    if (display == NULL) {
	fprintf(stderr, "Can't open dsplay\n");
	exit(1);
    }
    screenNumber = DefaultScreen(display);
    foreground = BlackPixel(display, screenNumber);
    background = WhitePixel(display, screenNumber);

    screen = DefaultScreenOfDisplay(display);
    screen_width = WidthOfScreen(screen);
    screen_height = HeightOfScreen(screen);

    hints.x = (screen_width - WIDTH) / 2;
    hints.y = (screen_height - HEIGHT) / 2;
    hints.width = WIDTH;
    hints.height = HEIGHT;
    hints.flags = PPosition | PSize;

    window = XCreateSimpleWindow(display,
				 DefaultRootWindow(display),
				 hints.x, hints.y, WIDTH, HEIGHT, 10,
				 foreground, background);

    XSetStandardProperties(display, window, 
			   "TiMidity", "TiMidity", 
			   None,
			   argv, 0,
			   &hints);

    XMapWindow(display, window);


    set_font();
    surface = cairo_xlib_surface_create(display, window,
					DefaultVisual(display, 0), WIDTH, HEIGHT);
    cairo_xlib_surface_set_size(surface, WIDTH, HEIGHT);

    paint_background();

    /*
    cr = cairo_create(surface);
    draw_text(g_array_index(lyric_lines.lines, GString *, 0)->str,
	      0.0, 0.0, 1.0, height_lyric_pixbufs[0]);
    draw_text(g_array_index(lyric_lines.lines, GString*, 1)->str,
	      0.0, 0.0, 1.0, height_lyric_pixbufs[0]);
    cairo_destroy(cr);
    */
    XFlush(display);
}
Exemplo n.º 6
0
/*
 * Handles expose events, that is, draws the window contents.
 *
 */
static int handle_expose() {
    /* re-draw the background */
    xcb_rectangle_t border = {0, 0, 300, (15 * font.height) + 8};
    xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND, (uint32_t[]){ get_colorpixel("#000000") });
    xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &border);

    set_font(&font);

#define txt(x, row, text) \
    draw_text_ascii(text, pixmap, pixmap_gc,\
            x, (row - 1) * font.height + 4, 300 - x * 2)

    if (current_step == STEP_WELCOME) {
        /* restore font color */
        set_font_colors(pixmap_gc, get_colorpixel("#FFFFFF"), get_colorpixel("#000000"));

        txt(10, 2, "You have not configured i3 yet.");
        txt(10, 3, "Do you want me to generate ~/.i3/config?");
        txt(85, 5, "Yes, generate ~/.i3/config");
        txt(85, 7, "No, I will use the defaults");

        /* green */
        set_font_colors(pixmap_gc, get_colorpixel("#00FF00"), get_colorpixel("#000000"));
        txt(25, 5, "<Enter>");

        /* red */
        set_font_colors(pixmap_gc, get_colorpixel("#FF0000"), get_colorpixel("#000000"));
        txt(31, 7, "<ESC>");
    }

    if (current_step == STEP_GENERATE) {
        set_font_colors(pixmap_gc, get_colorpixel("#FFFFFF"), get_colorpixel("#000000"));

        txt(10, 2, "Please choose either:");
        txt(85, 4, "Win as default modifier");
        txt(85, 5, "Alt as default modifier");
        txt(10, 7, "Afterwards, press");
        txt(85, 9, "to write ~/.i3/config");
        txt(85, 10, "to abort");

        /* the not-selected modifier */
        if (modifier == MOD_Mod4)
            txt(31, 5, "<Alt>");
        else txt(31, 4, "<Win>");

        /* the selected modifier */
        set_font(&bold_font);
        set_font_colors(pixmap_gc, get_colorpixel("#FFFFFF"), get_colorpixel("#000000"));
        if (modifier == MOD_Mod4)
            txt(10, 4, "-> <Win>");
        else txt(10, 5, "-> <Alt>");

        /* green */
        set_font(&font);
        set_font_colors(pixmap_gc, get_colorpixel("#00FF00"), get_colorpixel("#000000"));
        txt(25, 9, "<Enter>");

        /* red */
        set_font_colors(pixmap_gc, get_colorpixel("#FF0000"), get_colorpixel("#000000"));
        txt(31, 10, "<ESC>");
    }

    /* Copy the contents of the pixmap to the real window */
    xcb_copy_area(conn, pixmap, win, pixmap_gc, 0, 0, 0, 0, /* */ 500, 500);
    xcb_flush(conn);

    return 1;
}
Exemplo n.º 7
0
int
main(int argc, char **argv)
{
    GtkWidget *widget;
    gchar *glade_xml_file;

    gtk_init(&argc, &argv);
    set_font();
    get_asf_share_dir_with_argv0(argv[0]);

    asfPrintStatus("\nASF MapReady:\n");
    const char *share_dir = get_asf_share_dir();

    if (!share_dir)
      // this actually should never happen with the current implementation
      // of get_asf_share_dir() -- always sets the share dir to something
      // even if it is a bad guess... in which case the next check will fail
      asfPrintError("Could not find the ASF share directory!\n");

    glade_xml_file = (gchar *)find_in_share("mapready.glade");
    if (!glade_xml_file)
      asfPrintError("Could not find the mapready.glade file!\n"
                    "It should be in the share files directory, here:\n"
                    "  %s\n", share_dir);
    glade_xml = glade_xml_new(glade_xml_file, NULL, NULL);
    if (!glade_xml)
      asfPrintError("Could not load the mapready.glade file!\n"
                    "This file may be corrupt. mapready.glade was found in:\n"
                    "  %s\n", share_dir);
    g_free(glade_xml_file);

    asfPrintStatus("Using share files directory: %s\n\n", share_dir);

    /* thumbnails supported in GTK 2.4 or greater */
#ifdef G_THREADS_ENABLED
    use_thumbnails = gtk_major_version >= 2 && gtk_minor_version >= 4;
#else
    use_thumbnails = FALSE;
#endif

#ifdef win32
    // On windows, ensure that our installed sh.exe is the one that is found,
    // by severely restricting the path.
    char pathenv[1024];
    sprintf(pathenv, "PATH=%s", get_asf_bin_dir());
    putenv(pathenv);
#endif

    if (!use_thumbnails)
    {
        printf("GTK Version < 2.4 -- output thumbnails disabled.\n");
    }
    else
    {
        // We will want to load thumbnails in other threads.
        if ( !g_thread_supported () ) {
            g_thread_init (NULL);
        }
    }

    /* allow FOPEN, FREAD, FWRITE to fail without aborting */
    caplib_behavior_on_error = BEHAVIOR_ON_ERROR_CONTINUE;


    /* add version number to window title, request a default size */
    char gtitle [256];
    sprintf (gtitle, "ASF MapReady: Version %s",
             MAPREADY_VERSION_STRING);

    widget = get_widget_checked("asf_convert");
    gtk_window_set_title(GTK_WINDOW(widget), gtitle);
    // commenting this out - now supported within glade
    //gtk_window_resize(GTK_WINDOW(widget), 1000, 700);

    /* select defaults for dropdowns & buttons & labeling */
    widget = get_widget_checked("scaling_method_combobox");
    set_combo_box_item(widget, SCALING_METHOD_SIGMA);

    widget = get_widget_checked("import_checkbutton");
    gtk_widget_set_sensitive(widget, FALSE);

    widget = get_widget_checked("input_data_type_combobox");
    set_combo_box_item(widget, INPUT_TYPE_AMP);

    widget = get_widget_checked("resample_option_menu");
    set_combo_box_item(widget, RESAMPLE_BILINEAR);

    // Populate the colormap drop-downs on both the import tab and in the
    // browse dialog
    populate_polsarpro_classification_optionmenu();
    widget = get_widget_checked("browse_select_colormap_optionmenu");
    gtk_option_menu_set_history(GTK_OPTION_MENU(widget), 0);

    widget = get_widget_checked("output_format_combobox");
    set_combo_box_item(widget, OUTPUT_FORMAT_JPEG);

    widget = get_widget_checked("geocode_checkbutton");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
    geocode_options_changed();
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE);

    widget = get_widget_checked("about_dialog_copyright_label");
    gtk_label_set_text(GTK_LABEL(widget), ASF_COPYRIGHT_STRING);

    // Hide latitude selection stuff until we start supporting
    // swath products (level 0) again
    widget = get_widget_checked("latitude_checkbutton");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_low_label");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_hi_label");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_low_entry");
    gtk_widget_hide(widget);
    widget = get_widget_checked("latitude_hi_entry");
    gtk_widget_hide(widget);

    // This option is deprecated -- we always apply the fix now
    // and don't give the user the option of turning it off.  Probably
    // we can just delete all code associated with it, but for now we
    // just turn it on, and hide it.
    set_checked("apply_metadata_fix_checkbutton", TRUE);
    widget = get_widget_checked("apply_metadata_fix_checkbutton");
    gtk_widget_hide(widget);

    // Muck with the fonts in the About dialog
    widget = get_widget_checked("about_dialog_mapready_label");
    gchar *str = gtitle;
    gchar *text;
    PangoAttrList *attrs;
    sprintf(gtitle,
                "\n<b>ASF MapReady</b>\n"
                "<i>Remote Sensing Toolkit</i>\n"
                "ver. %s",
                MAPREADY_VERSION_STRING);
    if (strlen(SVN_REV)>0)
        sprintf(gtitle, "%s (build %s)", gtitle, SVN_REV);
    else
        strcat(gtitle, " (custom build)");

    pango_parse_markup(str, -1, 0, &attrs, &text, NULL, NULL);
    gtk_label_set_attributes(GTK_LABEL(widget), attrs);
    gtk_label_set_text(GTK_LABEL(widget), text);
    PangoFontDescription *font_desc =
      pango_font_description_from_string("Sans 12");
    gtk_widget_modify_font(widget, font_desc);

    // Muck with the "Select Processing Steps" label
    widget = get_widget_checked("select_processing_steps_label");
    str = gtitle;
    sprintf(gtitle, "<b><i>  Select Processing Steps:</i></b>");
    pango_parse_markup(str, -1, 0, &attrs, &text, NULL, NULL);
    gtk_label_set_attributes(GTK_LABEL(widget), attrs);
    gtk_label_set_text(GTK_LABEL(widget), text);
    font_desc = pango_font_description_from_string("Sans 12");
    gtk_widget_modify_font(widget, font_desc);

    /* fire handlers for hiding/showing stuff */
    output_format_combobox_changed();
    input_data_type_changed();
    geocode_options_changed();
    load_external_commands();
    external_settings_changed();
    set_toolbar_images();
    show_execute_button(TRUE);

    /* build columns in the files section */
    show_full_paths = FALSE; // Set before setup_files_list(), default to FALSE
    widget = get_widget_checked("show_full_path_names_checkbutton");
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), FALSE);
    setup_files_list();

    /* allow multiple selects */
    widget = get_widget_checked("input_file_selection");
    gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION(widget), TRUE);

    /* drag-n-drop setup */
    setup_dnd();

    /* right-click menu setup */
    setup_popup_menu();

    /* bands dropdown setup*/
    setup_band_comboboxes();

    current_naming_scheme = naming_scheme_default();

    /* set initial vpanel setting */
    //widget = get_widget_checked("vertical_pane");
    //gtk_paned_set_position(GTK_PANED(widget), 240);

    /* Connect signal handlers.  */
    glade_xml_signal_autoconnect (glade_xml);

    /* initial flag settings */
    processing = FALSE;
    settings_on_execute = NULL;

    /* explicit call to the function that refreshes the "summary" */
    /* section when options are changed, so get the settings      */
    /* initially in there                                         */
    input_data_formats_changed();
    input_data_type_combobox_changed();
    default_to_terrcorr_on();
    default_to_keep_temp();
    terrcorr_options_changed();
    init_browse_format_combobox();

    /* For some reason, it did not work to set this via glade        */
    /* So, we have to select our default faraday rotation style here */
    rb_select("rb_fr_global", TRUE);
    polarimetry_settings_changed();

    /* put files on the command-line into the files section */
    populate_files_list(argc, argv);

    /* set up the rgb stuff on the export tab */
    rgb_combo_box_setup();

    /* enters the main GTK loop */
    gtk_main ();

    /* clean up, application has been closed */
    if (settings_on_execute)
        settings_delete(settings_on_execute);

    if (output_directory)
        g_free(output_directory);

    if (current_naming_scheme)
        naming_scheme_delete(current_naming_scheme);

    release_predefined_projections();

    exit (EXIT_SUCCESS);
}
Exemplo n.º 8
0
static void bott_draw_normal(void **pp,long *s)
  {
  int i,j;int x,xs = 0,y;
  word *bott_scr;
  THUMAN *p;

  bott_scr = bott_clear();
  RedirectScreen(bott_scr);
  if (battle && cur_mode == MD_INBATTLE) put_picture(0,0,ablock(H_BATTLE_BAR));
  else put_picture(0,0,ablock(H_DESK));
  memcpy(&xs,ablock(H_OKNO),2);
  x = 54;
  for(j = 0;j<POCET_POSTAV;j++)
     if ((p =&postavy[i = group_sort[j]])->used)
     if (cur_mode != MD_PRESUN || i == moving_player)
     {
     char c[] =" ";int z,lv,llv;
     put_picture(x,0,ablock(H_OKNO));lv = p->lives;llv = p->vlastnosti[VLS_MAXHIT];
     if (lv || p->used & 0x80)
        {
        z = 3-((lv-1)*4/llv);if (lv == llv) z = 0;
        z*= 75;
        if (p->xicht>= 0)put_8bit_clipped(ablock(H_XICHTY+i),bott_scr+PIC_X+x+PIC_Y*scr_linelen2,z,54,75);
        if (p->bonus) draw_small_icone(0,PIC_X+x+1,PIC_Y+1);
        if (p->spell) draw_small_icone(1,PIC_X+x+1,PIC_Y+1);
        if (!p->voda) draw_small_icone(2,PIC_X+x+1,PIC_Y+1);
        if (!p->jidlo) draw_small_icone(3,PIC_X+x+1,PIC_Y+1);
        }
     else put_picture(PIC_X+x,PIC_Y,ablock(H_LEBKA));
     curcolor = 0;
     y = BARS_YS-p->lives*BARS_YS/p->vlastnosti[VLS_MAXHIT];
     if (y) bar(x+ZIVOTY_S,BARS_S,x+ZIVOTY_E,BARS_S+y);
     y = BARS_YS-p->kondice*BARS_YS/p->vlastnosti[VLS_KONDIC];
     if (y) bar(x+KONDIC_S,BARS_S,x+KONDIC_E,BARS_S+y);
     if (p->vlastnosti[VLS_MAXMANA]) y = BARS_YS-p->mana*BARS_YS/p->vlastnosti[VLS_MAXMANA];else y = BARS_YS;
     if (y<0) y = 0;
     if (y) bar(x+MANA_S,BARS_S,x+MANA_E,BARS_S+y);
     if (p->sektor != viewsector) trans_bar25(x,0,74,102);
     set_font(H_FLITT,p->groupnum == cur_group && !battle?SEL_COLOR:barvy_skupin[p->groupnum]);
     set_aligned_position(x+36,92,1,0,p->jmeno);outtext(p->jmeno);
     c[0] = p->groupnum+48;set_aligned_position(x+5,86,0,2,c);outtext(c);
     if (cur_mode == MD_INBATTLE)
        {
        char s[20];
		signed char dir;
        set_font(H_FBOLD,RGB555(31,31,0));
        sprintf(s,texty[40],p->actions);
        set_aligned_position(x+56,86,2,2,s);outtext(s);
		dir = viewdir-p->direction;
		if (abs(dir) == 2) c[0] = 2;
		else if (dir == -1 || dir == 3) c[0] = 1;
		else if (dir == -3 || dir == 1) c[0] = 3;
		  if (dir)
		  {
   			set_font(H_FSYMB,p->groupnum == cur_group && !battle?SEL_COLOR:barvy_skupin[p->groupnum]);
			c[0]+= 4;set_aligned_position(x+10,86,0,2,c);outtext(c);
		  }
        }
     if (i == select_player) rectangle(x+3,12,x+3+54,12+75,SEL_COLOR);
     if (p->dostal)
        {
        char s[20];
        put_picture(x+ZASAHB_X,ZASAHB_Y,ablock(H_PZASAH));
        set_font(H_FBOLD,RGB555(31,31,0));
        sprintf(s,"%d",p->dostal);
        set_aligned_position(x+ZASAHT_X,ZASAHT_Y,1,1,s);outtext(s);
        }
     x += xs;
     }
  if (cur_mode == MD_PRESUN || cur_mode == MD_UTEK)
     {
     char s[40];
     set_font(H_FBOLD,RGB555(31,31,16));
     position(150,20);outtext(texty[cur_mode == MD_PRESUN?42:44]);
     sprintf(s,texty[60+cislovka(postavy[moving_player].actions)],postavy[moving_player].actions);
     position(150,35);outtext(s);
     position(150,50);outtext(texty[63]);
     }
/*  if (mob_dostal)
        {
        word *w;
        char s[40];

        w = ablock(H_MZASAH1+mob_dostal-1);
        put_picture(580-(w[0]>>1),55-(w[1]>>1),w);
        itoa(mob_dostal_pocet,s,10);
        set_font(H_FLITT5,0xffff);
        set_aligned_position(580,55,1,1,s);
        outtext(s);
        }
 */
  *pp = GetScreenAdr();
  *s = _msize(*pp);
  RestoreScreen();
  }
Exemplo n.º 9
0
int
main(int argc, char **argv)
{
    if (detect_flag_options(argc, argv, "-help", "--help", NULL))
      help();

    char band[512], lut[512], mask_file_name[512];

    strcpy(band, "");
    strcpy(mask_file_name, "");

    int band_specified = extract_string_options(&argc, &argv, band,
        "-band", "--band", "-b", NULL);
    int lut_specified = extract_string_options(&argc, &argv, lut,
        "-colormap", "--colormap", "-lut", "--lut", NULL);
    int planner_mode = extract_flag_options(&argc, &argv,
        "-plan", "--plan", NULL);
    int mask_specified = extract_string_options(&argc, &argv, mask_file_name,
        "-mask", "--mask", "--layover-mask", "--layover-mask", NULL);
    generic_specified = extract_flag_options(&argc, &argv,
        "-generic", "--generic", NULL);
    if (generic_specified) {
       char type[512];
       if (!extract_int_options(&argc, &argv, &generic_bin_width,
                "-width", "--width", "-cols", "--cols", NULL) ||
           !extract_int_options(&argc, &argv, &generic_bin_height,
                "-height", "--height", "-rows", "--rows", NULL)) {
         asfPrintError("When reading generic data, specify the size "
            "(--width, --height).\n");
       }
       generic_bin_byteswap =
         extract_flag_options(&argc, &argv,
                              "--byteswap", "-byteswap", NULL);
       if (extract_string_options(&argc, &argv, type,
                "-type", "--type", NULL))
       {
         if (strcmp_case(type, "BYTE") == 0 ||
             strcmp_case(type, "INT8") == 0) {
           generic_bin_datatype = BYTE;
         }
         else if (strcmp_case(type, "FLOAT") == 0 ||
                  strcmp_case(type, "REAL32") == 0) {
           generic_bin_datatype = REAL32;
         }
         else {
           asfPrintError("Unknown generic data type: %s\n", type);
         }
       } else {
         asfPrintStatus("Generic binary: assuming REAL32 data.\n");
         generic_bin_datatype = REAL32;
       }
    }

    if (planner_mode) {
      if (detect_flag_options(argc, argv, "-calibrate-reference", NULL)) {
        calibrate_planner_reference();
        exit(EXIT_SUCCESS);
      }
    }

    handle_common_asf_args(&argc, &argv, "ASF View");

    // point to "polygon 0" as the one we initially work on
    g_poly = &g_polys[0];

    // set up image array
    curr = &image_info[0];
    curr->data_name = curr->meta_name = NULL;
    int ii;

    if (argc < 2) {
        curr->filename = STRDUP(find_in_share("startup.jpg"));
    }
    else {
        n_images_loaded = 0;
	for (ii=1; ii<argc; ++ii) {
           if (strlen(argv[ii]) > 0) {
               image_info[n_images_loaded].filename = STRDUP(argv[ii]);
               ++n_images_loaded;
           }
        }    
    }


    if (n_images_loaded == 1) {
        asfPrintStatus("Loading 1 image: %s\n", image_info[0].filename);
    }
    else {
        asfPrintStatus("Loading %d images:\n", n_images_loaded);
        for (ii=0; ii<n_images_loaded; ++ii)
            asfPrintStatus("%d: %s\n", ii+1, image_info[ii].filename);
    }

    if (mask_specified)
        asfPrintStatus("Mask: %s\n", mask_file_name);

    // we could call load_file() here, but don't because this way we can
    // interleave the call to gtk_init() with some of the loading code --
    // which keeps the window from showing up until after it has been loaded,
    // which looks much nicer

    // initialize globals
    reset_globals(TRUE);

    // Get rid of leftover (temporary) colormap luts if they exist, say if asf_view errored out
    // rather than being exited normally
    char embedded_tiff_lut_file[1024];
    char embedded_asf_colormap_file[1024];
    char *lut_loc = (char *)MALLOC(sizeof(char)*(strlen(get_asf_share_dir())+64));
    sprintf(lut_loc, "%s%clook_up_tables", get_asf_share_dir(), DIR_SEPARATOR);
    sprintf(embedded_tiff_lut_file,"%s%c%s", lut_loc, DIR_SEPARATOR, EMBEDDED_TIFF_COLORMAP_LUT_FILE);
    sprintf(embedded_asf_colormap_file,"%s%c%s", lut_loc, DIR_SEPARATOR,
            EMBEDDED_ASF_COLORMAP_LUT_FILE);
    FREE(lut_loc);
    if (fileExists(embedded_tiff_lut_file)) remove(embedded_tiff_lut_file);
    if (fileExists(embedded_asf_colormap_file)) remove(embedded_asf_colormap_file);

    if (mask_specified) {
        curr = mask = &mask_info;
        mask->filename = STRDUP(mask_file_name);

        if (mask->filename[strlen(mask->filename)-1] == '.')
            mask->filename[strlen(mask->filename)-1] = '\0';
        
        read_file(mask->filename, NULL, FALSE, TRUE);
        //set_lut("layover_mask");
    }
    
    // load the image we're going to actually show last
    for (ii=n_images_loaded-1; ii>=0; --ii)
    {
        curr = &image_info[ii];
        
        // strip off any trailing "."
        if (curr->filename[strlen(curr->filename)-1] == '.')
            curr->filename[strlen(curr->filename)-1] = '\0';
        
        read_file(curr->filename, band_specified ? band : NULL, FALSE, TRUE);
        check_for_embedded_tiff_lut(curr->filename, &lut_specified, lut);
        if (lut_specified)
            set_lut(lut);
        
        assert(curr->data_name);
        assert(curr->meta_name);
        
        // we load the thumbnail data before bringing up the window, looks
        // much nicer.  When loading an image within the GUI, we don't need
        // to do get_thumbnail_data() as a separate step.
        ThumbnailData *thumbnail_data = get_thumbnail_data(curr);
        
        // first time through the loop only, set up GTK
        if (ii == n_images_loaded-1) {
            gtk_init(&argc, &argv);
            
            gchar *glade_xml_file = (gchar *)find_in_share("asf_view.glade");
            printf("Found asf_view.glade: %s\n", glade_xml_file);
            glade_xml = glade_xml_new(glade_xml_file, NULL, NULL);
            free(glade_xml_file);
            
            // set up window title, etc
            set_button_images();
            
            // set up the acquisition planner, if we are in that mode
            if (planner_mode) {
                setup_planner();
                
                // getting rid of the info section makes more room for the found
                // acquisitions, and isn't really necessary in the planner
                show_widget("info_hbox", FALSE);
            }
            
            // populate the look up table list, and apply the default
            // look-up-table, if there is one.  In this case, we will need to
            // apply it retroactively to the thumbnail data we already loaded
            // (In new.c, this kludge isn't required - we load/apply in the
            // same pass -- here it is required because we pre-load the thumbnail)
            populate_lut_combo();
            if (check_for_embedded_tiff_lut(curr->filename, &lut_specified, lut)) {
                GtkWidget *option_menu = get_widget_checked("lut_optionmenu");
                gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), get_tiff_lut_index());
                set_current_index(get_tiff_lut_index());
            }
            else if (is_colormap_ASF_file(curr->filename)) {
                /*
                * lut_specified = 1;
                * strcpy(lut, EMBEDDED_ASF_COLORMAP_LUT);
                * GtkWidget *option_menu = get_widget_checked("lut_optionmenu");
                * gtk_option_menu_set_history(GTK_OPTION_MENU(option_menu), get_asf_lut_index());
                * set_current_index(get_asf_lut_index());
                * check_lut();
                * apply_lut_to_data(thumbnail_data);
                */
            }
        }
        else if (ii == 0) {
            set_title(band_specified, band);
        }

        if (curr->meta && curr->meta->general)  {
            if (set_lut_based_on_image_type(curr->meta->general->image_data_type))
            {
                check_lut();
                // data we loaded needs to be lutted
                apply_lut_to_data(thumbnail_data);
            }
        }
        
        // load the metadata & image data, other setup
        setup_gdk_window_ids();
        setup_small_image_size();
        fill_small_have_data(thumbnail_data, curr);
        fill_big(curr);
        update_pixel_info(curr);
        update_zoom();
        set_font();
        fill_meta_info();
        update_map_settings(curr);
        fill_stats(curr);
        set_mapping_defaults(curr);
        setup_bands_tab(curr->meta);
        disable_meta_button_if_necessary();
        if (lut_specified)
            select_lut(lut);
    }

    if (n_images_loaded>0) {
        asfPrintStatus("Currently displaying %d: %s\n",
                       current_image_info_index, curr->filename);
    }

    glade_xml_signal_autoconnect(glade_xml);
    gtk_main ();

    // If the last viewed file left behind a (temporary) color map lut,
    // then get rid of it
    if (fileExists(embedded_tiff_lut_file))
      remove(embedded_tiff_lut_file);
    if (fileExists(embedded_asf_colormap_file))
      remove(embedded_asf_colormap_file);

    image_info_free(curr);
    free_shapes();
    exit (EXIT_SUCCESS);
}
Exemplo n.º 10
0
map_typical_overlay::~map_typical_overlay()
{
    set_sprites(nullptr, false);
    set_font(nullptr, false);
}
Exemplo n.º 11
0
void new_setup()
  {
  WINDOW *w;
  CTL3D ctl;
  int i;
  static int textxp[]={ 75, 75,435,435,434,535,535,535,434,434,434,434,434, 35,410,510};
  static int textyp[]={275,305, 65, 95,125, 65, 95,125,185,215,245,275,305,235, 40, 40};
  static int  textc[]={ 53, 54, 56, 57, 58, 56, 57, 58,140,141,142,143,144 ,51, 55, 59};

  mix_back_sound(256000-16384);
  memset(&ctl,0,sizeof(ctl));
  change_click_map(setup,4);
  set_font(H_FBOLD,SETUP_COL2);
  default_font=curfont;
  memcpy(f_default,charcolors,sizeof(f_default));
  w=create_window(0,SCREEN_OFFLINE,639,359,0,&ctl);
  w->draw_event=show_setup_desktop;
  desktop_add_window(w);
  define(10,50,270,190,20,0,skeldal_checkbox);  c_default(get_snd_effect(SND_SWAP));   on_change(do_setup_change);
  if (check_snd_effect(SND_OUTFILTER))
     {
     define(20,50,300,190,20,0,skeldal_checkbox);c_default(get_snd_effect(SND_OUTFILTER));
        on_change(do_setup_change);
     }

  define(30,410,60,90,20,0,skeldal_checkbox);c_default(zoom_speed(-1)==0);
  on_change(change_zoom);
  define(40,410,90,90,20,0,skeldal_checkbox);c_default(zoom_speed(-1)==1);on_change(change_zoom);
  define(50,410,120,90,20,0,skeldal_checkbox);c_default(zoom_speed(-1)==2);on_change(change_zoom);

  define(60,510,60,90,20,0,skeldal_checkbox);c_default(turn_speed(-1)==0);on_change(change_turn);
  define(70,510,90,90,20,0,skeldal_checkbox);c_default(turn_speed(-1)==1);on_change(change_turn);
  define(80,510,120,90,20,0,skeldal_checkbox);c_default(turn_speed(-1)==2);on_change(change_turn);

  for(i=0;i<5;i++)
     {
     define((i+9)*10,410,180+i*30,190,20,0,skeldal_checkbox);
     switch(i)
        {
        case 0:c_default(show_names);break;
        case 1:c_default(enable_sort);break;
        case 2:c_default(autoattack);break;
        case 3:c_default(autosave_enabled);break;
        case 4:c_default(level_preload);break;
        }
     }

  for(i=0;i<sizeof(textc)/sizeof(int);i++)
     define(-1,textxp[i],textyp[i]-1,1,1,0,label,texty[textc[i]]);

  for(i=0;i<sizeof(effects)/sizeof(int);i++)
     if (check_snd_effect(effects[i]))
       {
       define(200+i*10,50+i*60,30,30,200,0,skeldal_soupak,effects[i]==SND_MUSIC?127:255);c_default(get_snd_effect(effects[i]));
       on_change(do_setup_change);
       }
  define(300,559,336,81,21,0,setup_ok_button,texty[174]);on_change(unwire_setup);
  property(NULL,ablock(H_FTINY),&color_topbar,0);
  redraw_window();
  add_to_timer(TM_CHECKBOX,4,-1,checkbox_animator);
  }
Exemplo n.º 12
0
int main(void)
{
	sysInfo = 0;
	
	SCS |= 0x01;
	FIODIR0 |= ((1<<21) | (1<<4) | (1<<11) | (1<<6) | (1<<23) | (1<<19) | (1<<17));
	FIODIR0 |= (1<<12);
	FIOSET0 |= (1<<12);
	xx = 0x00;

	setSpeed(SPEED_30);

	lcd_init(0);
	serial_init();

	startTimerIRQ();
	startADC();

	initKeys();

	initSound();
	startSoundIRQ();

	initIR();
	startIrIRQ();

    RF_init();
    startcc1100IRQ();
	enableWOR();
	
	initRTC();
	startRtcIRQ();
	
	enableIRQ();

	testmenu_init();
	init_menu();
	
	initBacklight();

	oldkeys[0] = keys[0];
	oldkeys[1] = keys[0];

	key_state = KEY_IDLE;

	set_font(BOLDFONT);
	
	BFS_Mount();
	load_RC_setting();
	load_RF_setting();
	load_setting();
	
	{
		struct RAWset_ RAWset;
        unsigned char x;
        unsigned long RAWcmdbase;
        
        RAWcmdbase = FLASH1_BASE +(secaddr[0]<<1);
        x=memcmp((void*)RAWcmdbase,"RC01",4);
		
        if(!x) {
               
				memcpy(&RAWset,(void *)RAWcmdbase,sizeof(struct RAWset_));
				RAWset.name[7] = 0;
				BFS_SaveFile(BFS_ID_RAWslot0, sizeof(struct RAWset_), (unsigned char*) &RAWset);
				eraseSector(1,0);
        }
	}
	
	if (EncIsValid(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set)) {
		setEncoder(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set);
	}	
	
	drawMainscreen();
	ask_for_time(0);
	
						
/*
	playSound((unsigned char*)sound1_data, sound1_len);
	waitSound();
	playSound((unsigned char*)sound2_data, sound2_len);
*/

	while (1)
	{
		if(keys[0] != oldkeys[0] || keys[1] != oldkeys[1])
		{
			oldkeys[0] = keys[0];
			oldkeys[1] = keys[1];
			sysInfo |= 0x40;
		}

		switch(key_state)
		{
			case KEY_IDLE:
				if(sysInfo & 0x40)
				{
					sysInfo &= 0xBF;
					if(KEY_Betty)
					{
						setBacklight(BL_AUTO);
						menu_exec(&mainMenu);
						if (EncIsValid(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set)) {
							setEncoder(irDevTab.device[irDevTab.active].encoder, irDevTab.device[irDevTab.active].set);
						}
						drawMainscreen();
					}
					else if(KEY_2)
					{
						//setSpeed(SPEED_30);
					}
					else if(KEY_3)
					{
						//setSpeed(SPEED_60);
					}
					else  if(KEY_A || KEY_B || KEY_C || KEY_D)
					{
						unsigned char x;
						//playSound((unsigned char*)sound3_data, sound3_len);
						x=0;
						if (KEY_B) x=1;
						if (KEY_C) x=2;
						if (KEY_D) x=3;
						
						if (EncIsValid(irDevTab.device[x].encoder, irDevTab.device[x].set)) {
							setBacklight(BL_AUTO);
							irDevTab.active = x;
							setEncoder(irDevTab.device[x].encoder, irDevTab.device[x].set);
							drawMainscreen();
						}	
					}
/*					else if(KEY_B)
					{
					
					}
					else if(KEY_C)
					{	
//						playSound((unsigned char*)sound1_data, sound1_len);
					}
					else if(KEY_D)
					{	
//						playSound((unsigned char*)sound2_data, sound2_len);
					}*/
					if((keys[0] != 0) || (keys[1] != 0))
						key_state = KEY_PRESS;
				}
				break;
			case KEY_PRESS:
				irSend(getCode());
				key_state = KEY_HOLD;
//				autorepeat = 0;
				break;
			case KEY_HOLD:
//				if(autorepeat >= AUTO_TIMEOUT)
					irRepeat();

				if(keys[0] == 0 && keys[1] == 0)
					key_state = KEY_RELEASE;

				break;
			case KEY_RELEASE:
				irStop();
				key_state = KEY_IDLE;
				break;
		}

		if(serial_tstc() > 0)
		{
			i = serial_getc();
			if(i=='.')
			{
				serial_puts("HELO");
			}
			else if(i=='0')
			{
				setBacklight(0x00);	// pwm value
			}
			else if(i=='1')
			{
				setBacklight(0x1F);	// pwm value
			}
			else if(i=='2')
			{
				setBacklight(0x3F);	// pwm value
			}
			else
				serial_putc(i);
		}
		
		if ((bl_val == 0) && (key_state == KEY_IDLE) && !((FIOPIN0 & (1<<30)) == 0) && (((RFstatus & (WORrxon | RXenabled)) == 0))) {
			EXTINT = 0x08;
			PCON = 0x02;
			PLLFEED = 0xAA;
			PLLFEED = 0x55;
		}
		
		if (timeInfo & timechanged) {
			printTime(86,152,(struct time_ *)&time);
			printDate(0,152,(struct date_ *)&date,0);
			
			timeInfo &= ~timechanged;
		}
		
	}
	return 0;
}
		TITANIUM_PROPERTY_SETTER(TableViewRow, font)
		{
			TITANIUM_ASSERT(argument.IsObject());
			set_font(js_to_Font(static_cast<JSObject>(argument)));
			return true;
		}
Exemplo n.º 14
0
/*  Access the caught url list and display in a scrollable window. */
static int display_url_handler(window_info *win)
{
#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE

	url_win_hover_url = NULL;
	
	/* save current position so K_WINDOWS_ON_TOP restores to where its been moved */
	url_win_x = win->cur_x;
	url_win_y = win->cur_y;
 
	glEnable(GL_TEXTURE_2D);
	set_font(0);
	
	/* check for external state change */
	if (!have_url_count && !url_win_status)
		url_win_status = URLW_EMPTY;
	/* if we have a status message, display it */
	if (url_win_status)
	{
		char *message[] = { urlcmd_none_str, urlwin_clear_str, urlwin_open_str };
		int y_start = (url_win_text_start_y - 0.75 * url_win_text_zoom * DEFAULT_FONT_Y_LEN)/2;
		glColor3f(1.0f,1.0f,1.0f);
		draw_string_zoomed(url_win_help_x, y_start, (unsigned char *)message[url_win_status-1], 1, 0.75 * url_win_text_zoom);
		url_win_status = (have_url_count) ?0 :URLW_EMPTY;
	}
	
	/* display a page of url */
 	if (have_url_count)
	{
		list_node_t *local_head = newest_url;
		int currenty = url_win_text_start_y;
		int start_url = 0;
		int num_url_displayed = 0;
		
		/* don't scroll if everything will fit in the window, also catch if the list has been cleared via #url */
		if (((url_win_line_step * have_url_count) <= url_win_text_len_y) || (url_win_top_line > have_url_count))
			url_win_top_line = 0;
		
		/* move to the first url to be displayed - set from the scroll bar */
		while (start_url < url_win_top_line && local_head->next != NULL)
		{
			local_head = local_head->next;
			start_url++;
		}
		
		/* loop over the remaining URLs while there is room in the window */
		while (local_head != NULL)
		{
			char *thetext = ((URLDATA *)local_head->data)->text;
			int dsp_string_len = 0;
			float string_width = 0;
			int highlight_url = 0;
			
			/* stop now if the url line will not fit into the window */
			if (((currenty - url_win_text_start_y) + url_win_line_step) > url_win_text_len_y)
				break;
				
			/* highlight the active (F2) url */
			if (local_head == active_url)
				glColor3f(0.0f,1.0f,0.0f);
			else
				glColor3f(1.0f,1.0f,1.0f);
			
			/* calculate the length of string we can display */
			while((*thetext != '\0') && (string_width < url_win_max_string_width))
			{
				float char_width = get_char_width(*thetext++) * url_win_text_zoom * DEFAULT_FONT_X_LEN / 12.0;
				if ((string_width+char_width) < url_win_max_string_width)
				{
					dsp_string_len++;
					string_width += char_width;
				}
			}
						
			/* if the string length will fit in the window, just draw it */
			if (dsp_string_len == strlen(((URLDATA *)local_head->data)->text))
				draw_string_zoomed(url_win_sep, currenty, (unsigned char *)((URLDATA *)local_head->data)->text, 1, url_win_text_zoom);
			/* otherwise, draw a truncated version with "..." at the end */
			else
			{
				//float toobig_width = (get_char_width('-') + get_char_width('>'))
				//	* url_win_text_zoom * DEFAULT_FONT_X_LEN / 12.0;
				float toobig_width = (3*get_char_width('.'))
					* url_win_text_zoom * DEFAULT_FONT_X_LEN / 12.0;
				draw_string_zoomed_width(url_win_sep, currenty, (unsigned char *)((URLDATA *)local_head->data)->text,
					url_win_sep + url_win_max_string_width - toobig_width, 1, url_win_text_zoom);
				draw_string_zoomed(url_win_sep + url_win_max_string_width - toobig_width, currenty,
					(unsigned char *)"..." , 1, url_win_text_zoom);
			}
			
			/* step down a line, do it now as the maths for mouse over below is easier */
			currenty += url_win_line_step;
			
			/* if the mouse is over the current line, hightlight it */
			if ((mouse_y >= win->cur_y + currenty - url_win_line_step) &&
				(mouse_y < win->cur_y + currenty) &&
				(mouse_x >= win->cur_x + (int)url_win_sep) &&
				(mouse_x - (int)url_win_sep <= win->cur_x + url_win_max_string_width))
			{
				/* remember which url we're over in case it's clicked */
				url_win_hover_url = local_head;				
				highlight_url = 1;
			}
				
			/* if a context menu is open, only hightlight the last URL hovered over before the context opened */
			if (cm_window_shown() != CM_INIT_VALUE)
			{
				if (cm_url == local_head)
					highlight_url = 1;
				else
					highlight_url = 0;
			}
			else
				cm_url = NULL;
			
			/* if mouse over or context activated, highlight the current URL */
			if (highlight_url)
			{
				char *help_substring = NULL;
				size_t help_substring_len = 0;
				int dsp_start = 0;
				int helpline = 0;
				Uint32 currenttime = SDL_GetTicks();
				size_t full_help_len = strlen(((URLDATA *)local_head->data)->text) + 30;
				char *full_help_text = (char *)malloc(sizeof(char) * full_help_len);
	
				/* display the mouse over help next time round */
				url_win_status = URLW_OVER;
			
				/* underline the text, just clicked links are red, otherwise blue - paler when visited */
				if ((currenttime - url_win_clicktime < 500) && (url_win_clicked_url == url_win_hover_url))
					glColor3f(1.0f,0.0f,0.3f);
				else if (((URLDATA *)local_head->data)->visited)
					glColor3f(0.3f,0.5f,1.0f);
				else
					glColor3f(0.1f,0.2f,1.0f);
				glDisable(GL_TEXTURE_2D);
				glBegin(GL_LINES);
				glVertex2i(url_win_sep, currenty-2);
				glVertex2i(url_win_sep+string_width, currenty-2);
				glEnd();
				glEnable(GL_TEXTURE_2D);
				
				/* write the full url as help text at the bottom of the window */
				safe_snprintf(full_help_text, full_help_len, "%s (seen %d time%s) (%s)",
					((URLDATA *)local_head->data)->text, ((URLDATA *)local_head->data)->seen_count,
					((URLDATA *)local_head->data)->seen_count == 1?"":"s",  ((((URLDATA *)local_head->data)->visited)?"visited":"unvisited"));
				thetext = full_help_text;
				dsp_string_len = 0;
				string_width = 0;
				while(*thetext != '\0')
				{
					float char_width = get_char_width(*thetext++) * SMALL_FONT_X_LEN / 12.0;
					if (((string_width+char_width) > (win->len_x - 2*url_win_sep)) || (*thetext == '\0'))
					{
						if (*thetext == '\0') /* catch the last line */
							dsp_string_len++;
						if (help_substring_len < dsp_string_len)
						{
							if (help_substring != NULL)
								free(help_substring);
							help_substring = (char *)malloc(sizeof(char)*(dsp_string_len+1));
							help_substring_len = dsp_string_len;
						}
						strncpy(help_substring, &full_help_text[dsp_start], dsp_string_len);
						help_substring[dsp_string_len] = '\0';
						show_help(help_substring, url_win_sep, (url_win_y_len - url_win_full_url_y_len) + helpline++ * SMALL_FONT_Y_LEN);
						dsp_start += dsp_string_len;
						dsp_string_len = 0;
						string_width = 0;
					}
					dsp_string_len++;
					string_width += char_width;
				}
				free(help_substring);
				free(full_help_text);
				
			} /* end if mouse over url */
			
			/* count how many displayed so we can set the scroll bar properly */
			num_url_displayed++;
			
			local_head = local_head->next;
		}
				
		/* set the number of steps for the scroll bar */
		vscrollbar_set_bar_len(url_win, url_scroll_id, have_url_count - num_url_displayed);

	} /* end if have url */
	
	/* draw a line below the list of url, above the current url full text */
	glColor3f(0.77f,0.59f,0.39f);
	glDisable(GL_TEXTURE_2D);
	glBegin(GL_LINES);
	glVertex2i(0, url_win_url_y_start);
	glVertex2i(url_win_x_len+1, url_win_url_y_start);
	glEnd();
	glEnable(GL_TEXTURE_2D);

#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
 
	return 1;
	
} /* end display_url_handler() */
Exemplo n.º 15
0
int main(int argc, char *argv[]) {
    format = sstrdup("%s");
    char *socket_path = NULL;
    char *pattern = sstrdup("pango:monospace 8");
    int o, option_index = 0;

    static struct option long_options[] = {
        {"socket", required_argument, 0, 's'},
        {"version", no_argument, 0, 'v'},
        {"limit", required_argument, 0, 'l'},
        {"prompt", required_argument, 0, 'P'},
        {"prefix", required_argument, 0, 'p'},
        {"format", required_argument, 0, 'F'},
        {"font", required_argument, 0, 'f'},
        {"help", no_argument, 0, 'h'},
        {0, 0, 0, 0}};

    char *options_string = "s:p:P:f:l:F:vh";

    while ((o = getopt_long(argc, argv, options_string, long_options, &option_index)) != -1) {
        switch (o) {
            case 's':
                FREE(socket_path);
                socket_path = sstrdup(optarg);
                break;
            case 'v':
                printf("i3-input " I3_VERSION);
                return 0;
            case 'p':
                /* This option is deprecated, but will still work in i3 v4.1, 4.2 and 4.3 */
                fprintf(stderr, "i3-input: WARNING: the -p option is DEPRECATED in favor of the -F (format) option\n");
                FREE(format);
                sasprintf(&format, "%s%%s", optarg);
                break;
            case 'l':
                limit = atoi(optarg);
                break;
            case 'P':
                i3string_free(prompt);
                prompt = i3string_from_utf8(optarg);
                break;
            case 'f':
                FREE(pattern);
                pattern = sstrdup(optarg);
                break;
            case 'F':
                FREE(format);
                format = sstrdup(optarg);
                break;
            case 'h':
                printf("i3-input " I3_VERSION "\n");
                printf("i3-input [-s <socket>] [-F <format>] [-l <limit>] [-P <prompt>] [-f <font>] [-v]\n");
                printf("\n");
                printf("Example:\n");
                printf("    i3-input -F 'workspace \"%%s\"' -P 'Switch to workspace: '\n");
                return 0;
        }
    }

    printf("using format \"%s\"\n", format);

    int screen;
    conn = xcb_connect(NULL, &screen);
    if (!conn || xcb_connection_has_error(conn))
        die("Cannot open display\n");

    sockfd = ipc_connect(socket_path);

    root_screen = xcb_aux_get_screen(conn, screen);
    root = root_screen->root;

    symbols = xcb_key_symbols_alloc(conn);

    init_dpi();
    font = load_font(pattern, true);
    set_font(&font);

    if (prompt != NULL)
        prompt_offset = predict_text_width(prompt);

    const xcb_rectangle_t win_pos = get_window_position();

    /* Open an input window */
    win = xcb_generate_id(conn);
    xcb_create_window(
        conn,
        XCB_COPY_FROM_PARENT,
        win,                                                 /* the window id */
        root,                                                /* parent == root */
        win_pos.x, win_pos.y, win_pos.width, win_pos.height, /* dimensions */
        0,                                                   /* X11 border = 0, we draw our own */
        XCB_WINDOW_CLASS_INPUT_OUTPUT,
        XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */
        XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK,
        (uint32_t[]){
            0, /* back pixel: black */
            1, /* override redirect: don’t manage this window */
            XCB_EVENT_MASK_EXPOSURE});

    /* Map the window (make it visible) */
    xcb_map_window(conn, win);

    /* Initialize the drawable surface */
    draw_util_surface_init(conn, &surface, win, get_visualtype(root_screen), win_pos.width, win_pos.height);

    /* Grab the keyboard to get all input */
    xcb_flush(conn);

    /* Try (repeatedly, if necessary) to grab the keyboard. We might not
     * get the keyboard at the first attempt because of the keybinding
     * still being active when started via a wm’s keybinding. */
    xcb_grab_keyboard_cookie_t cookie;
    xcb_grab_keyboard_reply_t *reply = NULL;

    int count = 0;
    while ((reply == NULL || reply->status != XCB_GRAB_STATUS_SUCCESS) && (count++ < 500)) {
        cookie = xcb_grab_keyboard(conn, false, win, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
        reply = xcb_grab_keyboard_reply(conn, cookie, NULL);
        usleep(1000);
    }

    if (reply->status != XCB_GRAB_STATUS_SUCCESS) {
        fprintf(stderr, "Could not grab keyboard, status = %d\n", reply->status);
        exit(-1);
    }

    xcb_flush(conn);

    xcb_generic_event_t *event;
    while ((event = xcb_wait_for_event(conn)) != NULL) {
        if (event->response_type == 0) {
            fprintf(stderr, "X11 Error received! sequence %x\n", event->sequence);
            continue;
        }

        /* Strip off the highest bit (set if the event is generated) */
        int type = (event->response_type & 0x7F);

        switch (type) {
            case XCB_KEY_PRESS:
                handle_key_press(NULL, conn, (xcb_key_press_event_t *)event);
                break;

            case XCB_KEY_RELEASE:
                handle_key_release(NULL, conn, (xcb_key_release_event_t *)event);
                break;

            case XCB_EXPOSE:
                if (((xcb_expose_event_t *)event)->count == 0) {
                    handle_expose(NULL, conn, (xcb_expose_event_t *)event);
                }

                break;
        }

        free(event);
    }

    draw_util_surface_free(conn, &surface);
    return 0;
}
Exemplo n.º 16
0
        /*NP*/
void plot_advectionprofile(void)
        /*************************************************************/
        /*  PLOT_ADVECTIONPROFILE                                    */
        /*  John Hart  SPC Norman                                    */
        /*                                                           */
        /*  Plots vertical profile of Wind Speeds                    */
        /*************************************************************/
{
        float bothgt, tophgt, h, wsp, advt, ix1, z;
        short x1, y1, x2, y2, x3, i, tlx, tly, wid, hgt;
        short pIndex, zIndex, wsIndex, wdIndex; 
        char st[10];

        pIndex = getParmIndex("PRES");
        zIndex = getParmIndex("HGHT");
        wsIndex = getParmIndex("SPED");

        if (!sndg || pIndex == -1 || zIndex == -1 || wsIndex == -1) return;

        tlx = skv.brx + 93;
        tly = skv.tly;
        wid = 67;
        hgt = skv.bry - skv.tly;

        setcliprgn(tlx, tly, tlx+wid, tly+hgt+15);
        setcolor(0);
        setlinestyle( 1, 1 );
        rectangle(1,tlx, tly, tlx+wid, tly+hgt);
        setcolor(1);
        rectangle(0, tlx, tly, tlx+wid, tly+hgt);

	/* Draw centerline */
        setlinestyle( 2, 1 );
	moveto( tlx + (wid/2), tly); lineto(tlx + (wid/2), tly + hgt);

	set_font(4);
        setlinestyle( 1, 1 );
	for (h=sndg[sfc()][pIndex]; h>=200; h-=100) {
		advt = advection_layer(&ix1, h, h - 100);

		/* Draw tick marks 
                x1 = tlx + (wid/2) + 5;
                x2 = tlx + (wid/2) - 5;
                y2 = pres_to_pix(h);
                y1 = pres_to_pix(h - 100);
		setcolor(1);
		moveto( x1, y1); lineto(x2, y1);
		moveto( x1, y2); lineto(x2, y2);
		*/
                x1 = tlx + (wid/2);
                x2 = tlx + (wid/2) + (advt*2.5);
                y2 = pres_to_pix(h);
                y1 = pres_to_pix(h - 100);
		setcolor(1);
		moveto( x1, y1); lineto(x2, y1);
		moveto( x1, y2); lineto(x2, y2);
		setcolor(26);
        	if (advt > 0) setcolor(13);
		sprintf( st, "%.1f", advt);
		if(advt > 0) rectangle(0, x1, y1, x2, y2); else rectangle(0, x2, y1, x1, y2);
		if (advt > 0) {
			x3 = x2 + 3;
			if (advt > 2) x3 = x1 + 3;
			}
		else {
			x3 = x2 - getgtextextent(st); 
			if (advt < -2) x3 = x1 - getgtextextent(st); 
			}
		if (advt > -999) outgtext( st, x3, ((y1+y2)/2)-4);
	}

        /* ----- Plot Label ----- */
        setcolor(1);
        set_font(5);
        outgtext("Inferred", tlx+5, tly+3);
        outgtext("Temp Advection",  tlx+5, tly+13);
        outgtext("(C / hr)",  tlx+5, tly+23);

	setcliprgn(1, 1, xwdth, xhght);
	copytodisplay();
}
Exemplo n.º 17
0
int AboutPrefs::create_objects()
{
	int x, y;

	BC_Resources *resources = BC_WindowBase::get_resources();

// 	add_subwindow(new BC_Title(mwindow->theme->preferencestitle_x, 
// 		mwindow->theme->preferencestitle_y, 
// 		_("About"), 
// 		LARGEFONT, 
// 		resources->text_default));
	
	x = mwindow->theme->preferencesoptions_x;
	y = mwindow->theme->preferencesoptions_y +
		get_text_height(LARGEFONT);

	set_font(LARGEFONT);
	set_color(resources->text_default);
	draw_text(x, y, PROGRAM_NAME " " CINELERRA_VERSION);

	y += get_text_height(LARGEFONT);

	set_font(MEDIUMFONT);
	draw_text(x, y, COPYRIGHTTEXT1
#if defined(COPYRIGHTTEXT2)
	"\n" COPYRIGHTTEXT2
#endif
#if defined(REPOMAINTXT)
	"\n" REPOMAINTXT
#endif
	);



	y += get_text_height(MEDIUMFONT) * 4;

	char versions[BCTEXTLEN];
	sprintf(versions, 
_("Quicktime version %d.%d.%d (%s)\n"
"Libmpeg3 version %d.%d.%d\n"),
quicktime_major(),
quicktime_minor(),
quicktime_release(),
FFMPEG_EXTERNALTEXT,
mpeg3_major(),
mpeg3_minor(),
mpeg3_release());
	draw_text(x, y, versions);



	y += get_text_height(MEDIUMFONT) * 3;
	set_font(LARGEFONT);
	draw_text(x, y, "Credits:");
	y += get_text_height(LARGEFONT);
	set_font(MEDIUMFONT);

	char credits[BCTEXTLEN];
	sprintf(credits,

"Jack Crossfire\n"
"Richard Baverstock\n"
"Karl Bielefeldt\n"
"Kevin Brosius\n"
"Jean-Luc Coulon\n"
"Jean-Michel POURE\n"
"Jerome Cornet\n"
"Pierre Marc Dumuid\n"
"Alex Ferrer\n"
"Jan Gerber\n"
"Koen Muylkens\n"
"Stefan de Konink\n"
"Nathan Kurz\n"
"Greg Mekkes\n"
"Eric Seigne\n"
"Joe Stewart\n"
"Dan Streetman\n"
#ifdef X_HAVE_UTF8_STRING
"Gustavo Iñiguez\n"
#else
"Gustavo I\361iguez\n"
#endif
"Johannes Sixt\n"
"Mark Taraba\n"
"Andraz Tori\n"
"Jonas Wulff\n"
"David Arendt\n"

);
	draw_utf8_text(x, y, credits);

	int x_indented;
	x_indented = x + get_text_width(MEDIUMFONT, "Pierre Marc Dumuid") + 20;

	char credits_cont1[BCTEXTLEN];
	sprintf(credits_cont1,

#ifdef X_HAVE_UTF8_STRING
"Einar Rünkaru\n"
#else
"Einar R\374nkaru\n"
#endif
"Monty Montgomery\n"

);
	draw_utf8_text(x_indented, y, credits_cont1);

	y = get_h() - 135;

	set_font(LARGEFONT);
	draw_text(x, y, "License:");
	y += get_text_height(LARGEFONT);

	set_font(MEDIUMFONT);

	char license3[BCTEXTLEN];
	sprintf(license3, _(
"This program is free software; you can redistribute it and/or modify it under the terms\n"
"of the GNU General Public License as published by the Free Software Foundation; either version\n"
"2 of the License, or (at your option) any later version.\n"
"\n"
"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
"without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n"
"PURPOSE.  See the GNU General Public License for more details.\n"
"\n"));
	draw_text(x, y, license3);

	x = get_w() - mwindow->theme->about_bg->get_w() - 10;
	y = mwindow->theme->preferencesoptions_y;
	BC_Pixmap *temp_pixmap = new BC_Pixmap(this, 
		mwindow->theme->about_bg,
		PIXMAP_ALPHA);
	draw_pixmap(temp_pixmap, 
		x, 
		y);

	delete temp_pixmap;


	x += mwindow->theme->about_bg->get_w() + 10;
	y += get_text_height(LARGEFONT) * 2;


	flash();
	flush();
	return 0;
}