#include "ListView.h"
#include "LogSingleton.h"
+#include "resource.h"
#include <commctrl.h>
// populate with columns
initColumns(headers);
+
+ // create a small icon imagelist and assign to listview control
+ // (the order of images matches ListViewLine::State enum)
+ HIMAGELIST hImgList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
+ GetSystemMetrics(SM_CYSMICON),
+ ILC_COLOR32, 2, 0);
+ ImageList_AddIcon(hImgList, LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_TREE_PLUS)));
+ ImageList_AddIcon(hImgList, LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_TREE_MINUS)));
+ ListView_SetImageList(hWndListView, hImgList, LVSIL_SMALL);
}
void
for (i = 0; i < contents->size(); i++)
{
LVITEM lvi;
- lvi.mask = LVIF_TEXT;
+ lvi.mask = LVIF_TEXT | LVIF_IMAGE;
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.pszText = LPSTR_TEXTCALLBACK;
+ lvi.iImage = I_IMAGECALLBACK;
ListView_InsertItem(hWndListView, &lvi);
}
static StringCache s;
s = (*contents)[iRow]->get_text(iCol);
pNmLvDispInfo->item.pszText = s;
+
+ if (pNmLvDispInfo->item.iSubItem == 0)
+ {
+ pNmLvDispInfo->item.iImage = (int)((*contents)[pNmLvDispInfo->item.iItem]->get_state());
+ }
}
return true;
class ListViewLine
{
public:
+ enum class State { collapsed, expanded, nothing=-1 };
+
virtual ~ListViewLine() {};
virtual const std::string get_text(int col) const = 0;
+ virtual State get_state() const = 0;
virtual ActionList *get_actions(int col) const = 0;
virtual int do_action(int col, int id) = 0;
};
cygwin-setup.ico \
cygwin-terminal.ico \
setup.exe.manifest \
- setup64.exe.manifest
+ setup64.exe.manifest \
+ tree-minus.ico \
+ tree-plus.ico
# iniparse.hh is generated from iniparse.yy via bison -d, so it needs to be
# included here for proper tracking (but not iniparse.cc, since automake
if (col_num == pkgname_col)
{
std::ostringstream s;
- s << (cat_tree->collapsed() ? "[+] " : "[-] ") << cat_tree->category().first;
+ s << cat_tree->category().first;
if (pkgcount)
s << " (" << pkgcount << ")";
return s.str();
return al;
}
+
+ListViewLine::State
+PickCategoryLine::get_state() const
+{
+ return cat_tree->collapsed() ? State::collapsed : State::expanded;
+}
}
const std::string get_text(int col) const;
+ State get_state() const;
ActionList *get_actions(int col) const;
int do_action(int col, int action_id);
{
};
const std::string get_text(int col) const;
+ State get_state() const { return State::nothing; }
ActionList *get_actions(int col_num) const;
int do_action(int col, int action_id);
private:
IDI_CYGWIN_SETUP ICON DISCARDABLE "cygwin-setup.ico"
IDI_CYGWIN ICON DISCARDABLE "cygwin.ico"
IDI_CYGWIN_TERMINAL ICON DISCARDABLE "cygwin-terminal.ico"
+IDI_TREE_PLUS ICON DISCARDABLE "tree-plus.ico"
+IDI_TREE_MINUS ICON DISCARDABLE "tree-minus.ico"
/////////////////////////////////////////////////////////////////////////////
//
#define IDI_CYGWIN_SETUP 401
#define IDI_CYGWIN 402
#define IDI_CYGWIN_TERMINAL 403
+#define IDI_TREE_PLUS 404
+#define IDI_TREE_MINUS 405
// controls
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="256px"
+ height="256px"
+ viewBox="0 0 256 256"
+ version="1.1"
+ id="SVGRoot"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="tree-minus.svg">
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="2.3754368"
+ inkscape:cx="135.00514"
+ inkscape:cy="129.49343"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1680"
+ inkscape:window-height="1027"
+ inkscape:window-x="1912"
+ inkscape:window-y="22"
+ inkscape:window-maximized="1"
+ inkscape:grid-bbox="true"
+ showguides="false"
+ inkscape:object-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4075" />
+ </sodipodi:namedview>
+ <defs
+ id="defs3756" />
+ <metadata
+ id="metadata3759">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:groupmode="layer"
+ inkscape:label="layer">
+ <g
+ id="box"
+ inkscape:label="box"
+ style="fill:#000000;fill-opacity:1"
+ transform="translate(8,8)">
+ <rect
+ y="56"
+ x="56"
+ height="16"
+ width="144"
+ id="top"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="top" />
+ <rect
+ y="184"
+ x="56"
+ height="16"
+ width="144"
+ id="bottom"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="bottom" />
+ <rect
+ transform="rotate(90)"
+ y="-72"
+ x="56"
+ height="16"
+ width="144"
+ id="left"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="left" />
+ <rect
+ transform="rotate(90)"
+ y="-200"
+ x="56"
+ height="16"
+ width="144"
+ id="right"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="right" />
+ </g>
+ <g
+ id="symbol"
+ inkscape:label="symbol"
+ style="fill:#000000;fill-opacity:1"
+ transform="translate(8,8)">
+ <rect
+ transform="rotate(90)"
+ y="-168"
+ x="120"
+ height="80"
+ width="16"
+ id="horiz"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="horiz" />
+ </g>
+ </g>
+</svg>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="256px"
+ height="256px"
+ viewBox="0 0 256 256"
+ version="1.1"
+ id="SVGRoot"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)"
+ sodipodi:docname="tree-plus.svg">
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="3.359375"
+ inkscape:cx="84.390698"
+ inkscape:cy="128"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ inkscape:window-width="1680"
+ inkscape:window-height="1027"
+ inkscape:window-x="1912"
+ inkscape:window-y="22"
+ inkscape:window-maximized="1"
+ inkscape:grid-bbox="true"
+ showguides="false"
+ inkscape:object-nodes="true">
+ <inkscape:grid
+ type="xygrid"
+ id="grid4075" />
+ </sodipodi:namedview>
+ <defs
+ id="defs3756" />
+ <metadata
+ id="metadata3759">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ id="layer1"
+ inkscape:groupmode="layer"
+ inkscape:label="layer">
+ <g
+ id="box"
+ inkscape:label="box"
+ style="fill:#000000;fill-opacity:1"
+ transform="translate(8,8)">
+ <rect
+ y="56"
+ x="56"
+ height="16"
+ width="144"
+ id="top"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="top" />
+ <rect
+ y="184"
+ x="56"
+ height="16"
+ width="144"
+ id="bottom"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="bottom" />
+ <rect
+ transform="rotate(90)"
+ y="-72"
+ x="56"
+ height="16"
+ width="144"
+ id="left"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="left" />
+ <rect
+ transform="rotate(90)"
+ y="-200"
+ x="56"
+ height="16"
+ width="144"
+ id="right"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="right" />
+ </g>
+ <g
+ id="symbol"
+ inkscape:label="symbol"
+ style="fill:#000000;fill-opacity:1"
+ transform="translate(8,8)">
+ <rect
+ y="88"
+ x="120"
+ height="80"
+ width="16"
+ id="vert"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="vert" />
+ <rect
+ transform="rotate(90)"
+ y="-168"
+ x="120"
+ height="80"
+ width="16"
+ id="horiz"
+ style="fill:#000000;fill-opacity:1"
+ inkscape:label="horiz" />
+ </g>
+ </g>
+</svg>