Changes in uspace/lib/ui/src/wdecor.c [252d03c:b48e680f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/wdecor.c
r252d03c rb48e680f 61 61 wdecor_edge_h = 4, 62 62 wdecor_tbar_h = 22, 63 wdecor_tbar_h_text = 1,64 63 wdecor_frame_w = 4, 65 64 wdecor_frame_w_text = 1 … … 160 159 } 161 160 161 /** Change caption. 162 * 163 * @param wdecor Window decoration 164 * @param caption New caption 165 * 166 * @return EOK on success or an error code 167 */ 168 errno_t ui_wdecor_set_caption(ui_wdecor_t *wdecor, const char *caption) 169 { 170 char *cdup; 171 172 cdup = str_dup(caption); 173 if (cdup == NULL) 174 return ENOMEM; 175 176 free(wdecor->caption); 177 wdecor->caption = cdup; 178 179 ui_wdecor_paint(wdecor); 180 return EOK; 181 } 182 162 183 /** Paint window decoration. 163 184 * … … 170 191 gfx_rect_t rect; 171 192 gfx_rect_t trect; 193 gfx_rect_t text_rect; 172 194 gfx_text_fmt_t fmt; 173 195 gfx_coord2_t pos; … … 180 202 181 203 if (wdecor->res->textmode != false) { 182 rc = ui_paint_bevel(wdecor->res->gc, &rect, 183 wdecor->res->wnd_frame_hi_color, 184 wdecor->res->wnd_frame_sh_color, 1, &rect); 204 rc = ui_paint_text_box(wdecor->res, &rect, 205 ui_box_double, wdecor->res->wnd_face_color); 185 206 if (rc != EOK) 186 207 return rc; … … 208 229 if (rc != EOK) 209 230 return rc; 231 232 rc = gfx_set_color(wdecor->res->gc, wdecor->active ? 233 wdecor->res->tbar_act_bg_color : 234 wdecor->res->tbar_inact_bg_color); 235 if (rc != EOK) 236 return rc; 237 238 rc = gfx_fill_rect(wdecor->res->gc, &trect); 239 if (rc != EOK) 240 return rc; 210 241 } 211 212 rc = gfx_set_color(wdecor->res->gc, wdecor->active ?213 wdecor->res->tbar_act_bg_color :214 wdecor->res->tbar_inact_bg_color);215 if (rc != EOK)216 return rc;217 218 rc = gfx_fill_rect(wdecor->res->gc, &trect);219 if (rc != EOK)220 return rc;221 242 222 243 gfx_text_fmt_init(&fmt); … … 230 251 pos.y = (trect.p0.y + trect.p1.y) / 2; 231 252 253 if (wdecor->res->textmode) { 254 /* Make space around caption text */ 255 gfx_text_rect(wdecor->res->font, &pos, &fmt, 256 wdecor->caption, &text_rect); 257 258 /* Only make space if caption is non-empty */ 259 if (text_rect.p0.x < text_rect.p1.x) { 260 text_rect.p0.x -= 1; 261 text_rect.p1.x += 1; 262 } 263 264 rc = gfx_set_color(wdecor->res->gc, wdecor->active ? 265 wdecor->res->tbar_act_bg_color : 266 wdecor->res->tbar_inact_bg_color); 267 if (rc != EOK) 268 return rc; 269 270 rc = gfx_fill_rect(wdecor->res->gc, &text_rect); 271 if (rc != EOK) 272 return rc; 273 } 274 232 275 rc = gfx_puttext(wdecor->res->font, &pos, &fmt, wdecor->caption); 233 276 if (rc != EOK) … … 301 344 { 302 345 gfx_coord_t frame_w; 303 gfx_coord_t tbar_h;304 346 305 347 /* Does window have a frame? */ … … 318 360 /* Does window have a title bar? */ 319 361 if ((wdecor->style & ui_wds_titlebar) != 0) { 320 tbar_h = wdecor->res->textmode ? 321 wdecor_tbar_h_text : wdecor_tbar_h; 322 323 geom->title_bar_rect.p0 = geom->interior_rect.p0; 324 geom->title_bar_rect.p1.x = geom->interior_rect.p1.x; 325 geom->title_bar_rect.p1.y = geom->interior_rect.p0.y + tbar_h; 362 if (wdecor->res->textmode) { 363 geom->title_bar_rect.p0 = wdecor->rect.p0; 364 geom->title_bar_rect.p1.x = wdecor->rect.p1.x; 365 geom->title_bar_rect.p1.y = wdecor->rect.p0.y + 1; 366 } else { 367 geom->title_bar_rect.p0 = geom->interior_rect.p0; 368 geom->title_bar_rect.p1.x = geom->interior_rect.p1.x; 369 geom->title_bar_rect.p1.y = geom->interior_rect.p0.y + 370 wdecor_tbar_h; 371 } 326 372 327 373 geom->app_area_rect.p0.x = geom->interior_rect.p0.x;
Note:
See TracChangeset
for help on using the changeset viewer.