int BC_FileBoxListBox::sort_order_event() { get_resources()->filebox_sortcolumn = filebox->sort_column = get_sort_column(); get_resources()->filebox_sortorder = filebox->sort_order = get_sort_order(); filebox->refresh(); return 1; }
int BC_FileBox::resize_event(int w, int h) { draw_background(0, 0, w, h); flash(); // OK button handles resize event itself // ok_button->reposition_window(ok_button->get_x(), // h - (get_h() - ok_button->get_y())); // cancel_button->reposition_window(w - (get_w() - cancel_button->get_x()), // h - (get_h() - cancel_button->get_y())); if(usethis_button) usethis_button->reposition_window(w / 2 - 50, h - (get_h() - usethis_button->get_y())); if(filter_popup) filter_popup->reposition_window(w - (get_w() - filter_popup->get_x()), h - (get_h() - filter_popup->get_y()), w - 30); if(filter_text) filter_text->reposition_window(filter_text->get_x(), h - (get_h() - filter_text->get_y()), w - (get_w() - filter_text->get_w()), 1); directory_title->reposition_window( directory_title->get_x(), directory_title->get_y(), get_w() - recent_popup->get_w() - 20, 1); recent_popup->reposition_window( directory_title->get_x() + directory_title->get_w(), directory_title->get_y(), directory_title->get_w() + recent_popup->get_w(), recent_popup->get_h()); textbox->reposition_window(textbox->get_x(), h - (get_h() - textbox->get_y()), w - (get_w() - textbox->get_w()), 1); listbox->reposition_window(listbox->get_x(), listbox->get_y(), w - (get_w() - listbox->get_w()), h - (get_h() - listbox->get_h())); icon_button->reposition_window(w - (get_w() - icon_button->get_x()), icon_button->get_y()); text_button->reposition_window(w - (get_w() - text_button->get_x()), text_button->get_y()); folder_button->reposition_window(w - (get_w() - folder_button->get_x()), folder_button->get_y()); reload_button->reposition_window(w - (get_w() - reload_button->get_x()), reload_button->get_y()); delete_button->reposition_window(w - (get_w() - delete_button->get_x()), delete_button->get_y()); updir_button->reposition_window(w - (get_w() - updir_button->get_x()), updir_button->get_y()); set_w(w); set_h(h); get_resources()->filebox_w = get_w(); get_resources()->filebox_h = get_h(); return 1; }
void BC_FileBox::move_column(int src, int dst) { ArrayList<BC_ListBoxItem*> *new_columns = new ArrayList<BC_ListBoxItem*>[columns]; int *new_types = new int[columns]; int *new_widths = new int[columns]; // Fill in remaining columns with consecutive data for(int out_column = 0, in_column = 0; out_column < columns; out_column++, in_column++) { // Copy destination column from src column if(out_column == dst) { for(int i = 0; i < list_column[src].total; i++) { new_columns[out_column].append(list_column[src].values[i]); } new_types[out_column] = column_type[src]; new_widths[out_column] = column_width[src]; in_column--; } else { // Skip source column if(in_column == src) in_column++; for(int i = 0; i < list_column[src].total; i++) { new_columns[out_column].append(list_column[in_column].values[i]); } new_types[out_column] = column_type[in_column]; new_widths[out_column] = column_width[in_column]; } } // Swap tables delete [] list_column; delete [] column_type; delete [] column_width; list_column = new_columns; column_type = new_types; column_width = new_widths; for(int i = 0; i < columns; i++) { get_resources()->filebox_columntype[i] = column_type[i]; get_resources()->filebox_columnwidth[i] = column_width[i]; column_titles[i] = BC_FileBox::columntype_to_text(column_type[i]); } refresh(); }
float BC_Pot::coords_to_angle(int x2, int y2) { int x1, y1, x, y; float angle = 0.; x1 = get_resources()->pot_x1; y1 = get_resources()->pot_y1; if(status == POT_DN) { x1 += 2; y1 += 2; } x = x2 - x1; y = y2 - y1; if(x > 0 && y <= 0) { angle = atan((float)-y / x) / (2 * M_PI) * 360; } else if(x < 0 && y <= 0) { angle = 180 - atan((float)-y / -x) / (2 * M_PI) * 360; } else if(x < 0 && y > 0) { angle = 180 - atan((float)-y / -x) / (2 * M_PI) * 360; } else if(x > 0 && y > 0) { angle = 360 + atan((float)-y / x) / (2 * M_PI) * 360; } else if(x == 0 && y < 0) { angle = 90; } else if(x == 0 && y > 0) { angle = 270; } else if(x == 0 && y == 0) { angle = 0; } return angle; }
static void show_begin_of_roster(XMPP_SERVER_REC *server) { char *show, *status, *priority, *text, *resources, *pgp_keyid; g_return_if_fail(IS_XMPP_SERVER(server)); show = (server->show == XMPP_PRESENCE_AVAILABLE) ? NULL : format_get_text(MODULE_NAME, NULL, server, NULL, XMPPTXT_FORMAT_RESOURCE_SHOW, xmpp_presence_show[server->show]); status = (server->away_reason == NULL || strcmp(server->away_reason, " ") == 0) ? NULL : format_get_text(MODULE_NAME, NULL, server, NULL, XMPPTXT_FORMAT_RESOURCE_STATUS, server->away_reason); priority = g_strdup_printf("%d", server->priority); pgp_keyid = !settings_get_str("xmpp_pgp") ? NULL : \ format_get_text(MODULE_NAME, NULL, server, NULL, XMPPTXT_FORMAT_PGP_KEYID, settings_get_str("xmpp_pgp")); text = format_get_text(MODULE_NAME, NULL, server, NULL, XMPPTXT_FORMAT_RESOURCE, show, server->resource, priority, status, pgp_keyid); g_free(show); g_free(status); g_free(priority); resources = get_resources(server, server->my_resources); printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CRAP, XMPPTXT_BEGIN_OF_ROSTER, server->jid, text, resources); g_free(text); g_free(resources); }
static void show_user(XMPP_SERVER_REC *server, XMPP_ROSTER_USER_REC *user) { const char *first_show; char *name, *resources, *subscription; g_return_if_fail(IS_SERVER(server)); g_return_if_fail(user != NULL); if (user->resources == NULL) first_show = xmpp_presence_show[user->error ? XMPP_PRESENCE_ERROR : XMPP_PRESENCE_UNAVAILABLE]; else first_show = get_first_show(user->resources); name = user->name != NULL ? format_get_text(MODULE_NAME, NULL, server, NULL, XMPPTXT_FORMAT_NAME, user->name, user->jid) : format_get_text(MODULE_NAME, NULL, server, NULL, XMPPTXT_FORMAT_JID, user->jid); resources = get_resources(server, user->resources); subscription = user->subscription == XMPP_SUBSCRIPTION_BOTH ? NULL : format_get_text(MODULE_NAME, NULL, server, NULL, XMPPTXT_FORMAT_SUBSCRIPTION, xmpp_subscription[user->subscription]); printformat_module(MODULE_NAME, server, NULL, MSGLEVEL_CRAP, XMPPTXT_ROSTER_CONTACT, first_show, name, resources, subscription); g_free(name); g_free(resources); g_free(subscription); }
/** * @brief Updates the content of the sprite description text edit. */ void SpriteEditor::update_description_to_gui() { QString description = get_resources().get_description(ResourceType::SPRITE, sprite_id); if (ui.description_field->text() != description) { ui.description_field->setText(description); } }
BC_Pixmap* BC_FileBox::get_icon(char *path, int is_dir) { char *suffix = strrchr(path, '.'); int icon_type = ICON_UNKNOWN; if(is_dir) return icons[ICON_FOLDER]; if(suffix) { suffix++; if(*suffix != 0) { for(int i = 0; get_resources()->suffix_to_type[i].suffix; i++) { if(!strcasecmp(suffix, BC_WindowBase::get_resources()->suffix_to_type[i].suffix)) { icon_type = BC_WindowBase::get_resources()->suffix_to_type[i].icon_type; break; } } } } return icons[icon_type]; }
Rect GUIComponent::render_text( Canvas &canvas, const std::string &text ) { Rect content_box = get_content_box(); Font font = impl->element.get_font(canvas, get_resources()); int baseline = content_box.top + font.get_font_metrics().get_ascent(); return impl->element.render_text(canvas, font, text, content_box, baseline, false ); }
Rect GUIComponent::render_text_span( Canvas &canvas, const std::string &text, const Rect &content_rect ) { Font font = impl->element.get_font(canvas, get_resources()); SpanLayout span = impl->element.create_span_layout(canvas, font, text, content_rect); span.draw_layout(canvas); return span.get_rect(); }
void _cairo_xcb_resources_get (cairo_xcb_screen_t *screen, cairo_xcb_resources_t *resources) { get_resources (screen->connection->xcb_connection, screen->xcb_screen, resources); if (resources->xft_rgba == FC_RGBA_UNKNOWN) { switch (screen->subpixel_order) { case XCB_RENDER_SUB_PIXEL_UNKNOWN: resources->xft_rgba = FC_RGBA_UNKNOWN; break; case XCB_RENDER_SUB_PIXEL_HORIZONTAL_RGB: resources->xft_rgba = FC_RGBA_RGB; break; case XCB_RENDER_SUB_PIXEL_HORIZONTAL_BGR: resources->xft_rgba = FC_RGBA_BGR; break; case XCB_RENDER_SUB_PIXEL_VERTICAL_RGB: resources->xft_rgba = FC_RGBA_VRGB; break; case XCB_RENDER_SUB_PIXEL_VERTICAL_BGR: resources->xft_rgba = FC_RGBA_VBGR; break; case XCB_RENDER_SUB_PIXEL_NONE: resources->xft_rgba = FC_RGBA_NONE; break; } } }
void DlgAddNewItem::populate(FileItemTypeFactory &factory) { int icon_index = 1; Canvas canvas = get_canvas(); ResourceManager resources = get_resources(); const std::vector<FileItemType*> &types = factory.types(); for(size_t i = 0; i < types.size(); ++i) { ListViewIcon icon; Sprite sprite = types[i]->get_icon(canvas, resources); icon.set_sprite(sprite, listview_mode_details); list_items->get_icon_list().set_icon(icon_index, icon); ListViewItem item1 = list_items->create_item(); item1.set_column_text("name", types[i]->get_name()); item1.set_icon(icon_index); item1.set_userdata(ListViewItemDataPtr(new ListViewItemData(types[i]))); list_items->get_document_item().append_child(item1); icon_index++; if(list_items->get_selected_item().is_null()) list_items->set_selected(item1); } }
int BC_FileBoxListBox::evaluate_query(int list_item, char *string) { ArrayList<BC_ListBoxItem*> *column = &filebox->list_column[filebox->column_of_type(FILEBOX_NAME)]; return(column->values[list_item]->get_color() != get_resources()->directory_color && strcmp(string, column->values[list_item]->get_text()) <= 0); }
BC_Toggle::BC_Toggle(int x, int y, VFrame **data, int value, const char *caption, int bottom_justify, int font, int color) : BC_SubWindow(x, y, 0, 0, -1) { this->data = data; for(int i = 0; i < 5; i++) images[i] = 0; bg_image = 0; status = value ? BC_Toggle::TOGGLE_CHECKED : BC_Toggle::TOGGLE_UP; this->value = value; strcpy(this->caption, caption); this->bottom_justify = bottom_justify; this->font = font; if(color >= 0) this->color = color; else this->color = get_resources()->default_text_color; select_drag = 0; enabled = 1; underline = -1; is_radial = 0; }
int BC_ProgressBar::draw(int force, int flush) { char string[32]; int new_pixel; new_pixel = (int)(((float)position / length) * get_w()); if(new_pixel != pixel || force) { pixel = new_pixel; // Clear background draw_top_background(parent_window, 0, 0, get_w(), get_h()); draw_3segmenth(0, 0, pixel, 0, get_w(), images[PROGRESS_HI]); draw_3segmenth(pixel, 0, get_w() - pixel, 0, get_w(), images[PROGRESS_UP]); if(do_text) { set_font(MEDIUMFONT); set_color(get_resources()->progress_text); // draw decimal percentage sprintf(string, "%d%%", (int)(100 * (float)position / length + 0.5 / w)); draw_center_text(w / 2, h / 2 + get_text_ascent(MEDIUMFONT) / 2, string); } flash(flush); } return 0; }
void RadialMenu::create_parts() { CL_GraphicContext gc = get_gc(); CL_ResourceManager resources = get_resources(); part_component = CL_GUIThemePart(this); CL_GUIThemePart part_selected_item(this, "selected"); CL_GUIThemePartProperty prop_text_color("text-color"); CL_GUIThemePartProperty prop_pointer_image("pointer-image"); CL_GUIThemePartProperty prop_text_distance("text-distance"); normal_text_color = part_component.get_property(prop_text_color); normal_font = part_component.get_font(); normal_text_distance = CL_StringHelp::text_to_float(part_component.get_property(prop_text_distance)); normal_font_height = normal_font.get_font_metrics().get_height(); selected_text_color = part_selected_item.get_property(prop_text_color); selected_font = part_selected_item.get_font(); selected_text_distance = CL_StringHelp::text_to_float(part_selected_item.get_property(prop_text_distance)); selected_font_height = selected_font.get_font_metrics().get_height(); CL_String pointer_image_name = part_component.get_property(prop_pointer_image); image_pointer = CL_Sprite(gc, pointer_image_name, &resources); image_pointer.set_alignment(origin_center); }
int BC_Pot::repeat_event(int64_t duration) { if(duration == top_level->get_resources()->tooltip_delay) { if(tooltip_on) { if(keypress_tooltip_timer > 0) { keypress_tooltip_timer -= get_resources()->tooltip_delay; } else if(status != POT_HIGH && status != POT_DN) { hide_tooltip(); } } else if(status == POT_HIGH) { if(use_caption && tooltip_text) { if(!tooltip_text[0] || isdigit(tooltip_text[0])) { set_tooltip(get_caption()); show_tooltip(50); } else show_tooltip(); tooltip_done = 1; } return 1; } } return 0; }
/** * @brief Updates the content of the map description text edit. */ void MapEditor::update_description_to_gui() { QString description = get_resources().get_description( ResourceType::MAP, map_id); if (ui.description_field->text() != description) { ui.description_field->setText(description); } }
Rect GUIComponent::render_text( Canvas &canvas, const std::string &text, int xpos, int baseline ) { Rect content_box = get_content_box(); content_box.left += xpos; content_box.top += baseline; Font font = impl->element.get_font(canvas, get_resources()); return impl->element.render_text(canvas, font, text, content_box, baseline, false ); }
ResizeTrackWindow::ResizeTrackWindow(MWindow *mwindow, ResizeTrackThread *thread, int x, int y) : BC_Window(PROGRAM_NAME ": Resize Track", x - 320 / 2, y - get_resources()->ok_images[0]->get_h() + 100 / 2, 340, get_resources()->ok_images[0]->get_h() + 100, 340, get_resources()->ok_images[0]->get_h() + 100, 0, 0, 1) { this->mwindow = mwindow; this->thread = thread; }
int BC_FileBox::update_filter(const char *filter) { fs->set_filter(filter); fs->update(0); refresh(); strcpy(get_resources()->filebox_filter, filter); return 0; }
/** * @brief Creates a new leaf item with the specified element id. * @param element_id Id of the element to create. * @return The created item. */ QStandardItem* ResourceModel::create_element_item(const QString& element_id) { QString description = get_resources().get_description(resource_type, element_id); QStandardItem* item = new QStandardItem(description); item->setData(element_id, Qt::UserRole); items.insert(element_id, item); return item; }
void BC_FileBox::create_history() { BC_Resources *resources = get_resources(); recent_dirs.remove_all_objects(); for(int i = 0; i < FILEBOX_HISTORY_SIZE; i++) { if(resources->filebox_history[i][0]) { recent_dirs.append(new BC_ListBoxItem(resources->filebox_history[i])); } } }
void BC_Pan::draw_popup() { popup->draw_background(0, 0, popup->get_w(), popup->get_h()); int x1, y1; float rotate_angle; float scale = (float)(popup->get_w() - get_resources()->pan_data[PAN_CHANNEL]->get_w()) / (virtual_r * 2); set_color(get_resources()->pan_text_color); set_font(SMALLFONT); for(int i = 0; i < total_values; i++) { x1 = (int)(value_x[i] * scale); y1 = (int)(value_y[i] * scale); rotate_angle = value_positions[i]; rotate_angle = -rotate_angle; while(rotate_angle < 0) rotate_angle += 360; rotater->rotate(temp_channel, get_resources()->pan_data[PAN_CHANNEL], rotate_angle, 0); BC_Pixmap *temp_pixmap = new BC_Pixmap(popup, temp_channel, PIXMAP_ALPHA); popup->draw_pixmap(temp_pixmap, x1, y1); delete temp_pixmap; char string[BCTEXTLEN]; float value = values[i] + 0.005; sprintf(string, "%.1f", value); popup->draw_text(x1, y1 + get_text_height(SMALLFONT), string); } x1 = (int)(stick_x * scale); y1 = (int)(stick_y * scale); popup->draw_pixmap(images[PAN_STICK], x1, y1); popup->flash(); }
int BC_ProgressBar::set_images() { for(int i = 0; i < 2; i++) if(images[i]) delete images[i]; for(int i = 0; i < 2; i++) { images[i] = new BC_Pixmap(parent_window, get_resources()->progress_images[i], PIXMAP_ALPHA); } return 0; }
int BC_Pot::draw(int flush) { int x1, y1, x2, y2; draw_top_background(parent_window, 0, 0, get_w(), get_h()); draw_pixmap(images[status]); set_color(get_resources()->pot_needle_color); angle_to_coords(x1, y1, x2, y2, percentage_to_angle(get_percentage())); draw_line(x1, y1, x2, y2); flash(flush); return 0; }
static GList * get_nicks(XMPP_SERVER_REC *server, const char *nick, gboolean quoted, gboolean complete_names) { GSList *gl, *ul; GList *list; XMPP_ROSTER_USER_REC *user; char *jid, *resource; int len; gboolean pass2; len = strlen(nick); /* resources completion */ resource = xmpp_extract_resource(nick); if (resource != NULL) { jid = xmpp_strip_resource(nick); list = get_resources(server, jid, resource, quoted); g_free(resource); g_free(jid); return list; } list = NULL; pass2 = FALSE; again: /* first complete with online contacts * then complete with offline contacts */ for (gl = server->roster; gl != NULL; gl = gl->next) { for (ul = ((XMPP_ROSTER_GROUP_REC *)gl->data)->users; ul != NULL ; ul = ul->next) { user = (XMPP_ROSTER_USER_REC *)ul->data; if ((!pass2 && user->resources == NULL) || (pass2 && user->resources != NULL)) continue; if (complete_names && user->name != NULL && g_ascii_strncasecmp(user->name, nick, len) == 0) list = g_list_prepend(list, quoted ? quoted_if_space(user->name, NULL) : g_strdup(user->name)); if (g_ascii_strncasecmp(user->jid, nick, len) == 0) list = g_list_prepend(list, quoted ? quoted_if_space(user->jid, NULL) : g_strdup(user->jid)); } } if ((pass2 = !pass2)) goto again; /* TODO: rewrite this function */ return list; }
/** * @brief Modifies the map description in the quest resource list with * the new text entered by the user. * * If the new description is invalid, an error dialog is shown. */ void MapEditor::set_description_from_gui() { QString description = ui.description_field->text(); if (description == get_resources().get_description(ResourceType::MAP, map_id)) { return; } if (description.isEmpty()) { GuiTools::error_dialog(tr("Invalid description")); update_description_to_gui(); return; } const bool was_blocked = blockSignals(true); try { get_resources().set_description(ResourceType::MAP, map_id, description); get_resources().save(); } catch (const EditorException& ex) { ex.print_message(); } update_description_to_gui(); blockSignals(was_blocked); }
int BC_Pot::initialize() { if(!data) { data = get_resources()->pot_images; } status = POT_UP; set_data(data); w = data[0]->get_w(); h = data[0]->get_h(); BC_SubWindow::initialize(); draw(0); return 0; }
/** * @brief Creates a resource model. * @param quest The quest. * @param resource_type Type of resources to show. * @param parent The parent object or nullptr. */ ResourceModel::ResourceModel(const Quest& quest, ResourceType resource_type, QObject* parent) : QStandardItemModel(parent), quest(quest), resource_type(resource_type), items(), icons(), directory_icon(":/images/icon_folder_open.png"), tileset_id() { QStringList ids = get_resources().get_elements(this->resource_type); for (const QString& id : ids) { add_element(id); } const QuestResources& resources = get_resources(); connect(&resources, SIGNAL(element_added(ResourceType, QString, QString)), this, SLOT(element_added(ResourceType, QString, QString))); connect(&resources, SIGNAL(element_removed(ResourceType, QString)), this, SLOT(element_removed(ResourceType, QString))); connect(&resources, SIGNAL(element_renamed(ResourceType, QString, QString)), this, SLOT(element_renamed(ResourceType, QString, QString))); connect(&resources, SIGNAL(element_description_changed(ResourceType, QString, QString)), this, SLOT(element_description_changed(ResourceType, QString, QString))); }