static void IME_OnConfig(t_HWindow handle, t_VkIme *wdata, t_sparam sparam, t_lparam lparam) { gu8 s = 0xff; wdata->lang = sparam; switch(wdata->lang){ case LANG_123: if(lparam != (t_lparam)(-1)) wdata->t_digit = lparam; s = IME_S_DIGIT_1; break; case aLANG_ENGLISH: if(lparam != (t_lparam)(-1)) wdata->t_case = lparam; s = IME_S_EN; break; default: break; } if(s != 0xff && wdata->s_idx != s){ wdata->s_idx = s; g_object_unref_0(wdata->vk_image); wdata->vk_image = brd_get_image(brd_get(PACK_GUID_SELF), ga_ime_vk[s].resid); wdata->image_width = image_get_width(wdata->vk_image); wdata->image_height = image_get_height(wdata->vk_image); } }
void build_tileset(const path_t* path, const image_t* image, int tile_width, int tile_height) { FILE* file; ptrdiff_t pitch; const uint32_t* pixelbuf; struct rts_header rts; struct rts_tile_header tile; int x, y; int i_y; uint16_t i; memset(&rts, 0, sizeof(struct rts_header)); memcpy(&rts.signature, ".rts", 4); rts.version = 1; rts.num_tiles = (image_get_width(image) / tile_width) * (image_get_height(image) / tile_height); rts.has_obstructions = 0; rts.tile_width = (uint16_t)tile_width; rts.tile_height = (uint16_t)tile_height; rts.tile_bpp = 32; file = fopen(path_cstr(path), "wb"); fwrite(&rts, sizeof(struct rts_header), 1, file); pitch = image_get_pitch(image); x = 0; y = 0; for (i = 0; i < rts.num_tiles; ++i) { for (i_y = 0; i_y < tile_height; ++i_y) { pixelbuf = image_get_pixelbuf(image) + x + (y + i_y) * pitch; fwrite(pixelbuf, tile_width * 4, 1, file); } if ((x += tile_width) + tile_width > image_get_width(image)) { x = 0; y += tile_height; } } memset(&tile, 0, sizeof(struct rts_tile_header)); for (i = 0; i < rts.num_tiles; ++i) fwrite(&tile, sizeof(struct rts_tile_header), 1, file); fclose(file); }
static gboolean dsource_Measure(t_HDataSource h, t_GuiViewType viewtype, int index, int *width, int *height) { t_DSAppStore* pme = (t_DSAppStore *)h; t_AppStoreDir *entry = pme->entry; t_AppStoreEntry* child; t_AppStoreDir *dir; t_AppStoreApp *app; BrdHandle brd; char title[GUID_NAME_MAX+1]; t_HImage image = NULL; int iw, ih, tw, th; child = _GetEntry(entry, index); if(!child) return FALSE; strcpy(title, "<N/A>"); if(child->type == APPSTORE_ENTRY_APP){ app = (t_AppStoreApp *)child; image = pack_GetIcon(app->guid); pack_GetModuleTitle(app->guid, app->module, title, sizeof(title)); }else{ dir = (t_AppStoreDir *)child; brd = brd_get("sys"); image = brd_get_image(brd, dir->icon); brd_get_string2(brd, dir->text, title, sizeof(title)); } iw = ih = tw = th = 0; font_measure_string(title, -1, CHARSET_UNDEF, -1, &tw, &th, NULL); if(g_object_valid(image)){ iw = image_get_width(image); ih = image_get_height(image); } if(viewtype == GUI_VIEWTYPE_NORMAL){ if(width)*width = tw+iw+ICON_TEXT_SPLIT; if(height)*height = MAX(th, ih); }else if(viewtype == GUI_VIEWTYPE_ICON_ONLY || viewtype == GUI_VIEWTYPE_ICON_TEXT_TITLE){ if(width)*width = iw; if(height)*height = ih; }else if(viewtype == GUI_VIEWTYPE_ICON_TEXT_TOP || viewtype == GUI_VIEWTYPE_ICON_TEXT_BOTTOM){ if(width){*width = MAX(tw, iw); if(*width > 80)*width = 80; } if(height){*height = th+ih+ICON_TEXT_SPLIT; if(*height > 80)*height = 80; } }else{ if(width)*width = 0; if(height)*height = 0; } g_object_unref(image); return TRUE; }
UINT32 imagelib_get_width(IMAGELIB_SESSION*_session) { if(_session == NULL) return 0; return image_get_width((IMAGE_INSTANCE*)_session->instance_p); }
static int lualock_lua_image_get_width(lua_State *L) { image_t *image = luaL_checkudata(L, 1, "lualock.image"); lua_pushinteger(L, image_get_width(image)); return 1; }
static error_t IME_VK_WndMsgHandler(t_HWindow handle, t_WidgetEvent evt, t_sparam sparam, t_lparam lparam) { error_t ret = NOT_HANDLED; t_VkIme *wdata = (t_VkIme *)wgt_get_tag(handle); switch(evt){ case WIDGET_OnMessage: { t_AmosMsg *msg = (t_AmosMsg *)lparam; switch(sparam){ case EVT_IME_CONFIG: IME_OnConfig(handle, wdata, msg->sparam, msg->lparam); ret = SUCCESS; break; } } break; case WINDOW_OnOpen: g_printf("WINDOW_OnOpen\r\n"); wdata = MALLOC(sizeof(t_VkIme)); memset(wdata, 0, sizeof(t_VkIme)); wgt_set_tag(handle, wdata); wdata->lang = LANG_UNDEF; wdata->s_idx = 0xff; wdata->t_digit = DIGIT_TYPE_NUMBER; wdata->t_case = IME_CASE_LOWER; IME_OnConfig(handle, wdata, LANG_123, DIGIT_TYPE_NUMBER); wgt_set_bound((t_HWidget)handle, 0, lcd_get_height()-wdata->image_height, lcd_get_width(), wdata->image_height); break; case WINDOW_OnClose: g_printf("WINDOW_OnClose\r\n"); if(wdata){ g_object_unref(wdata->vk_image); FREE(wdata); } ret = SUCCESS; break; case WINDOW_OnDraw: __ShowIME(handle, TRUE); ret = SUCCESS; break; #if defined(FTR_TOUCH_SCREEN) case WIDGET_OnPenEvent: { coord_t x, y; PEN_XY(lparam, x, y); { t_VkRegion *r; gui_rect_t rt; ret = SUCCESS; r = __vk_get(wdata->s_idx, x, y, &rt); switch(PEN_TYPE(lparam)){ case MMI_PEN_DOWN: wdata->prev_r = r; if(r != NULL){ memcpy(&wdata->prev_rt, &rt, sizeof(gui_rect_t)); __ShowRegion(handle, &rt, TRUE); } break; case MMI_PEN_MOVE: if(r != NULL && wdata->prev_r != r){ if(wdata->prev_r != NULL) __ShowRegion(handle, &wdata->prev_rt, FALSE); wdata->prev_r = r; memcpy(&wdata->prev_rt, &rt, sizeof(gui_rect_t)); __ShowRegion(handle, &rt, TRUE); } break; case MMI_PEN_UP: if(wdata->prev_r != NULL){ __ShowRegion(handle, &wdata->prev_rt, FALSE); wdata->prev_r = -1; } if(r != NULL && r->r != R_DISABLED){ if(r->r == R_UCS){ ime_agent_add_char(IME_ADD_MODE_NORMAL, r->ucs); }else if(r->r == R_BKSPACE){ ime_agent_add_char(IME_ADD_MODE_BKSPACE, 0); }else if(wdata->lang == LANG_123){ if(r->r == R_DIGIT_LSK){ if(wdata->t_digit == DIGIT_TYPE_PHONE){ if(wdata->s_idx == IME_S_DIGIT_1){ wdata->s_idx = IME_S_DIGIT_2; }else{ wdata->s_idx = IME_S_DIGIT_1; } g_object_unref_0(wdata->vk_image); wdata->vk_image = brd_get_image(brd_get(PACK_GUID_SELF), ga_ime_vk[wdata->s_idx].resid); wdata->image_width = image_get_width(wdata->vk_image); wdata->image_height = image_get_height(wdata->vk_image); __ShowIME(handle, FALSE); }else if(wdata->t_digit == DIGIT_TYPE_FLOAT){ ime_agent_add_char(IME_ADD_MODE_NORMAL, '.'); } } }else if(r->r == R_EN_SPACE){ ime_agent_add_char(IME_ADD_MODE_NORMAL, ' '); }else if(r->r == R_EN_123){ //2 Çл»µ½Êý×Ö¼üÅÌ }else if(r->r == R_EN_SHIFT){ //2 Çл»´óСд }else if(r->r == R_EN_IME){ //2 Çл»ÊäÈë·¨ }else if(r->r == R_EN_ENTER){ //2 »»ÐÐ } } break; } } } break; #endif } return ret; }