-void BScreen::LoadStyle(void) {
- Configuration style(False);
-
- const char *sfile = blackbox->getStyleFilename();
- if (sfile != NULL) {
- style.setFile(sfile);
- if (! style.load()) {
- style.setFile(DEFAULTSTYLE);
- if (! style.load())
- style.create(); // hardcoded default values will be used.
- }
- }
-
- // merge in the rc file
- style.merge(config->file(), True);
-
- string s;
-
- // load fonts/fontsets
- if (resource.wstyle.font)
- delete resource.wstyle.font;
-
- resource.wstyle.font = readDatabaseFont("window.", style);
-
- // load window config
- resource.wstyle.t_focus =
- readDatabaseTexture("window.title.focus", "white", style);
- resource.wstyle.t_unfocus =
- readDatabaseTexture("window.title.unfocus", "black", style);
- resource.wstyle.l_focus =
- readDatabaseTexture("window.label.focus", "white", style);
- resource.wstyle.l_unfocus =
- readDatabaseTexture("window.label.unfocus", "black", style);
- resource.wstyle.h_focus =
- readDatabaseTexture("window.handle.focus", "white", style);
- resource.wstyle.h_unfocus =
- readDatabaseTexture("window.handle.unfocus", "black", style);
- resource.wstyle.g_focus =
- readDatabaseTexture("window.grip.focus", "white", style);
- resource.wstyle.g_unfocus =
- readDatabaseTexture("window.grip.unfocus", "black", style);
- resource.wstyle.b_focus =
- readDatabaseTexture("window.button.focus", "white", style);
- resource.wstyle.b_unfocus =
- readDatabaseTexture("window.button.unfocus", "black", style);
- resource.wstyle.b_pressed =
- readDatabaseTexture("window.button.pressed", "black", style);
-
- //if neither of these can be found, we will use the previous resource
- resource.wstyle.b_pressed_focus =
- readDatabaseTexture("window.button.pressed.focus", "black", style, true);
- resource.wstyle.b_pressed_unfocus =
- readDatabaseTexture("window.button.pressed.unfocus", "black", style, true);
-
- if (resource.wstyle.close_button.mask != None)
- XFreePixmap(otk::OBDisplay::display, resource.wstyle.close_button.mask);
- if (resource.wstyle.max_button.mask != None)
- XFreePixmap(otk::OBDisplay::display, resource.wstyle.max_button.mask);
- if (resource.wstyle.icon_button.mask != None)
- XFreePixmap(otk::OBDisplay::display, resource.wstyle.icon_button.mask);
- if (resource.wstyle.stick_button.mask != None)
- XFreePixmap(otk::OBDisplay::display, resource.wstyle.stick_button.mask);
-
- resource.wstyle.close_button.mask = resource.wstyle.max_button.mask =
- resource.wstyle.icon_button.mask =
- resource.wstyle.icon_button.mask = None;
-
- readDatabaseMask("window.button.close.mask", resource.wstyle.close_button,
- style);
- readDatabaseMask("window.button.max.mask", resource.wstyle.max_button,
- style);
- readDatabaseMask("window.button.icon.mask", resource.wstyle.icon_button,
- style);
- readDatabaseMask("window.button.stick.mask", resource.wstyle.stick_button,
- style);
-
- // we create the window.frame texture by hand because it exists only to
- // make the code cleaner and is not actually used for display
- otk::BColor color = readDatabaseColor("window.frame.focusColor", "white",
- style);
- resource.wstyle.f_focus = otk::BTexture("solid flat", getScreenNumber(),
- image_control);
- resource.wstyle.f_focus.setColor(color);
-
- color = readDatabaseColor("window.frame.unfocusColor", "white", style);
- resource.wstyle.f_unfocus = otk::BTexture("solid flat", getScreenNumber(),
- image_control);
- resource.wstyle.f_unfocus.setColor(color);
-
- resource.wstyle.l_text_focus =
- readDatabaseColor("window.label.focus.textColor", "black", style);
- resource.wstyle.l_text_unfocus =
- readDatabaseColor("window.label.unfocus.textColor", "white", style);
- resource.wstyle.b_pic_focus =
- readDatabaseColor("window.button.focus.picColor", "black", style);
- resource.wstyle.b_pic_unfocus =
- readDatabaseColor("window.button.unfocus.picColor", "white", style);
-
- resource.wstyle.justify = LeftJustify;
- if (style.getValue("window.justify", s)) {
- if (s == "right" || s == "Right")
- resource.wstyle.justify = RightJustify;
- else if (s == "center" || s == "Center")
- resource.wstyle.justify = CenterJustify;
- }
-
- // sanity checks
- if (resource.wstyle.t_focus.texture() == otk::BTexture::Parent_Relative)
- resource.wstyle.t_focus = resource.wstyle.f_focus;
- if (resource.wstyle.t_unfocus.texture() == otk::BTexture::Parent_Relative)
- resource.wstyle.t_unfocus = resource.wstyle.f_unfocus;
- if (resource.wstyle.h_focus.texture() == otk::BTexture::Parent_Relative)
- resource.wstyle.h_focus = resource.wstyle.f_focus;
- if (resource.wstyle.h_unfocus.texture() == otk::BTexture::Parent_Relative)
- resource.wstyle.h_unfocus = resource.wstyle.f_unfocus;
-
- resource.border_color =
- readDatabaseColor("borderColor", "black", style);
-
- // load bevel, border and handle widths
- if (! style.getValue("handleWidth", resource.handle_width) ||
- resource.handle_width > (getWidth() / 2) || resource.handle_width == 0)
- resource.handle_width = 6;
-
- if (! style.getValue("borderWidth", resource.border_width))
- resource.border_width = 1;
-
- if (! style.getValue("bevelWidth", resource.bevel_width) ||
- resource.bevel_width > (getWidth() / 2) || resource.bevel_width == 0)
- resource.bevel_width = 3;
-
- if (! style.getValue("frameWidth", resource.frame_width) ||
- resource.frame_width > (getWidth() / 2))
- resource.frame_width = resource.bevel_width;
-
- if (style.getValue("rootCommand", s))
- bexec(s, displayString());
-}
-