示例#1
0
void BranchAcceptor::load(istream &is)
{
  double cutoff;
  Strand strand;
  SignalType signalType;
  BOOM::String p;
  int consensusOffset;
  is >> signalType;
  is >> p; 
  cutoff=p.asDouble();
  is >> strand;
  is >> consensusOffset;
  setSignalType(signalType);
  setStrand(strand);
  setCutoff(cutoff);

  BOOM::String dummy;
  is>>dummy; // will always be "WWAM"
  branchPoint=new WWAM(getGC(),is);
  is>>dummy; // will always be "WAM"
  acceptor=new WAM(getGC(),is);

  int contextWindowLength=branchPoint->getContextWindowLength()+
    acceptor->getContextWindowLength();
  setSizes(2,consensusOffset,contextWindowLength);
}
示例#2
0
SignalSensor *BranchAcceptor::reverseComplement()
{
  BranchAcceptor *other=new BranchAcceptor(getGC(),*this,true);
  other->branchPoint=(WWAM*) branchPoint->reverseComplement();
  other->acceptor=(WAM*) acceptor->reverseComplement();
  return other;
}
示例#3
0
void AreaScene::render()
{
	// render underlying scene:
	m_topScene->render();

	// render fading shadow:
	auto renderer = m_manager->getRenderer();
	CL_Draw::fill(renderer->getGC(), CL_Rectf(renderer->getGCSize()), CL_Colorf(0.0f, 0.0f, 0.0f, m_percent));
}
示例#4
0
文件: gui.c 项目: NgoHuy/unikey
//--------------------------------------------
void allocXResources()
{
  XColor exactColor, screenColor;
  XAllocNamedColor(display, MainColormap, "red", &screenColor, &exactColor);
  RedXColor = screenColor.pixel;
  XAllocNamedColor(display, MainColormap, "blue", &screenColor, &exactColor);  
  BlueXColor = screenColor.pixel;

  loadFont(&FontInfo);
  getGC(MainWindow, &MainGC, FontInfo);
}
示例#5
0
DialogScene::DialogScene(GameManager * manager, DialogBranch::Ref branch, Globals & globals)
: GameScene(manager), m_topScene(manager->getTopScene()), m_branch(branch), m_iter(m_branch->begin()), m_globals(globals)
{
	auto renderer = m_manager->getRenderer();
	
	// init phrase types animation:
	m_percent = 1.0f;
	m_oldtype = m_iter->first;
	m_newtype = m_iter->first;

	// create font data:
	m_font = CL_Font_System(renderer->getGC(), "Microsoft Sans Serif", 32);

	// provide initial layout:
	updateRects(renderer->getGCSize());
	updateLayout();

	// attach input handlers:
	m_slots.connect(renderer->getIC().get_keyboard().sig_key_down(), this, &DialogScene::onKeyDown);
	m_slots.connect(renderer->getIC().get_mouse().sig_key_down(), this, &DialogScene::onKeyDown);
}
int main (int argc, char** argv)
{
    XEvent event;
    connectX();
    x=500;
    y=400;
    main_window = openWindow(10,20,x,y,5, argc, argv);
    gc = getGC();
    XMapWindow(display, main_window);
    draw();
    XFlush(display);
    while (True)
    {
        XNextEvent(display, &event);
        switch(event.type)
        {
        case Expose:
            printf("Expose event\n");
            draw();
            break;
        case ButtonPress:
            printf("Button Pressed\n");
            doButtonPressEvent(&event);
            break;
        case ButtonRelease:
            printf("Button released\n");
            tst=0;
            break;
        case KeyPress:
            printf("Key pressed\n");
            doKeyPressEvent(&event);
            break;
        case MotionNotify:
            doMotionNotifyEvent(&event);
            break;
        }
    }
}
示例#7
0
   VirtualObject& CPU::instantiate(VirtualContext& context, const VirtualClass& klass, int constructor)
   {
      ASSERT(klass.canInstantiate());

      VirtualObject* pobject = mObjectCache.alloc();
      klass.instantiate(*pobject);

      ScopedValue<bool> scope(&mBlockGC, true, mBlockGC);
   
      VirtualValue objectvariant(*pobject);

      // run field initialization expressions
      const VirtualFunctionTableEntry* pentry = &klass.getVirtualFunctionTable()[1];
      execute(context, *pobject, *pentry, 0, NULL);

      // run the constructor (entry)
      pentry = (constructor == -1) ? klass.getDefaultConstructor() : &klass.getVirtualFunctionTable()[constructor];
      execute(context, *pobject, *pentry);

      // register object with GC
      getGC().collect(pobject);

      return *pobject;
   }
