/* gui object procedure for the color selection sliders */ static int my_slider_proc(int msg, IntPtr _d, int c) { DIALOG d = (DIALOG)_d; //int* color = (int*)d->dp3; int color = Marshal.ReadInt32(d.dp3); switch (msg) { case MSG_START: /* initialise the slider position */ //d->d2 = *color; d.d2 = color; break; // TODO: check why this one seem to reset the positiondk //case MSG_IDLE: // /* has the slider position changed? */ // //if (d->d2 != *color) // if (d.d2 != color) // { // //d->d2 = *color; // d.d2 = color; // object_message(d, MSG_DRAW, 0); // } // break; } return(d_slider_proc(msg, d, c)); }
private void AddObjects() { NEWS n = new NEWS { TITLE = "aaa", TIME = DateTime.Now, CONTENT = "jfjjfjjjf" }; Collections.News.Add(n); ALBUM a = new ALBUM { NAME = "Танцы с бубном", }; Collections.Albums.Add(a); FISH f = new FISH { NAME = "Ерш", DESCRIPTION = "blablalalbablalbalbalablalbala" }; Collections.Fishes.Add(f); STATE_INSPECTION i = new STATE_INSPECTION { PHONE = "+5255522", ADDRESS = "HHCKFKVKFV", REGION = "mINSK" }; Collections.Inspectios.Add(i); DIALOG d = new DIALOG { }; USER u = new USER { FIRSTNAME = "alb", LASTNAME = "ert" }; Collections.Friends.Add(u); }
static int Main(string[] argv) { // /* the submenu */ MENUS submenu = new MENUS(5); submenu[0] = new MENU("Submenu", NULL, NULL, D_DISABLED, NULL); submenu[1] = new MENU("", NULL, NULL, 0, NULL); submenu[2] = new MENU("Checked", check_callback, NULL, D_SELECTED, NULL); submenu[3] = new MENU("Disabled", NULL, NULL, D_DISABLED, NULL); submenu[4] = new MENU(null, NULL, NULL, 0, NULL); /* the first menu in the menubar */ MENUS menu1 = new MENUS(4); menu1[0] = new MENU("Test &1 \t1", menu_callback, NULL, 0, NULL); menu1[1] = new MENU("Test &2 \t2", menu_callback, NULL, 0, NULL); menu1[2] = new MENU("&Quit \tq/Esc", Marshal.GetFunctionPointerForDelegate(d_quit), NULL, 0, NULL); menu1[3] = new MENU(null, NULL, NULL, 0, NULL); /* the second menu in the menubar */ MENUS menu2 = new MENUS(3); menu2[0] = new MENU("&Test", menu_callback, NULL, 0, NULL); menu2[1] = new MENU("&Submenu", NULL, submenu, 0, NULL); menu2[2] = new MENU(null, NULL, NULL, 0, NULL); /* the help menu */ MENUS helpmenu = new MENUS(2); helpmenu[0] = new MENU("&About \tF1", Marshal.GetFunctionPointerForDelegate(d_about), NULL, 0, NULL); helpmenu[1] = new MENU(null, NULL, NULL, 0, NULL); /* the main menu-bar */ MENUS the_menu = new MENUS(4); the_menu[0] = new MENU("&First", NULL, menu1, 0, NULL); the_menu[1] = new MENU("&Second", NULL, menu2, 0, NULL); the_menu[2] = new MENU("&Help", NULL, helpmenu, 0, NULL); the_menu[3] = new MENU(null, NULL, NULL, 0, NULL); the_dialog[0] = new DIALOG(d_clear_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); /* these just display text, either left aligned, centered, or right aligned */ the_dialog[1] = new DIALOG("d_text_proc", 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_text_proc"), NULL, NULL); the_dialog[2] = new DIALOG("d_ctext_proc", 318, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_ctext_proc"), NULL, NULL); the_dialog[3] = new DIALOG("d_rtext_proc", 636, 20, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_rtext_proc"), NULL, NULL); ///* lots of descriptive text elements */ the_dialog[4] = new DIALOG("d_text_proc", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_menu_proc->"), NULL, NULL); the_dialog[5] = new DIALOG("d_text_proc", 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_button_proc->"), NULL, NULL); the_dialog[6] = new DIALOG("d_text_proc", 0, 70, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_check_proc->"), NULL, NULL); the_dialog[7] = new DIALOG("d_text_proc", 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_radio_proc->"), NULL, NULL); the_dialog[8] = new DIALOG("d_text_proc", 0, 130, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_edit_proc->"), NULL, NULL); the_dialog[9] = new DIALOG("d_text_proc", 0, 150, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_list_proc->"), NULL, NULL); the_dialog[10] = new DIALOG("d_text_proc", 0, 200, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_text_list_proc->"), NULL, NULL); the_dialog[11] = new DIALOG("d_text_proc", 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_textbox_proc->"), NULL, NULL); the_dialog[12] = new DIALOG("d_text_proc", 0, 300, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_slider_proc->"), NULL, NULL); the_dialog[13] = new DIALOG("d_text_proc", 0, 330, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_box_proc->"), NULL, NULL); the_dialog[14] = new DIALOG("d_text_proc", 0, 360, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_shadow_box_proc->"), NULL, NULL); the_dialog[15] = new DIALOG("d_text_proc", 0, 390, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_keyboard_proc. Press F1 to see me trigger the about box."), NULL, NULL); the_dialog[16] = new DIALOG("d_text_proc", 0, 410, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_clear_proc. I draw the white background."), NULL, NULL); the_dialog[17] = new DIALOG("d_text_proc", 0, 430, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("d_yield_proc. I make us play nice with the OS scheduler."), NULL, NULL); the_dialog[18] = new DIALOG("d_rtext_proc", 636, 40, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("<-d_bitmap_proc"), NULL, NULL); the_dialog[19] = new DIALOG("d_rtext_proc", 636, 80, 0, 0, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("<-d_icon_proc"), NULL, NULL); ///* a menu bar - note how it auto-calculates its dimension if they are not given */ the_dialog[20] = new DIALOG("d_menu_proc", 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, the_menu, NULL, NULL); ///* some more GUI elements, all of which require you to specify their dimensions */ the_dialog[21] = new DIALOG("d_button_proc", 160, 40, 160, 20, 0, 0, 't', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Toggle Me!"), NULL, NULL); the_dialog[22] = new DIALOG("d_check_proc", 160, 70, 160, 20, 0, 0, 'c', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Check Me!"), NULL, NULL); the_dialog[23] = new DIALOG("d_radio_proc", 160, 100, 160, 19, 0, 0, 's', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Select Me!"), NULL, NULL); the_dialog[24] = new DIALOG("d_radio_proc", 320, 100, 160, 19, 0, 0, 'o', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Or Me!"), NULL, NULL); the_dialog[25] = new DIALOG("d_edit_proc", 160, 130, 160, 8, 0, 0, 0, 0, LEN, 0, Marshal.StringToCoTaskMemAnsi(the_string), NULL, NULL); the_dialog[26] = new DIALOG("d_list_proc", 160, 150, 160, 44, 0, 0, 0, 0, 0, 0, Marshal.GetFunctionPointerForDelegate(d_listbox_getter), sel, NULL); the_dialog[27] = new DIALOG("d_text_list_proc", 160, 200, 160, 44, 0, 0, 0, 0, 0, 0, Marshal.GetFunctionPointerForDelegate(d_listbox_getter), NULL, NULL); the_dialog[28] = new DIALOG("d_textbox_proc", 160, 250, 160, 48, 0, 0, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi(the_text), NULL, NULL); the_dialog[29] = new DIALOG("d_slider_proc", 160, 300, 160, 12, 0, 0, 0, 0, 100, 0, NULL, NULL, NULL); the_dialog[30] = new DIALOG("d_box_proc", 160, 330, 160, 20, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); the_dialog[31] = new DIALOG("d_shadow_box_proc", 160, 360, 160, 20, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); ///* note how we don't fill in the dp field yet, because we first need to load the bitmap */ the_dialog[32] = new DIALOG("d_bitmap_proc", 480, 40, 30, 30, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); the_dialog[33] = new DIALOG("d_icon_proc", 480, 80, 30, 30, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); ///* the quit and info buttons use our customized dialog procedure, using dp3 as callback */ the_dialog[34] = new DIALOG(d_my_button_proc, 0, 450, 160, 20, 0, 0, 'q', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("&Quit"), NULL, Marshal.GetFunctionPointerForDelegate(d_quit)); the_dialog[35] = new DIALOG(d_my_button_proc, 400, 150, 160, 20, 0, 0, 'i', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("&Info"), NULL, Marshal.GetFunctionPointerForDelegate(d_info1)); the_dialog[36] = new DIALOG(d_my_button_proc, 400, 200, 160, 20, 0, 0, 'n', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("I&nfo"), NULL, Marshal.GetFunctionPointerForDelegate(d_info2)); the_dialog[37] = new DIALOG(d_my_button_proc, 400, 300, 160, 20, 0, 0, 'f', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("In&fo"), NULL, Marshal.GetFunctionPointerForDelegate(d_info3)); ///* the next two elements don't draw anything */ the_dialog[38] = new DIALOG("d_keyboard_proc", 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, Marshal.GetFunctionPointerForDelegate(d_about), NULL, NULL); the_dialog[39] = new DIALOG("d_yield_proc", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); the_dialog[the_dialog.Length - 1] = new DIALOG(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); //char buf[256]; byte[] buf = new byte[256]; int i; /* initialise everything */ if (allegro_init() != 0) { return(1); } install_keyboard(); install_mouse(); install_timer(); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message(string.Format("Unable to set any graphic mode\n{0}\n", allegro_error)); return(1); } } /* load the datafile */ //replace_filename(buf, argv[0], "example.dat", sizeof(buf)); //datafile = load_datafile(buf); replace_filename(buf, "./", "example.dat", buf.Length); datafile = load_datafile(Encoding.ASCII.GetString(buf)); if (!datafile) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message(string.Format("Error loading {0}!\n", buf)); return(1); } set_palette(datafile[THE_PALETTE].dat); /* set up colors */ gui_fg_color = makecol(0, 0, 0); gui_mg_color = makecol(128, 128, 128); gui_bg_color = makecol(200, 240, 200); set_dialog_color(the_dialog, gui_fg_color, gui_bg_color); /* white color for d_clear_proc and the d_?text_procs */ the_dialog[0].bg = makecol(255, 255, 255); for (i = 4; the_dialog[i].proc != NULL; i++) { if (the_dialog[i].proc == GetAddress("d_text_proc") || the_dialog[i].proc == GetAddress("d_ctext_proc") || the_dialog[i].proc == GetAddress("d_rtext_proc")) { the_dialog[i].bg = the_dialog[0].bg; } } /* fill in bitmap pointers */ the_dialog[BITMAP_OBJECT].dp = datafile[SILLY_BITMAP].dat; the_dialog[ICON_OBJECT].dp = datafile[SILLY_BITMAP].dat; /* shift the dialog 2 pixels away from the border */ position_dialog(the_dialog, 2, 2); /* do the dialog */ do_dialog(the_dialog, -1); unload_datafile(datafile); return(0); }
static int Main() { //IntPtr _colors = new Marshal.AllocCoTaskMem(6 * sizeof(Int32)); _colors[0].WriteInt(0, 255); _colors[1].WriteInt(0, 255); _colors[2].WriteInt(0, 255); _colors[3].WriteInt(0, 0); _colors[4].WriteInt(0, 0); _colors[5].WriteInt(0, 255); the_dlg[0] = new DIALOG(d_my_slider_proc, 32, 16, 256, 16, 0, 255, 0, 0, 255, 0, NULL, Marshal.GetFunctionPointerForDelegate(d_update_color_value), _colors[S_R]); the_dlg[1] = new DIALOG(d_my_slider_proc, 32, 64, 256, 16, 0, 255, 0, 0, 255, 0, NULL, Marshal.GetFunctionPointerForDelegate(d_update_color_value), _colors[S_G]); the_dlg[2] = new DIALOG(d_my_slider_proc, 32, 112, 256, 16, 0, 255, 0, 0, 255, 0, NULL, Marshal.GetFunctionPointerForDelegate(d_update_color_value), _colors[S_B]); the_dlg[3] = new DIALOG(d_my_slider_proc, 352, 336, 256, 16, 0, 255, 0, 0, 255, 0, NULL, Marshal.GetFunctionPointerForDelegate(d_update_color_value), _colors[S_H]); the_dlg[4] = new DIALOG(d_my_slider_proc, 352, 384, 256, 16, 0, 255, 0, 0, 255, 0, NULL, Marshal.GetFunctionPointerForDelegate(d_update_color_value), _colors[S_S]); the_dlg[5] = new DIALOG(d_my_slider_proc, 352, 432, 256, 16, 0, 255, 0, 0, 255, 0, NULL, Marshal.GetFunctionPointerForDelegate(d_update_color_value), _colors[S_V]); the_dlg[6] = new DIALOG("d_text_proc", 308, 22, 0, 0, 0, 255, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("R"), NULL, NULL); the_dlg[7] = new DIALOG("d_text_proc", 308, 70, 0, 0, 0, 255, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("G"), NULL, NULL); the_dlg[8] = new DIALOG("d_text_proc", 308, 118, 0, 0, 0, 255, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("B"), NULL, NULL); the_dlg[9] = new DIALOG("d_text_proc", 326, 342, 0, 0, 0, 255, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("H"), NULL, NULL); the_dlg[10] = new DIALOG("d_text_proc", 326, 390, 0, 0, 0, 255, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("S"), NULL, NULL); the_dlg[11] = new DIALOG("d_text_proc", 326, 438, 0, 0, 0, 255, 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("V"), NULL, NULL); the_dlg[12] = new DIALOG("d_bitmap_proc", 32, 32, 256, 16, 0, 255, 0, 0, 0, 0, NULL, NULL, NULL); the_dlg[13] = new DIALOG("d_bitmap_proc", 32, 80, 256, 16, 0, 255, 0, 0, 0, 0, NULL, NULL, NULL); the_dlg[14] = new DIALOG("d_bitmap_proc", 32, 128, 256, 16, 0, 255, 0, 0, 0, 0, NULL, NULL, NULL); the_dlg[15] = new DIALOG("d_bitmap_proc", 352, 352, 256, 16, 0, 255, 0, 0, 0, 0, NULL, NULL, NULL); the_dlg[16] = new DIALOG("d_bitmap_proc", 352, 400, 256, 16, 0, 255, 0, 0, 0, 0, NULL, NULL, NULL); the_dlg[17] = new DIALOG("d_bitmap_proc", 352, 448, 256, 16, 0, 255, 0, 0, 0, 0, NULL, NULL, NULL); the_dlg[18] = new DIALOG("d_box_proc", 170, 170, 300, 140, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); the_dlg[19] = new DIALOG(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); int i; if (allegro_init() != 0) { return(1); } install_keyboard(); install_mouse(); install_timer(); /* Set the deepest color depth we can set */ set_color_depth(32); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { set_color_depth(24); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { set_color_depth(16); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { set_color_depth(15); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { set_color_depth(8); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) { allegro_message(string.Format("Error setting a graphics mode\n{0}\n", allegro_error)); return(1); } } } } } /* In the case we're using an 8-bit color screen, we must set up the palette */ if (get_color_depth() == 8) { PALETTE pal332 = new PALETTE(); generate_332_palette(pal332); /* Set the palette to the best approximation of a truecolor palette * we can get with 8-bit color */ set_palette(pal332); /* In 8-bit color mode, if there's an RGB table, the sliders * will move a lot more smoothly and the updating will be * a lot quicker. But if there's no RGB table, this has the * advantage that the color conversion routines will take into * account any changes in the background color. Instead of * changing background color, we could also rely on the colored * rectangle like in the other color modes, but using the 3-3-2 * palette, this doesn't display the color as accurately as * changing the background color. */ #if ZERO /* Create an RGB table to speedup makecol8() */ create_rgb_table(&rgb_table, pal332, NULL); rgb_map = &rgb_table; #endif } clear_to_color(screen, makecol(255, 255, 255)); /* color the dialog controls appropriately */ /* R -> Red */ the_dlg[S_R].fg = the_dlg[DIALOG_NUM_SLIDERS + S_R].fg = makecol(255, 0, 0); /* G -> Green */ the_dlg[S_G].fg = the_dlg[DIALOG_NUM_SLIDERS + S_G].fg = makecol(0, 255, 0); /* B -> Blue */ the_dlg[S_B].fg = the_dlg[DIALOG_NUM_SLIDERS + S_B].fg = makecol(0, 0, 255); /* H -> Grey */ the_dlg[S_H].fg = the_dlg[DIALOG_NUM_SLIDERS + S_H].fg = makecol(192, 192, 192); /* S -> Dark Grey */ the_dlg[S_S].fg = the_dlg[DIALOG_NUM_SLIDERS + S_S].fg = makecol(128, 128, 128); /* V -> Black */ the_dlg[S_V].fg = the_dlg[DIALOG_NUM_SLIDERS + S_V].fg = makecol(0, 0, 0); /* Create the bitmaps for the color-bars */ for (i = 0; i < DIALOG_NUM_SLIDERS; i++) { if (!(color_bar_bitmap[i] = create_bitmap_ex(32, 256, 16))) { allegro_message("Error creating a color-bar bitmap\n"); return(1); } the_dlg[DIALOG_FIRST_COLOR_BAR + i].dp = color_bar_bitmap[i]; } for (i = 0; i < DIALOG_NUM_SLIDERS * 3; i++) { the_dlg[i].bg = makecol(255, 255, 255); } the_dlg[DIALOG_COLOR_BOX].fg = makecol(0, 0, 0); textout_ex(screen, font, "RGB<->HSV color spaces example.", 344, 4, makecol(0, 0, 0), -1); textout_ex(screen, font, "Drag sliders to change color values.", 344, 12, makecol(0, 0, 0), -1); textout_ex(screen, font, "The color-bars beneath the sliders", 24, 384, makecol(128, 128, 128), -1); textout_ex(screen, font, "show what the resulting color will", 24, 392, makecol(128, 128, 128), -1); textout_ex(screen, font, "look like when the slider is", 24, 400, makecol(128, 128, 128), -1); textout_ex(screen, font, "dragged to that position.", 24, 408, makecol(128, 128, 128), -1); switch (get_color_depth()) { case 32: textout_ex(screen, font, "Running in truecolor (32-bit 888)", 352, 24, makecol(128, 128, 128), -1); textout_ex(screen, font, "16777216 colors", 352, 32, makecol(128, 128, 128), -1); break; case 24: textout_ex(screen, font, "Running in truecolor (24-bit 888)", 352, 24, makecol(128, 128, 128), -1); textout_ex(screen, font, "16777216 colors", 352, 32, makecol(128, 128, 128), -1); break; case 16: textout_ex(screen, font, "Running in hicolor (16-bit 565)", 352, 24, makecol(128, 128, 128), -1); textout_ex(screen, font, "65536 colors", 352, 32, makecol(128, 128, 128), -1); break; case 15: textout_ex(screen, font, "Running in hicolor (15-bit 555)", 352, 24, makecol(128, 128, 128), -1); textout_ex(screen, font, "32768 colors", 352, 32, makecol(128, 128, 128), -1); break; case 8: textout_ex(screen, font, "Running in paletted mode (8-bit 332)", 352, 24, makecol(128, 128, 128), -1); textout_ex(screen, font, "256 colors", 352, 32, makecol(128, 128, 128), -1); break; default: textout_ex(screen, font, "Unknown color depth", 400, 16, 0, -1); break; } update_color_rectangle(colors[S_R], colors[S_G], colors[S_B]); update_color_bars(colors[S_R], colors[S_G], colors[S_B], colors[S_H] * 360.0f / 255.0f, colors[S_S] / 255.0f, colors[S_V] / 255.0f); do_dialog(the_dlg, -1); for (i = 0; i < DIALOG_NUM_SLIDERS; i++) { destroy_bitmap(color_bar_bitmap[i]); } return(0); }
static int Main(string[] argv) { /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */ the_dialog[0] = new DIALOG("d_clear_proc", 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, NULL, NULL, NULL); the_dialog[1] = new DIALOG("d_edit_proc", 12, 82, 256, 48, 255, 0, 0, 0, LEN, 0, Marshal.StringToCoTaskMemAnsi(the_string), NULL, NULL); the_dialog[2] = new DIALOG("d_check_proc", 12, 12, 161, 49, 255, 0, 't', 0, 0, 0, Marshal.StringToCoTaskMemAnsi("&Toggle Me"), NULL, NULL); the_dialog[3] = new DIALOG(d_clock_proc, 242, 12, 64, 64, 255, 0, 0, 0, 0, 0, NULL, NULL, NULL); the_dialog[4] = new DIALOG(d_change_font_proc, 12, 142, 141, 49, 255, 0, 'f', D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("Change &Font"), NULL, NULL); the_dialog[5] = new DIALOG("d_button_proc", 162, 142, 141, 49, 255, 0, 0, D_EXIT, 0, 0, Marshal.StringToCoTaskMemAnsi("Exit"), NULL, NULL); the_dialog[6] = new DIALOG(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); int item; //char buf[256]; byte[] buf = new byte[256]; if (allegro_init() != 0) { return(1); } install_keyboard(); install_mouse(); install_timer(); if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) { if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message(string.Format("Unable to set any graphic mode\n{0}\n", allegro_error)); return(1); } } set_palette(desktop_palette); /* We set up colors to match screen color depth (in case it changed) */ //for (item = 0; the_dialog[item].proc; item++) { for (item = 0; item < the_dialog.Length - 1; item++) { the_dialog[item].fg = makecol(0, 0, 0); the_dialog[item].bg = makecol(255, 255, 255); } /* load the datafile */ //replace_filename(buf, argv[0], "example.dat", sizeof(buf)); replace_filename(buf, "./", "example.dat", buf.Length); //datafile = load_datafile(buf); datafile = load_datafile(Encoding.ASCII.GetString(buf)); if (!datafile) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message(string.Format("Error loading {0}!\n", buf)); return(1); } /* store a copy of the default font */ original_font = font; do_dialog(the_dialog, -1); unload_datafile(datafile); return(0); }
/* custom dialog procedure for the clock object */ static int clock_proc(int msg, IntPtr _d, int c) { DIALOG d = (DIALOG)_d; //time_t current_time; //struct tm *t; tm t; BITMAP temp; int angle, x, y; /* process the message */ switch (msg) { /* initialise when we get a start message */ case MSG_START: /* store the current time */ //current_time = time(NULL); //t = localtime(¤t_time); //the_time = *t; t = new tm(DateTime.Now); the_time = new tm(DateTime.Now); /* draw the clock background onto a memory bitmap */ temp = create_bitmap(d.w, d.h); clear_to_color(temp, d.bg); /* draw borders and a nobble in the middle */ circle(temp, temp.w / 2, temp.h / 2, temp.w / 2 - 1, d.fg); circlefill(temp, temp.w / 2, temp.h / 2, 2, d.fg); /* draw ticks around the edge */ for (angle = 0; angle < itofix(256); angle += itofix(256) / 12) { x = fixcos(angle); y = fixsin(angle); line(temp, temp.w / 2 + fixtoi(x * temp.w * 15 / 32), temp.h / 2 + fixtoi(y * temp.w * 15 / 32), temp.w / 2 + fixtoi(x * temp.w / 2), temp.h / 2 + fixtoi(y * temp.w / 2), d.fg); } /* store the clock background bitmap in d.dp */ d.dp = temp; break; /* shutdown when we get an end message */ case MSG_END: /* destroy the clock background bitmap */ destroy_bitmap(d.dp); break; /* update the clock in response to idle messages */ case MSG_IDLE: /* read the current time */ //current_time = time(NULL); //t = localtime(¤t_time); t = new tm(DateTime.Now); ///* check if it has changed */ if ((the_time.tm_sec != t.tm_sec) || (the_time.tm_min != t.tm_min) || (the_time.tm_hour != t.tm_hour)) { // the_time = *t; the_time = t; /* Redraw ourselves if the time has changed. Note that the dialog * manager automatically turns off the mouse pointer whenever a * MSG_DRAW message is sent to an individual object or an entire * dialog, so we don't have to do it explicitly. Also note the use * of the object_message function rather than a simple recursive * call to clock_proc(). This vectors the call through the function * pointer in the dialog object, which allows other object * procedures to hook it, for example a different type of clock * could process the draw messages itself but pass idle messages * on to this procedure. */ object_message(d, MSG_DRAW, 0); } break; /* draw the clock in response to draw messages */ case MSG_DRAW: /* draw onto a temporary memory bitmap to prevent flicker */ temp = create_bitmap(d.w, d.h); /* copy the clock background onto the temporary bitmap */ blit(d.dp, temp, 0, 0, 0, 0, d.w, d.h); /* draw the hands */ draw_hand(temp, the_time.tm_sec, 60, 0, 1, itofix(9) / 10, d.fg); draw_hand(temp, the_time.tm_min, 60, the_time.tm_sec, 60, itofix(5) / 6, d.fg); draw_hand(temp, the_time.tm_hour, 12, the_time.tm_min, 60, itofix(1) / 2, d.fg); /* copy the temporary bitmap onto the screen */ blit(temp, screen, 0, 0, d.x, d.y, d.w, d.h); destroy_bitmap(temp); break; } /* always return OK status, since the clock doesn't ever need to close * the dialog or get the input focus. */ return(D_O_K); }
public static void Gui() { BITMAP buffer = create_bitmap(SCREEN_W, SCREEN_H); //gui_set_screen(buffer); //alert("CONFIG_FILE", "not found.", "Using defaults.", "&Continue", null, (int)'c', 0); BITMAP bmp1 = create_bitmap(180, 80); clear_to_color(bmp1, makecol(10, 10, 10)); line(bmp1, 0, 0, 180, 80, makecol(128, 128, 128)); line(bmp1, 180, 0, 0, 80, makecol(128, 128, 128)); BITMAP bmp2 = create_bitmap(20, 20); clear_to_color(bmp2, makecol(0, 0, 0)); circle(bmp2, 10, 10, 10, makecol(255, 0, 0)); DIALOG test_dialog = new DIALOG(d_test_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); //test_dialog.flags = D_HIDDEN; //object_message(test_dialog, MSG_START, 0); //return; //GCHandle handle = GCHandle.Alloc(d_test_proc, GCHandleType.Pinned); int ret = 0; //DIALOG d = new DIALOG(d_slider_proc, 0, 0, 0, 0, 0, 0, 0, 0, 100, 20, NULL, NULL, NULL); //DIALOG d = new DIALOG(d_slider_proc, 32, 16, 256, 16, 0, 255, 0, 0, 255, 0, NULL, NULL, NULL); //int ret = d_slider_proc(4, d, 1); //return; DIALOGS the_dialog = new DIALOGS(2); //the_dialog[0] = new DIALOG("d_clear_proc", 0, 0, 0, 0, 0, makecol(255, 255, 255), 0, 0, 0, 0, NULL, NULL, NULL); //the_dialog[1] = new DIALOG("d_box_proc", 10, 10, 180, 80, makecol(0, 255, 0), makecol(255, 0, 255), 0, 0, 0, 0, NULL, NULL, NULL); //the_dialog[2] = new DIALOG("d_shadow_box_proc", 20, 20, 180, 80, makecol(0, 0, 255), makecol(0, 255, 255), 0, 0, 0, 0, NULL, NULL, NULL); //the_dialog[3] = new DIALOG("d_bitmap_proc", 30, 30, 180, 80, 0, 0, 0, 0, 0, 0, bmp1, NULL, NULL); //the_dialog[4] = new DIALOG("d_text_proc", 10, 120, 180, 20, 0, makecol(255, 255, 255), 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("I guess this is text"), NULL, NULL); //the_dialog[5] = new DIALOG("d_ctext_proc", 10, 140, 180, 20, 0, makecol(255, 255, 255), 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("Centered"), NULL, NULL); //the_dialog[6] = new DIALOG("d_rtext_proc", 10, 160, 180, 20, 0, makecol(255, 255, 255), 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("Right"), NULL, NULL); //the_dialog[7] = new DIALOG("d_button_proc", 10, 180, 100, 20, makecol(255, 0, 0), makecol(0, 0, 255), 0, 0, 0, 0, Marshal.StringToCoTaskMemAnsi("Push me"), NULL, NULL); //the_dialog[8] = new DIALOG("d_check_proc", 10, 200, 100, 20, 0, makecol(255, 255, 255), 0, D_SELECTED, 0, 0, Marshal.StringToCoTaskMemAnsi("&Check me"), NULL, NULL); //the_dialog[9] = new DIALOG("d_radio_proc", 10, 220, 100, 20, 0, makecol(255, 255, 255), 0, D_SELECTED, 1, 0, Marshal.StringToCoTaskMemAnsi("Radio1"), NULL, NULL); //the_dialog[10] = new DIALOG("d_radio_proc", 110, 220, 100, 20, 0, makecol(255, 255, 255), 0, 0, 1, 1, Marshal.StringToCoTaskMemAnsi("Radio2"), NULL, NULL); //the_dialog[11] = new DIALOG("d_icon_proc", 10, 240, 20, 20, 0, makecol(255, 255, 255), 0, 0, 1, 1, bmp2, NULL, NULL); //the_dialog[12] = new DIALOG("d_keyboard_proc", 0, 0, 0, 0, 0, 0, (int)'a', 0, 0, 0, NULL, NULL, NULL); //the_dialog[13] = new DIALOG("d_edit_proc", 10, 280, 100, 20, 0, makecol(255, 255, 255), 0, 0, 20, "Edit me".Length, Marshal.StringToCoTaskMemAnsi("Edit me"), NULL, NULL); the_dialog[0] = new DIALOG("d_list_proc", 0, 0, 200, 20, 0, makecol(255, 255, 255), 1, 1, 1, 1, Marshal.GetFunctionPointerForDelegate(d_foobar), NULL, NULL); //the_dialog[0].proc = Marshal.GetFunctionPointerForDelegate(d_test_proc); the_dialog[the_dialog.Length - 1] = new DIALOG(NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL); DIALOG_PLAYER player = NULL; player = init_dialog(the_dialog, -1); while (update_dialog(player) > 0) { ; } int shutodown = shutdown_dialog(player); ret = do_dialog(the_dialog, -1); //init_dialog(the_dialog, -1); //d_test_proc(MSG_DRAW, d2, 0); //handle.Free(); readkey(); return; }