OSDN Git Service

Implement framework for GUI sash window layout controller.
authorKeith Marshall <keithmarshall@users.sourceforge.net>
Fri, 21 Sep 2012 11:16:31 +0000 (12:16 +0100)
committerKeith Marshall <keithmarshall@users.sourceforge.net>
Fri, 21 Sep 2012 11:16:31 +0000 (12:16 +0100)
ChangeLog
Makefile.in
configure.ac
src/guidata.rc [new file with mode: 0644]
src/guimain.cpp [new file with mode: 0644]
src/guimain.h [new file with mode: 0644]
src/pkgview.cpp [new file with mode: 0644]

index 0368aa0..56bee2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2012-09-21  Keith Marshall  <keithmarshall@users.sourceforge.net>
+
+       Implement framework for GUI sash window layout controller.
+
+       * configure.ac (AC_INIT): Bump version number to 0.6
+       (CLI_RELEASE_CLASS): New AC_SUBST variable; default to "beta".
+       (GUI_RELEASE_CLASS): New AC_SUBST variable; default to "alpha".
+       (SNAPSHOT_CLASS): Recognise as user specified environent variable
+       override for both CLI_RELEASE_CLASS and GUI_RELEASE_CLASS.
+       (RC): New AC_CHECK_TOOL substitution variable name; it replaces...
+       (WINDRES): ...this, as reference name for the resource compiler.
+       (MINGW_AC_ASSERT_MISSING): Add AC_CHECK_HEADER traps for missing
+       "lua-dev" and "wtklite-dev" support.
+
+       * Makefile.in (CLI_RELEASE_CLASS, GUI_RELEASE_CLASS): Use them.
+       (BUILD_TAG, RC_SCRIPT, RC_INCLUDES): New macros; define and use...
+       (RC): ...with this, to implement new target rule for compiling...
+       (%.rc): ...resource definition files to %.OBJEXT objects.
+       (GUIMAIN_OBJECTS, GUIMAIN_LIBS): New macros; define and use...
+       (guimain.EXEEXT): ...to implement build rule for this.
+       (LIBEXEC_PROGRAMS): Add guimain.EXEEXT
+       (lastrites.EXEEXT): Use GUI_LDFLAGS.
+       
+       * src/guimain.h src/guimain.cpp src/guidata.rc: New files.
+       * src/pkgview.cpp: New file.
+
 2012-09-20  Keith Marshall  <keithmarshall@users.sourceforge.net>
 
        Adjust incorrectly resolved 2012-09-14 merge from master.
index af717d7..3727572 100644 (file)
@@ -6,7 +6,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 
 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
-# Copyright (C) 2009, 2010, 2011, 2012, MinGW Project
+# Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project
 #
 #
 # Makefile template for mingw-get
@@ -22,16 +22,20 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
 # 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,
+# MinGW.org Project, accept liability for any damages, however caused,
 # arising from the use of this software.
 #
 PACKAGE_SUBSYSTEM = @host_os@
 
-srcdir = @srcdir@
-abs_top_srcdir = @abs_top_srcdir@
+CLI_RELEASE_CLASS = @CLI_RELEASE_CLASS@
+GUI_RELEASE_CLASS = @GUI_RELEASE_CLASS@
 
+BUILD_TAG = `>> build.tag; cat build.tag`
 DEBUGLEVEL = @DEBUGLEVEL@
 
+srcdir = @srcdir@
+abs_top_srcdir = @abs_top_srcdir@
+
 vpath %.ico @srcdir@/icons
 VPATH = @top_srcdir@/src:@top_srcdir@/src/pkginfo:@top_srcdir@/tinyxml
 
@@ -49,12 +53,21 @@ LEX = @LEX@
 AR = @AR@
 ARFLAGS = @ARFLAGS@
 
