// reset the variables to their initial values static void init_values() { int i; screen_width=screen_info.cols; screen_height=screen_info.rows - (HEADER_TOPLINE + 1); selection_width = screen_width/selection_size; selection_height = screen_height/selection_size; iterations = ITERATIONS; xMin=-2.0; yMin=-1.25; xMax=1.25; yMax=1.25; cursor_x=0; cursor_y=0; current_depth = 0; level[current_depth].cursor_pos = -1; active_renderer=0; GrSetGCForeground(mandel_gc, GR_RGB(BLACK)); for (i=0;i<max_depth+1;i++) { level[i].mandel_buffer = GrNewPixmap(screen_width, screen_height, NULL); GrFillRect(level[i].mandel_buffer,mandel_gc,0,0,screen_width, screen_height); } }
// Creates a new tunnel "app" window void new_tunnel_window(void) { tunnel_gc = pz_get_gc(1); /* Get the graphics context */ /* Open the window: */ tunnel_wid = pz_new_window (0, 21, screen_info.cols, screen_info.rows - (HEADER_TOPLINE+1), draw_header, handle_event); GrGetWindowInfo(tunnel_wid, &wi); /* Get screen info */ /* Select the types of events you need for your window: */ GrSelectEvents (tunnel_wid, GR_EVENT_MASK_TIMER|GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_KEY_UP); // set up pixmap temp_pixmap = GrNewPixmap(screen_info.cols, (screen_info.rows - (HEADER_TOPLINE + 1)), NULL); /* Display the window: */ GrMapWindow (tunnel_wid); draw_header(); readHighScore(); reset(); }
// create the circular status animation static void create_status() { int i; int xpie[] = { 0, 3, 6, 3, 0, -3, -6, -3 }; int ypie[] = { -6, -3, 0, 3, 6, 3, 0, -3 }; // we need 16 frames GrSetGCForeground (mandel_gc, appearance_get_color( CS_TITLEBG )); for (i=0;i<16;i++) { status_image[i] = GrNewPixmap(12, 12, NULL); GrFillRect(status_image[i],mandel_gc,0,0,12,12); } // the background for (i=1;i<8;i++) { GrSetGCForeground(mandel_gc, appearance_get_color(CS_TITLEFG)); GrFillEllipse(status_image[i],mandel_gc,6,6,6,6); GrSetGCForeground(mandel_gc, appearance_get_color(CS_TITLEBG)); GrArc(status_image[i],mandel_gc,6,6,6,6,0,-6,xpie[i],ypie[i],MWPIE); } // the foreground part GrSetGCForeground(mandel_gc, appearance_get_color(CS_TITLEFG)); GrFillEllipse(status_image[8],mandel_gc,6,6,6,6); for (i=9;i<16;i++) GrArc(status_image[i],mandel_gc,6,6,6,6,0,-6,xpie[i-8],ypie[i-8],MWPIE); }
/* initialize the window */ void new_lights_window(void) { /* Init randomizer */ srand(time(NULL)); lights_gc = pz_get_gc (1); GrSetGCUseBackground(lights_gc, GR_FALSE); GrSetGCForeground(lights_gc, GR_RGB(0,0,0)); lights_height = (lights_screen_info.rows - (HEADER_TOPLINE + 1)); lights_wid = pz_new_window( 0, HEADER_TOPLINE + 1, screen_info.cols, lights_height, lights_do_draw, lights_handle_event ); lights_bufwid = GrNewPixmap( lights_screen_info.cols, lights_height, NULL ); GrSelectEvents( lights_wid, GR_EVENT_MASK_TIMER | GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_KEY_DOWN ); lights_timer = GrCreateTimer( lights_wid, 300 ); GrMapWindow( lights_wid ); /* intialize game state */ lights_new_game(); }
void new_cube_window( void ) { if (screen_info.cols==220) { photo = 1; if (!z_off) z_off = 400; } else if (screen_info.cols==138) { if (!z_off) z_off = 800; } else { if (!z_off) z_off = 600; } cube_gc = pz_get_gc(1); GrSetGCUseBackground(cube_gc, GR_FALSE); GrSetGCForeground(cube_gc, BLACK); cube_wid = pz_new_window(0, HEADER_TOPLINE + 1, screen_info.cols, screen_info.rows - (HEADER_TOPLINE + 1), cube_do_draw, cube_handle_event); GrSelectEvents( cube_wid, GR_EVENT_MASK_TIMER| GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_UP|GR_EVENT_MASK_KEY_DOWN); cube_timer = GrCreateTimer( cube_wid, 100 ); GrMapWindow( cube_wid ); x_off = screen_info.cols/2; y_off = (screen_info.rows - (HEADER_TOPLINE + 1))/2; temp_pixmap = GrNewPixmap(screen_info.cols, (screen_info.rows - (HEADER_TOPLINE + 1)), NULL); cube_init(); }
void new_invaders_window() { invaders_gc = pz_get_gc(1); GrSetGCUseBackground(invaders_gc, GR_TRUE); GrSetGCBackground(invaders_gc, GR_RGB(255,255,255)); GrSetGCForeground(invaders_gc, GR_RGB(0,0,0)); invaders_score_pix = GrNewPixmap(screen_info.cols, 13, 0); invaders_wid = pz_new_window(0, HEADER_TOPLINE + 1, screen_info.cols, screen_info.rows - HEADER_TOPLINE - 1, invaders_do_draw, invaders_handle_event); GrSelectEvents(invaders_wid, GR_EVENT_MASK_TIMER | GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_KEY_DOWN); score = 0; level = 0; aliens_rows = (screen_info.rows - 40) / 20; game_status = GAME_STATUS_PLAY; invaders_create_board(level); invaders_timer_id = GrCreateTimer(invaders_wid, 50); GrMapWindow(invaders_wid); draw_first(); }
GR_WINDOW_ID resize(GR_SIZE w, GR_SIZE h, GR_WINDOW_ID pmap) { width = w; height = h; if (pmap) GrDestroyWindow(pmap); return GrNewPixmap(w, h, NULL); }
void load_pixmap(void) { GR_GC_ID gc = GrNewGC(); g_pixmap = GrNewPixmap(16, 16, 0); GrDrawImageFromFile(g_pixmap, gc, 0, 0, -1, -1, "bin/nxroach.pgm", 0); GrDestroyGC(gc); }
Pixmap XCreatePixmap(Display * dpy, Drawable d, unsigned int width, unsigned int height, unsigned int depth) { /* Drawable ignored with nano-X */ printf("XCreatePixmap %d,%d depth %d\n", width, height, depth); // FIXME depth ignored in pixmap if (depth == 1) printf("XCreatePixmap created with depth 1\n"); return GrNewPixmap(width, height, NULL); }
static void mappaint(){ int x=0; int i=0; int p=0; GrSetGCForeground(keyman_gc, BLACK); kmimage_id=GrLoadImageFromFile(pathimage,0); yomipict_pixmap=GrNewPixmap(384,128,NULL); allmap_pixmap=GrNewPixmap(160,(TATEHABA*16),NULL); GrDrawImageToFit(yomipict_pixmap,keyman_gc,0,0,384,128,kmimage_id); for (i=0;i<=(TATEHABA-1);i++){ for (p=0;p<=9;p++){ x=pictx(wyomidata.mapd[p][i]); GrCopyArea(allmap_pixmap,keyman_gc,(p*16),(i*16),16,16,yomipict_pixmap,x,0,0); } } }
/* Make an empty sprite structure with the specified file name, width, and * height. It is expected that you will probably already have tried calling * load_sprite() first and it failed, so you want to create the sprite * manually. */ sprite *make_empty_sprite(nbstate *state, unsigned char *fname, int width, int height) { sprite *s; GR_DRAW_ID a; GR_DRAW_ID p; /* Allocate the alpha channel and pixmap with the specified * dimensions (which must be valid): */ if(!(a = GrNewPixmap(width, height, 0))) return 0; if(!(p = GrNewPixmap(width, height, 0))) { GrDestroyWindow(a); return 0; } /* Make the sprite itself and return it to the caller: */ if(!(s = make_sprite(state, fname, width, height, p, a))) { GrDestroyWindow(a); GrDestroyWindow(p); return 0; } else return s; }
void new_keyman_window( void ) { keyman_gc = GrNewGC(); GrSetGCUseBackground(keyman_gc, GR_FALSE); GrSetGCForeground(keyman_gc, WHITE); GrGetScreenInfo(&screen_info); yomipict_pixmap=GrNewPixmap(384,128,NULL); mainmenu_pixmap=GrNewPixmap(160,128,NULL); shu_pixmap=GrNewPixmap(16,16,NULL); dialogall_pixmap=GrNewPixmap(96,80,NULL); dialog_pixmap=GrNewPixmap(96,80,NULL); keyman_wid = pz_new_window(0, 0, screen_info.cols, screen_info.rows, keyman_do_draw, keyman_handle_event); if (!(kmimage_id=GrLoadImageFromFile(pathimage,0))){ GAMEN=NODATA; } else { GAMEN=MENU; GrDrawImageToFit(yomipict_pixmap,keyman_gc,0,0,384,128,kmimage_id); makedialog(); } GrSelectEvents( keyman_wid, GR_EVENT_MASK_TIMER| GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_KEY_UP|GR_EVENT_MASK_KEY_DOWN); keyman_timer = GrCreateTimer( keyman_wid, 90 ); GrMapWindow( keyman_wid ); pz_draw_header( "KeyMan" ); }
static void GrNewPixmapWrapper(void *r) { nxNewPixmapReq *req = r; GR_WINDOW_ID wid; /* FIXME: Add support for passing info about shared memory * segment */ wid = GrNewPixmap(req->width, req->height, 0); GsWriteType(current_fd,GrNumNewPixmap); GsWrite(current_fd, &wid, sizeof(wid)); }
static void create_pixmaps(menu_st *menulist, int num) { int i; menulist->pixmaps = (GR_WINDOW_ID *)malloc(sizeof(GR_WINDOW_ID) * num); menulist->pixmap_pos = (int *)malloc(sizeof(int) * num); /* initialize pixmaps */ for (i = 0; i < num; i++) { menulist->pixmaps[i] = GrNewPixmap(440, menulist->height, NULL); menulist->pixmap_pos[i] = i; menu_clear_pixmap(menulist, i); } }
GR_WINDOW_ID capture_screen(nstate *state) { GR_WINDOW_ID pid; #if CAPTURESCREEN_DELAY /* This is a hack to give the system enough time to redraw the screen * before capturing it when we switch from one screensaver to another. * without it, we often capture an only partially redrawn screen. */ msleep(CAPTURESCREEN_DELAY); #endif pid = GrNewPixmap(state->si.cols, state->si.rows, NULL); GrCopyArea(pid, state->main_gc, 0, 0, state->si.cols, state->si.rows, GR_ROOT_WINDOW_ID, 0, 0, 0); return pid; }
void new_periodic_window(void) { periodic_gc = pz_get_gc(1); GrSetGCUseBackground(periodic_gc, GR_TRUE); GrSetGCForeground(periodic_gc, GR_RGB(0,0,0)); GrSetGCBackground(periodic_gc, GR_RGB(255,255,255)); periodic_wid = pz_new_window(0, HEADER_TOPLINE + 1, screen_info.cols, screen_info.rows - (HEADER_TOPLINE + 1), periodic_event_draw, periodic_handle_event); periodic_bufwid = GrNewPixmap(screen_info.cols, screen_info.rows - HEADER_TOPLINE, NULL); periodic_sel = -1; periodic_draw_table(periodic_bufwid, periodic_gc); periodic_sel = 0; GrSelectEvents(periodic_wid, GR_EVENT_MASK_EXPOSURE| GR_EVENT_MASK_KEY_UP| GR_EVENT_MASK_KEY_DOWN); GrMapWindow(periodic_wid); }
/** * Load image from filename and return its ID */ GR_WINDOW_ID theme_load_image(char * filename) { GR_GC_ID gc; GR_IMAGE_ID iid; GR_WINDOW_ID pid; GR_IMAGE_INFO iif; gc = GrNewGC(); if(!(iid = GrLoadImageFromFile(filename, 0))) { fprintf(stderr, "Failed to load image file \"%s\"\n", filename); return 0; } GrGetImageInfo(iid, &iif); pid = GrNewPixmap(iif.width, iif.height, NULL); GrDrawImageToFit(pid, gc, 0, 0, iif.width, iif.height, iid); GrDestroyGC(gc); GrFreeImage(iid); return pid; }
/* Create a new sprite from the specified image file. Returns the address of * the new sprite on success or 0 on failure. If width is -1, the real * dimensions of the image file will be used, otherwise the image will be * scaled up or down to the specified dimensions. */ sprite *load_sprite(nbstate *state, unsigned char *fname, int width, int height) { sprite *s; GR_DRAW_ID a; GR_DRAW_ID p; GR_IMAGE_ID img; GR_IMAGE_INFO ii; /* Make sure the file name has been specified: */ if (! fname) return 0; /* Try to find a sprite in the list with the specified filename and * dimensions (any dimensions are OK if width is -1). If one is found, * increment its usage count and return its address. */ for(s = state->spritelist; s; s = s->next) { if ((width == -1 || (width == s->w && height == s->h)) && s->fname && !strcmp(fname, s->fname)) { s->usage++; return s; } } #ifdef HAVE_FILEIO { /* Make the full path to the filename because the Nano-X server * probably isn't running from the game data directory: */ char buf[256]; if (snprintf(buf, 256, "%s/%s", state->gamedir, fname) >= 256){ debug_printf ("Warning: image path \"%s/%s\" is too long\n", state->gamedir, fname); return 0; } /* Try to load the image file, and return 0 on failure: */ img = GrLoadImageFromFile (buf, 0); } #else if (strcmp (fname, (unsigned char*) "nbb1.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb1_data, sizeof( nbb1_data), 0); else if (strcmp (fname, (unsigned char*) "nbb2.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb2_data, sizeof( nbb2_data), 0); else if (strcmp (fname, (unsigned char*) "nbb3.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb3_data, sizeof( nbb3_data), 0); else if (strcmp (fname, (unsigned char*) "nbb4.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb4_data, sizeof( nbb4_data), 0); else if (strcmp (fname, (unsigned char*) "nbb5.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb5_data, sizeof( nbb5_data), 0); else if (strcmp (fname, (unsigned char*) "nbb6.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb6_data, sizeof( nbb6_data), 0); else if (strcmp (fname, (unsigned char*) "nbb7.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb7_data, sizeof( nbb7_data), 0); else if (strcmp (fname, (unsigned char*) "nbb8.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb8_data, sizeof( nbb8_data), 0); else if (strcmp (fname, (unsigned char*) "nbb9.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbb9_data, sizeof( nbb9_data), 0); else if (strcmp (fname, (unsigned char*)"nbball1.gif") == 0) img = GrLoadImageFromBuffer ((char*)nbball1_data, sizeof(nbball1_data), 0); else if (strcmp (fname, (unsigned char*) "nbbat1.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbat1_data, sizeof( nbbat1_data), 0); else if (strcmp (fname, (unsigned char*) "nbbat2.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbat2_data, sizeof( nbbat2_data), 0); else if (strcmp (fname, (unsigned char*) "nbbat3.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbat3_data, sizeof( nbbat3_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg10.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg10_data, sizeof( nbbg10_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg1.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg1_data, sizeof( nbbg1_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg2.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg2_data, sizeof( nbbg2_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg3.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg3_data, sizeof( nbbg3_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg4.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg4_data, sizeof( nbbg4_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg5.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg5_data, sizeof( nbbg5_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg6.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg6_data, sizeof( nbbg6_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg7.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg7_data, sizeof( nbbg7_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg8.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg8_data, sizeof( nbbg8_data), 0); else if (strcmp (fname, (unsigned char*) "nbbg9.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbbg9_data, sizeof( nbbg9_data), 0); else if (strcmp (fname, (unsigned char*) "nbpf.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpf_data, sizeof( nbpf_data), 0); else if (strcmp (fname, (unsigned char*) "nbpn.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpn_data, sizeof( nbpn_data), 0); else if (strcmp (fname, (unsigned char*) "nbpp.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpp_data, sizeof( nbpp_data), 0); else if (strcmp (fname, (unsigned char*) "nbps.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbps_data, sizeof( nbps_data), 0); else if (strcmp (fname, (unsigned char*) "nbpt.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpt_data, sizeof( nbpt_data), 0); else if (strcmp (fname, (unsigned char*) "nbpw.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbpw_data, sizeof( nbpw_data), 0); else if (strcmp (fname, (unsigned char*) "nbsp1.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbsp1_data, sizeof( nbsp1_data), 0); else if (strcmp (fname, (unsigned char*) "nbsp2.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbsp2_data, sizeof( nbsp2_data), 0); else if (strcmp (fname, (unsigned char*) "nbsp3.gif") == 0) img = GrLoadImageFromBuffer ((char*) nbsp3_data, sizeof( nbsp3_data), 0); else { debug_printf ("No such image: \"%s\"\n", fname); uos_halt (0); return 0; } #endif if (! img) { debug_printf ("Warning: failed to load image \"%s\"- make " "sure it is where the server can find it and " "that support for loading the relevant image " "type has been built into the server\n", fname); return 0; } /* If a size wasn't specified, get the real image size from the server * instead: */ if(width == -1 || height == -1) { GrGetImageInfo(img, &ii); width = ii.width; height = ii.height; } /* Make the alpha channel and pixmap to store the image in: */ if(!(a = GrNewPixmap(width, height, 0))) { GrFreeImage(img); return 0; } if(!(p = GrNewPixmap(width, height, 0))) { GrFreeImage(img); GrDestroyWindow(a); return 0; } /* Draw the image into the specified pixmap and alpha channel, scaling * it up or down if necessary: */ GrDrawImageToFit(p, state->gc, 0, 0, width, height, img); GrFreeImage(img); /* Destroy the server image object. */ /* Make a new sprite and link it into the list, then return its * address to the caller: */ s = make_sprite(state, fname, width, height, p, a); if (! s) { GrDestroyWindow(a); GrDestroyWindow(p); return 0; } return s; }
int main(int argc,char **argv) { char *imagefile = "bin/slidebmp.bmp"; if (GrOpen() < 0) { GrError("cannot open graphics\n"); exit(1); } gc1 = GrNewGC(); #if USE_IMAGE image = GrNewWindow(GR_ROOT_WINDOW_ID, 300, 0, (WIDTH_IN_TILES * tile_width), (HEIGHT_IN_TILES * tile_height), 4, BLACK, WHITE); if (argc > 1) imagefile = argv[1]; /* need to find out image size.... */ image_addr = malloc(4 * (WIDTH_IN_TILES * tile_width) * (HEIGHT_IN_TILES * tile_height)); image = GrNewPixmap((WIDTH_IN_TILES * tile_width), (HEIGHT_IN_TILES * tile_height), image_addr); GrDrawImageFromFile(image, gc1, 0, 0, GR_IMAGE_MAX_SIZE, GR_IMAGE_MAX_SIZE, imagefile, 0); #endif /* calculate size of tile area */ calc_width = 10 + (WIDTH_IN_TILES * tile_width); calc_height = 15 + 35 + (HEIGHT_IN_TILES * tile_height); #if 0 /* enforce minimum size */ if (calc_width < 240) calc_width=240; if (calc_height < 320) calc_height=320; #endif master = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, calc_width, calc_height, 1, RED, WHITE); buttons = GrNewWindow((GR_WINDOW_ID) master, 5, 5, (calc_width - 5), 35, 1, RED, RED); tiles = GrNewWindow((GR_WINDOW_ID) master, (calc_width/2) - (WIDTH_IN_TILES * tile_width /2), 45 + ((calc_height - 50)/2) - (HEIGHT_IN_TILES * tile_height /2), (WIDTH_IN_TILES * tile_width), (HEIGHT_IN_TILES * tile_height), 1, RED, RED); GrMapWindow(master); GrMapWindow(buttons); GrMapWindow(tiles); /* set random seed */ srandom((int) getpid()); RandomiseTiles(); GrSelectEvents(master, GR_EVENT_MASK_EXPOSURE|GR_EVENT_MASK_CLOSE_REQ| GR_EVENT_MASK_KEY_DOWN); GrSelectEvents(buttons, GR_EVENT_MASK_BUTTON_DOWN); GrSelectEvents(tiles, GR_EVENT_MASK_BUTTON_DOWN); RefreshWindow(); while (GR_TRUE) { GR_EVENT event; GrGetNextEvent(&event); HandleEvents(&event); } }
// // Member Function // void CContextWeather::Init() { CObject* pObject; CObjectIcon* pObjectIcon; UINT id; CContext::Init(); // 배경 이미지 pObject = new CObjectImage(m_wid_parent, m_gc, 0, 0, g_scr_info.cols, g_scr_info.rows); if(pObject) { pObject->LoadImage(IMG_BACKGROUND, "/app/img/main_bg_blank.png"); id = m_ObjectList.AddObject(pObject); } // 왼쪽 날씨 이미지 pObject = new CObjectIcon(m_wid_parent, m_gc, 1, 169, 300, 246); if(pObject) { pObjectIcon = (CObjectIcon*)pObject; pObjectIcon->AllocImageCount(IMG_ENUM_WEATHER_COUNT); pObject->LoadImage(IMG_ENUM_WEATHER_SERENITY, "/app/img/weather/serenity.png"); pObject->LoadImage(IMG_ENUM_WEATHER_PARTLY_CLOUDY, "/app/img/weather/partly_cloudy.png"); pObject->LoadImage(IMG_ENUM_WEATHER_CLOUDY, "/app/img/weather/cloudy.png"); pObject->LoadImage(IMG_ENUM_WEATHER_SHOWER, "/app/img/weather/shower.png"); pObject->LoadImage(IMG_ENUM_WEATHER_RAINNY, "/app/img/weather/rainny.png"); pObject->LoadImage(IMG_ENUM_WEATHER_THUNDERSTORM, "/app/img/weather/thunderstorm.png"); pObject->LoadImage(IMG_ENUM_WEATHER_SNOW, "/app/img/weather/snow.png"); id = m_ObjectList.AddObject(pObject); } // 오른쪽 날씨 이미지 pObject = new CObjectIcon(m_wid_parent, m_gc, 499, 169, 300, 246); if(pObject) { pObjectIcon = (CObjectIcon*)pObject; pObjectIcon->AllocImageCount(IMG_ENUM_WEATHER_COUNT); pObject->LoadImage(IMG_ENUM_WEATHER_SERENITY, "/app/img/weather/serenity.png"); pObject->LoadImage(IMG_ENUM_WEATHER_PARTLY_CLOUDY, "/app/img/weather/partly_cloudy.png"); pObject->LoadImage(IMG_ENUM_WEATHER_CLOUDY, "/app/img/weather/cloudy.png"); pObject->LoadImage(IMG_ENUM_WEATHER_SHOWER, "/app/img/weather/shower.png"); pObject->LoadImage(IMG_ENUM_WEATHER_RAINNY, "/app/img/weather/rainny.png"); pObject->LoadImage(IMG_ENUM_WEATHER_THUNDERSTORM, "/app/img/weather/thunderstorm.png"); pObject->LoadImage(IMG_ENUM_WEATHER_SNOW, "/app/img/weather/snow.png"); id = m_ObjectList.AddObject(pObject); } // 가스On/Off 이미지 pObject = new CObjectIcon(m_wid_parent, m_gc, 325, 245, 137, 137); //좌측여백 13 if(pObject) { pObjectIcon = (CObjectIcon*)pObject; pObjectIcon->AllocImageCount(IMG_ENUM_GAS_COUNT); pObject->LoadImage(IMG_ENUM_GAS_ON, "/app/img/main_icon/main_gas_on.png"); //적색 가스사용 pObject->LoadImage(IMG_ENUM_GAS_OFF, "/app/img/main_icon/main_gas_off.png"); //녹색 가스차단 id = m_ObjectList.AddObject(pObject); } // 주차아이콘 pObject = new CObjectImage(m_wid_parent, m_gc, 0, 419, 261, 61); if(pObject) { pObject->LoadImage(IMG_BACKGROUND, "/app/img/main_bar_back.png"); id = m_ObjectList.AddObject(pObject); } //g_setup_data.m_SetupData.gas_stat: 0=사용중, 1=사용차단 m_isGasOff = (g_setup_data.m_SetupData.gas_stat) ? TRUE : FALSE; //멘트가 표시될 서브 윈도 m_wid_ment = GrNewWindow(g_wid, MENT_AREA_X, MENT_AREA_Y, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, 0, 0, 0); if(m_wid_ment) { // GrMapWindow(m_wid_ment); //이미지 버퍼링을 처리할 Pixel Map // m_pixmap_ment = GrNewPixmap(MENT_AREA_WIDTH, MENT_AREA_HEIGHT, NULL); m_pixmap_ment = GrNewPixmap(MENT_PIXEL_MAP_WIDTH, MENT_AREA_HEIGHT, NULL); #if 0 RedrawImage(m_wid_ment, g_gc, 0, 0, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, MENT_AREA_X, MENT_AREA_Y, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, WEATHER_OBJ_BG); RedrawImage(m_pixmap_ment, g_gc, 0, 0, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, MENT_AREA_X, MENT_AREA_Y, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, WEATHER_OBJ_BG); DrawText(g_szWeatherMent[g_setup_data.m_SetupData.today_weather], m_pixmap_ment, g_gc, 0, 0, m_width_ment, MENT_AREA_HEIGHT, g_font, 24, WHITE, TXT_HALIGN_LEFT|TXT_VALIGN_MIDDLE); GrRaiseWindow(m_wid_ment); #endif } else { DBGMSGC(DBG_WEATHER, "%s: GrNewWindow failure\r\n", __func__); } }
/* Assign an arbitrary char to the cursor */ Cursor XCreateGlyphCursor(Display * display, Font source_font, Font mask_font, unsigned int source_char, unsigned int mask_char, XColor XCONST * foreground, XColor XCONST * background) { Cursor ret; int tw[2], th[2], tb[2]; unsigned char ch[2]; GR_GC_ID gc; GR_WINDOW_ID cursor; GR_COLOR fc, bc; GR_RECT cbb, mbb; GR_FONT_INFO srcinfo, maskinfo; gc = GrNewGC(); /*GrSetGCUseBackground(gc, GR_FALSE);*/ /* assume NewGC defaults TRUE*/ GrSetGCForeground(gc, GR_RGB(255, 255, 255)); GrSetGCBackground(gc, GR_RGB( 0, 0, 0)); /* Draw both the fonts into their appropriate pixmap, and create the cursor */ GrGetFontInfo((GR_FONT_ID) source_font, &srcinfo); GrGetFontInfo((GR_FONT_ID) mask_font, &maskinfo); ch[0] = srcinfo.firstchar + source_char; ch[1] = maskinfo.firstchar + mask_char; /* Use the mask as the determining size */ GrSetGCFont(gc, (GR_FONT_ID) mask_font); GrGetGCTextSize(gc, &ch[0], 1, GR_TFTOP, &tw[0], &th[0], &tb[0]); GrGetGCTextSize(gc, &ch[1], 1, GR_TFTOP, &tw[1], &th[1], &tb[1]); cursor = GrNewPixmap(tw[1] * 2, th[1], 0); /* Draw the mask first, to avoid having to switch fonts in the GC */ GrText(cursor, gc, tw[1], 0, &ch[1], 1, GR_TFTOP|GR_TFASCII); /* Offset the first char by 1 1 */ GrSetGCFont(gc, (GR_FONT_ID) source_font); GrText(cursor, gc, 1, 1, &ch[0], 1, GR_TFTOP|GR_TFASCII); /* Calculate the bounding box */ cbb.x = 0; cbb.y = 0; cbb.width = tw[0]; cbb.height = th[0]; mbb.x = tw[1]; mbb.y = 0; mbb.width = tw[1]; mbb.height = th[1]; fc = GR_RGB(foreground->red >> 8, foreground->green >> 8, foreground->blue >> 8); bc = GR_RGB(background->red >> 8, background->green >> 8, background->blue >> 8); /* cursor hotspot is (leftbearing, ascent)*/ ret = _nxCreateCursor(cursor, &cbb, cursor, &mbb, 0, tb[1], fc, bc); GrDestroyWindow(cursor); GrDestroyGC(gc); return ret; }
void initialise(lstate *state) { GR_SCREEN_INFO si; GR_IMAGE_ID back_image; GR_IMAGE_INFO imageinfo; int rows = 1, columns = 1, width, height, x = 0, y = 0; GR_WM_PROPERTIES props; litem *i; if(GrOpen() < 0) { GrError("Couldn't connect to Nano-X server\n"); exit(4); } state->window_background_mode = 0; state->window_background_image = NULL; sspid = -1; read_config(state); GrGetScreenInfo(&si); if(si.rows > si.cols) { rows = state->numlitems; while((((rows / columns) + rows % columns) * ITEM_HEIGHT) > si.rows) { columns++; } if((columns * ITEM_WIDTH) > si.cols) goto toomany; rows = (rows / columns) + (rows % columns); width = columns * ITEM_WIDTH + 1 + columns; height = rows * ITEM_HEIGHT + 1 + rows; } else { columns = state->numlitems; while((((columns / rows) + (columns % rows)) * ITEM_WIDTH) > si.cols) { rows++; } if((rows * ITEM_HEIGHT) > si.rows) goto toomany; columns = (columns / rows) + (columns % rows); width = columns * ITEM_WIDTH + 1 + columns; height = (rows * ITEM_HEIGHT) + 1 + rows; y = si.rows - (rows * ITEM_HEIGHT) - 1 - rows; } state->gc = GrNewGC(); GrSetGCForeground(state->gc, ITEM_TEXT_COLOUR); GrSetGCBackground(state->gc, ITEM_BACKGROUND_COLOUR); if(state->window_background_image) { if(!(back_image = GrLoadImageFromFile( state->window_background_image, 0))) { GrError("Couldn't load background image\n"); } else { GrGetImageInfo(back_image, &imageinfo); if(!(state->background_pixmap = GrNewPixmap( imageinfo.width, imageinfo.height, NULL))) { GrError("Couldn't allocate pixmap " "for background image\n"); } else { GrDrawImageToFit(state->background_pixmap, state->gc, 0, 0, imageinfo.width, imageinfo.height, back_image); GrFreeImage(back_image); GrSetBackgroundPixmap(GR_ROOT_WINDOW_ID, state->background_pixmap, state->window_background_mode); GrClearWindow(GR_ROOT_WINDOW_ID, GR_TRUE); } } } if(state->ssitems) GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_SCREENSAVER); state->main_window = GrNewWindow(GR_ROOT_WINDOW_ID, 0, y, width, height, 0, ITEM_BACKGROUND_COLOUR, 0); GrSelectEvents(state->main_window, GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_TIMER); props.flags = GR_WM_FLAGS_PROPS; props.props = GR_WM_PROPS_NOMOVE | GR_WM_PROPS_NODECORATE | GR_WM_PROPS_NOAUTOMOVE | GR_WM_PROPS_NOAUTORESIZE; GrSetWMProperties(state->main_window, &props); i = state->lastlitem; y = 0; while(i) { i->wid = GrNewWindow(state->main_window, (x * ITEM_WIDTH) + x + 1, (y * ITEM_HEIGHT) + y + 1, ITEM_WIDTH, ITEM_HEIGHT, 1, ITEM_BACKGROUND_COLOUR, ITEM_BORDER_COLOUR); GrSelectEvents(i->wid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN); GrMapWindow(i->wid); i = i->prev; if(++x == columns) { x = 0; y++; } } GrMapWindow(state->main_window); signal(SIGCHLD, &reaper); do_startups(state); return; toomany: GrError("Too many items to fit on screen\n"); exit(6); }
/* Initialise the game and return the state structure or NULL on failure: */ nbstate *init(int argc, char *argv[]) { GR_PROP *prop; nbstate *state; GR_SCREEN_INFO si; GR_BITMAP cursor = 0; GR_WM_PROPERTIES props; /* Try to connect to the Nano-X server: */ if(GrOpen() < 1) { fprintf(stderr, "Couldn't connect to Nano-X server\n"); return NULL; } /* Check that the server was built with alpha blending support * (necessary for the alpha blended sprites and special effects): */ GrGetScreenInfo(&si); if(!si.alphablend) { fprintf(stderr, "Error: Nano-X server was built without alpha " "blending support\nSet ALPHABLENDING = 1 in " "include/device.h, rebuild, and try again.\n"); return NULL; } /* Allocate the state structure and initialise it with defaults: */ if(!(state = malloc(sizeof(nbstate)))) return NULL; setup_default_state(state); /* Try to parse the command line arguments: */ if(parse_cmd_args(state, argc, argv)) { free(state); return NULL; } /* Try to load the game file: */ if(load_game_file(state)) { free(state); return NULL; } /* Load the high score file: */ load_hiscore(state); /* Calculate the canvas size: */ state->canvaswidth = state->width * state->brickwidth; state->canvasheight = state->scores.h + state->ball.s->h + (2 * BALLS_BORDER) + (state->height * state->brickheight) + 3 * state->brickheight + state->batheight; /* Place the bat in the centre of the window: */ state->batx = state->canvaswidth / 2; /* Create various pixmaps and alpha channels: */ state->scores.p = GrNewPixmap(state->canvaswidth, state->scores.h, NULL); state->scores.a = GrNewAlpha(state->canvaswidth, state->scores.h); state->canvas = GrNewPixmap(state->canvaswidth, state->canvasheight, NULL); /* The new and old canvasses are only used when screen fading is * enabled: */ if(state->faderate) { state->newcanvas = GrNewPixmap(state->canvaswidth, state->canvasheight, NULL); state->oldcanvas = GrNewPixmap(state->canvaswidth, state->canvasheight, NULL); } state->brickalpha = GrNewAlpha(state->brickwidth, state->brickheight); /* Start off with the canvas completely black: */ GrSetGCForeground(state->gc, GR_COLOR_BLACK); GrFillRect(state->canvas, state->gc, 0, 0, state->canvaswidth, state->canvasheight); /* If there is a window manager running, place the window off the * screen and let the window manager move it where it wants (avoids * flicker if we were to draw the window on screen before the window * manager moved it somewhere else): */ if(GrGetWindowProperty(GR_ROOT_WINDOW_ID, "WINDOW_MANAGER", &prop)) { free(prop); state->winx = GR_OFF_SCREEN; } /* Create the output window: */ state->wid = GrNewWindow(GR_ROOT_WINDOW_ID, state->winx, 0, state->canvaswidth, state->canvasheight, 0, 0, 0); /* Set the window title: */ props.flags = GR_WM_FLAGS_TITLE; props.title = "NanoBreaker"; GrSetWMProperties(state->wid, &props); /* Make the cursor over the output window be invisible: */ GrSetCursor(state->wid, 1, 1, 1, 1, 0, 0, &cursor, &cursor); /* Select the events we want to receive for the output window: */ GrSelectEvents(state->wid, GR_EVENT_MASK_CLOSE_REQ | GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP | GR_EVENT_MASK_UPDATE | GR_EVENT_MASK_TIMER); /* Select for mouse position events on the root window so we can move * the bat even when the pointer strays outside the window (which it * often does because the cursor is invisible you don't know exactly * where it is): */ GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_MOUSE_POSITION); /* Map the output window (make it visible): */ GrMapWindow(state->wid); /* Create the one second periodic timer that is used to decrement the * power-up and power-down timers: */ state->tid = GrCreateTimer(state->wid, 1000, GR_TRUE); /* Reset the game: */ reset_game(state); return state; /* Return the newly allocated state structure. */ }
void new_chopper_window(void) { int i,g; i=0; chopGC = pz_get_gc(1); /* Get the graphics context */ GrGetScreenInfo(&screen_info); /* Get screen info */ /* Open the window: */ chopWindow = pz_new_window (0, 21, screen_info.cols, screen_info.rows - 21, /* Height of screen - header */ chopDrawScene, chopHandleEvent); chopBuffer = GrNewPixmap(screen_info.cols, (screen_info.rows - (HEADER_TOPLINE + 1)), NULL); iScreenX = screen_info.cols; iScreenY = screen_info.rows - 21; /* Select the types of events you need for your window: */ GrSelectEvents (chopWindow, GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_TIMER | GR_EVENT_MASK_KEY_UP); /* Display the window: */ GrMapWindow (chopWindow); /* Create the timer used for animating your application: */ chopTimer = GrCreateTimer (chopWindow, 75); /* Timer interval, millisecs */ /*chopDrawScene();*/ iRotorOffset = 0; //chopAddBlock(100,100,20,20); iPlayerPosX = 60; iPlayerPosY = iScreenY * 0.2; iLastBlockPlacedPosX = 0; iGravityTimerCountdown = 2; iPlayerAlive = 1; chopCounter = 0; while(i < NUMBER_OF_BLOCKS) { mBlocks[i].bIsActive = 0; i++; } g = iScreenY - 10; chopClearTerrain(&mGround); i=0; while(i < MAX_TERRAIN_NODES) //we could add less, probably. { chopAddTerrainNode(&mGround,i * 30,g - iR(0,20)); i++; } if(chopUpdateTerrainRecycling(&mGround)==1) chopCopyTerrain(&mGround,&mRoof,0,-( iScreenY * 0.75)); //mirror the sky if we've changed the ground iLevelMode = iR(1,2); iPlayerSpeedX = 4; iPlayerSpeedY = 0; if(iLevelMode == LEVEL_MODE_NORMAL) iPlayerSpeedX*=2; //make it a bit more exciting, cause it's easy terrain... //printf("level mode: %d",iLevelMode); bWaitingToStart = 1; }
int main() { #ifdef TEST_FOR_X Display *display; Window window; GC gc; XGCValues gcValues; Colormap colormap; Pixmap src_pixmap; unsigned long fgColor, bgColor; int screenNum; XPoint points[NUM_POINTS]; #else GR_WINDOW_ID window; GR_WINDOW_ID src_pixmap; unsigned char* src_pixmap_buf[320*240*2]; GR_GC_ID gc; GR_POINT points[NUM_POINTS]; #endif int c, c1, count=4500; int x, y, x1, y1, x2, y2; #ifdef TEST_FOR_X if(!(display=XOpenDisplay(""))) { printf("Cannot connect to X.\n"); } screenNum = DefaultScreen(display); colormap = DefaultColormap(display, screenNum); bgColor = BlackPixel(display, screenNum); fgColor = WhitePixel(display, screenNum); window = XCreateSimpleWindow(display, RootWindow(display, screenNum), 0, 0 , 639, 479, 0, fgColor, bgColor); src_pixmap = XCreatePixmap(display, window, 320, 240, 16); XMapRaised(display, window); gcValues.background = bgColor; gcValues.foreground = fgColor; gcValues.line_width = 1; gcValues.line_style = LineSolid; gcValues.fill_style = FillSolid; gcValues.fill_rule = WindingRule; gcValues.arc_mode = ArcPieSlice; gc = XCreateGC(display, window, GCForeground | GCBackground | GCLineWidth | GCLineStyle | GCFillStyle, &gcValues); #else GrOpen(); window = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 639, 479, 0, BLACK, BLUE); src_pixmap = GrNewPixmap(640, 480, src_pixmap_buf); GrMapWindow(window); gc = GrNewGC(); GrSetGCForeground(gc, WHITE); GrSetGCBackground(gc, BLACK); GrSetGCMode(gc, GR_MODE_COPY); #endif // Horizontal Line //////////////////////////////////////////////// printf("Horizontal Line(XDrawLine)\n"); start_timer(); for(c=0; c<count*20; c++) { y1=random()%480; #ifdef TEST_FOR_X XDrawLine(display, window, gc, 0, y1, 639, y1); XFlush(display); #else GrLine(window, gc, 0, y1, 639, y1); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // Vertical Line ///////////////////////////////////////////////// printf("Vertical Line(XDrawLine)\n"); start_timer(); for(c=0; c<count*19; c++) { x1=random()%640; #ifdef TEST_FOR_X XDrawLine(display, window, gc, x1, 0, x1, 479); XFlush(display); #else GrLine(window, gc, x1, 0, x1, 479); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // General Line ///////////////////////////////////////////////// printf("General Line(XDrawLine)\n"); start_timer(); for(c=0; c<count*22; c++) { x1 = random()%640; x2 = random()%640; y1 = random()%480; y2 = random()%480; #ifdef TEST_FOR_X XDrawLine(display, window, gc, x1, y1, x2, y2); XFlush(display); #else GrLine(window, gc, x1, y1, x2, y2); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // Point ////////////////////////////////////////////////// printf("XPoint\n"); start_timer(); for(c=0; c<count*25; c++) { x1 = random()%640; y1 = random()%480; #ifdef TEST_FOR_X XDrawPoint(display, window, gc, x1, y1); XFlush(display); #else GrPoint(window, gc, x1, y1); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // Rectangle ////////////////////////////////////////////////// printf("XRectangle\n"); start_timer(); for(c=0; c<count*20; c++) { x1=random()%639; y1=random()%479; x2=random()%(639-x1)+1; y2=random()%(479-y1)+1; #ifdef TEST_FOR_X XDrawRectangle(display, window, gc, x1, y1, x2, y2); XFlush(display); #else GrRect(window, gc, x1, y1, x2, y2); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // FillRectangle ////////////////////////////////////////////////// printf("XFillRectangle\n"); start_timer(); for(c=0; c<count*18; c++) { x1=random()%639; y1=random()%479; x2=random()%(639-x1)+1; y2=random()%(479-y1)+1; #ifdef TEST_FOR_X XFillRectangle(display, window, gc, x1, y1, x2, y2); XFlush(display); #else GrFillRect(window, gc, x1, y1, x2, y2); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // FillPolygon ////////////////////////////////////////////////// printf("XFillPolygon\n"); start_timer(); for(c=0; c<count; c++) { for(c1=0; c1<NUM_POINTS; c1++) { points[c1].x = random()%640; points[c1].y = random()%480; } #ifdef TEST_FOR_X XFillPolygon(display, window, gc, points, NUM_POINTS, 0, 0); XFlush(display); #else GrFillPoly(window, gc, NUM_POINTS, points); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XClearWindow(display, window); #else GrClearWindow(window, GR_TRUE); #endif // CopyArea ///////////////////////////////////////////////// printf("XCopyArea\n"); start_timer(); for(c=0; c<count*5; c++) { x1=random()%320; y1=random()%240; x2=random()%319+1; y2=random()%239+1; #ifdef TEST_FOR_X XCopyArea(display, src_pixmap, window, gc, 0, 0, x2, y2, x1, y1); XFlush(display); #else GrCopyArea(window, gc, x1, y1, x2 ,y2, src_pixmap, 0, 0, 0); GrFlush(); #endif } end_timer(); #ifdef TEST_FOR_X XDestroyWindow(display, window); #else GrClose(); #endif }
/* menu initialization, make sure to do a menu_destroy when you are finished */ menu_st *menu_init(GR_WINDOW_ID menu_wid, char *title, int x, int y, int w, int h, menu_st *parent, item_st *items, int op) { menu_st *menulist; int i; menulist = (menu_st *)malloc(sizeof(menu_st)); if (!menulist) { return NULL; } /* starting with an empty slate */ if(items == NULL) { menulist->items = (item_st *)malloc(20 * sizeof(item_st)); menulist->num_items = 0; menulist->alloc_items = 20; } /* starting with a static menu */ else { menulist->items = items; for(i = 0; items[i].text != 0; i++) items[i].orig_pos = i; menulist->num_items = i; menulist->alloc_items = 0; } menulist->title = title; menulist->op = op; menulist->sel = 0; menulist->init = 0; menulist->timer = 0; menulist->top_item = 0; menulist->scheme_no = -1; menulist->scrollbar = 0; menulist->timer_step = 0; menulist->parent = parent; menulist->lastsel = -1; menulist->menu_gc = pz_get_gc(1); GrGetGCTextSize(menulist->menu_gc, "abcdefghijhlmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, GR_TFASCII, &menulist->width, &menulist->height, &menulist->base); /* add a 2px padding to the text */ menulist->height += 4; /* determine how many items can fit on a screen */ menulist->screen_items = (int)h/menulist->height; menulist->x = x; menulist->y = y; menulist->w = w; menulist->h = h; menulist->menu_wid = menu_wid; menulist->font = get_current_font(); create_pixmaps(menulist, menulist->screen_items); menulist->transition = GrNewPixmap(menulist->w*2, menulist->h, NULL); #if 0 Dprintf("Init::%d items per screen at %dpx\n\tbecause %d/%d == %d\n", menulist->screen_items, menulist->height, menulist->h, menulist->height, menulist->screen_items); #endif return menulist; }
int main(int argc,char **argv) { GR_EVENT event; /* current event */ GR_BITMAP bitmap1fg[7]; /* bitmaps for first cursor */ GR_BITMAP bitmap1bg[7]; GR_BITMAP bitmap2fg[7]; /* bitmaps for second cursor */ GR_BITMAP bitmap2bg[7]; if (GrOpen() < 0) { fprintf(stderr, "cannot open graphics\n"); exit(1); } GrGetScreenInfo(&si); w1 = GrNewWindow(GR_ROOT_WINDOW_ID, 100, 50, si.cols - 120, si.rows - 60, 1, BROWN, WHITE); w2 = GrNewWindow(GR_ROOT_WINDOW_ID, 6, 6, W2_WIDTH, W2_HEIGHT, 2, GREEN, WHITE); w3 = GrNewWindow(GR_ROOT_WINDOW_ID, 250, 30, 80, 100, 1, LTGRAY, GREEN); w4 = GrNewWindow(GR_ROOT_WINDOW_ID, 350, 20, 200, 150, 5, BLACK, WHITE); w5 = GrNewWindow(GR_ROOT_WINDOW_ID, 11, 143, 209, 100, 1, BLUE, GREEN); p1 = GrNewPixmap(200,200,0); GrSelectEvents(w1, GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_FOCUS_IN | GR_EVENT_MASK_FOCUS_OUT | GR_EVENT_MASK_CLOSE_REQ); GrSelectEvents(w2, GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_CLOSE_REQ); GrSelectEvents(w3, GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_MOUSE_MOTION | GR_EVENT_MASK_CLOSE_REQ); GrSelectEvents(w4, GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_MOUSE_POSITION | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_CLOSE_REQ); GrSelectEvents(w5, GR_EVENT_MASK_MOUSE_ENTER | GR_EVENT_MASK_MOUSE_EXIT | GR_EVENT_MASK_CLOSE_REQ); GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_CLOSE_REQ); GrMapWindow(w1); GrMapWindow(w2); GrMapWindow(w3); GrMapWindow(w4); GrMapWindow(w5); gc1 = GrNewGC(); gc2 = GrNewGC(); gc3 = GrNewGC(); gc4 = GrNewGC(); GrSetGCForeground(gc1, RED); GrSetGCBackground(gc1, BROWN); GrSetGCForeground(gc2, MAGENTA); GrSetGCMode(gc4, GR_MODE_XOR); bitmap1fg[0] = MASK(_,_,_,X,_,_,_); bitmap1fg[1] = MASK(_,_,_,X,_,_,_); bitmap1fg[2] = MASK(_,_,_,X,_,_,_); bitmap1fg[3] = MASK(X,X,X,X,X,X,X); bitmap1fg[4] = MASK(_,_,_,X,_,_,_); bitmap1fg[5] = MASK(_,_,_,X,_,_,_); bitmap1fg[6] = MASK(_,_,_,X,_,_,_); bitmap1bg[0] = MASK(_,_,X,X,X,_,_); bitmap1bg[1] = MASK(_,_,X,X,X,_,_); bitmap1bg[2] = MASK(X,X,X,X,X,X,X); bitmap1bg[3] = MASK(X,X,X,X,X,X,X); bitmap1bg[4] = MASK(X,X,X,X,X,X,X); bitmap1bg[5] = MASK(_,_,X,X,X,_,_); bitmap1bg[6] = MASK(_,_,X,X,X,_,_); bitmap2fg[0] = MASK(_,_,X,X,X,_,_); bitmap2fg[1] = MASK(_,X,_,_,_,X,_); bitmap2fg[2] = MASK(X,_,_,_,_,_,X); bitmap2fg[3] = MASK(X,_,_,_,_,_,X); bitmap2fg[4] = MASK(_,X,_,_,_,X,_); bitmap2fg[5] = MASK(_,_,X,X,X,_,_); bitmap2bg[0] = MASK(_,_,X,X,X,_,_); bitmap2bg[1] = MASK(_,X,X,X,X,X,_); bitmap2bg[2] = MASK(X,X,X,X,X,X,X); bitmap2bg[3] = MASK(X,X,X,X,X,X,X); bitmap2bg[4] = MASK(_,X,X,X,X,X,_); bitmap2bg[5] = MASK(_,_,X,X,X,_,_); GrSetCursor(w1, 7, 7, 3, 3, WHITE, BLACK, bitmap1fg, bitmap1bg); GrSetCursor(w2, 7, 6, 3, 3, WHITE, BLACK, bitmap2fg, bitmap2bg); GrRect(GR_ROOT_WINDOW_ID, gc1, 0, 0, si.cols, si.rows); while (1) { GrGetNextEvent(&event); switch (event.type) { case GR_EVENT_TYPE_BUTTON_DOWN: do_buttondown(&event.button); break; case GR_EVENT_TYPE_BUTTON_UP: do_buttonup(&event.button); break; case GR_EVENT_TYPE_MOUSE_POSITION: case GR_EVENT_TYPE_MOUSE_MOTION: do_motion(&event.mouse); break; case GR_EVENT_TYPE_KEY_DOWN: do_keystroke(&event.keystroke); break; case GR_EVENT_TYPE_EXPOSURE: do_exposure(&event.exposure); break; case GR_EVENT_TYPE_FOCUS_IN: do_focusin(&event.general); break; case GR_EVENT_TYPE_FOCUS_OUT: do_focusout(&event.general); break; case GR_EVENT_TYPE_MOUSE_ENTER: do_enter(&event.general); break; case GR_EVENT_TYPE_MOUSE_EXIT: do_exit(&event.general); break; case GR_EVENT_TYPE_CLOSE_REQ: GrClose(); exit(0); case GR_EVENT_TYPE_NONE: do_idle(); break; } } }