void PhotoPreview::Redraw() { Glib::RefPtr<Gdk::Window> Window=get_window(); if (Window) Window->invalidate_rect(Gdk::Rectangle(0,0,get_width(),get_height()),1); }
int main(int argc, char* argv[]){ char* action; Window window; int arg[5]={0}; // Connexion à un serveur X display = XOpenDisplay(NULL); if(!display){ printf("Can not open display.\n"); exit(EXIT_FAILURE); } // Récupère la valeur par default des différentes variables. screen = DefaultScreen(display); gc = DefaultGC (display, screen); root = RootWindow (display, screen); // Détermine l'action à effectuer : // On vérifie que le 2er argument (autre que nom fichier) est un id de fenetre : if(argc>2 && ((!strncmp(argv[2],"0x",2) && strtoll(argv[2],NULL,16)) || strtoll(argv[2],NULL,10)) ){ action = argv[1]; window = get_window(argv); // Si 5 arguments, c'est soit un move, soit un resize: if (argc==3){ // 1 seul argument (ex: 0x32422 ) if(!strcmp(action,"mapRaise")) do_map_and_raise(window); else if(!strcmp(action,"map")) do_map(window); else if(!strcmp(action,"raise")) do_raise(window); else if(!strcmp(action,"destroy")) do_destroy(window); else if(!strcmp(action,"focus")) do_focus(window); else if(!strcmp(action,"minimize")) do_minimize(window); else if(!strcmp(action,"set_desktop")) set_desktop((int)strtoll(argv[2],NULL,10)); else fail(); } else if(argc==4){ // 2 arguments (ex : 0x4242535 1 ) if(!strcmp(action,"set_desktop_for_window")){ set_desktop(strtoll(argv[3],NULL,10)); set_desktop_for_window(window,strtoll(argv[3],NULL,10)); } else if(!strcmp(action,"set_viewport")) set_viewport((int)strtoll(argv[2],NULL,10),(int)strtoll(argv[3],NULL,10)); else fail(); } else if(argc==5){ arg[0]=(int)strtoll(argv[3],NULL,10); arg[1]=(int)strtoll(argv[4],NULL,10); if(!strcmp(action,"move")) do_move(window, arg[0], arg[1]); else if(!strcmp(action,"resize")) do_resize(window,arg[0],arg[1]); else fail(); } else if(argc==7){ arg[0]=(int)strtoll(argv[3],NULL,10); arg[1]=(int)strtoll(argv[4],NULL,10); arg[2]=(int)strtoll(argv[5],NULL,10); arg[3]=(int)strtoll(argv[6],NULL,10); if(!strcmp(action,"moveResize")) do_move_and_resize(window, arg[0], arg[1], arg[2], arg[3]); else fail(); } else fail(); } else fail(); XCloseDisplay(display); return EXIT_SUCCESS; }
static int perform_graphics_task(aroop_txt_t*msg, int*offset, int*cur_key, int*cur_type, int*cur_len, x11_window_t**gwin) { // check the task .. int cmd = msg_numeric_value(msg, offset, cur_type, cur_len); x11_window_t*win = *gwin; switch(cmd) { case ENUM_ROOPKOTHA_GRAPHICS_TASKS_DRAW_IMAGE: { SYNC_ASSERT(msg_next(msg, offset, cur_key, cur_type, cur_len) != -1); SYNC_ASSERT(*cur_key == ENUM_ROOPKOTHA_GUI_CORE_TASK_ARG); aroop_txt_t img_data; msg_binary_value(msg, offset, cur_type, cur_len, &img_data); unsigned int x,y,anc; msg_scan(msg, offset, cur_key, cur_type, cur_len, 3, &x, &y, &anc); break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_DRAW_LINE: { unsigned int x1,x2,y1,y2; msg_scan(msg, offset, cur_key, cur_type, cur_len, 4, &x1, &y1, &x2, &y2); if(win) { XDrawLine (gcore.disp, win->w, win->gc, x1, y1, x2, y2); } break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_DRAW_RECT: { unsigned int x,y,width,height; msg_scan(msg, offset, cur_key, cur_type, cur_len, 4, &x, &y, &width, &height); if(win) { XDrawRectangle (gcore.disp, win->w, win->gc, x, y, width, height); } break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_DRAW_ROUND_RECT: { int x,y,width,height,arcWidth,arcHeight; msg_scan(msg, offset, cur_key, cur_type, cur_len, 6, &x, &y, &width, &height, &arcWidth, &arcHeight); if(win) { XDrawRectangle (gcore.disp, win->w,win->gc, x, y, width, height); } break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_FILL_RECT: { unsigned int x,y,width,height; msg_scan(msg, offset, cur_key, cur_type, cur_len, 4, &x, &y, &width, &height); if(win) { XFillRectangle (gcore.disp, win->w,win->gc, x, y, width, height); } break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_FILL_ROUND_RECT: { int x,y,width,height,arcWidth,arcHeight; msg_scan(msg, offset, cur_key, cur_type, cur_len, 6, &x, &y, &width, &height, &arcWidth, &arcHeight); if(win) { XFillRectangle (gcore.disp, win->w,win->gc, x, y, width, height); } break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_FILL_TRIANGLE: { int x1,y1,x2,y2,x3,y3; msg_scan(msg, offset, cur_key, cur_type, cur_len, 6, &x1, &y1, &x2, &y2, &x3, &y3); // TODO draw line break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_DRAW_STRING: { SYNC_ASSERT(msg_next(msg, offset, cur_key, cur_type, cur_len) != -1); SYNC_ASSERT(*cur_key == ENUM_ROOPKOTHA_GUI_CORE_TASK_ARG); aroop_txt_t content; msg_string_value(msg, offset, cur_type, cur_len, &content); int x,y,width,height,anc; msg_scan(msg, offset, cur_key, cur_type, cur_len, 5, &x, &y, &width, &height, &anc); if(!win) { break; } int xpos = x; if(anc & ENUM_ROOPKOTHA_GRAPHICS_ANCHOR_RIGHT) { xpos = x+width-5*content.len; } int ypos = y+10; if(anc & ENUM_ROOPKOTHA_GRAPHICS_ANCHOR_BOTTOM) { ypos = y+height; } XDrawString (gcore.disp, win->w,win->gc, xpos, ypos, aroop_txt_to_string(&content), content.len); break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_SET_COLOR: // TODO abolish this task { SYNC_ASSERT(msg_next(msg, offset, cur_key, cur_type, cur_len) != -1); SYNC_ASSERT(*cur_key == ENUM_ROOPKOTHA_GUI_CORE_TASK_ARG); unsigned int rgb = msg_numeric_value(msg, offset, cur_type, cur_len); if(!win) { break; } Colormap colormap; colormap = DefaultColormap(gcore.disp, gcore.scrn); XColor rgbc; #define RGBC rgbc //#define RGBC gcore.rgbc unsigned char red = ((rgb & 0XFF0000)>>16) & 0xFF; unsigned char green = ((rgb & 0XFF00)>>8) & 0xFF; unsigned char blue = rgb & 0XFF; char spec[32]; snprintf(spec, 32, "#%02x%02x%02x", red, green, blue); XParseColor (gcore.disp, colormap, spec, &RGBC); XAllocColor(gcore.disp, colormap, &RGBC); // TODO free color ! XSetForeground (gcore.disp, win->gc, RGBC.pixel); break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_SET_FONT: // TODO abolish this task { SYNC_ASSERT(msg_next(msg, offset, cur_key, cur_type, cur_len) != -1); SYNC_ASSERT(*cur_key == ENUM_ROOPKOTHA_GUI_CORE_TASK_ARG); int fontid = msg_numeric_value(msg, offset, cur_type, cur_len); // TODO set font break; } case ENUM_ROOPKOTHA_GRAPHICS_TASKS_START_LAYER: { int wid,layer; msg_scan(msg, offset, cur_key, cur_type, cur_len, 2, &wid, &layer); win = get_window(wid); *gwin = win; // save the layer aroop_txt_t*oldTasks = opp_indexed_list_get(&gcore.layers, layer); if(oldTasks != msg) { opp_indexed_list_set(&gcore.layers, layer, msg); } if(oldTasks) { aroop_object_unref(aroop_txt_t*,0,oldTasks); } break; } } return 0; }
SANE_Status sane_start (SANE_Handle handle) { char *mode_str; Ricoh_Scanner *s = handle; SANE_Status status; struct ricoh_window_data wbuf; struct measurements_units_page mup; DBG (11, ">> sane_start\n"); /* First make sure we have a current parameter set. Some of the parameters will be overwritten below, but that's OK. */ status = sane_get_parameters (s, 0); if (status != SANE_STATUS_GOOD) return status; status = sanei_scsi_open (s->hw->sane.name, &s->fd, 0, 0); if (status != SANE_STATUS_GOOD) { DBG (1, "open of %s failed: %s\n", s->hw->sane.name, sane_strstatus (status)); return (status); } mode_str = s->val[OPT_MODE].s; s->xres = s->val[OPT_X_RESOLUTION].w; s->yres = s->val[OPT_Y_RESOLUTION].w; s->ulx = s->val[OPT_TL_X].w; s->uly = s->val[OPT_TL_Y].w; s->width = s->val[OPT_BR_X].w - s->val[OPT_TL_X].w; s->length = s->val[OPT_BR_Y].w - s->val[OPT_TL_Y].w; s->brightness = s->val[OPT_BRIGHTNESS].w; s->contrast = s->val[OPT_CONTRAST].w; s->bpp = s->params.depth; if (strcmp (mode_str, SANE_VALUE_SCAN_MODE_LINEART) == 0) { s->image_composition = RICOH_BINARY_MONOCHROME; } else if (strcmp (mode_str, SANE_VALUE_SCAN_MODE_HALFTONE) == 0) { s->image_composition = RICOH_DITHERED_MONOCHROME; } else if (strcmp (mode_str, SANE_VALUE_SCAN_MODE_GRAY) == 0) { s->image_composition = RICOH_GRAYSCALE; } memset (&wbuf, 0, sizeof (wbuf)); _lto2b(sizeof(wbuf) - 8, wbuf.len); _lto2b(s->xres, wbuf.x_res); _lto2b(s->yres, wbuf.y_res); _lto4b(s->ulx, wbuf.x_org); _lto4b(s->uly, wbuf.y_org); _lto4b(s->width, wbuf.width); _lto4b(s->length, wbuf.length); wbuf.image_comp = s->image_composition; /* if you throw the MRIF bit the brighness control reverses too */ /* so I reverse the reversal in software for symmetry's sake */ if (wbuf.image_comp == RICOH_GRAYSCALE || wbuf.image_comp == RICOH_DITHERED_MONOCHROME) { if (wbuf.image_comp == RICOH_GRAYSCALE) wbuf.mrif_filtering_gamma_id = (SANE_Byte) 0x90; if (wbuf.image_comp == RICOH_DITHERED_MONOCHROME) wbuf.mrif_filtering_gamma_id = (SANE_Byte) 0x10; wbuf.brightness = 256 - (SANE_Byte) s->brightness; if (is50) wbuf.contrast = (SANE_Byte) s->contrast; else wbuf.contrast = 256 - (SANE_Byte) s->contrast; } else /* wbuf.image_comp == RICOH_BINARY_MONOCHROME */ { wbuf.mrif_filtering_gamma_id = (SANE_Byte) 0x00; wbuf.brightness = (SANE_Byte) s->brightness; wbuf.contrast = (SANE_Byte) s->contrast; } wbuf.threshold = 0; wbuf.bits_per_pixel = s->bpp; wbuf.halftone_pattern[0] = 2; wbuf.halftone_pattern[1] = 0; wbuf.pad_type = 3; wbuf.bit_ordering[0] = 0; wbuf.bit_ordering[1] = 3; DBG (5, "xres=%d\n", _2btol(wbuf.x_res)); DBG (5, "yres=%d\n", _2btol(wbuf.y_res)); DBG (5, "ulx=%d\n", _4btol(wbuf.x_org)); DBG (5, "uly=%d\n", _4btol(wbuf.y_org)); DBG (5, "width=%d\n", _4btol(wbuf.width)); DBG (5, "length=%d\n", _4btol(wbuf.length)); DBG (5, "image_comp=%d\n", wbuf.image_comp); DBG (11, "sane_start: sending SET WINDOW\n"); status = set_window (s->fd, &wbuf); if (status != SANE_STATUS_GOOD) { DBG (1, "SET WINDOW failed: %s\n", sane_strstatus (status)); return (status); } DBG (11, "sane_start: sending GET WINDOW\n"); memset (&wbuf, 0, sizeof (wbuf)); status = get_window (s->fd, &wbuf); if (status != SANE_STATUS_GOOD) { DBG (1, "GET WINDOW failed: %s\n", sane_strstatus (status)); return (status); } DBG (5, "xres=%d\n", _2btol(wbuf.x_res)); DBG (5, "yres=%d\n", _2btol(wbuf.y_res)); DBG (5, "ulx=%d\n", _4btol(wbuf.x_org)); DBG (5, "uly=%d\n", _4btol(wbuf.y_org)); DBG (5, "width=%d\n", _4btol(wbuf.width)); DBG (5, "length=%d\n", _4btol(wbuf.length)); DBG (5, "image_comp=%d\n", wbuf.image_comp); DBG (11, "sane_start: sending MODE SELECT\n"); memset (&mup, 0, sizeof (mup)); mup.page_code = MEASUREMENTS_PAGE; mup.parameter_length = 0x06; mup.bmu = INCHES; mup.mud[0] = (DEFAULT_MUD >> 8) & 0xff; mup.mud[1] = (DEFAULT_MUD & 0xff); status = mode_select (s->fd, (struct mode_pages *) &mup); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: MODE_SELECT failed\n"); return (SANE_STATUS_INVAL); } status = trigger_scan (s->fd); if (status != SANE_STATUS_GOOD) { DBG (1, "start of scan failed: %s\n", sane_strstatus (status)); return (status); } /* Wait for scanner to become ready to transmit data */ status = ricoh_wait_ready (s); if (status != SANE_STATUS_GOOD) { DBG (1, "GET DATA STATUS failed: %s\n", sane_strstatus (status)); return (status); } s->bytes_to_read = s->params.bytes_per_line * s->params.lines; DBG (1, "%d pixels per line, %d bytes, %d lines high, total %lu bytes, " "dpi=%d\n", s->params.pixels_per_line, s->params.bytes_per_line, s->params.lines, (u_long) s->bytes_to_read, s->val[OPT_Y_RESOLUTION].w); s->scanning = SANE_TRUE; DBG (11, "<< sane_start\n"); return (SANE_STATUS_GOOD); }
void BugzillaNoteAddin::on_note_opened() { get_window()->editor()->signal_drag_data_received().connect( sigc::mem_fun(*this, &BugzillaNoteAddin::on_drag_data_received), false); }
bool knob::on_expose_event(GdkEventExpose* event) { // This is where we draw on the window Glib::RefPtr<Gdk::Window> window = get_window(); if(window) { Gtk::Allocation allocation = get_allocation(); const int width = allocation.get_width(); const int height = allocation.get_height() - (allocation.get_height()/3); const int height_offset = allocation.get_height()/6; // coordinates for the center of the window int xc, yc; xc = width / 2; yc = height / 2; Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context(); cr->set_line_width(6.0); // clip to the area indicated by the expose event so that we only redraw // the portion of the window that needs to be redrawn cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height); cr->clip(); // background grad Cairo::RefPtr<Cairo::LinearGradient> back_grad = Cairo::LinearGradient::create( 0,0,0,allocation.get_height() ); switch (pos_mode) { case 0: back_grad->add_color_stop_rgba(0,top_colour.get_red_p(),top_colour.get_green_p(),top_colour.get_blue_p(),1); back_grad->add_color_stop_rgba(1,bottom_colour.get_red_p(),bottom_colour.get_green_p(),bottom_colour.get_blue_p(),1); break; case 1: back_grad->add_color_stop_rgba(0,top_colour.get_red_p(),top_colour.get_green_p(),top_colour.get_blue_p(),1); back_grad->add_color_stop_rgba(1, (bottom_colour.get_red_p() + top_colour.get_red_p())/2, (bottom_colour.get_green_p() + top_colour.get_green_p())/2, (bottom_colour.get_blue_p() + top_colour.get_blue_p())/2, 1); break; case 2: back_grad->add_color_stop_rgba(0, (bottom_colour.get_red_p() + top_colour.get_red_p())/2, (bottom_colour.get_green_p() + top_colour.get_green_p())/2, (bottom_colour.get_blue_p() + top_colour.get_blue_p())/2, 1); back_grad->add_color_stop_rgba(1,bottom_colour.get_red_p(),bottom_colour.get_green_p(),bottom_colour.get_blue_p(),1); break; } // fill background if (rounded<5) { rounded_rectangle(cr,rounded, grad_top_colour, grad_bottom_colour, event->area.x, event->area.y, event->area.width, event->area.height,pos_mode, top_colour.to_string(),bottom_colour.to_string() ); } else { cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height); } cr->set_source(back_grad); cr->fill(); // ------------------------------------------------------------------ float cos_x = (allocation.get_width()/5) * (cos(((((1-knob_value)*0.75)-0.3)*2) * M_PI)); float sin_y = (allocation.get_width()/5) * (sin(((((1-knob_value)*0.75)-0.3)*2) * M_PI)); Cairo::RefPtr<Cairo::RadialGradient> grad1 = Cairo::RadialGradient::create( (allocation.get_width()/2) + sin_y, (allocation.get_height()/2) + cos_x, 0, (allocation.get_width()/2) , (allocation.get_height()/2) ,(allocation.get_width()/2.5)); grad1->add_color_stop_rgba(0,0.4,0.4,0.4,1); grad1->add_color_stop_rgba(0.5,0.2,0.2,0.2,1); grad1->add_color_stop_rgba(0.8,0.17,0.17,0.17,1); grad1->add_color_stop_rgba(1.0,0.0,0.0,0.0,1); cos_x = (allocation.get_width()/5) * (cos((((knob_value*0.75)-0.61)*2) * M_PI)); sin_y = (allocation.get_width()/5) * (sin((((knob_value*0.75)-0.61)*2) * M_PI)); cr->set_source(grad1); cr->arc(allocation.get_width()/2, allocation.get_height()/2, (allocation.get_width()/2.5), 0.0, 2 * M_PI); cr->fill(); cr->set_source_rgb(0.0, 0.0, 0.0); cr->arc((allocation.get_width()/2) +cos_x, (allocation.get_height()/2)+sin_y, (allocation.get_width()/16), 0.0, 2 * M_PI); cr->fill(); // draw text label cr->select_font_face("Bitstream Vera Sans", Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL); cr->set_font_size(width/4.5); cr->set_source_rgba(0.9,0.9,0.9,0.8); Cairo::FontOptions font_options; font_options.set_hint_style(Cairo::HINT_STYLE_NONE); font_options.set_hint_metrics(Cairo::HINT_METRICS_OFF); font_options.set_antialias(Cairo::ANTIALIAS_GRAY); int x_font_centre = (width/2) - ((width/5) * (label.length()/3.5)); cr->set_font_options(font_options); cr->move_to(x_font_centre,height/3.5); cr->show_text(label); cr->move_to(x_font_centre,allocation.get_height() - (height_offset/3) ); ostringstream slider_value; slider_value.str(""); if (invert) { slider_value << max - value; } else { slider_value << value; } slider_value.str(slider_value.str().substr(0,5)); x_font_centre = (width/2) - ((width/5) * (slider_value.str().length()/3.5)); cr->move_to(x_font_centre,allocation.get_height() - (height_offset/1.5) ); cr->show_text(slider_value.str()); } return true; }
static VALUE rbncurs_c_set_menu_sub(VALUE rb_menu, VALUE rb_sub) { MENU *menu = get_menu(rb_menu); WINDOW *win = get_window(rb_sub); return INT2NUM(set_menu_sub(menu, win)); }
void chooser::create_device (const std::set<scanner::info>& devices, const std::string& udi) { std::set<scanner::info>::const_iterator it = devices.begin (); while (devices.end () != it && udi != it->udi ()) { ++it; } if (devices.end () != it) { Glib::RefPtr< Gdk::Window > window = get_window (); if (window) { window->set_cursor (Gdk::Cursor (Gdk::WATCH)); Gdk::flush (); } scanner::ptr ptr; std::string why; try { // FIXME This is a bit clunky but scanner creation may be time // consuming and cannot be put in a separate thread if // the scanner object is run via process separation. // The child process would exit at thread end. while (Gtk::Main::events_pending ()) Gtk::Main::iteration (); ptr = scanner::create (*it); } catch (const std::exception& e) { why = e.what (); } catch (...) { // FIXME set a why we failed to create a device } if (window) { window->set_cursor (); } if (ptr) { cache_ = get_active (); set_tooltip_text (it->udi ()); signal_device_changed_.emit (ptr); } else { const std::string& name = get_active ()->get_value (cols_->name); const std::string& udi = get_active ()->get_value (cols_->udi); inhibit_callback_ = true; if (cache_) set_active (cache_); inhibit_callback_ = false; BOOST_THROW_EXCEPTION (std::runtime_error ((format (SEC_("Cannot access %1%\n(%2%)\n%3%")) % name % udi % _(why) ).str ())); } } }
void OSGDrawingArea::invalidate () { Gdk::Rectangle lRect = get_allocation (); get_window ()->invalidate_rect (Gdk::Rectangle (0, 0, lRect.get_width (), lRect.get_height ()), false); }
bool DimRegionChooser::on_expose_event(GdkEventExpose* event) { if (!region) return true; // This is where we draw on the window Glib::RefPtr<Gdk::Window> window = get_window(); Glib::RefPtr<Pango::Context> context = get_pango_context(); Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context); window->clear(); // draw labels on the left (reflecting the dimension type) int y = 0; double maxwidth = 0; for (int i = 0 ; i < region->Dimensions ; i++) { int nbZones = region->pDimensionDefinitions[i].zones; if (nbZones) { const char* dstr; char dstrbuf[10]; switch (region->pDimensionDefinitions[i].dimension) { case gig::dimension_none: dstr="none"; break; case gig::dimension_samplechannel: dstr="samplechannel"; break; case gig::dimension_layer: dstr="layer"; break; case gig::dimension_velocity: dstr="velocity"; break; case gig::dimension_channelaftertouch: dstr="channelaftertouch"; break; case gig::dimension_releasetrigger: dstr="releasetrigger"; break; case gig::dimension_keyboard: dstr="keyboard"; break; case gig::dimension_roundrobin: dstr="roundrobin"; break; case gig::dimension_random: dstr="random"; break; case gig::dimension_smartmidi: dstr="smartmidi"; break; case gig::dimension_roundrobinkeyboard: dstr="roundrobinkeyboard"; break; case gig::dimension_modwheel: dstr="modwheel"; break; case gig::dimension_breath: dstr="breath"; break; case gig::dimension_foot: dstr="foot"; break; case gig::dimension_portamentotime: dstr="portamentotime"; break; case gig::dimension_effect1: dstr="effect1"; break; case gig::dimension_effect2: dstr="effect2"; break; case gig::dimension_genpurpose1: dstr="genpurpose1"; break; case gig::dimension_genpurpose2: dstr="genpurpose2"; break; case gig::dimension_genpurpose3: dstr="genpurpose3"; break; case gig::dimension_genpurpose4: dstr="genpurpose4"; break; case gig::dimension_sustainpedal: dstr="sustainpedal"; break; case gig::dimension_portamento: dstr="portamento"; break; case gig::dimension_sostenutopedal: dstr="sostenutopedal"; break; case gig::dimension_softpedal: dstr="softpedal"; break; case gig::dimension_genpurpose5: dstr="genpurpose5"; break; case gig::dimension_genpurpose6: dstr="genpurpose6"; break; case gig::dimension_genpurpose7: dstr="genpurpose7"; break; case gig::dimension_genpurpose8: dstr="genpurpose8"; break; case gig::dimension_effect1depth: dstr="effect1depth"; break; case gig::dimension_effect2depth: dstr="effect2depth"; break; case gig::dimension_effect3depth: dstr="effect3depth"; break; case gig::dimension_effect4depth: dstr="effect4depth"; break; case gig::dimension_effect5depth: dstr="effect5depth"; break; default: sprintf(dstrbuf, "%d", region->pDimensionDefinitions[i].dimension); dstr = dstrbuf; break; } layout->set_text(dstr); Pango::Rectangle rectangle = layout->get_logical_extents(); double text_w = double(rectangle.get_width()) / Pango::SCALE; if (text_w > maxwidth) maxwidth = text_w; double text_h = double(rectangle.get_height()) / Pango::SCALE; Glib::RefPtr<const Gdk::GC> fg = get_style()->get_fg_gc(get_state()); window->draw_layout(fg, 4, int(y + (h - text_h) / 2 + 0.5), layout); } y += h; } // draw dimensions' zones areas y = 0; int bitpos = 0; label_width = int(maxwidth + 10); for (int i = 0 ; i < region->Dimensions ; i++) { int nbZones = region->pDimensionDefinitions[i].zones; if (nbZones) { // draw focus rectangle around dimension's label and zones if (has_focus() && focus_line == i) { Gdk::Rectangle farea(0, y, 150, 20); get_style()->paint_focus(window, get_state(), farea, *this, "", 0, y, label_width, 20); } Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc(); // draw top and bottom lines of dimension's zones window->draw_line(black, label_width, y, w - 1, y); window->draw_line(black, w - 1, y + h - 1, label_width, y + h - 1); // erase whole dimension's zones area window->draw_rectangle(get_style()->get_white_gc(), true, label_width + 1, y + 1, (w - label_width - 2), h - 2); int c = 0; if (dimregno >= 0) { int mask = ~(((1 << region->pDimensionDefinitions[i].bits) - 1) << bitpos); c = dimregno & mask; // mask away this dimension } bool customsplits = ((region->pDimensionDefinitions[i].split_type == gig::split_type_normal && region->pDimensionRegions[c]->DimensionUpperLimits[i]) || (region->pDimensionDefinitions[i].dimension == gig::dimension_velocity && region->pDimensionRegions[c]->VelocityUpperLimit)); // draw dimension's zone borders if (customsplits) { window->draw_line(black, label_width, y + 1, label_width, y + h - 2); for (int j = 0 ; j < nbZones ; j++) { gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)]; int upperLimit = d->DimensionUpperLimits[i]; if (!upperLimit) upperLimit = d->VelocityUpperLimit; int v = upperLimit + 1; int x = int((w - label_width - 1) * v / 128.0 + 0.5); window->draw_line(black, label_width + x, y + 1, label_width + x, y + h - 2); } } else { for (int j = 0 ; j <= nbZones ; j++) { int x = int((w - label_width - 1) * j / double(nbZones) + 0.5); window->draw_line(black, label_width + x, y + 1, label_width + x, y + h - 2); } } // draw fill for currently selected zone if (dimregno >= 0) { gc->set_foreground(red); int dr = (dimregno >> bitpos) & ((1 << region->pDimensionDefinitions[i].bits) - 1); if (customsplits) { int x1 = 0; for (int j = 0 ; j < nbZones ; j++) { gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)]; int upperLimit = d->DimensionUpperLimits[i]; if (!upperLimit) upperLimit = d->VelocityUpperLimit; int v = upperLimit + 1; int x2 = int((w - label_width - 1) * v / 128.0 + 0.5); if (j == dr && x1 < x2) { window->draw_rectangle(gc, true, label_width + x1 + 1, y + 1, (x2 - x1) - 1, h - 2); break; } x1 = x2; } } else { if (dr < nbZones) { int x1 = int((w - label_width - 1) * dr / double(nbZones) + 0.5); int x2 = int((w - label_width - 1) * (dr + 1) / double(nbZones) + 0.5); window->draw_rectangle(gc, true, label_width + x1 + 1, y + 1, (x2 - x1) - 1, h - 2); } } } y += h; } bitpos += region->pDimensionDefinitions[i].bits; }
MPI_Win _XMP_mpi_coarray_get_window(const _XMP_coarray_t *desc, bool is_acc) { return get_window(desc, is_acc); }
// this drags the image around // big thanks to Ramax Lo for fixing this!! bool CPagePreview::on_button1_pressed_motion(GdkEventMotion *event) { // get the cairo context amd allocation Gtk::Allocation allocation = get_allocation(); const int width = allocation.get_width(); const int height = allocation.get_height(); static int x,y; get_pointer(x, y); #ifdef DEBUG std::cout << "PAGE_PREVIEW::PRESSED_MOTION: x\ty : " << x << '\t' << y << std::endl; #endif // DEBUG if(ImagePixbuf->get_width() < page_width-lmargin-rmargin ) { if( (xpos + (x - dragoldx)) >= uleft.x && (xpos + (x - dragoldx)) <= ( lright.x - ImagePixbuf->get_width() ) ) { xpos = xpos + (x - dragoldx); dragoldx = x; } //snap to end else if( (xpos + (x - dragoldx)) < uleft.x ) { xpos = uleft.x; dragoldx = x; } else if( (xpos + (x - dragoldx)) > ( lright.x - ImagePixbuf->get_width() ) ) { xpos = lright.x - ImagePixbuf->get_width(); dragoldx = x; } } if(ImagePixbuf->get_height() < page_height-lmargin-rmargin ) { if( (ypos + (y - dragoldy)) >= uleft.y && (ypos + (y - dragoldy)) <= ( lright.y - ImagePixbuf->get_height() ) ) { ypos = ypos + (y - dragoldy); dragoldy = y; } //snap to end else if( (ypos + (y - dragoldy)) < uleft.y ) { ypos = uleft.y; dragoldy = y; } else if( (ypos + (y - dragoldy)) > ( lright.y - ImagePixbuf->get_height() ) ) { ypos = lright.y - ImagePixbuf->get_height(); dragoldy = y; } } // force redraw Glib::RefPtr<Gdk::Window> window = get_window(); if (window) { Gdk::Rectangle r(0, 0, get_allocation().get_width(), get_allocation().get_height()); window->invalidate_rect(r, false); } return true; }
bool CPagePreview::on_expose_event(GdkEventExpose *event) { Glib::RefPtr<Gdk::Window> window = get_window(); if(window) { // get the cairo context amd allocation Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context(); Gtk::Allocation allocation = get_allocation(); const int width = allocation.get_width(); const int height = allocation.get_height(); // coordinates for the center of the window int xc, yc; xc = width / 2; yc = height / 2; // clip to the area indicated by the expose event so that we only redraw // the portion of the window that needs to be redrawn cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height); cr->clip(); // draw a neat shadow cr->set_source_rgba(0.0,0.0,0.0,0.4); cr->begin_new_path(); cr->move_to( xborder+offset,yborder+offset ); cr->line_to( width-xborder+offset,yborder+offset ); cr->line_to( width-xborder+offset,height-yborder+offset ); cr->line_to( xborder+offset,height-yborder+offset ); cr->close_path(); cr->fill(); // draw the page outline cr->set_source_rgb(0.0,0.0,0.0); // black cr->set_line_width( 2.0 ); cr->begin_new_path(); cr->move_to( xborder-offset,yborder-offset ); cr->line_to( width-xborder-offset,yborder-offset ); cr->line_to( width-xborder-offset,height-yborder-offset ); cr->line_to( xborder-offset,height-yborder-offset ); cr->close_path(); cr->stroke_preserve(); // fill the page with white cr->save(); cr->set_source_rgb(1.0,1.0,1.0); // white cr->fill_preserve(); cr->restore(); // draw the page margin cr->set_source_rgb( 0.8,0.8,0.8 ); // light grey cr->set_line_width( 1.0 ); cr->begin_new_path(); cr->move_to( uleft.x, uleft.y ); cr->line_to( lright.x, uleft.y ); cr->line_to( lright.x, lright.y ); cr->line_to( uleft.x, lright.y ); cr->close_path(); cr->stroke(); // and the image preview ImagePixbuf->render_to_drawable( get_window(), get_style()->get_black_gc(), 0, 0, xpos, ypos, ImagePixbuf->get_width(), //image->get_width(), ImagePixbuf->get_height(), //image->get_height(), Gdk::RGB_DITHER_NONE,0,0 ); // */ return true; } }
bool PhotoPreview::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { if (!Image) return false; int Width,Height; Gtk::Allocation Allocation = get_allocation(); Width=Allocation.get_width(); Height=Allocation.get_height(); if (Width<=1 || Height<=1) return false; /* Scale the photo */ Glib::RefPtr<Gdk::Pixbuf> Scaled; /* Preserve aspect ratio */ double ImageAspectRatio,PreviewAspectRatio; PreviewAspectRatio=(float)Width/Height; ImageAspectRatio=(float)Image->get_width()/Image->get_height(); if (ImageAspectRatio<PreviewAspectRatio) { Width=Height*ImageAspectRatio; } else { Height=Width/ImageAspectRatio; } Scaled=Image->scale_simple( Width, Height, Gdk::INTERP_BILINEAR); if (Cfg->GetFlipPreview()) Scaled=Scaled->flip(); Gdk::Cairo::set_source_pixbuf(cr, Scaled, (Allocation.get_width()/2)-(Scaled->get_width()/2), (Allocation.get_height()/2)-(Scaled->get_height()/2) ); cr->paint(); double TimeLeft=Util::TimeDiff(&PhotoTime,NULL); double MinDim=get_width(); if (get_height()<MinDim) MinDim=get_height(); if (Overlay.length()==0 && TimeLeft>0) { double TotalTime=Cfg->GetCountdownCount()*(Cfg->GetCountdownTimeout()/1000.0); unsigned int Whole=floor(Cfg->GetCountdownCount()*TimeLeft/TotalTime); float Frac=(Cfg->GetCountdownCount()*TimeLeft/TotalTime)-Whole; Cairo::RefPtr<Cairo::Context> Context = get_window()->create_cairo_context(); Context->set_source_rgba(1.0, 1.0, 1.0,0.5); Context->translate(get_width()/2.0,get_height()/2.0); /* Draw the fractional portion of the countdown */ Context->save(); Context->rotate(M_PI/2.0); Context->arc(0.0,0.0,MinDim/4.0,0,Frac*2*M_PI); Context->fill(); Context->restore(); /* Draw the Whole portion of the countdown */ Context->save(); Context->set_font_size(MinDim/2.0); char StrBuf[1024]; snprintf(StrBuf,sizeof(StrBuf),"%d",Whole+1); Cairo::TextExtents Extents; Context->get_text_extents(StrBuf,Extents); Context->translate(-Extents.width/2.0,Extents.height/2.0); Context->show_text(StrBuf); Context->stroke(); Context->restore(); } if (Overlay.length()) { Cairo::RefPtr<Cairo::Context> Context = get_window()->create_cairo_context(); Context->set_source_rgba(1.0, 1.0, 1.0,0.5); Context->translate(get_width()/2.0,get_height()/2.0); Context->save(); Context->set_font_size(MinDim/2.0); Cairo::TextExtents Extents; Context->get_text_extents(Overlay,Extents); Context->translate(-Extents.width/2.0,Extents.height/2.0); Context->show_text(Overlay); Context->stroke(); Context->restore(); } return true; }
void Gui::draw(Piece *piece) { // The spritesheet is ordered to correlate with the Piece::Color and Piece::Type enums, so drawing from it is rather convenient. spritesheet->render_to_drawable(get_window(), get_style()->get_black_gc(), piece->type * TileSize, piece->color * TileSize, Position::File(piece->pos) * TileSize, (NUM_RANKS - 1 - Position::Rank(piece->pos)) * TileSize, TileSize, TileSize, Gdk::RGB_DITHER_NONE, 0, 0); }
void LogoScene::goinit(){ get_window()->changeScene(SceneType::INIT); }
void knob::draw_slider(int x, int y) { if (drag==false && max>1) { if (y > get_allocation().get_height()/2 && value > min) { value -= 1; } if (y < get_allocation().get_height()/2 && value < max) { value += 1; } } if (drag==false && max==1) { if (y > get_allocation().get_height()/2 && value > min) { value -= 0.001; } if (y < get_allocation().get_height()/2 && value < max) { value += 0.001; } } float width = get_allocation().get_width(); float height = (get_allocation().get_height() / 1.5); if (drag==true) { // converty mouse y to knob value y-=(get_allocation().get_height()/6); knob_value = (height-y)/height; if (knob_value < 0) { knob_value = 0; } if (knob_value > 1) { knob_value = 1; } if (max > min) { value = min + (knob_value*(max-min)); } if (max <= min) { value = max + ((1-knob_value)*(min-max)); } } if (snap) { value = int(value); set_value(value); } // which port to write to, check your .ttl file for the index of // each port // here we use the LV2UI_Controller and LV2UI_write_function "things" // to write some data to a port if (invert) { float inverted_value = max - value; write_function( controller, port_number, sizeof(float), 0, (const void*)&inverted_value); } else { write_function( controller, port_number, sizeof(float), 0, (const void*)&value); } // ask GTK to redraw when it suits Glib::RefPtr<Gdk::Window> win = get_window(); if (win) { Gdk::Rectangle r(0,0,get_allocation().get_width(), get_allocation().get_height() ); win->invalidate_rect(r, false); } }
void on_add_location_activate(GtkAction * action, gpointer user_data) { LocationDialog *dialog = location_dialog_new(get_window(app)); location_dialog_show(dialog, ""); }
void tunit_preview_pane::profile_button_callback() { if(get_window()) { help::show_unit_help((*get_window()).video(), current_type_); } }
void on_add_playlist_activate(GtkAction * action, gpointer user_data) { PlaylistDialog *dialog; dialog = playlist_dialog_new(get_window(app)); playlist_dialog_show(dialog, NULL); }
static SANE_Status attach (const char *devnam, Ricoh_Device ** devp) { SANE_Status status; Ricoh_Device *dev; int fd; struct inquiry_data ibuf; struct measurements_units_page mup; struct ricoh_window_data wbuf; size_t buf_size; char *str; DBG (11, ">> attach\n"); for (dev = first_dev; dev; dev = dev->next) { if (strcmp (dev->sane.name, devnam) == 0) { if (devp) *devp = dev; return (SANE_STATUS_GOOD); } } DBG (3, "attach: opening %s\n", devnam); status = sanei_scsi_open (devnam, &fd, NULL, NULL); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: open failed: %s\n", sane_strstatus (status)); return (status); } DBG (3, "attach: sending INQUIRY\n"); memset (&ibuf, 0, sizeof (ibuf)); buf_size = sizeof(ibuf); status = inquiry (fd, &ibuf, &buf_size); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: inquiry failed: %s\n", sane_strstatus (status)); sanei_scsi_close (fd); return (status); } if (ibuf.devtype != 6 || strncmp ((char *)ibuf.vendor, "RICOH", 5) != 0 || (strncmp ((char *)ibuf.product, "IS50", 4) != 0 && strncmp ((char *)ibuf.product, "IS60", 4) != 0)) { DBG (1, "attach: device doesn't look like the Ricoh scanner I know\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } is50 = (strncmp ((char *)ibuf.product, "IS50", 4) == 0); DBG (3, "attach: sending TEST_UNIT_READY\n"); status = test_unit_ready (fd); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: test unit ready failed (%s)\n", sane_strstatus (status)); sanei_scsi_close (fd); return (status); } DBG (3, "attach: sending OBJECT POSITION\n"); status = object_position (fd); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: OBJECT POSTITION failed\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } memset (&mup, 0, sizeof (mup)); mup.page_code = MEASUREMENTS_PAGE; mup.parameter_length = 0x06; mup.bmu = INCHES; mup.mud[0] = (DEFAULT_MUD >> 8) & 0xff; mup.mud[1] = (DEFAULT_MUD & 0xff); #if 0 DBG (3, "attach: sending MODE SELECT\n"); status = mode_select (fd, (struct mode_pages *) &mup); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: MODE_SELECT failed\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } #endif #if 0 DBG (3, "attach: sending MODE SENSE\n"); memset (&mup, 0, sizeof (mup)); status = mode_sense (fd, (struct mode_pages *) &mup, PC_CURRENT | MEASUREMENTS_PAGE); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: MODE_SENSE failed\n"); sanei_scsi_close (fd); return (SANE_STATUS_INVAL); } #endif DBG (3, "attach: sending GET WINDOW\n"); memset (&wbuf, 0, sizeof (wbuf)); status = get_window (fd, &wbuf); if (status != SANE_STATUS_GOOD) { DBG (1, "attach: GET_WINDOW failed %d\n", status); sanei_scsi_close (fd); DBG (11, "<< attach\n"); return (SANE_STATUS_INVAL); } sanei_scsi_close (fd); dev = malloc (sizeof (*dev)); if (!dev) return (SANE_STATUS_NO_MEM); memset (dev, 0, sizeof (*dev)); dev->sane.name = strdup (devnam); dev->sane.vendor = "RICOH"; str = malloc (16 + 1); memset (str, 0, sizeof (str)); strncpy (str, (char *)ibuf.product, sizeof(ibuf.product)); strncpy (str + sizeof(ibuf.revision), (char *)ibuf.revision, sizeof(ibuf.revision)); str[sizeof(ibuf.product) + sizeof(ibuf.revision)] = '\0'; dev->sane.model = str; dev->sane.type = "flatbed scanner"; DBG (5, "dev->sane.name = %s\n", dev->sane.name); DBG (5, "dev->sane.vendor = %s\n", dev->sane.vendor); DBG (5, "dev->sane.model = %s\n", dev->sane.model); DBG (5, "dev->sane.type = %s\n", dev->sane.type); dev->info.xres_default = _2btol(wbuf.x_res); dev->info.yres_default = _2btol(wbuf.y_res); dev->info.image_mode_default = wbuf.image_comp; /* if you throw the MRIF bit the brighness control reverses too */ /* so I reverse the reversal in software for symmetry's sake */ /* I should make this into an option */ if (wbuf.image_comp == RICOH_GRAYSCALE || wbuf.image_comp == RICOH_DITHERED_MONOCHROME) { dev->info.brightness_default = 256 - wbuf.brightness; if (is50) dev->info.contrast_default = wbuf.contrast; else dev->info.contrast_default = 256 - wbuf.contrast; } else /* wbuf.image_comp == RICOH_BINARY_MONOCHROME */ { dev->info.brightness_default = wbuf.brightness; dev->info.contrast_default = wbuf.contrast; } #if 1 dev->info.bmu = mup.bmu; dev->info.mud = _2btol(mup.mud); if (dev->info.mud == 0) { /* The RICOH says it uses points as default Basic Measurement Unit */ /* but gives a Measurement Unit Divisor of zero */ /* So, we set it to the default (SCSI-standard) of 1200 */ /* with BMU in inches, i.e. 1200 points equal 1 inch */ dev->info.bmu = INCHES; dev->info.mud = DEFAULT_MUD; } #else dev->info.bmu = INCHES; dev->info.mud = DEFAULT_MUD; #endif DBG (5, "xres_default=%d\n", dev->info.xres_default); DBG (5, "xres_range.max=%d\n", dev->info.xres_range.max); DBG (5, "xres_range.min=%d\n", dev->info.xres_range.min); DBG (5, "yres_default=%d\n", dev->info.yres_default); DBG (5, "yres_range.max=%d\n", dev->info.yres_range.max); DBG (5, "yres_range.min=%d\n", dev->info.yres_range.min); DBG (5, "x_range.max=%d\n", dev->info.x_range.max); DBG (5, "y_range.max=%d\n", dev->info.y_range.max); DBG (5, "image_mode=%d\n", dev->info.image_mode_default); DBG (5, "brightness=%d\n", dev->info.brightness_default); DBG (5, "contrast=%d\n", dev->info.contrast_default); DBG (5, "bmu=%d\n", dev->info.bmu); DBG (5, "mud=%d\n", dev->info.mud); ++num_devices; dev->next = first_dev; first_dev = dev; if (devp) *devp = dev; DBG (11, "<< attach\n"); return (SANE_STATUS_GOOD); }
void on_preferences_activate(GtkAction * action, gpointer user_data) { PrefsDialog *dialog; dialog = prefs_dialog_new(get_window(app)); prefs_dialog_show(dialog, &prefs); }
void ScreenArea::vShowCursor() { get_window()->set_cursor(); m_bShowCursor = true; }
tdialog* twidget::dialog() { twindow* window = get_window(); return window ? window->dialog() : NULL; }
void handle_msg(int *msg) { WINDOWP window; wake_mouse(); window= get_window(msg[3]); /* Zugeh�riges Fenster */ switch (msg[0]) /* Art der Nachricht */ { case MN_SELECTED: if (makro_rec) /* Makro wird Tastendruck vorgegaukelt */ { int kstate, kreturn; char str[50]; get_string(menu, msg[4], str); if (str_to_key(str, &kstate, &kreturn)) { kstate |= (kstate & 3); to_makro(kstate, kreturn); } } handle_menu(msg[3], msg[4], menu_ctrl); menu_ctrl = FALSE; break; case WM_REDRAW : if (msg[3] == akt_handle) redraw_aktion(); else redraw_window (window, (GRECT*)(msg+4)); break; case WM_CLOSED : do_icon(window->handle, DO_DELETE); break; case WM_FULLED : full_window (window); break; case WM_ARROWED : arrow_window (window, msg[4], 1); break; case WM_HSLID : h_slider (window, msg[4]); break; case WM_VSLID : v_slider (window, msg[4]); break; case WM_SIZED : size_window (window, (GRECT*)(msg+4), TRUE); break; case WM_MOVED : move_window (window, (GRECT*)(msg+4)); break; case WM_NEWTOP : /* Fenster von qed ist irgendwie nach oben gekommen */ case WM_ONTOP : ontop_window(window); break; case WM_TOPPED : top_window (window); break; case WM_UNTOPPED: /* qed hat jetzt nicht mehr das Top-Fenster */ untop_window (window); break; case WM_BOTTOMED: /* AES 4.00 MagiC 3 : Fenster nach hinten */ case WM_M_BDROPPED : /* Magic 2 */ bottom_window (window, msg[0]); break; case WM_ICONIFY: iconify_window(window, (GRECT*)(msg+4)); break; case WM_ALLICONIFY: all_iconify(window, (GRECT*)(msg+4)); break; case WM_UNICONIFY: if (all_iconified) all_uniconify(NULL, (GRECT*)(msg+4)); else uniconify_window(window, (GRECT*)(msg+4)); break; case WM_SHADED : case WM_UNSHADED : shade_window(window, msg[0]); break; case AP_TERM: if (all_iconified) all_uniconify(NULL, NULL); quick_close = TRUE; if (prepare_quit()) do_quit(); break; case AP_DRAGDROP : if (all_iconified) Bconout(2, 7); else handle_dd(msg); break; case SC_CHANGED : /* * Ignorieren, da wir vor dem Paste sowieso neu laden. */ break; case VA_START : case VA_PROTOSTATUS : case VA_DRAG_COMPLETE : case VA_DRAGACCWIND : case AV_SENDKEY : handle_av(msg); break; case SE_INIT: case SE_OK: case SE_ACK: case SE_OPEN: case SE_ERROR: case SE_ERRFILE: case SE_PROJECT: case SE_QUIT: case SE_TERMINATE: case SE_CLOSE : case SE_MENU : if (all_iconified) all_uniconify(NULL, NULL); handle_se(msg); break; case OLGA_INIT : case OLE_NEW : case OLGA_ACK : case OLE_EXIT : handle_olga(msg); break; case SH_WDRAW: /* schickt Freedom st�ndig */ case DHST_ACK: /* SMU antwortet */ /* ignore */ break; case FONT_CHANGED : if (msg[4] != 0) font_id = msg[4]; if (msg[5] != 0) font_pts = msg[5]; font_change(); break; default: if (debug_level) { char str[12]; int d, i, id; if ((appl_xgetinfo(4, &d, &d, &i, &d)) && (i == 1)) /* gibts appl_search? */ { i = appl_search(0, str, &d, &id); while (i != 0) { if (id == msg[1]) break; i = appl_search( 1, str, &d, &id); } } else { strcpy(str, ""); id = msg[1]; } debug("Unbekannte Msg %d (0x%X) von %s (%d)\n", msg[0], msg[0], str, id); } break; } }
/// Invalidate whole window. void invalidate() { get_window()->invalidate_rect(get_allocation(), false); }
void Video_GL::init() { std::cout << "Initializing OpenGL" << std::endl; //double buffer, no stencil, no accumulation buffer SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_RED_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_GREEN_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, 0); if(get_multisampling() > 1) { SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES, get_multisampling()); SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS, 1); } set_opengl_flag(true); Video::init(); #if SDL_VERSION_ATLEAST(1,3,0) m_context = SDL_GL_CreateContext(get_window()); #endif { const GLenum err = glewInit(); if(GLEW_OK != err) { std::cerr << "GLEW Error: " << glewGetErrorString(err) << std::endl; throw Video_Init_Failure(); } } // Set Fill/Shade Mode glShadeModel(GL_SMOOTH); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glEnable(GL_NORMALIZE); //GL_RESCALE_NORMALIZE); // Enable Alpha Blitting glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glBlendEquation(GL_FUNC_ADD); // default // would require ARB ext // Set lighting variables glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); if(glGetError() == GL_INVALID_ENUM) std::cerr << "Quality Warning: Your graphics card does not support separate specular lighting in OpenGL.\n"; // Initialize Assorted Variables glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //glPointSize(static_cast<GLfloat>(sqrt(pow(double(get_screen_width()), 2.) * pow(double(get_screen_height()), 2.)) / 1000000)); //glLineWidth(static_cast<GLfloat>(sqrt(pow(double(get_screen_width()), 2.) * pow(double(get_screen_height()), 2.)) / 1000000)); // Finish with a few function calls set_2d(); set_color(get_color()); set_clear_color(get_clear_color()); set_backface_culling(get_backface_culling()); set_lighting(get_lighting()); set_ambient_lighting(get_ambient_lighting()); set_alpha_test(is_alpha_test_enabled(), get_alpha_test_function(), get_alpha_test_value()); set_zwrite(is_zwrite_enabled()); set_ztest(is_ztest_enabled()); union { void * v; #ifdef _LINUX PFNGLXSWAPINTERVALEXTPROC pglSwapIntervalEXT; PFNGLXSWAPINTERVALSGIPROC pglSwapIntervalSGI; #endif PFNGLBINDBUFFERARBPROC pglBindBufferARB; PFNGLDELETEBUFFERSARBPROC pglDeleteBuffersARB; PFNGLGENBUFFERSARBPROC pglGenBuffersARB; PFNGLBUFFERDATAARBPROC pglBufferDataARB; } ptr; #ifdef _LINUX ptr.v = SDL_GL_GetProcAddress("glXSwapIntervalEXT"); if(!ptr.v) ptr.v = SDL_GL_GetProcAddress("wglSwapIntervalEXT"); m_pglSwapIntervalEXT = ptr.pglSwapIntervalEXT; ptr.v = SDL_GL_GetProcAddress("glXSwapIntervalSGI"); if(!ptr.v) ptr.v = SDL_GL_GetProcAddress("wglSwapIntervalSGI"); m_pglSwapIntervalSGI = ptr.pglSwapIntervalSGI; #endif // Has to be done after finding the function pointer set_vertical_sync(get_vertical_sync()); m_vertex_buffers = strstr(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)), "ARB_vertex_buffer_object") != 0; if(m_vertex_buffers) { ptr.v = SDL_GL_GetProcAddress("glBindBufferARB"); m_pglBindBufferARB = ptr.pglBindBufferARB; ptr.v = SDL_GL_GetProcAddress("glDeleteBuffersARB"); m_pglDeleteBuffersARB = ptr.pglDeleteBuffersARB; ptr.v = SDL_GL_GetProcAddress("glGenBuffersARB"); m_pglGenBuffersARB = ptr.pglGenBuffersARB; ptr.v = SDL_GL_GetProcAddress("glBufferDataARB"); m_pglBufferDataARB = ptr.pglBufferDataARB; } else std::cerr << "Performance Warning: Your graphics card does not offer Vertex Buffer Objects (VBO) in OpenGL.\n"; if(strstr((char*)glGetString(GL_EXTENSIONS), "GL_EXT_texture_filter_anisotropic")) glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, reinterpret_cast<GLint *>(&m_maximum_anisotropy)); else m_maximum_anisotropy = 0; }
/** Escribe los datos referentes a cada separacion de cada uno de los ejes del histograma @param dx, desplazamiento en el eje X cuando cambiamos el tamaño de la ventana @param dy, desplazamiento en el eje Y cuando cambiamos el tamaño de la ventana */ void PlotHistogram::pintaTextoPango(int dx, int dy) { double ejeX, ejeY, incX, incY, actX, actY; double scala; double numYcorrect; int contX; scala = -25.0; ejeX = anchoPlot -100; incX = ejeX / numX; ejeY = altoPlot - 100; incY = ejeY / 10; actX = 75; actY = 375; layout->set_font_description(*timesnr_8); contX = -1; //Rellenado de nombres while(actX <= 705) { scala = scala + 25; contX++; if(scala == 0) { layout->set_markup(Utiles::converString(scala)); get_window()->draw_layout(Gdk::GC::create(get_window()), actX + 15, actY + dy + 20, layout); } else if(contX == 4) { layout->set_markup(Utiles::converString(scala)); get_window()->draw_layout(Gdk::GC::create(get_window()), actX + 10, actY + dy + 20, layout); contX = 0; } actX = actX + incX; } actX = 75; numYcorrect = numY/10; //Ajustamos la escala para el numero mayor scala = numYcorrect - (2 * numYcorrect); //Pintamos las separaciones del ejeY while(actY >= 25) { scala = scala + numYcorrect; layout->set_markup(Utiles::converString(Utiles::redondearNDecimales(scala, 3))); get_window()->draw_layout(Gdk::GC::create(get_window()), actX - 20, actY - 5 + dy, layout); actY = actY - incY; } //Pintamos las referencias del histograma layout->set_font_description(*caligua_20_V); //Eje X layout->set_markup("Oocyte diameter (um)"); get_window()->draw_layout(Gdk::GC::create(get_window()), 250 + dx, 410 + dy, layout); //Eje y layout->set_markup("Freq."); get_window()->draw_layout(Gdk::GC::create(get_window()), 5, 170 + dy, layout); }
bool ImageDrawingArea::on_expose_event( GdkEventExpose* /*event*/ ) { if ( m_pixBuf == NULL ) { return true; } Glib::Mutex::Lock lock(m_pixBufMutex); const int width = m_pixBuf->get_width(); const int height = m_pixBuf->get_height(); double validTextureWidth = 1.0; double validTextureHeight = 1.0; bool useTiledTextures = false; GLenum errorno; BeginGL(); SetImageSize( width, height ); int screenWidth = 0; int screenHeight = 0; get_window()->get_size( screenWidth, screenHeight ); // This makes sure that sampling for rendering doesn't occur on the border of pixels. const double halfPixelAdjustW = 0.25 / (double)screenWidth; const double halfPixelAdjustH = 0.25 / (double)screenHeight; glEnable( GL_TEXTURE_2D ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // center the image glTranslated( -(m_scaleX - 1.0)/2.0 + halfPixelAdjustW, -(m_scaleY - 1.0)/2.0 + halfPixelAdjustH, 0.0); // apply mouse-drag shift glTranslated(m_shiftX, m_shiftY, 0.0); // scale the image glScaled(m_scaleX, m_scaleY, 0.0); // draw the image glBindTexture(GL_TEXTURE_2D, m_imageTextures[0]); #ifdef _WIN32 if (m_PBOSupported) { glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, m_PBO); errorno = glGetError(); if (errorno != GL_NO_ERROR) { m_PBOSupported = false; } else { glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, width * height * 4, m_pixBuf->get_pixels(), GL_STREAM_DRAW_ARB); errorno = glGetError(); if (errorno != GL_NO_ERROR) { m_PBOSupported = false; } } } #endif glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_PBOSupported ? NULL : m_pixBuf->get_pixels() ); errorno = glGetError(); if (errorno != GL_NO_ERROR) { // Attempt to fall back and use a power-of-two sized texture. // This is for older cards that don't support more arbitrary // texture sizes. #ifdef _WIN32 if (m_PBOSupported) { // unbind PBO to use normal texture transfer glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, 0); } #endif const int textureWidth = GetMinimumPowerOfTwo(width); const int textureHeight = GetMinimumPowerOfTwo(height); validTextureWidth = (double)width / textureWidth; validTextureHeight = (double)height / textureHeight; glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, textureWidth, textureHeight, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, NULL ); errorno = glGetError(); if (errorno != GL_NO_ERROR) { // The graphics doesn't seem to support this texture size. // Images must be split and then tiled. useTiledTextures = true; } else { glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_pixBuf->get_pixels() ); errorno = glGetError(); if ( errorno != GL_NO_ERROR) { // Error } } } if (useTiledTextures) { // // The image is split into multiple textures. // const int bytesPerPixel = 4; const int tileSize = 1024; int horizResidual = width % tileSize; int vertResidual = height % tileSize; int numHorizTextures = width / tileSize + (horizResidual > 0); int numVertTextures = height / tileSize + (vertResidual > 0); unsigned char *tileBuffer = new unsigned char[tileSize * tileSize * bytesPerPixel]; for (int tileY = 0; tileY < numVertTextures ; tileY++) { for (int tileX = 0; tileX < numHorizTextures; tileX++) { int subTexHeight = tileSize; if ( tileY == numVertTextures - 1 && vertResidual > 0) { subTexHeight = vertResidual; } int subTexWidth = tileSize; if (tileX == numHorizTextures - 1 && horizResidual > 0) { subTexWidth = horizResidual; } // copy image buffer to the tile for (int line = 0; line < subTexHeight; line++) { memcpy( tileBuffer + line * tileSize * bytesPerPixel, m_pixBuf->get_pixels() + ((line + tileSize * tileY) * width + tileSize * tileX) * bytesPerPixel, subTexWidth * bytesPerPixel); } const unsigned int texId = tileY * numHorizTextures + tileX; if (texId >= sk_maxNumTextures) { continue; } glBindTexture( GL_TEXTURE_2D, m_imageTextures[ texId] ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, tileSize, tileSize, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, tileBuffer ); const double validTileWidth = (double)subTexWidth/tileSize; const double validTileHeight = (double)subTexHeight/tileSize; const double x_begin = (double)tileSize / width * tileX; const double x_end = (double)tileSize / width * ( tileX + validTileWidth); const double y_begin = 1.0 - (double)tileSize / height * ( tileY + validTileHeight); const double y_end = 1.0 - (double)tileSize / height * tileY; glBegin( GL_QUADS ); glTexCoord2d(0.0, validTileHeight); glVertex2d(x_begin, y_begin); glTexCoord2d(validTileWidth, validTileHeight); glVertex2d(x_end, y_begin); glTexCoord2d(validTileWidth, 0.0); glVertex2d(x_end, y_end); glTexCoord2d(0.0, 0.0); glVertex2d(x_begin, y_end); glEnd(); } } delete [] tileBuffer; } else { // Just one texture glBegin( GL_QUADS ); glTexCoord2d(0.0, validTextureHeight); glVertex2d(0.0, 0.0); glTexCoord2d(validTextureWidth, validTextureHeight); glVertex2d(1.0, 0.0); glTexCoord2d(validTextureWidth, 0.0); glVertex2d(1.0, 1.0); glTexCoord2d(0.0, 0.0); glVertex2d(0.0, 1.0); glEnd(); } if ( m_showCrosshair ) { const double aspectRatio = (double)width/height; glTranslated(0.5, 0.5, 0.0); glScaled(1.0, aspectRatio, 0.0); ShowCrosshair(); } if (get_gl_window()->is_double_buffered()) { get_gl_window()->swap_buffers(); } else { glFlush(); } EndGL(); lock.release(); m_displayedFrameRate.NewFrame(); return true; }
void tscroll_label::signal_handler_left_button_down(const event::tevent event) { DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n"; get_window()->keyboard_capture(this); }