/** @brief Main in-game rendering routine. * * @param b Board configuration to render. */ void draw_scene(board_t *b, GLuint fb, int reflections) { char temp[80]; int clock_seconds = 0; int clock_minutes = 0; glBindFramebuffer(GL_FRAMEBUFFER, fb); transition_update(); gg_dialog_cleanup(); glDisable(GL_BLEND); glDepthFunc(GL_ALWAYS); draw_backdrop(); glEnable(GL_BLEND); glDepthFunc(GL_LEQUAL); go_3d(get_screen_width(), get_screen_height()); render_scene_3d(b, fb, reflections); mouse_square = find_square(get_true_mouse_x(), get_true_mouse_y()); glBindFramebuffer(GL_FRAMEBUFFER, fb); resize_window(get_screen_width(), get_screen_height()); glPushMatrix(); draw_ui_elements(); // draw_move_list(get_col(COL_WHITE), get_col(COL_YELLOW)); // draw_capture_list(get_col(COL_WHITE)); clock_minutes = (((SDL_GetTicks() - get_turn_counter()) / 1000) / 60); clock_seconds = ((SDL_GetTicks() - get_turn_counter()) / 1000) - (clock_minutes * 60); snprintf(temp, sizeof(temp), "%i:%02i", clock_minutes, clock_seconds); /*text_draw_string( 303, 440, temp, 1, &col_black);*/ glPopMatrix(); /*if ( get_white_in_check() == TRUE ) text_draw_string_bouncy( 180, 420, "White is in check!", 1, get_col(COL_WHITE)); else if ( get_black_in_check() == TRUE ) text_draw_string_bouncy( 180, 420, "Black is in check!", 1, get_col(COL_WHITE));*/ gg_dialog_render_all(); if (get_fading_out()) { if (!draw_fade(FADE_OUT)) set_switch_to_menu(TRUE); } else { if (get_show_egg()) draw_sonic_fade(FADE_IN); else draw_fade(FADE_IN); } /* Draw mouse cursor.. */ draw_texture(get_mouse_cursor(), get_mouse_x(), (479 - get_mouse_y() - 32), 32, 32, 1.0f, get_col(COL_WHITE)); }
void Init_Frame_Buffer_Mode(mp_image_t *mpi) { if(display_mode & LCD_OUT) { if(display_mode & DISP_32BIT) img_param.ipu_d_fmt |= OUT_FMT_RGB888; else // 16BIT img_param.ipu_d_fmt |= OUT_FMT_RGB565; } else //tv_out img_param.ipu_d_fmt |= (OUT_FMT_YUV422 | (1 << 16)); img_param.in_bpp = 16; useframebuf = (int)lcd_get_change_phyframe(); img_param.out_buf = useframebuf; stride.out = get_screen_width() * (img_param.in_bpp / 8 ); jz47_put_image_with_ipu = jz47_put_image_with_framebuf; img_param.y_buf = mpi->planes[0]; img_param.u_buf = mpi->planes[1]; img_param.v_buf = mpi->planes[2]; stride.y = mpi->stride[0]; stride.u = mpi->stride[1]; stride.v = mpi->stride[2]; dump(&img_param); lcd_clean_frame_all(); lcd_ioctl((void*)&img_param,IOCTL_SET_IPU); }
/* * figure out max length, then figure out number of cols we * can do and then list them */ list_show() { int i; int maxlen = 0; int pagewidth; int cols, col_len, col_wid; int row, col; char *name; /* figure out lengths and widths of columns */ for(i=0; i<taken; i++) if ( strlen(namelist[i]) > maxlen ) maxlen = strlen(namelist[i]); col_wid = maxlen+1; pagewidth = get_screen_width(); cols = pagewidth / col_wid ; col_len = taken / cols ; if ( taken % cols ) /* for uneven cols, put the */ col_len++; /* extra on the left */ /* print the list using these numbers */ for( row = 0 ; row < col_len ; row++ ) for( col = 0 ; col < cols ; col++ ){ i = row + col*col_len ; if ( i < taken ){ if ( i + col_len < taken ) printf("%-*s",col_wid,namelist[i]); else printf("%s\n",namelist[i]); } } }
int main(int argc, char* argv[]) { create_image_world(); int image = create_image(100, 100); for(int x = 0; x < 100; x++) { for(int y = 0; y < 100; y++) { if (x == y) { set_pixel(image, x, y, 255, 0, 0, 255); } else if (x+y == 100) { set_pixel(image, x, y, 255, 255, 0, 0); } else { set_pixel(image, x, y, 255, 0, 255, 0); } } } put_image(image, get_screen_width()/2-get_image_width(image)/2, get_screen_height()/2-get_image_height(image)/2); return p1world_shutdown(); }
/* Calculate how many groups fit across the screen */ static unsigned int get_groups_across(const struct electorate *voter_elec) { unsigned int group_width; group_width = get_group_width(voter_elec); /* We want to round UP, not DOWN. */ /* NOOOO, we want to round down!!! or else we get a partial group */ return (get_screen_width()) / group_width; }
static float get_area_ui_object_virtual_x (ui_object *obj) { area_ui_object *area; float px = 0; ui_object *parent; if (get_ui_object_virtual_coords (obj)) { // is this right ? check parent = get_ui_object_parent (obj); if (parent) { //px = get_ui_object_virtual_x (parent); } area = (area_ui_object *) obj->data; return area->x_start + px; } else { float x; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { x = (get_ui_object_x (obj) - get_ui_object_x (parent)) / get_ui_object_x_size (parent); } else { x = get_ui_object_x (obj) / get_screen_width (video_screen); } return x; } }
int main(int argc, char* argv) { turn_on_debug_output(); create_image_world(); // Write your code here int v = load_bmp("plane.bmp"); put_image(v, (get_screen_width() / 2) - (get_image_width(v) / 2), (get_screen_height() / 2) - (get_image_height(v) / 2)); return p1world_shutdown(); }
void Video_GL::render_all() { assert(!m_render_target); #ifdef _WINDOWS glFlush(); #else glFinish(); #endif get_Textures().unlose_resources(); get_Fonts().unlose_resources(); get_Game().prerender(); glViewport(0, 0, get_screen_width(), get_screen_height()); if(!is_zwrite_enabled()) glDepthMask(GL_TRUE); set_clear_color_impl(get_clear_color()); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if(!is_zwrite_enabled()) glDepthMask(GL_FALSE); get_Game().render(); /*** Begin CPU saver ***/ #ifdef MANUAL_GL_VSYNC_DELAY Timer &tr = get_Timer(); if(get_vertical_sync()) { Time buffer_swap_start_time = tr.get_time(); const unsigned int time_allowed = 1000u/60u - 2u; const unsigned int new_time_taken = buffer_swap_start_time.get_ticks_since(m_buffer_swap_end_time); m_time_taken = (1.0f - m_weight_new) * m_time_taken + m_weight_new * new_time_taken; if(m_time_taken < time_allowed) SDL_Delay(static_cast<unsigned int>(time_allowed - m_time_taken)); } #endif /// Swap the buffers <-- NOT part of the CPU saver, but the reason it is "needed" #if SDL_VERSION_ATLEAST(1,3,0) SDL_GL_SwapWindow(get_window()); #else SDL_GL_SwapBuffers(); #endif #ifdef MANUAL_GL_VSYNC_DELAY m_buffer_swap_end_time = tr.get_time(); #endif }
void MenuBar::slot_clicked (size_t k) { for (;;) { assert (k < item_list.size ()); // Get the item Item &item = item_list[k]; // Highlight the selected item choose_palette (PALETTE_ID_MENUBAR_SELECT); item.text.output(*this, {item.w, 0}, item.text.get_width()); Size left = window().get_pos() + get_pos() + Size{item.w, 1}; Size right{get_screen_width(), left.y}; // Pop out sub menu MenuItem *chosen_item = item.menu->show (left, right); // Restore display choose_palette (PALETTE_ID_MENUBAR); item.text.output(*this, {item.w, 0}, item.text.get_width()); // Deal with the result if (chosen_item) { chosen_item->action.emit (); break; } // LEFT/RIGHT key? MouseEvent me_buf; wchar_t c = window().get_noblock(&me_buf); if (c == LEFT) { k = (k + item_list.size () - 1) % item_list.size (); } else if (c == RIGHT) { k = (k + 1) % item_list.size (); } else { if (c) { if (c == MOUSE) { window().unget(me_buf); } else { window().unget(c); } } break; } } }
/* * Show prograss bar as follows. * * 45.0 % [===============> ] 180 MB / 400 MB */ void show_progress(uint64_t done, uint64_t total, bool raw) { char done_str[256], total_str[256]; int screen_width = get_screen_width(); int bar_length = screen_width - 30; char *buf; if (!is_stdout_console()) return; if (screen_width <= 0) return; printf("\r"); /* move to the beginning of the line */ if (raw) { snprintf(done_str, sizeof(done_str), "%"PRIu64, done); snprintf(total_str, sizeof(total_str), "%"PRIu64, total); } else { size_to_str(done, done_str, sizeof(done_str)); size_to_str(total, total_str, sizeof(total_str)); } buf = xmalloc(screen_width + 1); snprintf(buf, screen_width, "%5.1lf %% [", (double)done / total * 100); for (int i = 0; i < bar_length; i++) { if (total * (i + 1) / bar_length <= done) strcat(buf, "="); else if (total * i / bar_length <= done && done < total * (i + 1) / bar_length) strcat(buf, ">"); else strcat(buf, " "); } snprintf(buf + strlen(buf), screen_width - strlen(buf), "] %s / %s", done_str, total_str); /* fill the rest of buffer with blank characters */ memset(buf + strlen(buf), ' ', screen_width - strlen(buf)); buf[screen_width] = '\0'; printf("%s", buf); if (done == total) printf("\n"); fflush(stdout); free(buf); }
void asgtk_image_view_screen_aspect_toggle (GtkWidget * checkbutton, gpointer data) { ASGtkImageView *iv = ASGTK_IMAGE_VIEW (data); if (GTK_TOGGLE_BUTTON (checkbutton)->active) { asgtk_image_view_set_aspect (iv, get_screen_width (NULL), get_screen_height (NULL)); asgtk_image_view_set_resize (iv, ASGTK_IMAGE_VIEW_TILE_TO_ASPECT, ASGTK_IMAGE_VIEW_TILE_TO_ASPECT); } else { asgtk_image_view_set_aspect (iv, -1, -1); asgtk_image_view_set_resize (iv, 0, ASGTK_IMAGE_VIEW_TILE_TO_ASPECT); } }
void Video_DX9::render_all() { assert(!m_render_target); static bool reset = false; if(reset) { const HRESULT result = m_d3d_device->TestCooperativeLevel(); if(result == D3DERR_DEVICELOST) return; else if(result == D3DERR_DRIVERINTERNALERROR) throw Video_Device_Failure(); if(result == D3DERR_DEVICENOTRESET) { if(FAILED(m_d3d_device->Reset(&m_d3d_parameters))) throw Video_Device_Failure(); reset = false; init_context(); } } get_Textures().unlose_resources(); get_Fonts().unlose_resources(); HRESULT result = m_d3d_device->Present(0, 0, 0, 0); if(result == S_OK) { D3DVIEWPORT9 vp = {0, 0, DWORD(get_screen_width()), DWORD(get_screen_height()), 0, 1}; m_d3d_device->SetViewport(&vp); m_d3d_device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(get_clear_color().r_ub(), get_clear_color().g_ub(), get_clear_color().b_ub()), 1.0f, 0); m_d3d_device->BeginScene(); get_Game().render(); m_d3d_device->EndScene(); } else if(result == D3DERR_DEVICELOST) { reset = true; return; } else if(result == D3DERR_DEVICEREMOVED) { throw Video_Device_Failure(); } }
void mouse_input(int button, int state, int x, int y) { unsigned char pixelrgb[4]; unsigned int distance; //printf("mouse button: %i state: %i position (%i,%i)\n", button, state, x, y); last_position.button = button; last_position.state = state; last_position.x = x; last_position.y = y; if (button == LEFT_MOUSE && state == MOUSE_DOWN) ray_test(glm::vec2(x,y), glm::vec2(get_screen_width(), get_screen_height())); else if( button == MIDDLE_MOUSE && state == MOUSE_DOWN) { glReadPixels(x, get_screen_height() - y - 1, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char *)pixelrgb); glReadPixels( x, get_screen_height() - y - 1, 1, 1, GL_DEPTH_COMPONENT, GL_INT, &distance ); printf("(%u, %u, %u, %u) Distance: %i\n", pixelrgb[0], pixelrgb[1], pixelrgb[2], pixelrgb[3], distance); } }
TS_DefaultOnStartSelecting(TS* ts) { HWND hwnd = HWND_FROM_TS(ts); HDC hdc; RECT rect; int max_width; int max_height; int screen_width; int screen_height; int i; hdc = GetDC(hwnd); if (hdc == NULL) { FAILURE(T("TS_DefaultOnStartSelecting/GetDC")); return !0; } ZeroMemory(&rect, sizeof(rect)); max_height = 2; max_width = 2; for (i = 0; i < g_TaskList->count; i++) { DrawText( hdc, g_TaskList->list[i]->title, -1, &rect, DT_CALCRECT | DT_NOPREFIX | DT_SINGLELINE ); if (max_height < rect.bottom) max_height = rect.bottom; if (max_width < rect.right) max_width = rect.right; } resize( hwnd, 2 + max_width + 2, 2 + ((1+max_height+1) * g_TaskList->count) + 2 ); screen_width = get_screen_width(); screen_height = get_screen_height(); GetClientRect(hwnd, &rect); move( hwnd, screen_width / 2 - rect.right / 2, screen_height / 2 - rect.bottom / 2 ); ReleaseDC(hwnd, hdc); return 0; }
static float get_area_ui_object_x (ui_object *obj) { area_ui_object *area; float x, px = 0; ui_object *parent; parent = get_ui_object_parent (obj); if (parent) { px = get_ui_object_x (parent); } area = (area_ui_object *) obj->data; x = area->x_start + ( get_ui_object_bounded_t_value (obj) * ( area->x_end - area->x_start ) ); if (area->virtual_coords) { if (parent) { x *= get_ui_object_x_size (parent); } else { x *= get_screen_width (video_screen); } } return x + px; }
void widget_move(int16 x, int16 y) { ui.screen.newmousepos.x = x; ui.screen.newmousepos.y = y; if(ui.moving){ int windowx, windowy; glfwGetWindowPos(get_the_window(),&windowx, &windowy); glfwSetWindowPos(get_the_window(),x + windowx - ui.screen.mouseclick.x, y + windowy - ui.screen.mouseclick.y); } else{ if(focused){ if(focused->action & WIDGET_MOVING){ int16 tempx = x - ui.screen.mousepos.x ; int16 tempy = y - ui.screen.mousepos.y ; if(focused->pos.x + tempx <= 0 || focused->pos.y + tempy <= 0) return; if(focused->pos.x + focused->width + tempx>= get_screen_width() +400|| focused->pos.y + focused->height + tempy >= get_screen_height() + 400) return; focused->pos.x = focused->pos.x + tempx ; focused->pos.y = focused->pos.y + tempy ; widget_position_update(focused); } if(widget_rect_contains(focused)) widget_mouse_over(focused); } else{ if(ui.root) widget_mouse_over(ui.root); } } }
void save_high_res_screen_image ( void ) { char filename[100], image_filename[100]; int x, y, x_repeat, y_repeat, screen_width, screen_height, screen_pitch; unsigned short int *huge_screen_shot_memory; unsigned char *screen_data; x_repeat = 8; y_repeat = 8; screen_width = get_screen_width ( video_screen ); screen_height = get_screen_height ( video_screen ); huge_screen_shot_memory = ( unsigned short int * ) safe_malloc ( sizeof ( unsigned short int ) * screen_width * screen_height * x_repeat * y_repeat ); for ( y = 0; y < y_repeat; y++ ) { for ( x = 0; x < x_repeat; x++ ) { unsigned short int *destination_ptr, *screen_line; int screen_y; // // Render the big views // draw_application_highres_screen ( x, y, x_repeat, y_repeat ); if ( lock_screen ( video_screen ) ) { screen_data = get_screen_data ( video_screen ); screen_pitch = get_screen_pitch ( video_screen ); destination_ptr = huge_screen_shot_memory + ( y * x_repeat * screen_width * screen_height ) + ( x * screen_width ); for ( screen_y = 0; screen_y < screen_height; screen_y++ ) { screen_line = ( unsigned short int * ) ( screen_data + ( screen_y * screen_pitch ) ); memcpy ( destination_ptr, screen_line, screen_width * sizeof ( unsigned short int ) ); destination_ptr += x_repeat * screen_width; } unlock_screen ( video_screen ); } } } // // find first screen shot index // if (!found_first_screen_shot_index) { while (TRUE) { sprintf (image_filename, "%sIMAGE%03d.PSD", LARGE_IMAGE_PATH, screen_shot_index); if (file_exist (image_filename)) { screen_shot_index++; if (screen_shot_index == 1000) { break; } } else { found_first_screen_shot_index = TRUE; break; } } } // // write screen files and viewpoint data file // if (screen_shot_index <= MAX_SCREEN_SHOT_INDEX) { sprintf (filename, "IMAGE%03d", screen_shot_index); debug_log ("Saving screen image (%s)", filename); sprintf (image_filename, "%s%s.PSD", LARGE_IMAGE_PATH, filename); write_psd_screen_file ( image_filename, screen_width * x_repeat, screen_height * y_repeat, screen_width * x_repeat * sizeof ( unsigned short int ), ( unsigned char * ) huge_screen_shot_memory ); screen_shot_index++; } else { debug_colour_log (DEBUG_COLOUR_RED, "Exceeded screen image limit"); } safe_free ( huge_screen_shot_memory ); }
void Video_DX9::init() { set_opengl_flag(false); Video::init(); SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); SDL_GetWMInfo(&wmInfo); cout << "Initializing DirectX 9" << endl; m_d3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_d3d_capabilities); m_dpi = GetDeviceCaps(GetDC(wmInfo.window), LOGPIXELSY); ZeroMemory(&m_d3d_parameters, sizeof(m_d3d_parameters)); m_d3d_parameters.hDeviceWindow = wmInfo.window; m_d3d_parameters.Windowed = true; m_d3d_parameters.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; m_d3d_parameters.BackBufferCount = 1; m_d3d_parameters.BackBufferWidth = UINT(get_screen_width()); m_d3d_parameters.BackBufferHeight = UINT(get_screen_height()); m_d3d_parameters.BackBufferFormat = D3DFMT_A8R8G8B8; m_d3d_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; m_d3d_parameters.PresentationInterval = get_vertical_sync() ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; m_d3d_parameters.Flags = 0; //D3DPRESENTFLAG_LOCKABLE_BACKBUFFER; m_d3d_parameters.EnableAutoDepthStencil = true; m_d3d_parameters.AutoDepthStencilFormat = D3DFMT_D16; if(get_multisampling() > 1) switch(get_multisampling()) { case 2: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; break; case 3: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_3_SAMPLES; break; case 4: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_4_SAMPLES; break; case 5: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_5_SAMPLES; break; case 6: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_6_SAMPLES; break; case 7: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_7_SAMPLES; break; case 8: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES; break; case 9: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_9_SAMPLES; break; case 10: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_10_SAMPLES; break; case 11: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_11_SAMPLES; break; case 12: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_12_SAMPLES; break; case 13: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_13_SAMPLES; break; case 14: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_14_SAMPLES; break; case 15: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_15_SAMPLES; break; case 16: default: m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_16_SAMPLES; break; } else if(get_multisampling() < 0) m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_16_SAMPLES; else m_d3d_parameters.MultiSampleType = D3DMULTISAMPLE_NONE; m_d3d_parameters.MultiSampleQuality = 0; // Initialize the D3D device if(!init_device()) throw Video_Init_Failure(); // Initialize the rendering context init_context(); }
static void draw_area_ui_object (ui_object *obj) { float x, y, x1, y1, x2, y2; int redraw_flag = FALSE, masked, width, height, pitch; font_types font_id; area_ui_object *area; struct SCREEN *old_active_screen, *memory_graphic; unsigned short int *graphic; struct ZOOMABLE_GRAPHIC *zoomable_graphic; unsigned char *data; ui_object *parent; if (get_ui_object_redraw (obj)) { area = (area_ui_object *) obj->data; //debug_log ("AR_DRAW: drawing area %f, %f %f, %f", area->x, area->y, area->x_size, area->y_size); x1 = area->x; y1 = area->y; x2 = x1 + area->x_size; y2 = y1 + area->y_size; old_active_screen = get_active_screen (); if (get_ui_object_active_screen (obj)) { set_active_screen (get_ui_object_active_screen (obj)); } else { set_active_screen (video_screen); } if (lock_screen (active_screen)) { switch (get_ui_object_graphic_type (obj)) { case UI_OBJECT_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_MEMORY_GRAPHIC: { memory_graphic = get_ui_object_memory_graphic (obj); if (lock_screen (memory_graphic)) { width = get_screen_width (memory_graphic); height = get_screen_height (memory_graphic); data = get_screen_data (memory_graphic); pitch = get_screen_pitch (memory_graphic); masked = get_ui_object_clear (obj); ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, masked); unlock_screen (memory_graphic); } redraw_flag = TRUE; break; } case UI_OBJECT_ALPHA_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_alpha_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_ZOOMABLE_PALETTE_GRAPHIC: { if (!get_ui_object_clear (obj)) { zoomable_graphic = get_ui_object_zoomable_palette_graphic (obj); draw_zoomable_graphic (zoomable_graphic, area->cx, area->cy, x1, y1, x2, y2, area->zoom); redraw_flag = TRUE; } break; } case UI_OBJECT_NO_GRAPHIC: default: { if (!get_ui_object_clear (obj)) { ui_draw_area (x1, y1, x2, y2); redraw_flag = TRUE; } } } // text position if (get_ui_object_text (obj)) { font_id = get_ui_font (); set_ui_font (get_ui_object_font (obj)); get_text_position (&x, &y, x1, y1, x2, y2, obj); ui_display_text (get_ui_object_text (obj), x, y); set_ui_font (font_id); redraw_flag = TRUE; } if (redraw_flag) { set_ui_repaint_area (x1 + ui_x_origin, y1 + ui_y_origin, x2 + ui_x_origin + 1, y2 + ui_y_origin + 1); } unlock_screen (active_screen); } set_active_screen (old_active_screen); area->redraw --; call_ui_object_draw_function (obj, NULL); } }
static void jz47_ipu_init (struct vf_instance_s* vf,mp_image_t *mpi) { F("1\n"); SwsContext *c = vf->priv->ctx; int outW, outH; int out_w,out_h; int out_x,out_y; outW = mpi->width; outH = mpi->height; c->dstW = outW; c->dstH = outH; if(ipu_inited) PEND_IPU(); switch(ipu_size_cfg) { case MP_IMAGE_TYPE_CUSTORM: out_w = g_out_w; out_h = g_out_h; break; case MP_IMAGE_TYPE_INITSIZE: if((outH <= FB_LCD_HEIGHT) && (outW <= FB_LCD_WIDTH)) { out_x = (FB_LCD_WIDTH - outW) / 2; out_y = (FB_LCD_HEIGHT - outH) / 2; out_w = outW; out_h = outH; }else eqscale(outW,outH,&out_x,&out_y,&out_w,&out_h); break; case MP_IMAGE_TYPE_EQSIZE: eqscale(outW,outH,&out_x,&out_y,&out_w,&out_h); break; case MP_IMAGE_TYPE_FULLSCREEN: fullscreen(outW,outH,&out_x,&out_y,&out_w,&out_h); break; } img_param.ratio_table = ipu_ratio_table; { img_param.in_width = outW; img_param.in_height = outH; img_param.out_width = out_w; img_param.out_height = out_h; img_param.out_x = out_x; img_param.out_y = out_y; img_param.stride = &stride; img_param.csc = &ipu_csc; } dump(&img_param); if((ipu_inited == 0) || (display_mode & CHANGE_OUT_MODE)) { display_mode &= ~CHANGE_OUT_MODE; int srcFormat= c->srcFormat; switch (srcFormat) { case PIX_FMT_YUV420P: img_param.ipu_d_fmt = IN_FMT_YUV420; break; case PIX_FMT_YUV422P: img_param.ipu_d_fmt = IN_FMT_YUV422; break; case PIX_FMT_YUV444P: img_param.ipu_d_fmt = IN_FMT_YUV444; break; case PIX_FMT_YUV411P: img_param.ipu_d_fmt = IN_FMT_YUV411; break; } get_ipu_addr(ipu_addr); // if(display_mode & DISP_ALL) // { // if(1)//get_screen_height() * get_screen_width() <= 480 * 272 * 2) // display_mode |= DISP_DIRECT; // else // display_mode &= ~DISP_ALL; // } display_mode &= ~IPU_PEND; Init_Direct_Mode(mpi); // if((display_mode & LCD_OUT) && (display_mode & DISP_DIRECT)) // { // display_mode &= ~IPU_PEND; // Init_Direct_Mode(mpi); // }else // { // printf("Init Frame Buffer mode\n"); // display_mode |= IPU_PEND; // Init_Frame_Buffer_Mode(mpi); // } ipu_inited = 1; }else { printf("+++++++++++++++++++resize\n"); if((display_mode & DISP_DIRECT)) { lcd_ioctl(&img_param, IOCTL_LCD_RESIZE_ALL); }else { lcd_clean_frame_all(); useframebuf = lcd_get_change_phyframe(); img_param.out_buf = useframebuf; lcd_ioctl(&img_param, IOCTL_LCD_RESIZE); } Flush_OSDScrean(); printf("-------------------resize\n"); } SetVideoOutMode(mplayer_setdisplaymode); framebuf_offset = (img_param.out_x + img_param.out_y * get_screen_width()) * (img_param.in_bpp / 8); dump(&img_param); }
int get_mouse_x(void) { return ((float)mouse_pos.x / (float)get_screen_width()) * get_gl_width(); }
int main(int argc, char **argv) { prog_name = argv[0]; int show_the_system_info = 0; int show_the_numastat_info = 0; static struct option long_options[] = { {"help", 0, 0, '?'}, {0, 0, 0, 0} }; int long_option_index = 0; int opt; while ((opt = getopt_long(argc, argv, "cmnp:s::vVz?", long_options, &long_option_index)) != -1) { switch (opt) { case 0: printf("Unexpected long option %s", long_options[long_option_index].name); if (optarg) { printf(" with arg %s", optarg); } printf("\n"); display_usage_and_exit(); break; case 'c': compress_display = 1; break; case 'm': show_the_system_info = 1; break; case 'n': show_the_numastat_info = 1; break; case 'p': if ((optarg) && (all_digits(optarg))) { add_pid_to_list(atoi(optarg)); } else { add_pids_from_pattern_search(optarg); } break; case 's': sort_table = 1; if ((optarg) && (all_digits(optarg))) { sort_table_node = atoi(optarg); } break; case 'v': verbose = 1; break; case 'V': display_version_and_exit(); break; case 'z': show_zero_data = 0; break; default: case '?': display_usage_and_exit(); break; } } // Figure out the display width, which is used to format the tables // and limit the output columns per row screen_width = get_screen_width(); // Any remaining arguments are assumed to be additional process specifiers while (optind < argc) { if (all_digits(argv[optind])) { add_pid_to_list(atoi(argv[optind])); } else { add_pids_from_pattern_search(argv[optind]); } optind += 1; } // If there are no program options or arguments, be extremely compatible // with the old numastat perl script (which is included at the end of this // file for reference) compatibility_mode = (argc == 1); init_node_ix_map_and_header(compatibility_mode); // enumarate the NUMA nodes if (compatibility_mode) { show_numastat_info(); free_node_ix_map_and_header(); exit(EXIT_SUCCESS); } // Figure out page sizes page_size_in_bytes = (double)sysconf(_SC_PAGESIZE); huge_page_size_in_bytes = get_huge_page_size_in_bytes(); // Display the info for the process specifiers if (num_pids > 0) { sort_pids_and_remove_duplicates(); show_process_info(); } if (pid_array != NULL) { free(pid_array); } // Display the system-wide memory usage info if (show_the_system_info) { show_system_info(); } // Display the numastat statistics info if ((show_the_numastat_info) || ((num_pids == 0) && (!show_the_system_info))) { show_numastat_info(); } free_node_ix_map_and_header(); exit(EXIT_SUCCESS); }
int main() { struct egui_uds client_uds = {0}; si_t s_width = 0, s_height = 0, gd = 0; const char test_str[] = "hello, egui!"; struct rectangle area = {0}; /** * 初始化客户端通信句柄 **/ if(0 != uds_init(&client_uds, SOCK_STREAM, SERVER_PATH, PEER_ROLE_CLIENT)) { EGUI_PRINT_ERROR("Failed to init server uds"); return -1; } /** * 初始化客户端 **/ client_lib_init(&client_uds, NULL); EGUI_PRINT_INFO("client init sucessfully!"); /** * 获取屏幕的高和宽,输出 **/ s_width = get_screen_width(); s_height = get_screen_height(); if(s_width < 0 || s_height < 0) { EGUI_PRINT_ERROR("failed to get screen width or height"); return -1; } EGUI_PRINT_INFO("screen width = %d, height = %d", (int)s_width, (int)s_height); /** * 初始化图形设备 **/ gd = graphics_device_init(300, 300, 1000, 600, 255, 0, 0, 0, FONT_MATRIX_12); if(gd < 0) { EGUI_PRINT_ERROR("failed to init gd"); return -1; } /** * 显示字符串:hello egui **/ if(0 != show_text(gd, 300, 300, test_str, strlen(test_str)) || 0 != update(gd)) { EGUI_PRINT_ERROR("failed to show test \"%s\"", test_str); return -1; } /** * 图形设备退出 **/ if(0 != graphics_device_exit(gd)) { EGUI_PRINT_ERROR("failed to exit graph device"); return -1; } /** * 最大化窗口,输出返回的窗口大小 **/ if(0 != maximize_window(10, &area)) { EGUI_PRINT_ERROR("failed to max window"); return -1; } EGUI_PRINT_INFO("maximize window area = (%d, %d), %d, %d", (int)area.x, (int)area.y, (int)area.width, (int)area.height); if(0 != window_manager_quit()) { EGUI_PRINT_ERROR("failed to let window manager quit"); return -1; } /** * 清理通信句柄 **/ if(0 != uds_exit(&client_uds)) { EGUI_PRINT_ERROR("failed to clean uds"); return -1; } return 0; }
/* public functions */ GtkWidget * asgtk_gradient_new () { ASGtkGradient *ge; GtkWidget *main_vbox, *main_hbox; GtkWidget *scrolled_window ; GtkWidget *list_vbox ; GtkWidget *frame, *hbox, *vbox, *btn, *table; GtkWidget *label ; ge = g_object_new (ASGTK_TYPE_GRADIENT, NULL); colorize_gtk_window( GTK_WIDGET(ge) ); gtk_container_set_border_width( GTK_CONTAINER (ge), 5 ); main_vbox = GTK_DIALOG(ge)->vbox ; main_hbox = gtk_hbox_new (FALSE, 5); gtk_widget_show (main_hbox); gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, TRUE, TRUE, 0); list_vbox = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (main_hbox), list_vbox, FALSE, FALSE, 0); frame = gtk_frame_new("Gradient direction : "); gtk_box_pack_start (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5); table = gtk_table_new( 2, 2, FALSE ); gtk_container_add (GTK_CONTAINER (frame), table); gtk_container_set_border_width (GTK_CONTAINER (table), 3); ge->l2r_radio = gtk_radio_button_new_with_label( NULL, "Left to Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->l2r_radio, 0, 1, 0, 1); ge->t2b_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->l2r_radio), "Top to Bottom" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->t2b_radio, 0, 1, 1, 2); ge->tl2br_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->t2b_radio), "Top-Left to Bottom-Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->tl2br_radio, 1, 2, 0, 1); ge->bl2tr_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->tl2br_radio), "Bottom-Left to Top-Right" ); gtk_table_attach_defaults (GTK_TABLE (table), ge->bl2tr_radio, 1, 2, 1, 2); gtk_widget_show_all (table); gtk_widget_show (table); colorize_gtk_widget( frame, get_colorschemed_style_normal() ); g_signal_connect ((gpointer) ge->l2r_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->tl2br_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->t2b_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); g_signal_connect ((gpointer) ge->bl2tr_radio, "clicked", G_CALLBACK (on_direction_clicked), ge); ge->screen_width_check = gtk_check_button_new_with_label("Use screen width"); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_width_check), TRUE ); ge->width_entry = gtk_spin_button_new_with_range( 1, 10000, 1 ); gtk_widget_set_sensitive( ge->width_entry, FALSE ); ge->screen_height_check = gtk_check_button_new_with_label("Use screen height"); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_height_check), TRUE ); ge->height_entry = gtk_spin_button_new_with_range( 1, 10000, 1 ); gtk_widget_set_sensitive( ge->height_entry, FALSE ); g_signal_connect ((gpointer) ge->screen_width_check, "clicked", G_CALLBACK (on_size_clicked), ge); g_signal_connect ((gpointer) ge->screen_height_check, "clicked", G_CALLBACK (on_size_clicked), ge); ge->size_frame = gtk_frame_new("Rendered gradient size : "); gtk_box_pack_start (GTK_BOX (list_vbox), ge->size_frame, FALSE, FALSE, 5); colorize_gtk_tree_view_window( GTK_WIDGET(ge->size_frame) ); table = gtk_table_new( 2, 4, FALSE ); gtk_container_set_border_width( GTK_CONTAINER (table), 3 ); gtk_container_add( GTK_CONTAINER(ge->size_frame), table ); gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Width : "), 0, 1, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), ge->width_entry, 1, 2, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Height : "), 2, 3, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), ge->height_entry, 3, 4, 0, 1); gtk_table_attach (GTK_TABLE (table), ge->screen_width_check, 0, 2, 1, 2, GTK_FILL, GTK_FILL, 10, 0); gtk_table_attach (GTK_TABLE (table), ge->screen_height_check, 2, 4, 1, 2, GTK_FILL, GTK_FILL, 10, 0); gtk_widget_show_all (table); gtk_widget_show (table); colorize_gtk_widget( ge->size_frame, get_colorschemed_style_normal() ); scrolled_window = asgtk_gradient_create_color_list( ge ); gtk_box_pack_start (GTK_BOX (list_vbox), scrolled_window, FALSE, FALSE, 0); ge->color_entry = gtk_entry_new_with_max_length(24); gtk_entry_set_width_chars( GTK_ENTRY(ge->color_entry), 16 ); #if 0 ge->color_preview = gtk_color_button_new(); g_signal_connect ((gpointer) ge->color_preview, "clicked", G_CALLBACK (on_color_preview_clicked), ge); #else ge->color_preview = gtk_image_new(); update_color_preview( ge, DEFAULT_COLOR_STR ); #endif ge->offset_entry = gtk_spin_button_new_with_range( 0., 1., 0.05 ); frame = gtk_frame_new("Change point attributes : "); gtk_box_pack_end (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5); colorize_gtk_tree_view_window( GTK_WIDGET(frame) ); vbox = gtk_vbox_new( FALSE, 5 ); gtk_container_add( GTK_CONTAINER(frame), vbox ); table = gtk_table_new( 4, 2, FALSE ); gtk_container_set_border_width( GTK_CONTAINER (table), 3 ); // hbox = gtk_hbox_new( FALSE, 5 ); // gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 ); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); label = gtk_label_new("Color : "); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1); label = gtk_label_new("Offset : "); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 0, 1); gtk_table_attach (GTK_TABLE (table), ge->color_entry, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2); gtk_table_attach (GTK_TABLE (table), ge->offset_entry, 3, 4, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2); frame = gtk_frame_new(NULL); colorize_gtk_tree_view_window( GTK_WIDGET(frame) ); gtk_widget_set_size_request( frame, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT ); gtk_container_set_border_width( GTK_CONTAINER (table), 0 ); gtk_container_add( GTK_CONTAINER(frame), ge->color_preview ); gtk_widget_show( ge->color_preview ); btn = gtk_button_new(); gtk_container_set_border_width( GTK_CONTAINER (btn), 0 ); //btn = gtk_button_new_with_label(" Color selector "); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_container_add (GTK_CONTAINER (btn), frame); gtk_widget_show (frame); g_signal_connect ((gpointer) frame, "size-allocate", G_CALLBACK (color_preview_size_alloc), ge); gtk_table_attach (GTK_TABLE (table), btn, 0, 2, 1, 2, GTK_FILL, GTK_SHRINK, 2, 2); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_color_clicked), ge); gtk_widget_show_all (table); gtk_widget_show (table); hbox = gtk_hbox_new( FALSE, 5 ); gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 ); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); ge->delete_btn = btn = gtk_button_new_from_stock(GTK_STOCK_DELETE); gtk_widget_set_sensitive( ge->delete_btn, FALSE ); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_delete_point_clicked), ge); btn = gtk_button_new_from_stock(GTK_STOCK_ADD); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_add_point_clicked), ge); ge->apply_btn = btn = gtk_button_new_from_stock(GTK_STOCK_APPLY); gtk_widget_set_sensitive( ge->apply_btn, FALSE ); colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button()); gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0); g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_apply_point_clicked), ge); gtk_widget_show_all (hbox); gtk_widget_show (hbox); /* The preview : */ ge->image_view = ASGTK_IMAGE_VIEW(asgtk_image_view_new()); gtk_widget_set_size_request (GTK_WIDGET(ge->image_view), PREVIEW_WIDTH, PREVIEW_HEIGHT); gtk_box_pack_end (GTK_BOX (main_hbox), GTK_WIDGET(ge->image_view), TRUE, TRUE, 0); asgtk_image_view_set_aspect ( ge->image_view, get_screen_width(NULL), get_screen_height(NULL) ); asgtk_image_view_set_resize ( ge->image_view, ASGTK_IMAGE_VIEW_SCALE_TO_VIEW| ASGTK_IMAGE_VIEW_TILE_TO_ASPECT, ASGTK_IMAGE_VIEW_RESIZE_ALL ); gtk_widget_show_all (list_vbox); gtk_widget_show_all (main_hbox); gtk_widget_hide(ge->image_view->details_label); btn = gtk_check_button_new_with_label( "Use screen aspect ratio" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE ); gtk_widget_show (btn); colorize_gtk_widget( btn, get_colorschemed_style_normal() ); g_signal_connect (G_OBJECT (btn), "toggled", G_CALLBACK (asgtk_image_view_screen_aspect_toggle), (gpointer) ge->image_view); gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5); asgtk_image_view_add_detail( ge->image_view, btn, 0 ); btn = gtk_check_button_new_with_label( "Scale to fit this view" ); gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE ); gtk_widget_show (btn); colorize_gtk_widget( btn, get_colorschemed_style_normal() ); g_signal_connect (G_OBJECT (btn), "toggled", G_CALLBACK (asgtk_image_view_scale_to_view_toggle), (gpointer) ge->image_view); gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5); asgtk_image_view_add_detail( ge->image_view, btn, 0 ); btn = asgtk_add_button_to_box( NULL, GTK_STOCK_REFRESH, NULL, G_CALLBACK(on_refresh_clicked), ge ); asgtk_image_view_add_tool( ge->image_view, btn, 3 ); LOCAL_DEBUG_OUT( "created image ASGtkGradient object %p", ge ); return GTK_WIDGET (ge); }
static void refresh_gradient_preview(ASGtkGradient *ge) { int width = get_screen_width(NULL); int height = get_screen_height(NULL); struct ASGradient gradient ; struct ASImageListEntry *entry; ARGB32 *color ; double *offset ; if( ge->points->count <= 0 ) return ; if( GTK_WIDGET_STATE( ge->width_entry) != GTK_STATE_INSENSITIVE ) if( (width = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->width_entry))) == 0 ) width = get_screen_width(NULL) ; if( GTK_WIDGET_STATE( ge->height_entry) != GTK_STATE_INSENSITIVE ) if( (height = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ge->height_entry))) == 0 ) height = get_screen_height(NULL) ; entry = create_asimage_list_entry(); /* rendering gradient preview : */ gradient.npoints = 0 ; gradient.type = ge->type ; gradient.offset = offset = safemalloc((ge->points->count+2) * sizeof(double) ); gradient.color = color = safemalloc((ge->points->count+2) * sizeof(ARGB32) ); ++gradient.offset ; ++gradient.color ; iterate_asbidirlist( ge->points, add_point_to_gradient, &gradient, NULL, False ); if( gradient.offset[0] > 0. ) { --gradient.offset ; --gradient.color ; gradient.offset[0] = 0. ; gradient.color[0] = DEFAULT_COLOR ; /* black */ ++gradient.npoints; } if( gradient.offset[gradient.npoints-1] < 1. ) { gradient.offset[gradient.npoints] = 1. ; gradient.color[gradient.npoints] = DEFAULT_COLOR ; /* black */ ++gradient.npoints; } entry->preview = make_gradient(get_screen_visual(NULL), &gradient, width, height, SCL_DO_ALL, ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT); free( offset ); free( color ); /* applying gradient preview : */ if( entry->preview ) asgtk_image_view_set_entry ( ge->image_view, entry); else asgtk_image_view_set_entry ( ge->image_view, NULL); unref_asimage_list_entry( entry ); }
int ui_clip_area (float *x_min, float *y_min, float *x_max, float *y_max) { int clipped_flag = FALSE; float screen_min_x, screen_min_y, screen_max_x, screen_max_y; screen_min_x = 0 - ui_x_origin; screen_min_y = 0 - ui_y_origin; screen_max_x = get_screen_width (active_screen) - ui_x_origin; screen_max_y = get_screen_height (active_screen) - ui_y_origin; // // clip to left extent // if (*x_min < active_viewport.x_min - ui_x_origin) { *x_min = active_viewport.x_min - ui_x_origin; clipped_flag = TRUE; } // clip to screen if (*x_min < screen_min_x) { *x_min = screen_min_x; clipped_flag = TRUE; } // guarentee valid area if (*x_max < *x_min) { *x_max = *x_min; clipped_flag = TRUE; } // // clip right // if (*x_max > active_viewport.x_max - ui_x_origin) { *x_max = active_viewport.x_max - ui_x_origin; clipped_flag = TRUE; } // clip to screen if (*x_max > screen_max_x) { *x_max = screen_max_x; clipped_flag = TRUE; } // guarentee valid area if (*x_min > *x_max) { *x_min = *x_max; clipped_flag = TRUE; } // // clip top // if (*y_min < active_viewport.y_min - ui_y_origin) { *y_min = active_viewport.y_min - ui_y_origin; clipped_flag = TRUE; } // clip to screen if (*y_min < screen_min_y) { *y_min = screen_min_y; clipped_flag = TRUE; } // guarentee valid area if (*y_max < *y_min) { *y_max = *y_min; clipped_flag = TRUE; } // // clip bottom // if (*y_max > active_viewport.y_max - ui_y_origin) { *y_max = active_viewport.y_max - ui_y_origin; clipped_flag = TRUE; } // clip to screen if (*y_max > screen_max_y) { *y_max = screen_max_y; clipped_flag = TRUE; } // guarentee valid area if (*y_min > *y_max) { *y_min = *y_max; clipped_flag = TRUE; } return clipped_flag; }
void myback_parse (char *tline, FILE * fd, char **myname, int *mylook) { FilePtrAndData fpd; ConfigDef *ConfigReader; MyBackgroundConfig *back_config = NULL; FreeStorageElem *Storage = NULL, *more_stuff = NULL; MyLook *look = (MyLook *) mylook; MyBackground *myback = NULL; ConfigData cd; if (look == NULL) look = get_screen_look (NULL); fpd.fp = fd; fpd.data = safemalloc (12 + 1 + strlen (tline) + 1 + 1); sprintf (fpd.data, "MyBackground %s\n", tline); LOCAL_DEBUG_OUT ("fd(%p)->tline(\"%s\")->fpd.data(\"%s\")", fd, tline, fpd.data); cd.fileptranddata = &fpd; ConfigReader = InitConfigReader ((char *)myname, &MyBackgroundSyntax, CDT_FilePtrAndData, cd, NULL); free (fpd.data); if (!ConfigReader) return; PrintConfigReader (ConfigReader); ParseConfig (ConfigReader, &Storage); /* getting rid of all the crap first */ StorageCleanUp (&Storage, &more_stuff, CF_DISABLED_OPTION); DestroyFreeStorage (&more_stuff); back_config = ParseMyBackgroundOptions (Storage, (char *)myname); DestroyConfig (ConfigReader); DestroyFreeStorage (&Storage); if (back_config == NULL) return; /* now we have to turn MyBackgroundConfig into MyBackground structure : */ myback = create_myback (back_config->name); if (get_flags (back_config->flags, BGFLAG_FILE)) myback->type = MB_BackImage; else if (get_flags (back_config->flags, BGFLAG_MYSTYLE)) myback->type = MB_BackMyStyle; else myback->type = MB_BackCmd; myback->data = back_config->data; back_config->data = NULL; if (get_flags (back_config->flags, BGFLAG_CUT)) myback->cut = back_config->cut; if (get_flags (back_config->flags, BGFLAG_SCALE)) { myback->scale = back_config->scale; if (!get_flags (back_config->scale.flags, WidthValue)) myback->scale.width = get_screen_width (NULL); if (!get_flags (back_config->scale.flags, HeightValue)) myback->scale.height = get_screen_height (NULL); set_flags (myback->scale.flags, WidthValue | HeightValue); } myback->tint = TINT_LEAVE_SAME; if (get_flags (back_config->flags, BGFLAG_TINT) && back_config->tint) parse_argb_color (back_config->tint, &(myback->tint)); myback->pad_color = ARGB32_Black; if (get_flags (back_config->flags, BGFLAG_PAD) && back_config->pad) parse_argb_color (back_config->pad, &(myback->pad_color)); myback->align_flags = NO_ALIGN; if (get_flags (back_config->flags, BGFLAG_PAD_HOR)) { if (get_flags (back_config->flags, BGFLAG_ALIGN_RIGHT)) myback->align_flags = ALIGN_RIGHT; else if (get_flags (back_config->flags, BGFLAG_ALIGN_CENTER)) myback->align_flags = ALIGN_HCENTER; else myback->align_flags = ALIGN_LEFT; } if (get_flags (back_config->flags, BGFLAG_PAD_VERT)) { if (get_flags (back_config->flags, BGFLAG_ALIGN_BOTTOM)) myback->align_flags |= ALIGN_BOTTOM; else if (get_flags (back_config->flags, BGFLAG_ALIGN_CENTER)) myback->align_flags |= ALIGN_VCENTER; else myback->align_flags = ALIGN_TOP; } LOCAL_DEBUG_OUT ("myback added: name(\"%s\")->type(%d)->data(\"%s\")", myback->name, myback->type, myback->data); add_myback (look, myback); /* final cleanup : */ DestroyMyBackgroundConfig (&back_config); }
/** * Invert screen rotation flag */ jboolean winceapp_reverse_orientation() { reverse_orientation = !reverse_orientation; gxj_system_screen_buffer.width = get_screen_width(); gxj_system_screen_buffer.height = get_screen_height(); return reverse_orientation; }
/** * Return screen width */ int lfjport_get_screen_width() { get_screen_width(); }
/** * Bridge function to return screen width */ int lfjport_get_screen_width() { return get_screen_width(); }