/* this is when the panel size changes */ static void button_size_allocated (GtkWidget *button, GtkAllocation *allocation, ButtonData *button_data) { g_debug("Got size allocation %dx%d", allocation->width, allocation->height); switch (button_data->orient) { case GTK_ORIENTATION_HORIZONTAL: update_size (button_data, allocation->height); break; case GTK_ORIENTATION_VERTICAL: update_size (button_data, allocation->width); break; } }
static int db_write(backend_store_interface* i, const char* rel_path, const char *buf, size_t size, off_t offset, uint64_t* file_handle) { int j; logger_logf(LOG(i), "rel_path = %s", rel_path); ERR_IF_DOESNT_EXIST(i, rel_path); ERR_IF_CANT_WRITE_TO_FILE(i, rel_path); char* contents = get_contents(rel_path); size_t old_size = get_size(rel_path); size_t new_size = (offset + size > old_size ? offset + size : old_size); logger_logf(LOG(i), "old_size = %ld, new_size = %ld, offset = %ld", old_size, new_size, offset); char new_contents[new_size]; for (j = 0; j < offset; ++j) { new_contents[j] = contents[j]; } for (j = offset; j < offset + size; ++j) { new_contents[j] = buf[j - offset]; } for (j = offset; j < old_size; ++j) { new_contents[offset + size + offset - j] = buf[j]; } update_contents(rel_path, new_contents, new_size); update_size(rel_path, new_size); free(contents); return size; }
void menu::set_max_width(const int new_max_width) { max_width_ = new_max_width; itemRects_.clear(); column_widths_.clear(); update_size(); }
void menu::set_max_height(const int new_max_height) { max_height_ = new_max_height; itemRects_.clear(); max_items_ = -1; update_size(); }
void menu::wrap_words() { int total_width = max_width_ - (style_->get_cell_padding() + (2 * style_->get_thickness())); if(has_scrollbar()) { total_width -= scrollbar_width(); } if(total_width <= 0) { return; } std::vector<int> const &widths = column_widths(); for(std::vector<item>::iterator i = items_.begin(); i != items_.end(); ++i) { int space_remaining = total_width; for(size_t col = 0; col < i->fields.size() && col < widths.size(); ++col) { std::string &to_wrap = i->fields[col]; if (!to_wrap.empty()) { if(widths[col] > space_remaining && to_wrap[0] != IMAGE_PREFIX) { to_wrap = font::word_wrap_text(to_wrap, style_->get_font_size(), space_remaining); break; } space_remaining -= widths[col] + 5; } } } itemRects_.clear(); column_widths_.clear(); max_items_ = -1; // Force recalculation of the max items. item_height_ = -1; // Force recalculation of the item height. update_size(); }
static int db_truncate(backend_store_interface* i, const char* rel_path, off_t newsize) { int j; logger_logf(LOG(i), "rel_path = %s", rel_path); ERR_IF_DOESNT_EXIST(i, rel_path); ERR_IF_CANT_WRITE_TO_FILE(i, rel_path); char* contents = get_contents(rel_path); size_t current_size = get_size(rel_path); char buf[newsize]; for (j = 0; j < newsize; ++j) { if (j < current_size) { buf[j] = contents[j]; } else { buf[j] = '\0'; } } update_contents(rel_path, buf, newsize); update_size(rel_path, newsize); free(contents); return 0; }
void tb_present(void) { unsigned int x,y; struct tb_cell *back, *front; /* invalidate cursor position */ lastx = LAST_COORD_INIT; lasty = LAST_COORD_INIT; if (buffer_size_change_request) { update_size(); buffer_size_change_request = 0; } for (y = 0; y < front_buffer.height; ++y) { for (x = 0; x < front_buffer.width; ++x) { back = &CELL(&back_buffer, x, y); front = &CELL(&front_buffer, x, y); if (memcmp(back, front, sizeof(struct tb_cell)) == 0) continue; send_attr(back->fg, back->bg); send_char(x, y, back->ch); memcpy(front, back, sizeof(struct tb_cell)); } } if (!IS_CURSOR_HIDDEN(cursor_x, cursor_y)) write_cursor(cursor_x, cursor_y); memstream_flush(&write_buffer); }
void NDArray::init(NDArray::Type type, const QList<int> &shape, char *dptr) { m_ndim = shape.count(); m_shapelst = shape; if (m_type == Unknown) return; // Get the total size of the allocated memory required int size = 1; foreach(int dim, shape) size *= dim; int dsize = size * m_typesize; if (dptr == 0) { dptr = new char[dsize]; } m_data_ch = dptr; m_data_ptr = new ArrayData(dptr, dsize); // Get shape and offsets right m_shape = QSharedPointer<int>::create(m_ndim); m_strides = QSharedPointer<int>::create(m_ndim); int str = 1; for (int i=0; i<m_ndim; ++i) { m_shape.data()[i] = shape[i]; int i_r = m_ndim - i - 1; m_strides.data()[i_r] = str; str *= shape[i_r]; } update_size(); }
void render() { int cursor_pos; FcChar8 t; update_size(); XftDrawRect(draw, &bg, 0, 0, w, h); if (prompt[0]) draw_string(prompt, PADDING, PADDING + ascent); if (text_input) { draw_string(text, PADDING + prompt_width, PADDING + ascent); t = text[cursor]; text[cursor] = '\0'; cursor_pos = prompt_width + text_width(text); text[cursor] = t; draw_string("_", PADDING + 1 + cursor_pos, PADDING + ascent); } if (draw_options) render_options(PADDING + ((text_input || prompt[0]) ? ascent + descent : 0)); XCopyArea(display, buf, win, gc, 0, 0, w, h, 0, 0); }
void SeqWindow::change_name_width(int newwidth) { if(newwidth < width - 5 && newwidth > 1) { names_width = newwidth; update_size(); _recalculate_num_displayed(); } }
void Growblock::hit() { active = false; pos_x = -20.0f; pos_y = -20.0f; update_size(-0.1f); }
void GLUI_Panel::set_type( int new_type ) { if ( new_type != int_val ) { int_val = new_type; update_size(); redraw(); } }
void tb_clear(void) { if (buffer_size_change_request) { update_size(); buffer_size_change_request = 0; } cellbuf_clear(&back_buffer); }
/** * Changes the size of a client. */ void ClientModel::change_size(Window client, Dimension width, Dimension height) { if (width > 0 && height > 0) { update_size(client, width, height); m_changes.push(new ChangeSize(client, width, height)); } }
void GLUI_Panel::set_name( char *new_name ) { strncpy(name,new_name,sizeof(GLUI_String)); update_size(); if ( glui ) glui->refresh(); }
void GLUI_Panel::set_name( const char *new_name ) { name = new_name ? new_name : ""; update_size(); if ( glui ) glui->refresh(); }
void fix() { sum = value; if (L) { L->updateLazy(); sum += L->sum; } if (R) { R->updateLazy(); sum += R->sum; } update_size(); }
void GLUI_ActiveText::set_text( const char *text ) { if (name == text) return; int old_w = w; name = text; update_size(); if ((w != old_w)&&(glui)) glui->refresh(); draw_translated_active_area(); }
void GLUI_Panel::set_type( int new_type ) { int old_window; if ( new_type != int_val ) { int_val = new_type; /* translate_and_draw_front(); */ update_size(); old_window = set_to_glut_window(); glutPostRedisplay( ); restore_window( old_window ); } }
static gboolean bigboard_button_applet_fill (PanelApplet *applet) { ButtonData *button_data; #ifdef GUI_LOG log_debug_messages = TRUE; #endif g_log_set_default_handler(log_handler, NULL); g_log_set_handler(G_LOG_DOMAIN, (GLogLevelFlags) (G_LOG_LEVEL_DEBUG | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION), log_handler, NULL); panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR); button_data = bigboard_button_add_to_widget (GTK_WIDGET (applet)); g_debug ("Got panel applet size %d", panel_applet_get_size (applet)); update_size (button_data, panel_applet_get_size (applet)); update_orientation (button_data, panel_applet_get_orient (applet)); /* FIXME: Update this comment. */ /* we have to bind change_orient before we do applet_widget_add since we need to get an initial change_orient signal to set our initial oriantation, and we get that during the _add call */ g_signal_connect (G_OBJECT (button_data->applet), "change_orient", G_CALLBACK (applet_change_orient), button_data); panel_applet_set_background_widget (PANEL_APPLET (button_data->applet), GTK_WIDGET (button_data->applet)); panel_applet_setup_menu_from_file (PANEL_APPLET (button_data->applet), NULL, "GNOME_OnlineDesktop_BigBoardButtonApplet.xml", NULL, bigboard_button_menu_verbs, button_data); gtk_widget_show_all (button_data->applet); return TRUE; }
// Refresh, get the slice of the sequence, add the formatting, // and use wprintw to put everything on the screen. void SeqWindow::display() { int w = width; int h = height; update_size(); if(w != width || h != height) modified = true; if(modified) { _recalculate_num_displayed(); _display_names(); _display_positions(); _display_seqs(); _display_filename(); wrefresh(window); } else { } }
void tb_present(void) { int x,y,w,i; struct tb_cell *back, *front; /* invalidate cursor position */ lastx = LAST_COORD_INIT; lasty = LAST_COORD_INIT; if (buffer_size_change_request) { update_size(); buffer_size_change_request = 0; } for (y = 0; y < front_buffer.height; ++y) { for (x = 0; x < front_buffer.width; ) { back = &CELL(&back_buffer, x, y); front = &CELL(&front_buffer, x, y); w = wcwidth(back->ch); if (w < 1) w = 1; if (memcmp(back, front, sizeof(struct tb_cell)) == 0) { x += w; continue; } memcpy(front, back, sizeof(struct tb_cell)); send_attr(back->fg, back->bg); if (w > 1 && x >= front_buffer.width - (w - 1)) { // Not enough room for wide ch, so send spaces for (i = x; i < front_buffer.width; ++i) { send_char(i, y, ' '); } } else { send_char(x, y, back->ch); for (i = 1; i < w; ++i) { front = &CELL(&front_buffer, x + i, y); front->ch = 0; front->fg = back->fg; front->bg = back->bg; } } x += w; } } if (!IS_CURSOR_HIDDEN(cursor_x, cursor_y)) write_cursor(cursor_x, cursor_y); bytebuffer_flush(&output_buffer, inout); }
void SeqWindow::resize(int upperleftX, int upperleftY, int newwidth, int newheight) { wattron(window, COLOR_PAIR(8)); for(int i = 0; i < height; i++) { mvwprintw(window, i, 0, string(width, ' ').c_str()); } wrefresh(window); delwin(window); window = newwin(newheight, newwidth, upperleftY, upperleftX); height = newheight; width = newwidth; update_size(); _recalculate_num_displayed(); modified = true; display(); }
static int db_mkdir(backend_store_interface* i, const char* rel_path, mode_t mode) { logger_logf(LOG(i), "rel_path = %s, mode = %ld", rel_path, mode); if (file_exists(rel_path)) { logger_logf(LOG(i), "file already exists: -EEXIST"); return -EEXIST; } ERR_IF_CANT_WRITE_TO_DIR(i, rel_path); int ret = db_mknod(i, rel_path, mode | S_IFDIR, 0); if (ret == 0) { update_directory_status(rel_path, 1); update_size(rel_path, 4906); } return ret; }
void GLUI_Graph::set_graph_size( int g_w, int g_h ) { if ((g_w>0) && (g_h>0)) { graph_w = g_w; graph_h = g_h; update_size(); if( glui ) glui->refresh(); } else { fprintf(stderr,"GLUI_Graph::set_img_size - Bad dimensions.\n"); } }
static void gbm_winsys_main_loop(void *data) { struct gbm_winsys *winsys = data; struct sigaction action = { .sa_handler = sigint_handler, }; struct sigaction old_action; sigemptyset(&action.sa_mask); sigaction(SIGINT, &action, &old_action); update_size(winsys); while (!quit) { winsys->callbacks->draw(winsys->cb_data); swap(winsys); } sigaction(SIGINT, &old_action, NULL); }
SeqWindow::SeqWindow(int upperleftX, int upperleftY, int _width, int _height, SeqSet &sq) { window = newwin(_height, _width, upperleftY, upperleftX); width = _width; height = _height; seqs = sq; scrollmode = 1; display_mode = NORMAL; names_width = 15; first_pos = 0; first_seq = 0; update_size(); _recalculate_num_displayed(); isfocal = true; bolded = false; modified = true; compare = NOCOMPARE; pcomp = NUCAMB; transl_adj = 1; display(); }
uint fat_write(char* name, uint offset, uint length, char* buffer){ char* fname = fat_name_conv(name); fat_dir_t* entry = fat_dir_search(fname); if(entry == NULL) return (uint) -1; update_size(entry, offset, length); if(offset_to_cluster(offset) > fat_cluster_size(entry)){ uint extension = offset_to_cluster(offset); while(extension < offset_to_cluster(offset + length)){ fat_write_block(name, extension, buffer); extension += CLUSTER_BSIZE; } } uchar* scratch = (uchar*) kmalloc(CLUSTER_BSIZE * 2); while(length != 0){ fat_read_block(name, offset_to_cluster(offset), scratch); uint index = offset_in_cluster(offset); if(CLUSTER_BSIZE - index < length){ memcpy(&scratch[index], buffer, CLUSTER_BSIZE - index); buffer = (uchar*) ((uint) buffer + (CLUSTER_BSIZE - index)); length -= CLUSTER_BSIZE - index; } else{ memcpy(&scratch[index], buffer, length); length = 0; } fat_write_block(name, offset_to_cluster(offset), scratch); } kfree(scratch); return 0; }
SeqWindow::SeqWindow(int upperleftX, int upperleftY, int _width, int _height, string filename, ParserFunction parser) { SeqSet sq; parser(filename, sq); window = newwin(_height, _width, upperleftY, upperleftX); width = _width + 1; height = _height + 1; seqs = sq; scrollmode = 1; display_mode = NORMAL; names_width = 15; first_pos = 0; first_seq = 0; update_size(); _recalculate_num_displayed(); bolded = false; modified = true; compare = NOCOMPARE; pcomp = NUCAMB; transl_adj = 1; display(); }
void menu::fill_items(const std::vector<std::string>& items, bool strip_spaces) { for(std::vector<std::string>::const_iterator itor = items.begin(); itor != items.end(); ++itor) { if(itor->empty() == false && (*itor)[0] == HEADING_PREFIX) { heading_ = utils::quoted_split(itor->substr(1),COLUMN_SEPARATOR, !strip_spaces); continue; } const size_t id = items_.size(); item_pos_.push_back(id); const item new_item(utils::quoted_split(*itor, COLUMN_SEPARATOR, !strip_spaces),id); items_.push_back(new_item); //make sure there is always at least one item if(items_.back().fields.empty()) { items_.back().fields.push_back(" "); } //if the first character in an item is an asterisk, //it means this item should be selected by default std::string& first_item = items_.back().fields.front(); if(first_item.empty() == false && first_item[0] == DEFAULT_ITEM) { selected_ = id; first_item.erase(first_item.begin()); } } create_help_strings(); if(sortby_ >= 0) { do_sort(); } update_size(); }