-WINDRES = @WINDRES@
+RC = @RC@
+RC_SCRIPT = tag=$(BUILD_TAG); \
+  test "x$$tag" != x && tag="-$(GUI_RELEASE_CLASS)-$$tag"; sed \
+    -e "s!%PACKAGE_NAME%!$(PACKAGE_TARNAME)!g" \
+    -e "s!%PACKAGE_VERSION%!$(PACKAGE_VERSION)$$tag!g" \
+    -e "s!%COPYRIGHT_HOLDER%!@COPYRIGHT_HOLDER@!g" \
+    -e "s!%YEARS_OF_ISSUE%!@YEARS_OF_ISSUE@!g"
+
+RC_INCLUDES = -I ${srcdir}/src -I ${srcdir}/icons
 
 OBJEXT = @OBJEXT@
 EXEEXT = @EXEEXT@
 
 LDFLAGS = @LDFLAGS@
+GUI_LDFLAGS = -mwindows $(LDFLAGS)
 LIBS = -Wl,-Bstatic -llua -lz -lbz2 -llzma -Wl,-Bdynamic -lwininet
 
 CORE_DLL_OBJECTS  =  climain.$(OBJEXT) pkgshow.$(OBJEXT) dmh.$(OBJEXT) \
@@ -69,14 +82,21 @@ CORE_DLL_OBJECTS  =  climain.$(OBJEXT) pkgshow.$(OBJEXT) dmh.$(OBJEXT) \
 CLI_EXE_OBJECTS  =   \
    clistub.$(OBJEXT) version.$(OBJEXT) approot.$(OBJEXT) getopt.$(OBJEXT)
 
+GUIMAIN_OBJECTS  =   \
+   guimain.$(OBJEXT) guidata.$(OBJEXT) approot.$(OBJEXT) pkgview.$(OBJEXT)
+
+GUIMAIN_LIBS = -lwtklite -lcomctl32
+
 script_srcdir = ${srcdir}/scripts/libexec
 
 BIN_PROGRAMS = pkginfo$(EXEEXT) mingw-get$(EXEEXT)
-LIBEXEC_PROGRAMS = gui$(EXEEXT) lastrites$(EXEEXT)
+LIBEXEC_PROGRAMS = gui$(EXEEXT) guimain$(EXEEXT) lastrites$(EXEEXT)
 LIBEXEC_SCRIPTS = ${script_srcdir}/setup.lua ${script_srcdir}/wsh.lua \
    ${script_srcdir}/shlink.js ${script_srcdir}/unlink.js
 LIBEXEC_DATA = mingw-get-0.dll
 
+# Primary build goals...
+#
 all: $(BIN_PROGRAMS) $(LIBEXEC_PROGRAMS) $(LIBEXEC_DATA)
 
 pkginfo$(EXEEXT):  driver.$(OBJEXT) pkginfo.$(OBJEXT)
@@ -85,23 +105,14 @@ pkginfo$(EXEEXT):  driver.$(OBJEXT) pkginfo.$(OBJEXT)
 mingw-get$(EXEEXT): $(CLI_EXE_OBJECTS)
        $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $+
 
-GUI_LDFLAGS = -mwindows $(LDFLAGS)
-
-# FIXME: the following is a Q&D kludge, to assign my choice of icon
-# to the GUI mode executable stub.  Eventually, this will need to be
-# assigned within a resource definition file, but for the time being,
-# besides providing a notification that the GUI is not yet available,
-# the stub serves only to illustrate mingw-get's shortcut creation
-# capability; thus, this simple hack will suffice.
-#
-%.$(OBJEXT): %.ico
-       echo $* ICON $*.ico | $(WINDRES) -I ${srcdir}/icons -o $@
-#
 gui$(EXEEXT): guistub.$(OBJEXT) pkgicon.$(OBJEXT)
        $(CXX) -o $@ $(CXXFLAGS) $(GUI_LDFLAGS) $+
 
+guimain$(EXEEXT): $(GUIMAIN_OBJECTS) $(LIBEXEC_DATA)
+       $(CXX) -o $@ $(CXXFLAGS) $(GUI_LDFLAGS) $+ $(GUIMAIN_LIBS)
+
 lastrites$(EXEEXT): rites.$(OBJEXT)
