The MinGW.org Installation Manager Tool
Revision | 039ea8af00232730e36e7b5417132c50a748e019 (tree) |
---|---|
Time | 2012-12-20 19:52:45 |
Author | Keith Marshall <keithmarshall@user...> |
Commiter | Keith Marshall |
Create foundation for implementation of package category tree view.
@@ -1,3 +1,23 @@ | ||
1 | +2012-12-20 Keith Marshall <keithmarshall@users.sourceforge.net> | |
2 | + | |
3 | + Create foundation for implementation of package category tree view. | |
4 | + | |
5 | + * Makefile.in (GUIMAIN_OBJECTS): Add pkgtree.$OBJEXT reference to... | |
6 | + * src/pkgtree.cpp: ...incorporate this new file; it implements... | |
7 | + (AppWindowMaker::InitPackageTreeView): ...this new class method... | |
8 | + (pkgInitCategoryTreeGraft): ...and this new extern "C" function. | |
9 | + | |
10 | + * src/guimain.h (pkgInitCategoryTreeGraft): Declare prototype. | |
11 | + (AppWindowMaker::InitPackageTreeView): New private method; declare it. | |
12 | + (AppWindowMaker::PackageTreeView): New member variable; declare it. | |
13 | + | |
14 | + * src/guixmld.cpp (AppWindowMaker::LoadPackageData): Call | |
15 | + pkgInitCategoryTreeGraft(), after loading profile.xml | |
16 | + (AppWindowMaker::Invoked): Call InitPackageTreeView() | |
17 | + | |
18 | + * src/pkgview.cpp (AppWindowMaker::LayoutEngine): | |
19 | + [ID_PACKAGE_TREEVIEW]: Handle it. | |
20 | + | |
1 | 21 | 2012-12-19 Keith Marshall <keithmarshall@users.sourceforge.net> |
2 | 22 | |
3 | 23 | Make the "Apply Changes" dialogue "failure-aware". |
@@ -91,8 +91,8 @@ CLI_EXE_OBJECTS = \ | ||
91 | 91 | |
92 | 92 | GUIMAIN_OBJECTS = \ |
93 | 93 | guimain.$(OBJEXT) guidata.$(OBJEXT) guixmld.$(OBJEXT) guidmh.$(OBJEXT) \ |
94 | - approot.$(OBJEXT) pkgview.$(OBJEXT) pkglist.$(OBJEXT) pkgdata.$(OBJEXT) \ | |
95 | - pkgnget.$(OBJEXT) | |
94 | + approot.$(OBJEXT) pkgview.$(OBJEXT) pkgtree.$(OBJEXT) pkglist.$(OBJEXT) \ | |
95 | + pkgdata.$(OBJEXT) pkgnget.$(OBJEXT) | |
96 | 96 | |
97 | 97 | GUIMAIN_LIBS = -lwtklite -lcomctl32 |
98 | 98 |
@@ -198,6 +198,9 @@ class AppWindowMaker: public WTK::MainWindowMaker | ||
198 | 198 | pkgProgressMeter *AttachedProgressMeter; |
199 | 199 | HFONT DefaultFont; |
200 | 200 | |
201 | + HWND PackageTreeView; | |
202 | + void InitPackageTreeView( void ); | |
203 | + | |
201 | 204 | HWND PackageListView; |
202 | 205 | void InitPackageListView( void ); |
203 | 206 | void UpdatePackageMenuBindings( void ); |
@@ -220,5 +223,9 @@ inline long AppWindowMaker::DialogueResponse( int id, DLGPROC handler ) | ||
220 | 223 | return DialogBox( AppInstance, MAKEINTRESOURCE( id ), AppWindow, handler ); |
221 | 224 | } |
222 | 225 | |
226 | +/* FIXME: this prototype belongs in pkgtree.h | |
227 | + */ | |
228 | +EXTERN_C void pkgInitCategoryTreeGraft( pkgXmlNode* ); | |
229 | + | |
223 | 230 | #endif /* ! RC_INVOKED */ |
224 | 231 | #endif /* GUIMAIN_H: $RCSfile$: end of file */ |
@@ -184,6 +184,11 @@ void AppWindowMaker::LoadPackageData( bool force_update ) | ||
184 | 184 | */ |
185 | 185 | free( (void *)(dfile) ); |
186 | 186 | |
187 | + /* Create a graft point for attachment of the package | |
188 | + * group hierarchy tree to the loaded XML data image. | |
189 | + */ | |
190 | + pkgInitCategoryTreeGraft( pkgData->GetRoot() ); | |
191 | + | |
187 | 192 | /* Establish the repository URI references, for retrieval |
188 | 193 | * of the downloadable catalogue files, and load them... |
189 | 194 | */ |
@@ -574,12 +579,17 @@ int AppWindowMaker::Invoked( void ) | ||
574 | 579 | */ |
575 | 580 | InitCommonControls(); |
576 | 581 | |
577 | - /* Load the data from the XML catalogue files, and construct | |
578 | - * the initial view of the available package list; this activity | |
582 | + /* Load the data from the XML catalogue files; this activity | |
579 | 583 | * is invoked in a background thread, initiated from a progress |
580 | 584 | * dialogue derived from the "Update Catalogue" template. |
581 | 585 | */ |
582 | 586 | DispatchDialogueThread( IDD_REPO_UPDATE, pkgInvokeInitDataLoad ); |
587 | + | |
588 | + /* Establish the initial views of the package category selection | |
589 | + * tree, and the list of available packages; (the initial package | |
590 | + * list includes everything in the "All Packages" category). | |
591 | + */ | |
592 | + InitPackageTreeView(); | |
583 | 593 | InitPackageListView(); |
584 | 594 | |
585 | 595 | /* Initialise the data-sheet tab control, displaying the default |
@@ -0,0 +1,109 @@ | ||
1 | +/* | |
2 | + * pkgtree.cpp | |
3 | + * | |
4 | + * $Id$ | |
5 | + * | |
6 | + * Written by Keith Marshall <keithmarshall@users.sourceforge.net> | |
7 | + * Copyright (C) 2012, MinGW.org Project | |
8 | + * | |
9 | + * | |
10 | + * Implementation of the methods for the pkgTreeViewMaker class, and | |
11 | + * its AppWindowMaker client API, to support the display of the package | |
12 | + * category tree in the mingw-get graphical user interface. | |
13 | + * | |
14 | + * | |
15 | + * This is free software. Permission is granted to copy, modify and | |
16 | + * redistribute this software, under the provisions of the GNU General | |
17 | + * Public License, Version 3, (or, at your option, any later version), | |
18 | + * as published by the Free Software Foundation; see the file COPYING | |
19 | + * for licensing details. | |
20 | + * | |
21 | + * Note, in particular, that this software is provided "as is", in the | |
22 | + * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not | |
23 | + * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY | |
24 | + * PARTICULAR PURPOSE. Under no circumstances will the author, or the | |
25 | + * MinGW Project, accept liability for any damages, however caused, | |
26 | + * arising from the use of this software. | |
27 | + * | |
28 | + */ | |
29 | +#include "guimain.h" | |
30 | +#include "pkgbase.h" | |
31 | +#include "pkgkeys.h" | |
32 | + | |
33 | +static const char *package_group_key = "package-group"; | |
34 | +static const char *package_group_all = "All Packages"; | |
35 | + | |
36 | +/* The following are candidates for inclusion in "pkgkeys"; | |
37 | + * for now, we may keep them as local defines. | |
38 | + */ | |
39 | +static const char *expand_key = "expand"; | |
40 | +static const char *value_true = "true"; | |
41 | + | |
42 | +EXTERN_C void pkgInitCategoryTreeGraft( pkgXmlNode *root ) | |
43 | +{ | |
44 | + /* Helper function to create the graft point, at which the | |
45 | + * category tree records, as defined by the XML package group | |
46 | + * hierarchy, will be attached to the internal representation | |
47 | + * of the XML database image. | |
48 | + */ | |
49 | + pkgXmlNode *pkgtree = new pkgXmlNode( package_group_key ); | |
50 | + pkgtree->SetAttribute( name_key, package_group_all ); | |
51 | + pkgtree->SetAttribute( expand_key, value_true ); | |
52 | + root->LinkEndChild( pkgtree ); | |
53 | +} | |
54 | + | |
55 | +void AppWindowMaker::InitPackageTreeView() | |
56 | +{ | |
57 | + /* Create and initialise a TreeView window, in which to present | |
58 | + * the package group hierarchy display... | |
59 | + */ | |
60 | + PackageTreeView = CreateWindow( WC_TREEVIEW, NULL, | |
61 | + WS_VISIBLE | WS_BORDER | WS_CHILD, 0, 0, 0, 0, | |
62 | + AppWindow, (HMENU)(ID_PACKAGE_TREEVIEW), | |
63 | + AppInstance, NULL | |
64 | + ); | |
65 | + | |
66 | + /* Assign the application's chosen default font, for use when | |
67 | + * displaying the category headings within the tree view. | |
68 | + */ | |
69 | + SendMessage( PackageTreeView, WM_SETFONT, (WPARAM)(DefaultFont), TRUE ); | |
70 | + | |
71 | + /* Initialise a tree view insertion structure, to the appropriate | |
72 | + * state for assignment of the root entry in the tree view. | |
73 | + */ | |
74 | + TVINSERTSTRUCT cat; | |
75 | + cat.hParent = TVI_ROOT; | |
76 | + cat.item.mask = TVIF_TEXT; | |
77 | + cat.hInsertAfter = TVI_ROOT; | |
78 | + | |
79 | + /* Retrieve the root category entry, if any, as recorded in | |
80 | + * the package XML database, for assignment as the root entry | |
81 | + * in the category tree view. | |
82 | + */ | |
83 | + pkgXmlNode *tree = pkgData->GetRoot(); | |
84 | + if( (tree = tree->FindFirstAssociate( package_group_key )) == NULL ) | |
85 | + { | |
86 | + /* There was no category tree recorded in the XML database; | |
87 | + * create an artificial root entry, (which will then become | |
88 | + * the sole entry in our tree view). | |
89 | + */ | |
90 | + cat.item.pszText = (char *)(package_group_all); | |
91 | + TreeView_InsertItem( PackageTreeView, &cat ); | |
92 | + } | |
93 | + else while( tree != NULL ) | |
94 | + { | |
95 | + /* The package group hierarchy has been incorporated into | |
96 | + * the in-core image of the XML database; create a windows | |
97 | + * "tree view" representation of its structure. | |
98 | + * | |
99 | + * FIXME: this currently creates only the root of the tree; | |
100 | + * we need to walk the XML hierarchy, and add an additional | |
101 | + * tree view node for each element found. | |
102 | + */ | |
103 | + cat.item.pszText = (char *)(tree->GetPropVal( name_key, value_unknown )); | |
104 | + HTREEITEM top = TreeView_InsertItem( PackageTreeView, &cat ); | |
105 | + tree = tree->FindNextAssociate( package_group_key ); | |
106 | + } | |
107 | +} | |
108 | + | |
109 | +/* $RCSfile$: end of file */ |
@@ -182,6 +182,14 @@ int AppWindowMaker::LayoutEngine( HWND pane, LPARAM region ) | ||
182 | 182 | /* Each of the panes and sashes is computed individually, in the |
183 | 183 | * following order: |
184 | 184 | */ |
185 | + case ID_PACKAGE_TREEVIEW: | |
186 | + /* Left hand pane; occupies the full height of the parent window, | |
187 | + * and shares its top-left co-ordinate position, with width set to | |
188 | + * the fraction of the parent's width specified as... | |
189 | + */ | |
190 | + pane_width = HorizontalSash->Displacement( pane_width ); | |
191 | + break; | |
192 | + | |
185 | 193 | case ID_PACKAGE_LISTVIEW: |
186 | 194 | /* Upper right hand pane; occupies the full width of the parent |
187 | 195 | * window which remains to the right of the tree view, (after an |