1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef UI_VIEWS_CONTROLS_TABLE_TABLE_UTILS_H_ 6#define UI_VIEWS_CONTROLS_TABLE_TABLE_UTILS_H_ 7 8#include <vector> 9 10#include "ui/base/models/table_model.h" 11#include "ui/views/views_export.h" 12 13namespace gfx { 14class FontList; 15} 16 17namespace views { 18 19class TableView; 20 21VIEWS_EXPORT extern const int kUnspecifiedColumnWidth; 22 23// Returns the width needed to display the contents of the specified column. 24// This is used internally by CalculateTableColumnSizes() and generally not 25// useful by itself. |header_padding| is padding added to the header. 26VIEWS_EXPORT int WidthForContent(const gfx::FontList& header_font_list, 27 const gfx::FontList& content_font_list, 28 int padding, 29 int header_padding, 30 const ui::TableColumn& column, 31 ui::TableModel* model); 32 33// Determines the width for each of the specified columns. |width| is the width 34// to fit the columns into. |header_font_list| the font list used to draw the 35// header and |content_font_list| the header used to draw the content. |padding| 36// is extra horizontal spaced added to each cell, and |header_padding| added to 37// the width needed for the header. 38VIEWS_EXPORT std::vector<int> CalculateTableColumnSizes( 39 int width, 40 int first_column_padding, 41 const gfx::FontList& header_font_list, 42 const gfx::FontList& content_font_list, 43 int padding, 44 int header_padding, 45 const std::vector<ui::TableColumn>& columns, 46 ui::TableModel* model); 47 48// Converts a TableColumn::Alignment to the alignment for drawing the string. 49int TableColumnAlignmentToCanvasAlignment(ui::TableColumn::Alignment alignment); 50 51// Returns the index of the closest visible column index to |x|. Return value is 52// in terms of table->visible_columns(). 53int GetClosestVisibleColumnIndex(const TableView* table, int x); 54 55} // namespace views 56 57#endif // UI_VIEWS_CONTROLS_TABLE_TABLE_UTILS_H_ 58