OSDN Git Service

Create foundation for implementation of package category tree view.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 20 Dec 2012 10:52:45 +0000 (10:52 +0000)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Thu, 20 Dec 2012 10:52:45 +0000 (10:52 +0000)
ChangeLog
Makefile.in
src/guimain.h
src/guixmld.cpp
src/pkgtree.cpp [new file with mode: 0644]
src/pkgview.cpp

index 354c361..7d420f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2012-12-20  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Create foundation for implementation of package category tree view.
+
+       * Makefile.in (GUIMAIN_OBJECTS): Add pkgtree.$OBJEXT reference to...
+       * src/pkgtree.cpp: ...incorporate this new file; it implements...
+       (AppWindowMaker::InitPackageTreeView): ...this new class method...
+       (pkgInitCategoryTreeGraft): ...and this new extern "C" function.
+
+       * src/guimain.h (pkgInitCategoryTreeGraft): Declare prototype.
+       (AppWindowMaker::InitPackageTreeView): New private method; declare it.
+       (AppWindowMaker::PackageTreeView): New member variable; declare it.
+
+       * src/guixmld.cpp (AppWindowMaker::LoadPackageData): Call
+       pkgInitCategoryTreeGraft(), after loading profile.xml
+       (AppWindowMaker::Invoked): Call InitPackageTreeView()
+
+       * src/pkgview.cpp (AppWindowMaker::LayoutEngine):
+       [ID_PACKAGE_TREEVIEW]: Handle it.
+
 2012-12-19  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Make the "Apply Changes" dialogue "failure-aware".
index db410e4..a867195 100644 (file)
@@ -91,8 +91,8 @@ CLI_EXE_OBJECTS  =   \
 
 GUIMAIN_OBJECTS  =   \
    guimain.$(OBJEXT) guidata.$(OBJEXT) guixmld.$(OBJEXT) guidmh.$(OBJEXT) \
-   approot.$(OBJEXT) pkgview.$(OBJEXT) pkglist.$(OBJEXT) pkgdata.$(OBJEXT) \
-   pkgnget.$(OBJEXT)
+   approot.$(OBJEXT) pkgview.$(OBJEXT) pkgtree.$(OBJEXT) pkglist.$(OBJEXT) \
+   pkgdata.$(OBJEXT) pkgnget.$(OBJEXT)
 
 GUIMAIN_LIBS = -lwtklite -lcomctl32
 
index 87270fa..35caf19 100644 (file)
@@ -198,6 +198,9 @@ class AppWindowMaker: public WTK::MainWindowMaker
     pkgProgressMeter *AttachedProgressMeter;
     HFONT DefaultFont;
 
+    HWND PackageTreeView;
+    void InitPackageTreeView( void );
+
     HWND PackageListView;
     void InitPackageListView( void );
     void UpdatePackageMenuBindings( void );
@@ -220,5 +223,9 @@ inline long AppWindowMaker::DialogueResponse( int id, DLGPROC handler )
   return DialogBox( AppInstance, MAKEINTRESOURCE( id ), AppWindow, handler );
 }
 
+/* FIXME: this prototype belongs in pkgtree.h
+ */
+EXTERN_C void pkgInitCategoryTreeGraft( pkgXmlNode* );
+
 #endif /* ! RC_INVOKED */
 #endif /* GUIMAIN_H: $RCSfile$: end of file */
index 5fb32fb..5f30412 100644 (file)
@@ -184,6 +184,11 @@ void AppWindowMaker::LoadPackageData( bool force_update )
    */
   free( (void *)(dfile) );
 
+  /* Create a graft point for attachment of the package
+   * group hierarchy tree to the loaded XML data image.
+   */
+  pkgInitCategoryTreeGraft( pkgData->GetRoot() );
+
   /* Establish the repository URI references, for retrieval
    * of the downloadable catalogue files, and load them...
    */
@@ -574,12 +579,17 @@ int AppWindowMaker::Invoked( void )
    */
   InitCommonControls();
 
-  /* Load the data from the XML catalogue files, and construct
-   * the initial view of the available package list; this activity
+  /* Load the data from the XML catalogue files; this activity
    * is invoked in a background thread, initiated from a progress
    * dialogue derived from the "Update Catalogue" template.
    */
   DispatchDialogueThread( IDD_REPO_UPDATE, pkgInvokeInitDataLoad );