示例#8
0
文件: hello.c 项目: tomby42/prg-xws
/*
 * Vstupní bod programu
 */
int main(int argc, char *argv[])
{
    XWMHints *wm_hints; /* Doporuèení pro window manager */
    XClassHint *class_hints; /* Jméno tøídy pro resource management */
    XTextProperty window_name, icon_name; /* Jména zobrazovaná window
                                               managerem */
    XSizeHints *size_hints; /* Doporuèená velikost okna */
    char *str_window_name = (char *) "Hello World";
    char *str_icon_name = (char *) "Hello Icon";
    XEvent event; /* Pro zpracování pøijatých událostí */
    static Bool window_too_small = False;
                        
    /* Inicializace */
    progname = argv[0];
    
    /* Pøipojení k X serveru */
    if(!(display = XOpenDisplay(display_name))) {
        fprintf(stderr, "%s: cannot connect to X server %s\n",
                progname, XDisplayName(display_name));
        exit(-1);
    }
    printf("Connected to X server %s\n", XDisplayName(display_name));
    screen_num = DefaultScreen(display);
    printf("Default screen number is %d\n", screen_num);
    screen_ptr = DefaultScreenOfDisplay(display);

    display_width = DisplayWidth(display, screen_num);
    display_height = DisplayHeight(display, screen_num);
    printf("Display is %u x %u pixels\n", display_width, display_height);

    /* Vytvoøení okna */
    x = y = 0; /* Okno umístí window manager */
    width = display_width/2;
    height = display_height/2;
    win = XCreateSimpleWindow(display, RootWindow(display, screen_num),
                              x, y, width, height, border_width,
                              BlackPixel(display, screen_num),
                              WhitePixel(display, screen_num));
    printf("Created window with ID %#lx\n", win);
    
    /* Pixmapa ikony */
    icon_pixmap = XCreateBitmapFromData(display, win, hello_icon_bits,
                                        hello_icon_width, hello_icon_height);
    printf("Created pixmap with ID %#lx\n", icon_pixmap);
    
    /* Nastavení properties pro window manager */
    if(!(size_hints = XAllocSizeHints())) {
        fprintf(stderr, "Cannot allocate memory\n");
        exit(-1);
    }
    if(!(wm_hints = XAllocWMHints())) {
        fprintf(stderr, "Cannot allocate memory\n");
        exit(-1);
    }
    if(!(class_hints = XAllocClassHint())) {
        fprintf(stderr, "Cannot allocate memory\n");
        exit(-1);
    }
    /* Poloha a velikost se bere ze skuteèných hodnot okna v oka¾iku
     * namapování. PPosition | PSize øíká, ¾e hodnoty nastavil program (a
     * window manager je mù¾e mìnit podle potøeby). USSize | USPosition by
     * znamenalo, ¾e hodnoty zadal u¾ivatel (napø. na pøíkazové øádce) a
     * window manager by je nemìl mìnit. */
    size_hints->flags = PPosition | PSize | PMinSize;
    /* Window manager by nemìl okno nikdy zmen¹it na ménì ne¾
     * min_width x min_height pixelù. */
    size_hints->min_width = 300;
    size_hints->min_height = 200;
    /* Ulo¾ení jména okna a ikony */
    if(!XStringListToTextProperty(&str_window_name, 1, &window_name)) {
        fprintf(stderr, "XStringListToTextProperty() for window_name"
                " failed\n");
        exit(-1);
    }
    if(!XStringListToTextProperty(&str_icon_name, 1, &icon_name)) {
        fprintf(stderr, "XStringListToTextProperty() for icon_name"
                " failed\n");
        exit(-1);
    }
    wm_hints->initial_state = NormalState;/* Na zaèátku má být zobrazeno
                                             normální okno (ne ikona) */
    wm_hints->input = True; /* Aplikace potøebuje vstup z klávesnice */
    wm_hints->icon_pixmap = icon_pixmap;
    wm_hints->flags = StateHint | InputHint | IconPixmapHint;
    /* Jméno programu a tøídy pro hledání v resource databázi */
    class_hints->res_name = progname;
    class_hints->res_class = (char *) "HelloWorld";
    XSetWMProperties(display, win, &window_name, &icon_name, argv, argc,
                     size_hints, wm_hints, class_hints);
    
    /* Výbìr typù událostí ke zpracování */
    XSelectInput(display, win, ExposureMask | KeyPressMask |
                 ButtonPressMask | StructureNotifyMask);

    /* Nahrát font */
    load_font(&font_info);

    /* Vytvoøit graphics context pro kreslení */
    getGC(win, &gc, font_info);

    /* Namapovat okno na obrazovku (zobrazit) */
    XMapWindow(display, win);

    /* Smyèka pro pøíjem a zpracování událostí */
    while(1) {
        XNextEvent(display, &event); /* Èeká na pøíchod dal¹í události */
        switch(event.type) { /* Zpracování události */
            case Expose:
                printf("Drawing (serial=%lu send=%d count=%d x=%d y=%d "
                       "w=%d h=%d)\n",
                       event.xexpose.serial,
                       event.xexpose.send_event,
                       event.xexpose.count,
                       event.xexpose.x,
                       event.xexpose.y,
                       event.xexpose.width,
                       event.xexpose.height);
                if(event.xexpose.count == 0) {
                    if(window_too_small) { /* Pøíli¹ zmen¹ené okno */
                        printf("Drawing small\n");
                        draw_too_small(win, gc, font_info);
                    } else { /* Nakreslit obsah okna */
                        printf("Drawing normal (w=%d h=%d)\n", width, height);
                        draw_text(win, gc, font_info, width, height);
                        draw_graphics(win, gc, width, height);
                    }
                }
                break;
            case ConfigureNotify:
                /* Kdybychom nevolali XClearWindow(), tak pøi rychlé zmìnì
                 * velikosti okna my¹í postupnì window manager mìní velikost
                 * okna, co¾ má za následek smazání pøedchozího obsahu okna a
                 * vygenerování událostí ConfigureNotify a Expose. Jen¾e
                 * jestli¾e program nestihne pøekreslit okno pøed dal¹í
                 * zmìnou velikosti okna, tak X server jednou sma¾e okno, pak
                 * program nìkolikrát pøeète ConfigureNotify a Expose a
                 * nìkolikrát nakreslí obsah okna pro rùzné velikosti
                 * zji¹tìné z ConfigureNotify. Takto se pøekryje nìkolik rùznì
                 * velkých kreseb a obsah okna je ¹patný. */
		if(width != event.xconfigure.width || height != event.xconfigure.height)
		    XClearWindow(display, win);
                width = event.xconfigure.width;
                height = event.xconfigure.height;
                window_too_small = (int) width < size_hints->min_width+10 ||
                    (int) height < size_hints->min_height+10;
                printf("ConfigureNotify (serial=%lu send=%d w=%d h=%d)\n",
                       event.xconfigure.serial,
                       event.xconfigure.send_event,
                       event.xconfigure.width,
                       event.xconfigure.height);
                break;
            case ButtonPress:
            case KeyPress:
                /* Libovolná klávesa nebo tlaèítko my¹i ukonèí program */
                /* Následující dvì volání nejsou nezbytná, XCloseDisplay()
                 * uklidí v¹echny server resources alokované tímto klientem */
                XUnloadFont(display, font_info->fid);
                XFreeGC(display, gc);
                /* Odpojení od X serveru */
                XCloseDisplay(display);
                return 0;
                break;
            default:
                /* Sem se dostanou události vybrané maskou StructureNotifyMask
                 * kromì ConfigureNotify. */
                break;
        }
    }

    /* Sem se program nikdy nedostane */
    return 0;
}
示例#9
0
文件: xwin.c 项目: omnister/pdplot
void initX() {
    int x,y;
    unsigned int border_width = 4;
    unsigned int display_width, display_height;
    char *window_name = "postplot";
    char *icon_name = "postplot";
    Pixmap icon_pixmap;
    XSizeHints *size_hints;
    XIconSize *size_list;
    XWMHints *wm_hints;
    XClassHint *class_hints;
    XTextProperty windowName, iconName;
    XSetWindowAttributes attr;
    int icount;
    XFontStruct *font_info;
    char *display_name = NULL;

    int dbug=0;

    if (!(size_hints = XAllocSizeHints())) {
        fprintf(stderr, "%s: failure allocating SizeHints memory\n", progname);
        exit (0);
    }
    if (!(wm_hints = XAllocWMHints())) {
        fprintf(stderr, "%s: failure allocating WMHints memory\n", progname);
        exit (0);
    }
    if (!(class_hints = XAllocClassHint())) {
        fprintf(stderr, "%s: failure allocating ClassHint memory\n", progname);
        exit (0);
    }

    /* Connect to X server */
    if ( (dpy=XOpenDisplay(display_name)) == NULL ) {
        (void) fprintf( stderr, "%s: cannot connect to X server %s\n",
            progname, XDisplayName(display_name));
        exit(-1);
    }

    /* Get screen size from display structure macro */
    screen_num = DefaultScreen(dpy);
    display_width = DisplayWidth(dpy, screen_num);
    display_height = DisplayHeight(dpy, screen_num);

    /* eventually we want to set x,y from command line or
       resource database */

    x=y=0;

    /* Size window */
    width = display_width/2, height = display_height/2;


    /* Create opaque window */
    win = XCreateSimpleWindow(dpy, RootWindow(dpy,screen_num),
        x,y,width, height, border_width, WhitePixel(dpy,screen_num),
        BlackPixel(dpy,screen_num));

    /* Get available icon sizes from window manager */

    if (XGetIconSizes(dpy, RootWindow(dpy, screen_num),
            &size_list, &icount) == 0) {
        if (dbug) fprintf(stderr, 
		"%s: WM didn't set icon sizes - using default.\n", progname);
    } else {
        /* should eventually create a pixmap here */
        ;
    }

    /* Create pixmap of depth 1 (bitmap) for icon */
    icon_pixmap = XCreateBitmapFromData(dpy, win,
        icon_bitmap_bits, icon_bitmap_width, icon_bitmap_height);
    
    size_hints->flags = PPosition | PSize | PMinSize;
    size_hints->min_width =  300;
    size_hints->min_height = 200;

    if (XStringListToTextProperty(&window_name, 1, &windowName) == 0) {
        fprintf(stderr, "%s: structure allocation for windowName failed.\n",
            progname);
        exit(-1);
    }

    if (XStringListToTextProperty(&icon_name, 1, &iconName) == 0) {
        fprintf(stderr, "%s: structure allocation for iconName failed.\n",
            progname);
        exit(-1);
    }
    
    wm_hints->initial_state = NormalState;
    wm_hints->input = True;
    wm_hints->icon_pixmap = icon_pixmap;

    wm_hints->flags = StateHint | IconPixmapHint | InputHint;

    class_hints->res_name = progname;
    class_hints->res_class = "pdp";

    XSetWMProperties(dpy, win, &windowName, &iconName,
             (char **) NULL, (int) 0, size_hints, wm_hints, class_hints);

    /* Select event types wanted */
    XSelectInput(dpy, win, ExposureMask | KeyPressMask |
        ButtonPressMask | ButtonReleaseMask | StructureNotifyMask | 
	Button1MotionMask );

    init_colors();
    load_font(&font_info);

    /* Create GC for text and drawing */
    getGC(win, &gc, font_info);
    getGC(win, &gcx, font_info);
    XSetFunction(dpy, gcx, GXxor);

    /* Display window */
    XMapWindow(dpy, win);

    /* turn on backing store */
    attr.backing_store = Always;
    XChangeWindowAttributes(dpy,win,CWBackingStore,&attr);     
}