Example #1
0
	table_view::child_widget_scrolling_disposition_e table_view::scrolling_disposition(const i_widget& aChildWidget) const
	{
		if (&aChildWidget == &column_header())
			return ScrollChildWidgetHorizontally;
		else
			return item_view::scrolling_disposition(aChildWidget);
	}
Example #2
0
void EDE_Browser::sort(int column, SortType type, bool reverse) {
	char *h=column_header_;
	int hlen=strlen(h);
	char colchar = Fl_Icon_Browser::column_char();

	// FIXME sort() shouldn't call column_header() because that calls show_header() and that
	// deletes all buttons from header (so they could be recreated). This cause valgrind errors
	// since sort is called in button callback - you can't delete a widget in its own callback

	// Remove old sort direction symbol (if any) from header
	char *delim = 0;
	int col=0;
	if (sort_type != NO_SORT) {
		bool found=false;
		while ((delim=strchr(h, colchar))) {
			if (col==sort_column) {
				for (uint i=0; i<=strlen(delim); i++) delim[i-SYMLEN+1]=delim[i];
				found=true;
				break;
			}
			h=delim+1;
			col++;
		}
		if (!found && col==sort_column)
			column_header_[hlen-SYMLEN+1]='\0';
		h=column_header_;
		delim = 0;
		col=0;
	}

	// Add new symbol
	char *newheader = new char[hlen+6];
	if (type != NO_SORT) {
		// Construct symbol
		char sym[SYMLEN];
		if (reverse) snprintf(sym,SYMLEN,"@-22<");
		else snprintf(sym,SYMLEN,"@-22>");

		// Find column
		bool found=false;
		while ((delim=strchr(h, colchar))) {
			if (col==column) {
				*delim='\0';
				snprintf(newheader,hlen+SYMLEN,"%s%s\t%s",column_header_,sym,delim+1);
				found=true;
				break;
			}
			h=delim+1;
			col++;
		}
		if (!found && col==column) // Just append symbol to string
			snprintf(newheader, hlen+SYMLEN,"%s%s",column_header_,sym);
	} else {
		strncpy (newheader, column_header_, hlen);
		newheader[hlen]='\0';
	}
	column_header(newheader);
	delete[] newheader;
	sort_column=column; sort_type=type; sort_direction=reverse;

	// Start actually sorting
	if (type != NO_SORT) {
		// First create an array of strings in a given column
		char** sorttext = (char**)malloc(sizeof(char*)*(size()+1)); // index starts from 1 for simplicity in mqsort
		for (int i=1;i<=size();i++) {
			char *tmp = strdup(text(i));
			char *l = tmp;
			int col=0;
			while ((delim=strchr(l, Fl_Icon_Browser::column_char()))) {
				*delim = '\0';
				if (col==column) break;
				l=delim+1;
				col++;
			}
			sorttext[i] = strdup(l);
			free(tmp);
		}

		mqsort(sorttext, 1, size()+1, type);
		redraw();

		// Free the allocated memory
		for (int i=1; i<=size(); i++) free (sorttext[i]);
		free(sorttext);
	}
}
Example #3
0
	void table_view::presentation_model_changed()
	{
		column_header().set_presentation_model(presentation_model());
	}
Example #4
0
	void table_view::model_changed()
	{
		column_header().set_model(model());
	}
Example #5
0
	dimension table_view::column_width(uint32_t aColumn) const
	{
		return column_header().section_width(aColumn);
	}
Example #6
0
	size table_view::item_total_area(graphics_context& aGraphicsContext) const
	{
		return size(column_header().total_width(), presentation_model().total_height(aGraphicsContext));
	}
Example #7
0
	rect table_view::item_display_rect() const
	{
		return rect(
			point(0.0, column_header().visible() ? column_header().extents().cy : 0.0),
			size(std::min(client_rect().width(), column_header().total_width()), client_rect().height() - (column_header().visible() ? column_header().extents().cy : 0.0)));
	}
Example #8
0
	void table_view::batch_update_ended()
	{
		column_header().end_batch_update();
	}
Example #9
0
	void table_view::batch_update_started()
	{
		column_header().start_batch_update();
	}