linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #04949
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2718: add some spacing between list-view groups
------------------------------------------------------------
revno: 2718
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Wed 2011-12-14 18:18:00 +0100
message:
add some spacing between list-view groups
modified:
dwt/include/dwt/GCCHeaders.h
dwt/include/dwt/widgets/Table.h
dwt/src/widgets/Table.cpp
win32/StylesPage.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 'dwt/include/dwt/GCCHeaders.h'
--- dwt/include/dwt/GCCHeaders.h 2011-11-07 19:32:44 +0000
+++ dwt/include/dwt/GCCHeaders.h 2011-12-14 17:18:00 +0000
@@ -244,6 +244,44 @@
#define LVGA_FOOTER_RIGHT 0x00000020 // Don't forget to validate exclusivity
#endif
+#ifndef LVVGR_HEADER
+#define LVGGR_HEADER 1
+#endif
+#ifndef LVSIL_GROUPHEADER
+#define LVSIL_GROUPHEADER 3
+#endif
+#ifndef LVM_GETGROUPRECT
+#define LVM_GETGROUPRECT (LVM_FIRST + 98)
+#endif
+#ifndef ListView_GetGroupRect
+#define ListView_GetGroupRect(hwnd, iGroupId, type, prc) \
+ SNDMSG((hwnd), LVM_GETGROUPRECT, (WPARAM)(iGroupId), \
+ ((prc) ? (((RECT*)(prc))->top = (type)), (LPARAM)(RECT*)(prc) : (LPARAM)(RECT*)NULL))
+#endif
+
+#ifndef LVGMF_NONE
+#define LVGMF_NONE 0x00000000
+#define LVGMF_BORDERSIZE 0x00000001
+#define LVGMF_BORDERCOLOR 0x00000002
+#define LVGMF_TEXTCOLOR 0x00000004
+
+typedef struct tagLVGROUPMETRICS
+{
+ UINT cbSize;
+ UINT mask;
+ UINT Left;
+ UINT Top;
+ UINT Right;
+ UINT Bottom;
+ COLORREF crLeft;
+ COLORREF crTop;
+ COLORREF crRight;
+ COLORREF crBottom;
+ COLORREF crHeader;
+ COLORREF crFooter;
+} LVGROUPMETRICS, *PLVGROUPMETRICS;
+#endif
+
// MinGW doesn't have all the fields in the following structure, so re-define it better.
typedef struct tagNMLVCUSTOMDRAW_
{
=== modified file 'dwt/include/dwt/widgets/Table.h'
--- dwt/include/dwt/widgets/Table.h 2011-12-13 21:15:23 +0000
+++ dwt/include/dwt/widgets/Table.h 2011-12-14 17:18:00 +0000
@@ -288,6 +288,9 @@
bool isGrouped() const { return grouped; }
+ /** Get the rectangle of the specified group's header. Only available on >= Vista. */
+ bool getGroupRect(unsigned groupId, Rectangle& rect) const;
+
/// Returns the checked state of the given row
/** A list view can have checkboxes in each row, if the checkbox for the given
* row is CHECKED this funtion returns true.
@@ -407,7 +410,7 @@
*/
void setStateImageList(ImageListPtr imageList);
- /** Set the image list to find icons from when adding groups. Only available on >= Visa. */
+ /** Set the image list to find icons from when adding groups. Only available on >= Vista. */
void setGroupImageList(ImageListPtr imageList);
/// Change the view for the Data Grid.
=== modified file 'dwt/src/widgets/Table.cpp'
--- dwt/src/widgets/Table.cpp 2011-12-13 21:15:23 +0000
+++ dwt/src/widgets/Table.cpp 2011-12-14 17:18:00 +0000
@@ -356,7 +356,24 @@
grouped = true;
}
+bool Table::getGroupRect(unsigned groupId, Rectangle& rect) const {
+ if(util::win32::ensureVersion(util::win32::VISTA)) {
+ ::RECT rc;
+ if(ListView_GetGroupRect(handle(), groupId, LVGGR_HEADER, &rc)) {
+ rect = Rectangle(rc);
+ return true;
+ }
+ }
+ return false;
+}
+
void Table::initGroupSupport() {
+ // add some spacing between groups.
+ LVGROUPMETRICS metrics = { sizeof(LVGROUPMETRICS), LVGMF_BORDERSIZE };
+ ListView_GetGroupMetrics(handle(), &metrics);
+ metrics.Bottom += std::max(metrics.Top, 12u);
+ ListView_SetGroupMetrics(handle(), &metrics);
+
/* fiddle with the painting of group headers to allow custom colors that match the background (the
theme will be respected). */
@@ -383,9 +400,9 @@
FreeCanvas canvas(data.nmcd.hdc);
Brush brush(0xFFFFFF - bgColor);
- Rectangle rect(data.rcText);
- if(!theme && util::win32::ensureVersion(util::win32::VISTA))
- rect.size.y += 6;
+ Rectangle rect;
+ if(!getGroupRect(data.nmcd.dwItemSpec, rect))
+ rect = Rectangle(data.rcText);
LONG iconPos = 0;
@@ -409,7 +426,7 @@
canvas.fill(rect, brush);
// set a flag so we don't have to re-compare colors on CDDS_POSTPAINT.
- data.nmcd.lItemlParam = std::max(iconPos, 0L) + 1;
+ data.nmcd.lItemlParam = iconPos + 1;
}
break;
}
@@ -420,7 +437,10 @@
LONG iconPos = data.nmcd.lItemlParam - 1;
FreeCanvas canvas(data.nmcd.hdc);
- Rectangle rect(data.rcText);
+
+ Rectangle rect;
+ if(!getGroupRect(data.nmcd.dwItemSpec, rect))
+ rect = Rectangle(data.rcText);
if(iconPos > 0) {
rect.size.x = iconPos;
=== modified file 'win32/StylesPage.cpp'
--- win32/StylesPage.cpp 2011-12-13 21:15:23 +0000
+++ win32/StylesPage.cpp 2011-12-14 17:18:00 +0000
@@ -195,7 +195,7 @@
void StylesPage::layout() {
PropPage::layout();
- table->setColumnWidth(COLUMN_TEXT, table->getWindowSize().x - 20);
+ table->setColumnWidth(COLUMN_TEXT, table->getWindowSize().x - 30);
}
void StylesPage::write() {