-       $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $+
+       $(CC) -o $@ $(CFLAGS) $(GUI_LDFLAGS) $+
 
 mingw-get-0.dll: $(CORE_DLL_OBJECTS)
        $(CXX) -shared -o $@ $(CXXFLAGS) $(LDFLAGS) $+ $(LIBS)
@@ -119,6 +130,13 @@ sinclude *.d
        $(CXX) $(DEPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $<
        $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
 
+%.$(OBJEXT): %.rc
+       $(CC) $(DEPFLAGS) $(RC_INCLUDES) -DRC_INVOKED -xc-header $<
+       $(RC_SCRIPT) $< | $(RC) $(RC_INCLUDES) -o $@
+
+%.$(OBJEXT): %.ico
+       echo $* ICON $*.ico | $(RC) -I ${srcdir}/icons -o $@
+
 # Installation tools and directory paths...
 #
 mkinstalldirs = @MKDIR_P@
index 030965d..1072844 100644 (file)
@@ -3,7 +3,7 @@
 # $Id$
 #
 # Written by Keith Marshall <keithmarshall@users.sourceforge.net>
-# Copyright (C) 2009, 2010, 2011, 2012, MinGW Project
+# Copyright (C) 2009, 2010, 2011, 2012, MinGW.org Project
 #
 #
 # Configuration script for mingw-get
 # 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,
+# MinGW.org Project, accept liability for any damages, however caused,
 # arising from the use of this software.
 #
-  AC_INIT([mingw-get],[0.5-beta-20120426-1],[http://mingw.org/Reporting_Bugs])
+  AC_INIT([mingw-get],[0.6],[http://mingw.org/Reporting_Bugs])
 
-  AC_SUBST([COPYRIGHT_HOLDER],["MinGW Project"])
+  AC_SUBST([COPYRIGHT_HOLDER],["MinGW.org Project"])
   AC_SUBST([YEARS_OF_ISSUE],["2009, 2010, 2011, 2012"])
 
+# Identify the formal release classes for each of the CLI and the GUI
+# application sub-packages; these may be overriden at configure time,
+# by specifying a common SNAPSHOT_CLASS definition, (e.g. by running
+#
+#   SNAPSHOT_CLASS=pre ./config.status --recheck && ./config.status
+#
+# to update the configuration for the "preview" class), when we wish
+# to build snapshots for distribution between formal releases.
+#
+  AC_SUBST([CLI_RELEASE_CLASS],[${SNAPSHOT_CLASS-"beta"}])
+  AC_SUBST([GUI_RELEASE_CLASS],[${SNAPSHOT_CLASS-"alpha"}])
+
 # Override the normal UNIX-centric autoconf default prefix;
 # substitute the MinGW standard in its place.
 #
 # We also need a Windows resource compiler,
 # and a lexical analyser generator
 #
-  AC_CHECK_TOOL([WINDRES],[windres],[windres])
+  AC_CHECK_TOOL([RC],[windres],[windres])
   AC_PROG_LEX
 
 # Ensure that (at least the headers for) prerequisite libraries,
-# zlib, libbz2 and liblzma are available
+# zlib, libbz2, liblzma, liblua, and libwtklite are available
 #
   AC_CHECK_HEADER([zlib.h],,MINGW_AC_ASSERT_MISSING([zlib-dev],
     [libz-1.2.3-1-mingw32-dev.tar.gz]))
     [bzip2-1.0.5-2-mingw32-dev.tar.gz]))
   AC_CHECK_HEADER([lzma.h],,MINGW_AC_ASSERT_MISSING([liblzma-dev],
     [liblzma-4.999.9beta_20091209-3-mingw32-dev.tar.bz2]))
+  AC_CHECK_HEADER([lua.h],,MINGW_AC_ASSERT_MISSING([lua-dev],
+    [lua-5.2.0-1-mingw32-dev.tar.xz]))
+  AC_CHECK_HEADER([wtklite.h],,MINGW_AC_ASSERT_MISSING([wtklite-dev],
+    [wtklite-0.1.0-1-mingw32-dev.tar.xz]))
 
 # Set up the archive librarian, to match our compiler settings
 #
diff --git a/src/guidata.rc b/src/guidata.rc
new file mode 100644 (file)
index 0000000..7438cfc
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * guimain.rc
+ *
+ * $Id$
+ *
+ * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
+ * Copyright (C) 2012, MinGW Project
+ *
+ *
+ * Resource definitions for the mingw-get GUI implementation.
+ *
+ *
+ * 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 <windows.h>
+
+/* The icon representing the mingw-get application; it is a clone
+ * of the icon representing the synaptic package for Debian APT.
+ */
+ID_MAIN_WINDOW ICON    DISCARDABLE     "pkgicon.ico"
+
+/* Specification for the layout and content of the dialogue panel
+ * which is called out by the "Help --> About mingw-get" menu pick.
+ */
+IDD_HELP_ABOUT DIALOG  DISCARDABLE     80, 50, 250, 185
+CAPTION                                        "about mingw-get"
+STYLE                                  DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_DLGFRAME
+FONT                                   9, "Verdana"
+BEGIN
+  DEFPUSHBUTTON                        "OK", IDOK, 100, 155, 50, 14, WS_GROUP
+  ICON                                 ID_MAIN_WINDOW, ID_MAIN_WINDOW, 115, 30, 0, 0
+  CTEXT                                        "%PACKAGE_NAME% version %PACKAGE_VERSION%", -1, 0, 10, 250, 20
+  CTEXT                                        "Written by Keith Marshall", -1, 0, 60, 250, 12
+  CTEXT                                        "Copyright \xa9 %YEARS_OF_ISSUE%, %COPYRIGHT_HOLDER%", \
+                                       -1, 0, 72, 250, 12
+  CTEXT                                        "http://mingw.org", -1, 0, 84, 250, 12
+  CTEXT                                        "\
+This is free software; see the product documentation or source code, for copying and redistribution \
+conditions.  There is NO WARRANTY; not even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR \
+ANY PARTICULAR PURPOSE.", -1, 10, 108, 230, 40
+END
+
+/* Miscellaneous string constants.
+ */
+STRINGTABLE            DISCARDABLE
+BEGIN
+  ID_MAIN_WINDOW_CLASS                 "mingw-get-gui"
+  ID_MAIN_WINDOW_CAPTION               "MinGW Installation Manager"
+  ID_FONT_PREF                         "Verdana"
+END
+
+/* Top menu bar...
+ */
+ID_MAIN_WINDOW MENU    DISCARDABLE
+BEGIN
+  /* The "Repository" drop-down menu; this also includes options
+   * which are commonly found on the "File" menu of applications
+   * with conventional menu bar content.
+   */
+  POPUP        "&Repository"
+  BEGIN
+    MENUITEM     "&Update Catalogue",                  IDM_REPO_UPDATE, GRAYED
+    MENUITEM     SEPARATOR
+    MENUITEM     "&Quit\tAlt+F4",                      IDM_REPO_QUIT
+  END
+
+  /* The "Package" drop-down menu; this provides for selection of
+   * the actions to be performed on a collection of packages.
+   */
+  POPUP                "&Package"
+  BEGIN
+    MENUITEM     "U&nmark",                            IDM_PACKAGE_UNMARK, GRAYED
+    MENUITEM     "Mark for &Installation",             IDM_PACKAGE_INSTALL, GRAYED
+    MENUITEM     "Mark for R&einstallation",           IDM_PACKAGE_REINSTALL, GRAYED
+    MENUITEM     "Mark for &Upgrade",                  IDM_PACKAGE_UPGRADE, GRAYED
+    MENUITEM     "Mark for &Removal",                  IDM_PACKAGE_REMOVE, GRAYED
+  END
+
+  /* The "Settings" drop-down menu is currently unimplemented.
+   */
+  POPUP                "&Settings"
+  BEGIN
+  END
+
+  /* The "Help" drop-down menu.
+   */
+  POPUP        "&Help",                                HELP
+  BEGIN
+    MENUITEM   "&Contents",                            IDM_HELP_CONTENTS, GRAYED
+    MENUITEM   "Quick &Introduction",                  IDM_HELP_INTRO, GRAYED
+    MENUITEM   "Icon &Legend",                         IDM_HELP_LEGEND, GRAYED
+    MENUITEM   "&About mingw-get",                     IDM_HELP_ABOUT
+  END
+END
+
+/* $RCSfile$: end of file */
diff --git a/src/guimain.cpp b/src/guimain.cpp
new file mode 100644 (file)
index 0000000..7cfc4c2
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * guimain.cpp
+ *
+ * $Id$
+ *
+ * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
+ * Copyright (C) 2012, MinGW Project
+ *
+ *
+ * Implementation of the WinMain() function, providing the program
+ * entry point for the GUI variant of mingw-get.
+ *
+ *
+ * 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 "pkglock.h"
+
+using WTK::StringResource;
+using WTK::WindowClassMaker;
+using WTK::MainWindowMaker;
+using WTK::runtime_error;
+
+int APIENTRY WinMain
+( HINSTANCE Instance, HINSTANCE PrevInstance, char *CmdLine, int ShowMode )
+{
+  try
+  { /* We allow only one instance of mingw-get to run at any time,
+     * so first, we check to ensure that there is no other instance
+     * already running...
+     */
+    HWND AppWindow = FindWindow(
+       StringResource( Instance, ID_MAIN_WINDOW_CLASS ), NULL
+      );
+    if( (AppWindow != NULL) && IsWindow( AppWindow ) )
+    {
+      /* ...and when one is, we identify its active window...
+       */
+      HWND AppPopup = GetLastActivePopup( AppWindow );
+      if( IsWindow( AppPopup ) )
+       AppWindow = AppPopup;
+
+      /* ...bring it to the foreground...
+       */
+      SetForegroundWindow( AppWindow );
+      /*
+       * ...restore it from minimised state, if necessary...
+       */
+      if( IsIconic( AppWindow ) )
+       ShowWindow( AppWindow, SW_RESTORE );
+
+      /* ...and defer execution to it.
+       */
+      return EXIT_SUCCESS;
+    }
+
+    /* There is no running instance of mingw-get; before we create one,
+     * ensure we can acquire an exclusive lock for the XML catalogue.
+     */
+    int lock;
+    StringResource MainWindowCaption( Instance, ID_MAIN_WINDOW_CAPTION );
+    if( (lock = pkgLock( MainWindowCaption )) >= 0 )
+    {
+      /* We've acquired the lock; we may now proceed to create an
+       * instance of the mingw-get GUI application window.
+       *
+       * First, register the window class name...
+       */
+      WindowClassMaker( Instance, ID_MAIN_WINDOW ).Register(
+         StringResource( Instance, ID_MAIN_WINDOW_CLASS )
+       );
+
+      /* ...and then proceed to create the window itself.
+       */
+      AppWindowMaker MainWindow( Instance );
+      AppWindow = MainWindow.Create(
+         StringResource( Instance, ID_MAIN_WINDOW_CLASS ),
+         MainWindowCaption
+       );
+
+      /* Show the window and paint its initial contents...
+       */
+      MainWindow.Show( ShowMode );
+      MainWindow.Update();
+
+      /* ...then invoke its message loop, ultimately release our
+       * lock, and return the status code which prevails when the
+       * main window application terminates.
+       */
+      return pkgRelease( lock, MainWindowCaption, MainWindow.Invoked() );
+    }
+  }
+  catch( runtime_error &e )
+  {
+    /* Here, we diagnose any error which was captured during the
+     * creation of the application's window hierarchy, or processing
+     * of its message loop...
+     */
+    MessageBox( NULL, e.what(), "WinMain", MB_ICONERROR );
+    return EXIT_FAILURE;
+  }
+  catch(...)
+  { /* ...while here, we diagnose any other error which we weren't
+     * able to explicitly identify.
+     */
+    MessageBox( NULL, "Unknown exception", "WinMain", MB_ICONERROR );
+    return EXIT_FAILURE;
+  }
+}
+
+/* $RCSfile$: end of file */
diff --git a/src/guimain.h b/src/guimain.h
new file mode 100644 (file)
index 0000000..d6a4d11
--- /dev/null
@@ -0,0 +1,112 @@
+#ifndef GUIMAIN_H
+/*
+ * guimain.h
+ *
+ * $Id$
+ *
+ * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
+ * Copyright (C) 2012, MinGW Project
+ *
+ *
+ * Resource definitions and window management class declarations for
+ * the mingw-get GUI implementation.
+ *
+ *
+ * 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.
+ *
+ */
+#define GUIMAIN_H  1
+
+/* Resource identifiers, and associated manifest constants.
+ */
+#define ID_MAIN_WINDOW                  100
+#define ID_MAIN_WINDOW_CLASS            101
+#define ID_MAIN_WINDOW_CAPTION          102
+#define ID_FONT_PREF                    103
+
+#define ID_HORIZONTAL_SASH              105
+#define ID_VERTICAL_SASH                106
+
+#define SASH_BAR_THICKNESS                4
+
+#define ID_PACKAGE_TREEVIEW             201
+#define ID_PACKAGE_LISTVIEW             202
+#define ID_PACKAGE_TABCONTROL           203
+
+#define IDM_MAIN_MENU                   300
+#define IDM_REPO_UPDATE                 301
+#define IDM_REPO_QUIT                   302
+
+#define IDM_PACKAGE_UNMARK              400
+#define IDM_PACKAGE_INSTALL             401
+#define IDM_PACKAGE_REINSTALL           402
+#define IDM_PACKAGE_UPGRADE             403
+#define IDM_PACKAGE_REMOVE              404
+
+#define IDM_HELP_CONTENTS               600
+#define IDM_HELP_INTRO                  601
+#define IDM_HELP_LEGEND                         602
+#define IDM_HELP_ABOUT                          603
+#define IDD_HELP_ABOUT                  603
+
+#ifndef RC_INVOKED
+#define WIN32_LEAN_AND_MEAN
+/*
+ * The following declarations may be required by GUI object modules,
+ * other than the resource module; they are suppressed when compiling
+ * the resource module, because they choke the resource compiler.
+ *
+ */
+#include <wtklite.h>
+
+class pkgXmlDocument;
+
+class AppWindowMaker;
+inline AppWindowMaker *GetAppWindow( HWND lookup )
+{
+  /* Helper routine to retrieve a pointer to the C++ structure
+   * which implements any application window, given its W32API
+   * window handle; note that this assumes that the window has
+   * been derived from the WTKPLUS GenericWindow() base class.
+   */
+  return (AppWindowMaker *)(WTK::WindowObjectReference( lookup ));
+}
+
+class AppWindowMaker: public WTK::MainWindowMaker
+{
+  public:
+    AppWindowMaker( HINSTANCE inst ): WTK::MainWindowMaker( inst ),
+    pkgData( NULL ), DefaultFont( (HFONT)(GetStockObject( DEFAULT_GUI_FONT )) ){}
+    ~AppWindowMaker(){ /* delete ChildWindows; */ DeleteObject( DefaultFont ); }
+
+    inline long AdjustLayout(){ return OnSize( 0, 0, 0 ); }
+
+
+  private:
+    virtual long OnCreate();
+    virtual long OnCommand( WPARAM );
+    virtual long OnNotify( WPARAM, LPARAM );
+    virtual long OnSize( WPARAM, int, int );
+
+    static int CALLBACK LayoutController( HWND, LPARAM );
+
+    int LayoutEngine( HWND, LPARAM );
+    WTK::SashWindowMaker *HorizontalSash, *VerticalSash;
+
+    pkgXmlDocument *pkgData;
+    HFONT DefaultFont;
+};
+
+#endif /* ! RC_INVOKED */
+#endif /* GUIMAIN_H: $RCSfile$: end of file */
diff --git a/src/pkgview.cpp b/src/pkgview.cpp
new file mode 100644 (file)
index 0000000..3441fe9
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * pkgview.cpp
+ *
+ * $Id$
+ *
+ * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
+ * Copyright (C) 2012, MinGW Project
+ *
+ *
+ * Implementation of the layout controller for the main mingw-get
+ * application window.
+ *
+ *
+ * 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"
+
+using WTK::GenericDialogue;
+using WTK::HorizontalSashWindowMaker;
+using WTK::VerticalSashWindowMaker;
+using WTK::StringResource;
+
+/* The main application window is divided into two
+ * horizontally adjustable sash panes; the following
+ * three constants specify the starting position for
+ * the sash bar, and the range over which it may be
+ * moved, as fractions of the width of the window,
+ * measured from its left hand side.
+ */
+static const double HSASH_MIN_POS = 0.10;
+static const double HSASH_INIT_POS = 0.20;
+static const double HSASH_MAX_POS = 0.40;
+
+/* The rightmost of these sash panes is further
+ * subdivided into two vertically adjustable panes;
+ * the following three constants similarly specify the
+ * initial position for the sash bar, and its range of
+ * adjustment, as fractions of the main window height,
+ * measured from its top edge.
+ */
+static const double VSASH_MIN_POS = 0.25;
+static const double VSASH_INIT_POS = 0.30;
+static const double VSASH_MAX_POS = 0.60;
+
+long AppWindowMaker::OnCreate()
+{
+  /* Handler for creation of the top-level application window;
+   * begin by initialising the sash window controls to support the
+   * desired three-pane sash window layout.
+   */
+  HorizontalSash = new HorizontalSashWindowMaker( ID_HORIZONTAL_SASH,
+      AppWindow, AppInstance, HSASH_MIN_POS, HSASH_INIT_POS, HSASH_MAX_POS
+    );
+  VerticalSash = new VerticalSashWindowMaker( ID_VERTICAL_SASH,
+      AppWindow, AppInstance, VSASH_MIN_POS, VSASH_INIT_POS, VSASH_MAX_POS
+    );
+
+  /* Assign the preferred font for use in the main window, falling
+   * back to the system default, if the choice is unavailable.
+   */
+  LOGFONT font_info;
+  HFONT font = DefaultFont;
+  GetObject( font, sizeof( LOGFONT ), &font_info );
+  strcpy( (char *)(&(font_info.lfFaceName)),
+      StringResource( AppInstance, ID_FONT_PREF )
+    );
+  if( (font = CreateFontIndirect( &font_info )) != NULL )
+  {
+    /* The preferred font choice is available; we may delete the
+     * object reference for the system default, then assign our
+     * preference in its place.
+     */
+    DeleteObject( DefaultFont );
+    DefaultFont = font;
+  }
+
+  /* Report that we've successfully handled the window set-up.
+   */
+  return EXIT_SUCCESS;
+}
+
+long AppWindowMaker::OnCommand( WPARAM cmd )
+{
+  /* Handler for WM_COMMAND messages which are directed to the
+   * top level application window.
+   */
+  switch( cmd )
+  {
+    case IDM_HELP_ABOUT:
+      /*
+       * This request is initiated by selecting "About mingw-get"
+       * from the "Help" menu; we respond by displaying the "about"
+       * dialogue box.
+       */
+      GenericDialogue( AppInstance, AppWindow, IDD_HELP_ABOUT );
+      break;
+
+    case IDM_REPO_QUIT:
+      /*
+       * This request is initiated by selecting the "Quit" option
+       * from the "Repository" menu; we respond by sending a WM_QUIT
+       * message, to terminate the current application instance.
+       */
+      SendMessage( AppWindow, WM_CLOSE, 0, 0L );
+      break;
+  }
+  return EXIT_SUCCESS;
+}
+
+long AppWindowMaker::OnNotify( WPARAM client_id, LPARAM data )
+{
+  /* Handler for notifications received from user controls; for now
+   * we simply quash any of these which we might receive.
+   */
+  return EXIT_SUCCESS;
+}
+
+long AppWindowMaker::OnSize( WPARAM mode, int width, int height )
+{
+  /* Handler for WM_SIZE event, applied to main application window;
+   * we delegate to the LayoutController, to place, resize, and update
+   * the view for each child window pane, such that they fit within,
+   * and fill the main window's client area.
+   */
+  RECT ClientArea;
+  GetClientRect( AppWindow, &ClientArea );
+  EnumChildWindows( AppWindow, LayoutController, (LPARAM)(&ClientArea) );
+  return EXIT_SUCCESS;
+}
+
+int CALLBACK AppWindowMaker::LayoutController( HWND pane, LPARAM region )
+{
+  /* The LayoutController provides a windows API callback hook, to
+   * service the WM_SIZE event; implemented as a static method...
+   */
+  HWND parent;
+  if( (parent = GetParent( pane )) != NULL )
+  {
+    /* ...it must retrieve an instance pointer to the C++ class
+     * object associated with the window to be laid out, then it
+     * may delegate the actual layout duty to the (non-static)
+     * LayoutEngine method associated with this object.
+     */
+    AppWindowMaker *p;
+    if( (p = GetAppWindow( parent )) != NULL )
+      return p->LayoutEngine( pane, region );
+  }
+  return TRUE;
+}
+
+int AppWindowMaker::LayoutEngine( HWND pane, LPARAM region )
+{
+  /* Formal implementation for the LayoutController; this computes
+   * the positions and sizes for each of the panes and sash bars, to
+   * create a three pane layout similar to:
+   *
+   *         +----------+----------------------------+
+   *         |          |                            |
+   *         |   TREE   |       LIST VIEW PANE       |
+   *         |          |                            |
+   *         |   VIEW   +----------------------------+
+   *         |          |                            |
+   *         |   PANE   |   TABBED DATA-SHEET PANE   |
+   *         |          |                            |
+   *         |          |                            |
+   *         +----------+----------------------------+
+   */
+  long pane_id;
+
+  int pane_top = ((LPRECT)(region))->top;
+  int pane_left = ((LPRECT)(region))->left;
+  int pane_height = ((LPRECT)(region))->bottom - pane_top;
+  int pane_width = ((LPRECT)(region))->right - pane_left;
+
+  pane_top = pane_left = 0;
+  switch( pane_id = GetWindowLong( pane, GWL_ID ) )
+  {
+    /* Each of the panes and sashes is computed individually, in the
+     * following order:
+     */
+    case ID_HORIZONTAL_SASH:
+      /* A slim window, placed to the right of the tree view pane, and
+       * occupying the full height of the parent window, representing the
+       * vertical sash bar, (which may be moved horizontally), and which
+       * separates the tree view pane from the list view and the tabbed
+       * data sheet panes.
+       */
+      pane_left = HorizontalSash->Displacement( pane_width ) - 1;
+      pane_width = 1 + SASH_BAR_THICKNESS;
+      break;
+
+    case ID_VERTICAL_SASH:
+      /* A slim window, placed below PANE TWO, and occupying the parent
+       * to the same width as PANE TWO and PANE THREE, representing the
+       * horizontal sash bar, (which may be moved vertically), which
+       * separates PANE TWO from PANE THREE.
+       */
+      pane_top = VerticalSash->Displacement( pane_height ) - 1;
+      pane_left = HorizontalSash->Displacement( pane_width ) + SASH_BAR_THICKNESS;
+      pane_height = 1 + SASH_BAR_THICKNESS; pane_width -= pane_left;
+      break;
+  }
+  /* Having computed the size and position for the pane or sash which
+   * is the target of the current call, move it into place within the
+   * parent window, and cause it to be displayed.
+   */
+  MoveWindow( pane, pane_left, pane_top, pane_width, pane_height, TRUE );
+  ShowWindow( pane, SW_SHOW );
+  return TRUE;
+}
+
+/* $RCSfile$: end of file */