+
+  /* Establish the initial views of the package category selection
+   * tree, and the list of available packages; (the initial package
+   * list includes everything in the "All Packages" category).
+   */
+  InitPackageTreeView();
   InitPackageListView();
 
   /* Initialise the data-sheet tab control, displaying the default
diff --git a/src/pkgtree.cpp b/src/pkgtree.cpp
new file mode 100644 (file)
index 0000000..b4285fe
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * pkgtree.cpp
+ *
+ * $Id$
+ *
+ * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
+ * Copyright (C) 2012, MinGW.org Project
+ *
+ *
+ * Implementation of the methods for the pkgTreeViewMaker class, and
+ * its AppWindowMaker client API, to support the display of the package
+ * category tree in the mingw-get graphical user interface.
+ *
+ *
+ * This is free software.  Permission is granted to copy, modify and
+ * redistribute this software, under the provisions of the GNU General
+ * Public License, Version 3, (or, at your option, any later version),
+ * as published by the Free Software Foundation; see the file COPYING
+ * for licensing details.
+ *
+ * Note, in particular, that this software is provided "as is", in the
+ * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
+ * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
+ * PARTICULAR PURPOSE.  Under no circumstances will the author, or the
+ * MinGW Project, accept liability for any damages, however caused,
+ * arising from the use of this software.
+ *
+ */
+#include "guimain.h"
+#include "pkgbase.h"
+#include "pkgkeys.h"
+
+static const char *package_group_key = "package-group";
+static const char *package_group_all = "All Packages";
+
+/* The following are candidates for inclusion in "pkgkeys";
+ * for now, we may keep them as local defines.
+ */
+static const char *expand_key = "expand";
+static const char *value_true = "true";
+
+EXTERN_C void pkgInitCategoryTreeGraft( pkgXmlNode *root )
+{
+  /* Helper function to create the graft point, at which the
+   * category tree records, as defined by the XML package group
+   * hierarchy, will be attached to the internal representation
+   * of the XML database image.
+   */
+  pkgXmlNode *pkgtree = new pkgXmlNode( package_group_key );
+  pkgtree->SetAttribute( name_key, package_group_all );
+  pkgtree->SetAttribute( expand_key, value_true );
+  root->LinkEndChild( pkgtree );
+}
+
+void AppWindowMaker::InitPackageTreeView()
+{
+  /* Create and initialise a TreeView window, in which to present
+   * the package group hierarchy display...
+   */
+  PackageTreeView = CreateWindow( WC_TREEVIEW, NULL,
+      WS_VISIBLE | WS_BORDER | WS_CHILD, 0, 0, 0, 0,
+      AppWindow, (HMENU)(ID_PACKAGE_TREEVIEW),
+      AppInstance, NULL
+    );
+
+  /* Assign the application's chosen default font, for use when
+   * displaying the category headings within the tree view.
+   */
+  SendMessage( PackageTreeView, WM_SETFONT, (WPARAM)(DefaultFont), TRUE );
+
+  /* Initialise a tree view insertion structure, to the appropriate
+   * state for assignment of the root entry in the tree view.
+   */
+  TVINSERTSTRUCT cat;
+  cat.hParent = TVI_ROOT;
+  cat.item.mask = TVIF_TEXT;
+  cat.hInsertAfter = TVI_ROOT;
+
+  /* Retrieve the root category entry, if any, as recorded in
+   * the package XML database, for assignment as the root entry
+   * in the category tree view.
+   */
+  pkgXmlNode *tree = pkgData->GetRoot();
+  if( (tree = tree->FindFirstAssociate( package_group_key )) == NULL )
+  {
+    /* There was no category tree recorded in the XML database;
+     * create an artificial root entry, (which will then become
+     * the sole entry in our tree view).
+     */
+    cat.item.pszText = (char *)(package_group_all);
+    TreeView_InsertItem( PackageTreeView, &cat );
+  }
+  else while( tree != NULL )
+  {
+    /* The package group hierarchy has been incorporated into
+     * the in-core image of the XML database; create a windows
+     * "tree view" representation of its structure.
+     *
+     * FIXME: this currently creates only the root of the tree;
+     * we need to walk the XML hierarchy, and add an additional
+     * tree view node for each element found.
+     */
+    cat.item.pszText = (char *)(tree->GetPropVal( name_key, value_unknown ));
+    HTREEITEM top = TreeView_InsertItem( PackageTreeView, &cat );
+    tree = tree->FindNextAssociate( package_group_key );
+  }
+}
+
+/* $RCSfile$: end of file */
index 335614f..2c5f6ad 100644 (file)
@@ -182,6 +182,14 @@ int AppWindowMaker::LayoutEngine( HWND pane, LPARAM region )
     /* Each of the panes and sashes is computed individually, in the
      * following order:
      */
+    case ID_PACKAGE_TREEVIEW:
+      /* Left hand pane; occupies the full height of the parent window,
+       * and shares its top-left co-ordinate position, with width set to
+       * the fraction of the parent's width specified as...
+       */
+      pane_width = HorizontalSash->Displacement( pane_width );
+      break;
+
     case ID_PACKAGE_LISTVIEW:
       /* Upper right hand pane; occupies the full width of the parent
        * window which remains to the right of the tree view, (after an