linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05173
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2807: Clean up dwt table columns
------------------------------------------------------------
revno: 2807
committer: Jacek Sieka <arnetheduck@xxxxxxxxx>
branch nick: dcplusplus
timestamp: Sun 2012-01-08 23:14:11 +0100
message:
Clean up dwt table columns
added:
dwt/include/dwt/aspects/Columns.h
dwt/include/dwt/widgets/Column.h
modified:
dcpp/Text.h
dwt/include/dwt/Rectangle.h
dwt/include/dwt/widgets/Table.h
dwt/src/Rectangle.cpp
dwt/src/widgets/RichTextBox.cpp
dwt/src/widgets/Table.cpp
dwt/test/TableTest.cpp
win32/PropPage.cpp
win32/SearchFrame.cpp
win32/StringListDlg.cpp
win32/WinUtil.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/Text.h'
--- dcpp/Text.h 2011-12-22 22:14:45 +0000
+++ dcpp/Text.h 2012-01-08 22:14:11 +0000
@@ -150,6 +150,18 @@
string toDOS(string tmp);
wstring toDOS(wstring tmp);
+ template<typename T, typename F>
+ inline void tokenize(const std::basic_string<T>& str, T token, F f) {
+ string::size_type i = 0;
+ string::size_type j = 0;
+ while( (i=str.find(token, j)) != string::npos ) {
+ f(str.substr(j, i-j));
+ j = i + 1;
+ }
+ if(j < str.size())
+ f(str.substr(j));
+
+ }
}
} // namespace dcpp
=== modified file 'dwt/include/dwt/Rectangle.h'
--- dwt/include/dwt/Rectangle.h 2011-01-02 17:12:02 +0000
+++ dwt/include/dwt/Rectangle.h 2012-01-08 22:14:11 +0000
@@ -62,6 +62,7 @@
*/
explicit Rectangle( const Point & pSize ) : pos(0, 0), size(pSize) { }
+ ::RECT toRECT() const;
operator ::RECT() const;
/// Constructor initializing the rectangle with longs instead of Points.
=== added file 'dwt/include/dwt/aspects/Columns.h'
--- dwt/include/dwt/aspects/Columns.h 1970-01-01 00:00:00 +0000
+++ dwt/include/dwt/aspects/Columns.h 2012-01-08 22:14:11 +0000
@@ -0,0 +1,179 @@
+/*
+ DC++ Widget Toolkit
+
+ Copyright (c) 2007-2011, Jacek Sieka
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the DWT nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef DWT_ASPECTCOLUMNS_H_
+#define DWT_ASPECTCOLUMNS_H_
+
+#include <vector>
+
+#include <boost/range/algorithm/for_each.hpp>
+
+#include "../forward.h"
+#include "../widgets/Column.h"
+
+namespace dwt { namespace aspects {
+
+/** Aspect for widgets that display data in columns.
+ *
+ * Columns are zero-indexed.
+ */
+template<typename WidgetType>
+class Columns {
+ WidgetType& W() { return *static_cast<WidgetType*>(this); }
+ const WidgetType& W() const { return *static_cast<const WidgetType*>(this); }
+
+public:
+ /** Add a column at the end of the current list of columns */
+ void addColumn(const tstring& header = tstring(), int width = -1, Column::Alignment alignement = Column::LEFT);
+
+ /** Add a column at the end of the current list of columns */
+ void addColumn(const Column& column);
+
+ /** Insert a column after the specified column.
+ *
+ * @return The index of the inserted column
+ */
+ int insertColumn(const Column& column, int after);
+
+ /** Reset the column list to the givent columns */
+ void setColumns(const std::vector<Column>& columns);
+
+ /** Remove the specified column.
+ * Any columns after the specified columns will be shifted back.
+ */
+ void eraseColumn(unsigned column);
+
+ /** Returns the current number of columns */
+ unsigned getColumnCount() const;
+
+ /** Returns information about all columns */
+ std::vector<Column> getColumns() const;
+
+ /** Return column information about the given column */
+ Column getColumn(unsigned column) const;
+
+ /** Return the current column order.
+ * The returned vector will have the same number of elements as there are currently columns.
+ */
+ std::vector<int> getColumnOrder() const;
+
+ /** Update the column order.
+ *
+ * @param columns The new column order - the vector must have as many elements as there are columns
+ */
+ void setColumnOrder(const std::vector<int>& columns);
+
+ /** Return all column widths */
+ std::vector<int> getColumnWidths() const;
+
+ /** Update all column widths.
+ *
+ * @param widths The new column widths - the vector must have as many elements as there are columns
+ */
+ void setColumnWidths(const std::vector<int>& widths);
+
+ /** Set the width of the specified column
+ *
+ * @param column Column index
+ * @param width Width in pixels, or one of the constants in Column::AutoWidth
+ */
+ void setColumnWidth( unsigned column, int width );
+};
+
+template<typename WidgetType>
+inline void Columns<WidgetType>::addColumn(const tstring& header, int width, Column::Alignment alignment) {
+ addColumn(Column(header, width, alignment));
+}
+
+template<typename WidgetType>
+inline void Columns<WidgetType>::addColumn(const Column& column) {
+ insertColumn(column, getColumnCount());
+}
+
+template<typename WidgetType>
+inline int Columns<WidgetType>::insertColumn(const Column& column, int after) {
+ return W().insertColumnImpl(column, after);
+}
+
+template<typename WidgetType>
+inline void Columns<WidgetType>::setColumns(const std::vector<Column>& columns) {
+ for(auto i = 0u, iend = getColumnCount(); i < iend; ++i) eraseColumn(i);
+ for(auto i = 0u, iend = columns.size(); i < iend; ++i) insertColumn(columns[i], i);
+}
+
+template<typename WidgetType>
+inline void Columns<WidgetType>::eraseColumn(unsigned column) {
+ W().eraseColumnImpl(column);
+}
+
+template<typename WidgetType>
+inline unsigned Columns<WidgetType>::getColumnCount() const {
+ return W().getColumnCountImpl();
+}
+
+template<typename WidgetType>
+inline std::vector<Column> Columns<WidgetType>::getColumns() const {
+ return W().getColumnsImpl();
+}
+
+template<typename WidgetType>
+inline Column Columns<WidgetType>::getColumn(unsigned column) const {
+ return W().getColumnImpl(column);
+}
+
+template<typename WidgetType>
+inline std::vector<int> Columns<WidgetType>::getColumnOrder() const {
+ return W().getColumnOrderImpl();
+}
+
+template<typename WidgetType>
+inline void Columns<WidgetType>::setColumnOrder(const std::vector<int>& columns) {
+ W().setColumnOrderImpl(columns);
+}
+
+template<typename WidgetType>
+inline std::vector<int> Columns<WidgetType>::getColumnWidths() const {
+ return W().getColumnWidthsImpl();
+}
+
+template<typename WidgetType>
+inline void Columns<WidgetType>::setColumnWidths(const std::vector<int>& widths) {
+ for(auto i = 0u, iend = widths.size(); i < iend; ++i) setColumnWidth(i, widths[i]);
+}
+
+template<typename WidgetType>
+inline void Columns<WidgetType>::setColumnWidth( unsigned column, int width ) {
+ W().setColumnWidthImpl(column, width);
+}
+
+} }
+
+#endif /* DWT_ASPECTCHILD_H_ */
=== added file 'dwt/include/dwt/widgets/Column.h'
--- dwt/include/dwt/widgets/Column.h 1970-01-01 00:00:00 +0000
+++ dwt/include/dwt/widgets/Column.h 2012-01-08 22:14:11 +0000
@@ -0,0 +1,62 @@
+/*
+ DC++ Widget Toolkit
+
+ Copyright (c) 2007-2011, Jacek Sieka
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the DWT nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef DWT_COLUMN_H_
+#define DWT_COLUMN_H_
+
+namespace dwt {
+
+struct Column {
+ enum Alignment {
+ LEFT,
+ RIGHT,
+ CENTER
+ };
+
+ enum AutoWidth {
+ SIZE_TO_CONTENT = -1,
+ SIZE_TO_HEADER = -2
+ };
+
+ tstring header;
+ int width;
+ Alignment alignment;
+
+ Column();
+ Column(tstring header, int width = -1, Alignment alignment = LEFT);
+};
+
+inline Column::Column() { }
+inline Column::Column(tstring header, int width, Alignment alignment) : header(header), width(width), alignment(alignment) { }
+
+}
+
+#endif /* COLUMN_H_ */
=== modified file 'dwt/include/dwt/widgets/Table.h'
--- dwt/include/dwt/widgets/Table.h 2012-01-07 20:25:42 +0000
+++ dwt/include/dwt/widgets/Table.h 2012-01-08 22:14:11 +0000
@@ -40,6 +40,7 @@
#include "../resources/ImageList.h"
#include "../aspects/Clickable.h"
#include "../aspects/Collection.h"
+#include "../aspects/Columns.h"
#include "../aspects/CustomDraw.h"
#include "../aspects/Data.h"
#include "../aspects/Scrollable.h"
@@ -69,6 +70,7 @@
public CommonControl,
public aspects::Clickable<Table>,
public aspects::Collection<Table, int>,
+ public aspects::Columns<Table>,
public aspects::CustomDraw<Table, NMLVCUSTOMDRAW>,
public aspects::Data<Table, int>,
public aspects::Scrollable<Table>,
@@ -78,6 +80,7 @@
friend class WidgetCreator<Table>;
friend class aspects::Collection<Table, int>;
+ friend class aspects::Columns<Table>;
friend class aspects::Data<Table, int>;
friend class aspects::Selection<Table, int>;
friend class aspects::Clickable<Table>;
@@ -215,57 +218,6 @@
*/
void setReadOnly( bool value = true );
- /// Returns the number of column in the grid
- /** Returns the number of columns in the Data Grid. <br>
- * Useful if you need to know how many values you must use when inserting rows
- * into the List View
- */
- unsigned getColumnCount();
-
- /// Returns the name of a specific column
- /** Which column you wish to retrieve the name for is supplied in the "id" parameter.
- */
- tstring getColumnName( unsigned col );
-
- bool setColumnOrder(const std::vector<int>& columns);
-
- std::vector<int> getColumnOrder();
-
- void setColumnWidths(const std::vector<int>& widths);
-
- std::vector<int> getColumnWidths();
-
- /// Create columns in the grid
- /** Normally this would be called just after creation of the grid, it MUST be
- * called before adding items to the grid. <br>
- * The vector parameter is a vector containing the column names of the columns.
- * <br>
- * Columns will be added the way they sequentially appear in the vector.
- */
- void createColumns( const std::vector< tstring > & colNames, const std::vector<int>& widths = std::vector<int>(),
- const std::vector<bool>& alignment = std::vector<bool>(), const std::vector<int>& order = std::vector<int>());
-
- /// Deletes the given column
- /** Column zero CANNOT be deleted.
- */
- void eraseColumn( unsigned columnNo );
-
- /// Sets the width of a given column
- /** Sets the width of the given column, the columnNo parameter is a zero - based
- * index of the column you wish to change, the width parameter is number of
- * pixels you wish the column to be. <br>
- * If you submit LVSCW_AUTOSIZE as the width parameter the column is being
- * "autosized" meaning it will aquire the width needed to display the "widest"
- * cell content in that column, if you submit LVSCW_AUTOSIZE_USEHEADER as the
- * width parameter it will be as wide as it needs to minimum display the
- * complete header text of the column. <br>
- * If you use the LVSCW_AUTOSIZE_USEHEADER on the last column of the list it
- * will be resized to be as wide as it needs to completely fill the remaining
- * width of the list which is quite useful to make the Data Grid fill its whole
- * client area.
- */
- void setColumnWidth( unsigned columnNo, int width );
-
/** Enable group support, and insert each given group. The group id used as the "index" param
of the insert function will be the position of the group in the vector given here.
Once a table has been set into grouped mode, it cannot be switched back to non-grouped mode. */
@@ -517,6 +469,17 @@
static Message getClickMessage();
static Message getRightClickMessage();
static Message getDblClickMessage();
+
+ // aspects::Columns
+ int insertColumnImpl(const Column& column, int after);
+ void eraseColumnImpl(unsigned column);
+ unsigned getColumnCountImpl() const;
+ std::vector<Column> getColumnsImpl() const;
+ Column getColumnImpl(unsigned column) const;
+ std::vector<int> getColumnOrderImpl() const;
+ void setColumnOrderImpl(const std::vector<int>& columns);
+ std::vector<int> getColumnWidthsImpl() const;
+ void setColumnWidthImpl( unsigned column, int width );
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -571,18 +534,6 @@
this->Widget::addRemoveStyle( LVS_EDITLABELS, !value );
}
-inline tstring Table::getColumnName( unsigned col ) {
- // TODO: Fix
- const int BUFFER_MAX = 2048;
- TCHAR buffer[BUFFER_MAX + 1];
- LV_COLUMN colInfo;
- colInfo.mask = LVCF_TEXT;
- colInfo.cchTextMax = BUFFER_MAX;
- colInfo.pszText = buffer;
- ListView_GetColumn( handle(), col, & colInfo );
- return colInfo.pszText;
-}
-
inline bool Table::isChecked( unsigned row ) {
return ListView_GetCheckState( handle(), row ) == TRUE;
}
@@ -666,8 +617,8 @@
return sortType;
}
-inline bool Table::setColumnOrder(const std::vector<int>& columns) {
- return ::SendMessage(handle(), LVM_SETCOLUMNORDERARRAY, static_cast<WPARAM>(columns.size()), reinterpret_cast<LPARAM>(&columns[0])) > 0;
+inline void Table::setColumnOrderImpl(const std::vector<int>& columns) {
+ ::SendMessage(handle(), LVM_SETCOLUMNORDERARRAY, static_cast<WPARAM>(columns.size()), reinterpret_cast<LPARAM>(&columns[0])) > 0;
}
inline void Table::setTableStyle(int style) {
=== modified file 'dwt/src/Rectangle.cpp'
--- dwt/src/Rectangle.cpp 2011-01-02 17:12:02 +0000
+++ dwt/src/Rectangle.cpp 2012-01-08 22:14:11 +0000
@@ -37,12 +37,16 @@
: pos( x, y ), size( width, height )
{}
-Rectangle::operator RECT() const
+::RECT Rectangle::toRECT() const
{
RECT retVal = { left(), top(), right(), bottom() };
return retVal;
}
+Rectangle::operator ::RECT() const {
+ return toRECT();
+}
+
Rectangle Rectangle::subRect( double xFraction, double yFraction,
double widthFraction, double heightFraction ) const
{
=== modified file 'dwt/src/widgets/RichTextBox.cpp'
--- dwt/src/widgets/RichTextBox.cpp 2011-11-22 18:01:45 +0000
+++ dwt/src/widgets/RichTextBox.cpp 2012-01-08 22:14:11 +0000
@@ -140,7 +140,7 @@
Point RichTextBox::getScrollPos() const {
POINT scrollPos;
sendMessage(EM_GETSCROLLPOS, 0, reinterpret_cast< LPARAM >(&scrollPos));
- return scrollPos;
+ return Point(scrollPos);
}
void RichTextBox::setScrollPos(Point& scrollPos) {
=== modified file 'dwt/src/widgets/Table.cpp'
--- dwt/src/widgets/Table.cpp 2011-12-23 14:47:37 +0000
+++ dwt/src/widgets/Table.cpp 2012-01-08 22:14:11 +0000
@@ -31,6 +31,9 @@
#include <dwt/widgets/Table.h>
+#include <boost/scoped_array.hpp>
+#include <boost/range/algorithm/for_each.hpp>
+
#include <dwt/CanvasClasses.h>
#include <dwt/util/check.h>
#include <dwt/util/StringUtils.h>
@@ -39,10 +42,10 @@
#include <dwt/dwt_vsstyle.h>
#include <dwt/dwt_vssym32.h>
-#include <boost/scoped_array.hpp>
-
namespace dwt {
+using boost::range::for_each;
+
const TCHAR Table::windowClass[] = WC_LISTVIEW;
/* the following dance adds Vista members to LVGROUP (notably iTitleImage to have group icons)
@@ -158,33 +161,27 @@
}
}
-void Table::createColumns(const std::vector<tstring>& names, const std::vector<int>& widths,
- const std::vector<bool>& alignment, const std::vector<int>& order)
-{
- // Deleting all data
- clear();
- while ( ListView_DeleteColumn( handle(), 0 ) == TRUE );
-
- for(size_t i = 0; i < names.size(); ++i) {
- LVCOLUMN lvColumn = { LVCF_TEXT };
-
- lvColumn.pszText = const_cast < TCHAR * >( names[i].c_str() );
- if(i < widths.size()) {
- lvColumn.mask |= LVCF_WIDTH;
- lvColumn.cx = widths[i];
- }
- if(i < alignment.size()) {
- lvColumn.mask |= LVCF_FMT;
- lvColumn.fmt |= alignment[i] ? LVCFMT_RIGHT : LVCFMT_LEFT;
- }
- if ( ListView_InsertColumn( handle(), i, &lvColumn) == - 1 ) {
- throw Win32Exception("Error while trying to create Columns in list view" );
- }
- }
-
- if(order.size() == names.size()) {
- setColumnOrder(order);
- }
+int Table::insertColumnImpl(const Column& column, int n) {
+ LVCOLUMN lvColumn = { LVCF_FMT };
+
+ lvColumn.fmt |= column.alignment == Column::LEFT ? LVCFMT_LEFT : column.alignment == Column::CENTER ? LVCFMT_CENTER : LVCFMT_RIGHT;
+
+ if(!column.header.empty()) {
+ lvColumn.mask |= LVCF_TEXT,
+ lvColumn.pszText = const_cast < TCHAR * >( column.header.c_str() );
+ }
+
+ if(column.width >= 0) {
+ lvColumn.mask |= LVCF_WIDTH;
+ lvColumn.cx = column.width;
+ }
+
+ auto ret = ListView_InsertColumn( handle(), n, &lvColumn);
+ if ( ret == - 1 ) {
+ throw Win32Exception("Error while trying to create column in list view" );
+ }
+
+ return ret;
}
int Table::insert(const std::vector<tstring>& row, LPARAM lPar, int index, int iconIndex) {
@@ -285,7 +282,7 @@
return retVal;
}
-unsigned Table::getColumnCount() {
+unsigned Table::getColumnCountImpl() const {
HWND header = ListView_GetHeader(handle());
return Header_GetItemCount(header);
}
@@ -303,7 +300,7 @@
ListView_SetExtendedListViewStyle( handle(), newStyle );
}
-std::vector<int> Table::getColumnOrder() {
+std::vector<int> Table::getColumnOrderImpl() const {
std::vector<int> ret(this->getColumnCount());
if(!::SendMessage(handle(), LVM_GETCOLUMNORDERARRAY, static_cast<WPARAM>(ret.size()), reinterpret_cast<LPARAM>(&ret[0]))) {
ret.clear();
@@ -311,13 +308,7 @@
return ret;
}
-void Table::setColumnWidths(const std::vector<int>& widths) {
- for(size_t i = 0; i < widths.size(); ++i) {
- this->setColumnWidth(i, widths[i]);
- }
-}
-
-std::vector<int> Table::getColumnWidths() {
+std::vector<int> Table::getColumnWidthsImpl() const {
std::vector<int> ret(this->getColumnCount());
for(size_t i = 0; i < ret.size(); ++i) {
ret[i] = ::SendMessage(handle(), LVM_GETCOLUMNWIDTH, static_cast<WPARAM>(i), 0);
@@ -526,12 +517,12 @@
}
}
-void Table::eraseColumn( unsigned columnNo ) {
+void Table::eraseColumnImpl( unsigned columnNo ) {
dwtassert(columnNo != 0, "Can't delete the leftmost column");
ListView_DeleteColumn( handle(), columnNo );
}
-void Table::setColumnWidth( unsigned columnNo, int width ) {
+void Table::setColumnWidthImpl( unsigned columnNo, int width ) {
if ( ListView_SetColumnWidth( handle(), columnNo, width ) == FALSE ) {
dwtWin32DebugFail("Couldn't resize columns of Table");
}
=== modified file 'dwt/test/TableTest.cpp'
--- dwt/test/TableTest.cpp 2012-01-08 12:00:31 +0000
+++ dwt/test/TableTest.cpp 2012-01-08 22:14:11 +0000
@@ -16,11 +16,24 @@
auto table = window->addChild(dwt::Table::Seed());
- std::vector<tstring> columns;
- columns.push_back(_T("A"));
- columns.push_back(_T("B"));
- table->createColumns(columns);
- table->insert(columns);
+ table->addColumn(dwt::Column(_T("Column A")));
+ table->addColumn(dwt::Column(_T("Column B")));
+
+ table->eraseColumn(1);
+ table->addColumn(_T("Column C"), dwt::Column::SIZE_TO_HEADER);
+
+ table->setColumnWidth(0, 100);
+
+ auto order = table->getColumnOrder();
+ order[0] = 1;
+ order[1] = 0;
+ table->setColumnOrder(order);
+
+ std::vector<tstring> rows;
+ rows.push_back(_T("A"));
+ rows.push_back(_T("B"));
+
+ table->insert(rows);
table->resize(dwt::Rectangle(window->getClientSize()));
=== modified file 'win32/PropPage.cpp'
--- win32/PropPage.cpp 2011-12-22 22:14:45 +0000
+++ win32/PropPage.cpp 2012-01-08 22:14:11 +0000
@@ -88,7 +88,7 @@
dcassert(listItems && list);
lists[list] = listItems;
- list->createColumns(TStringList(1));
+ list->addColumn();
SettingsManager* settings = SettingsManager::getInstance();
for(size_t i = 0; listItems[i].setting != 0; ++i) {
=== modified file 'win32/SearchFrame.cpp'
--- win32/SearchFrame.cpp 2012-01-01 21:25:05 +0000
+++ win32/SearchFrame.cpp 2012-01-08 22:14:11 +0000
@@ -238,7 +238,7 @@
hubs = group->addChild(ls);
addWidget(hubs);
- hubs->createColumns(TStringList(1));
+ hubs->addColumn();
hubs->onRaw([this](WPARAM w, LPARAM l) { return handleHubItemChanged(w, l); }, dwt::Message(WM_NOTIFY, LVN_ITEMCHANGED));
=== modified file 'win32/StringListDlg.cpp'
--- win32/StringListDlg.cpp 2011-12-22 22:14:45 +0000
+++ win32/StringListDlg.cpp 2012-01-08 22:14:11 +0000
@@ -167,7 +167,7 @@
.first->handle(), GWLP_ID, 0); // the def button is the "Add" button
}
- list->createColumns(TStringList(1));
+ list->addColumn();
for(auto i = initialValues.begin(), iend = initialValues.end(); i != iend; ++i)
insert(*i);
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2012-01-08 12:47:07 +0000
+++ win32/WinUtil.cpp 2012-01-08 22:14:11 +0000
@@ -1447,20 +1447,22 @@
void WinUtil::makeColumns(dwt::TablePtr table, const ColumnInfo* columnInfo, size_t columnCount, const string& order,
const string& widths)
{
- std::vector<tstring> n(columnCount);
+ std::vector<dwt::Column> n(columnCount);
std::vector<int> o(columnCount);
- std::vector<int> w(columnCount);
- std::vector<bool> a(columnCount);
for(size_t i = 0; i < columnCount; ++i) {
- n[i] = T_(columnInfo[i].name);
+ n[i].header = Text::toT(columnInfo[i].name);
+ n[i].width = columnInfo[i].size;
+ n[i].alignment = columnInfo[i].numerical ? dwt::Column::RIGHT : dwt::Column::LEFT;
o[i] = i;
- w[i] = columnInfo[i].size;
- a[i] = columnInfo[i].numerical;
}
+
toInts(order, o);
- toInts(widths, w);
- table->createColumns(n, w, a, o);
+ size_t i = 0;
+ Text::tokenize(widths, ',', [&] (const string& w) { if(i < n.size()) n[i++].width = Util::toInt(w); });
+
+ table->setColumns(n);
+ table->setColumnOrder(o);
}
dwt::IconPtr WinUtil::createIcon(unsigned id, long size) {