Revision: 1573
http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=1573&view=rev
Author: rorthomas
Date: 2011-01-17 09:52:46 +0000 (Mon, 17 Jan 2011)
Log Message:
-----------
improved installer a bit
MSVS 2010 bug with UAC still present :-/
Modified Paths:
--------------
trunk/source/installer/CMakeLists.txt
trunk/source/installer/ConfigManager.cpp
trunk/source/installer/wizard.cpp
trunk/source/installer/wizard.h
trunk/source/installer/wthread.cpp
trunk/source/installer/wthread.h
Added Paths:
-----------
trunk/source/installer/checked.xpm
trunk/source/installer/checked_dis.xpm
trunk/source/installer/checkedlistctrl.cpp
trunk/source/installer/checkedlistctrl.h
trunk/source/installer/unchecked.xpm
trunk/source/installer/unchecked_dis.xpm
Modified: trunk/source/installer/CMakeLists.txt
===================================================================
--- trunk/source/installer/CMakeLists.txt 2011-01-16 21:34:19 UTC (rev
1572)
+++ trunk/source/installer/CMakeLists.txt 2011-01-17 09:52:46 UTC (rev
1573)
@@ -85,7 +85,7 @@
# no more static linking :/
#SET_TARGET_PROPERTIES(installer PROPERTIES COMPILE_FLAGS "/bigobj /MT /MP")
# TODO: fix UAC and VS2010
- #SET_TARGET_PROPERTIES(installer PROPERTIES LINK_FLAGS
"/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\"
/SUBSYSTEM:WINDOWS /NODEFAULTLIB:\"msvcprt.lib\" /NODEFAULTLIB:\"MSVCRT.lib\"")
+ SET_TARGET_PROPERTIES(installer PROPERTIES LINK_FLAGS
"/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\"")
ELSE(WIN32)
add_executable(installer ${source_files} ${include_files} ${resource_files})
TARGET_LINK_LIBRARIES(installer ${Boost_LIBRARIES})
Modified: trunk/source/installer/ConfigManager.cpp
===================================================================
--- trunk/source/installer/ConfigManager.cpp 2011-01-16 21:34:19 UTC (rev
1572)
+++ trunk/source/installer/ConfigManager.cpp 2011-01-17 09:52:46 UTC (rev
1573)
@@ -66,7 +66,7 @@
WsyncDownload *wsdl = new WsyncDownload();
std::vector< std::vector< std::string > > list;
char tmp[256] = "";
- sprintf(tmp, "%s/%s/%s", INSTALLER_VERSION, INSTALLER_PLATFORM,
WSYNC_VERSION_INFO);
+ sprintf(tmp, "/%s/%s/%s", INSTALLER_VERSION, INSTALLER_PLATFORM,
WSYNC_VERSION_INFO);
int res = wsdl->downloadConfigFile(WSYNC_MAIN_SERVER, std::string(tmp),
list);
delete(wsdl);
if(!res && list.size()>0 && list[0].size()>0)
@@ -75,14 +75,15 @@
return 0;
} else
{
- currVersion = std::string();
+ currVersion = std::string(" unknown "); // spaces intentionally
}
return 1;
}
int ConfigManager::writeVersionInfo()
{
- wxString fn = getInstallationPath() + wxT("\\version");
+ if(currVersion == " unknown ") return 1;
+ wxString fn = getInstallationPath() + wxT("\\version.txt");
FILE *f = fopen(conv(fn).c_str(), "w");
if(!f) return -1;
fprintf(f, "%s", currVersion.c_str());
@@ -92,7 +93,7 @@
std::string ConfigManager::readVersionInfo()
{
- wxString fn = getInstallationPath() + wxT("\\version");
+ wxString fn = getInstallationPath() + wxT("\\version.txt");
FILE *f = fopen(conv(fn).c_str(), "r");
if(!f) return std::string("unkown");
char tmp[256]="";
@@ -100,7 +101,7 @@
fclose(f);
if(res>0)
return std::string(tmp);
- return std::string("unkown");
+ return std::string("unknown");
}
wxString ConfigManager::getInstallationPath()
@@ -366,7 +367,7 @@
#endif
char url_tmp[256]="";
- sprintf(url_tmp, API_CHINSTALLER, ourHash.c_str(), platform_str);
+ sprintf(url_tmp, API_CHINSTALLER, ourHash.c_str(), platform_str,
INSTALLER_VERSION);
WsyncDownload *wsdl = new WsyncDownload();
LOG("checking for installer updates...\n");
Added: trunk/source/installer/checked.xpm
===================================================================
--- trunk/source/installer/checked.xpm (rev 0)
+++ trunk/source/installer/checked.xpm 2011-01-17 09:52:46 UTC (rev 1573)
@@ -0,0 +1,24 @@
+/* XPM */
+static char * checked_xpm[] = {
+"16 16 5 1",
+" c None",
+". c #808080",
+"X c Black",
+"o c #c0c0c0",
+"w c White",
+" ",
+" ",
+" ............ ",
+" .XXXXXXXXXXo ",
+" .Xwwwwwwwwwo ",
+" .XwwwwwwwXwo ",
+" .XwwwwwwXXwo ",
+" .XwXwwwXXXwo ",
+" .XwXXwXXXwwo ",
+" .XwXXXXXwwwo ",
+" .XwwXXXwwwwo ",
+" .XwwwXwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .ooooooooooo ",
+" ",
+" "};
Added: trunk/source/installer/checked_dis.xpm
===================================================================
--- trunk/source/installer/checked_dis.xpm (rev 0)
+++ trunk/source/installer/checked_dis.xpm 2011-01-17 09:52:46 UTC (rev
1573)
@@ -0,0 +1,23 @@
+/* XPM */
+static char * checked_dis_xpm[] = {
+"16 16 4 1",
+" c None",
+". c #808080",
+"X c Black",
+"o c #c0c0c0",
+" ",
+" ",
+" ............ ",
+" .XXXXXXXXXXo ",
+" .Xoooooooooo ",
+" .Xooooooo.oo ",
+" .Xoooooo..oo ",
+" .Xo.ooo...oo ",
+" .Xo..o...ooo ",
+" .Xo.....oooo ",
+" .Xoo...ooooo ",
+" .Xooo.oooooo ",
+" .Xoooooooooo ",
+" .ooooooooooo ",
+" ",
+" "};
Added: trunk/source/installer/checkedlistctrl.cpp
===================================================================
--- trunk/source/installer/checkedlistctrl.cpp (rev 0)
+++ trunk/source/installer/checkedlistctrl.cpp 2011-01-17 09:52:46 UTC (rev
1573)
@@ -0,0 +1,396 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: checkedlistctrl.cpp
+// Purpose: wxCheckedListCtrl
+// Author: Uknown ? (found at
http://wiki.wxwidgets.org/wiki.pl?WxListCtrl)
+// Modified by: Francesco Montorsi
+// Created: 2005/06/29
+// RCS-ID: $Id: checkedlistctrl.cpp,v 1.15 2005/10/20 16:06:01 frm Exp $
+// Copyright: (c) 2005 Francesco Montorsi
+// Licence: wxWidgets licence
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+// includes
+#include "checkedlistctrl.h"
+#include <wx/icon.h>
+
+// resources
+#include "checked.xpm"
+#include "unchecked.xpm"
+#include "checked_dis.xpm"
+#include "unchecked_dis.xpm"
+
+IMPLEMENT_CLASS(wxCheckedListCtrl, wxListCtrl)
+BEGIN_EVENT_TABLE(wxCheckedListCtrl, wxListCtrl)
+ EVT_LEFT_DOWN(wxCheckedListCtrl::OnMouseEvent)
+END_EVENT_TABLE()
+
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_CHECKED);
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_UNCHECKED);
+
+
+
+// ------------------
+// wxCHECKEDLISTCTRL
+// ------------------
+
+bool wxCheckedListCtrl::Create(wxWindow* parent, wxWindowID id, const wxPoint&
pt,
+ const wxSize& sz, long style, const wxValidator& validator, const
wxString& name)
+{
+ if (!wxListCtrl::Create(parent, id, pt, sz, style, validator, name))
+ return FALSE;
+
+ SetImageList(&m_imageList, wxIMAGE_LIST_SMALL);
+
+ // the add order must respect the wxCLC_XXX_IMGIDX defines in the
headers !
+ m_imageList.Add(wxIcon(unchecked_xpm));
+ m_imageList.Add(wxIcon(checked_xpm));
+ m_imageList.Add(wxIcon(unchecked_dis_xpm));
+ m_imageList.Add(wxIcon(checked_dis_xpm));
+
+ return TRUE;
+}
+
+/* static */
+int wxCheckedListCtrl::GetItemImageFromAdditionalState(int addstate)
+{
+ bool checked = (addstate & wxLIST_STATE_CHECKED) != 0;
+ bool enabled = (addstate & wxLIST_STATE_ENABLED) != 0;
+
+ if (checked && enabled)
+ return wxCLC_CHECKED_IMGIDX;
+ else if (checked && !enabled)
+ return wxCLC_DISABLED_CHECKED_IMGIDX;
+ else if (!checked && enabled)
+ return wxCLC_UNCHECKED_IMGIDX;
+
+ wxASSERT(!checked && !enabled); // this is the last possibility
+ return wxCLC_DISABLED_UNCHECKED_IMGIDX;
+}
+
+wxColour wxCheckedListCtrl::GetBgColourFromAdditionalState(int additionalstate)
+{
+ if ((additionalstate & wxLIST_STATE_ENABLED) &&
+ this->IsEnabled())
+ return *wxWHITE;
+#ifdef __WXMSW__
+ return wxColour(212, 208, 200);
+#else
+ return wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
+#endif
+}
+
+/* static */
+int wxCheckedListCtrl::GetAndRemoveAdditionalState(long *state, int statemask)
+{
+ int additionalstate = 0;
+ if (!state) return -1;
+
+ // extract the bits we are interested in
+ bool checked = (*state & wxLIST_STATE_CHECKED) != 0;
+ bool enabled = (*state & wxLIST_STATE_ENABLED) != 0;
+
+ // and set them in a different variable if they are included in the
statemask
+ if (checked && (statemask & wxLIST_STATE_CHECKED)) additionalstate |=
wxLIST_STATE_CHECKED;
+ if (enabled && (statemask & wxLIST_STATE_ENABLED)) additionalstate |=
wxLIST_STATE_ENABLED;
+
+ // remove them from the original state var...
+ *state &= ~wxLIST_STATE_CHECKED;
+ *state &= ~wxLIST_STATE_ENABLED;
+ return additionalstate;
+}
+
+bool wxCheckedListCtrl::GetItem(wxListItem& info) const
+{
+ // wx internal wxListCtrl::GetItem remove from the state mask the
+ // wxLIST_STATE_CHECKED & wxLIST_STATE_ENABLED bits since they
+ // are not part of wx standard flags... so we need to check those
+ // flags against the original wxListItem's statemask...
+ wxListItem original(info);
+
+#ifdef __WXDEBUG__
+ // we always want to retrieve also the image state for checking
purposes...
+ info.m_mask |= wxLIST_MASK_IMAGE;
+#endif
+
+ if (!wxListCtrl::GetItem(info))
+ return FALSE;
+
+ // these are our additional supported states: read them from m_stateList
+ bool checked = (m_stateList[info.m_itemId] & wxLIST_STATE_CHECKED) != 0;
+ bool enabled = (m_stateList[info.m_itemId] & wxLIST_STATE_ENABLED) != 0;
+
+ // now intercept state requests about enable or check mode
+ if ((original.m_mask & wxLIST_MASK_STATE) &&
+ (original.m_stateMask & wxLIST_STATE_CHECKED)) {
+ info.m_state |= (m_stateList[info.m_itemId] &
wxLIST_STATE_CHECKED);
+ info.m_stateMask |= wxLIST_STATE_CHECKED;
+ info.m_mask |= wxLIST_MASK_STATE; // contains
valid info !
+ }
+ if ((original.m_mask & wxLIST_MASK_STATE) &&
+ (original.m_stateMask & wxLIST_STATE_ENABLED)) {
+ info.m_state |= (m_stateList[info.m_itemId] &
wxLIST_STATE_ENABLED);
+ info.m_stateMask |= wxLIST_STATE_ENABLED;
+ info.m_mask |= wxLIST_MASK_STATE; // contains
valid info !
+ }
+
+ // check that state & image are synch
+#ifdef __WXDEBUG__
+
+ wxASSERT_MSG((int)m_stateList.GetCount() == (int)GetItemCount(),
+ wxT("Something wrong ! See
InsertItem()"));
+
+ // read info by image index
+ bool imagecheck = (info.m_image == wxCLC_CHECKED_IMGIDX) ||
+ (info.m_image ==
wxCLC_DISABLED_CHECKED_IMGIDX);
+ bool imageenabled = (info.m_image == wxCLC_CHECKED_IMGIDX) ||
+ (info.m_image ==
wxCLC_UNCHECKED_IMGIDX);
+ wxASSERT_MSG((checked && imagecheck) || (!checked && !imagecheck),
+ wxT("This is item has checked state but it's shown as unchecked
(or viceversa)"));
+ wxASSERT_MSG((enabled && imageenabled) || (!enabled && !imageenabled),
+ wxT("This is item has enabled state but it's shown as disabled
(or viceversa)"));
+#endif
+
+ return TRUE;
+}
+
+bool wxCheckedListCtrl::SetItem(wxListItem& info)
+{
+ // remove the checked & enabled states from the state flag:
+ // we'll store them in our separate array
+ int additionalstate = GetAndRemoveAdditionalState(&info.m_state,
info.m_stateMask);
+
+ // set image index
+ // we will ignore the info.m_image field since we need
+ // to overwrite it...
+ if (info.m_mask & wxLIST_MASK_STATE) {
+
+ // if some state is not included in the state mask, then get
the state info
+ // from our internal state array
+ if (!(info.m_stateMask & wxLIST_STATE_ENABLED))
+ additionalstate |= (m_stateList[info.m_itemId] &
wxLIST_STATE_ENABLED);
+ if (!(info.m_stateMask & wxLIST_STATE_CHECKED))
+ additionalstate |= (m_stateList[info.m_itemId] &
wxLIST_STATE_CHECKED);
+
+ // state is valid: use it to determine the image to set...
+ info.m_mask |= wxLIST_MASK_IMAGE;
+ info.m_image = GetItemImageFromAdditionalState(additionalstate);
+
+ // since when changing the background color, also the
foreground color
+ // and the font of the item are changed, we try to respect the
user
+ // choices of such attributes
+ info.SetTextColour(this->GetItemTextColour(info.GetId()));
+#if wxCHECK_VERSION(2, 6, 2)
+ // before wx 2.6.2 the wxListCtrl::SetItemFont function is
missing
+ info.SetFont(this->GetItemFont(info.GetId()));
+#endif
+
+ // change the background color to respect the enabled/disabled
status...
+
info.SetBackgroundColour(GetBgColourFromAdditionalState(additionalstate));
+
+ m_stateList[info.m_itemId] = additionalstate;
+
+ } else {
+
+ // state is invalid; don't change image
+ info.m_mask &= ~wxLIST_MASK_IMAGE;
+ }
+
+ // save the changes
+ return wxListCtrl::SetItem(info);
+}
+
+long wxCheckedListCtrl::InsertItem(wxListItem &info)
+{
+ int additionalstate = GetAndRemoveAdditionalState(&info.m_state,
info.m_stateMask);
+ if (!(info.m_mask & wxLIST_MASK_STATE) ||
+ !(info.m_stateMask & wxLIST_STATE_ENABLED)) {
+
+ // if not specified, the default additional state is ENABLED
+ additionalstate = wxLIST_STATE_ENABLED;
+ }
+
+ // we always want to insert items with images...
+ info.m_mask |= wxLIST_MASK_IMAGE;
+ info.m_image = GetItemImageFromAdditionalState(additionalstate);
+
info.SetBackgroundColour(GetBgColourFromAdditionalState(additionalstate));
+
+ int itemcount = GetItemCount();
+ wxASSERT_MSG(info.m_itemId <= itemcount, wxT("Invalid index !"));
+ wxASSERT_MSG((int)m_stateList.GetCount() == (int)GetItemCount(),
+ wxT("Something wrong !"));
+ if (info.m_itemId == itemcount) {
+
+ // we are adding a new item at the end of the list
+ m_stateList.Add(additionalstate);
+
+ } else {
+
+ // we must shift all following items
+ for (int i=itemcount; i > info.m_itemId; i++)
+ m_stateList[i] = m_stateList[i-1];
+ m_stateList[info.m_itemId] = additionalstate;
+ }
+
+ return wxListCtrl::InsertItem(info);
+}
+
+bool wxCheckedListCtrl::SetItemState(long item, long state, long stateMask)
+{
+ wxListItem li;
+ li.SetId(item);
+ li.SetMask(wxLIST_MASK_STATE);
+ li.SetState(state);
+ li.SetStateMask(stateMask);
+
+ // so we are sure to use wxCheckedListCtrl::SetItem
+ // (and not wxListCtrl::SetItem)
+ return SetItem(li);
+}
+
+int wxCheckedListCtrl::GetItemState(long item, long stateMask) const
+{
+ wxListItem li;
+ li.SetId(item);
+ li.SetMask(wxLIST_MASK_STATE);
+ li.SetStateMask(stateMask);
+
+ // so we are sure to use wxCheckedListCtrl::GetItem
+ // (and not wxListCtrl::GetItem)
+ if (!GetItem(li))
+ return -1;
+ return li.GetState();
+}
+
+long wxCheckedListCtrl::SetItem(long index, int col, const wxString& label,
int WXUNUSED(imageId))
+{
+ wxListItem li;
+ li.SetId(index);
+ li.SetColumn(col);
+ li.SetText(label);
+ li.SetMask(wxLIST_MASK_TEXT);
+
+ // so we are sure to use wxCheckedListCtrl::SetItem
+ // (and not wxListCtrl::SetItem)
+ return SetItem(li);
+}
+
+long wxCheckedListCtrl::InsertItem( long index, const wxString& label, int
WXUNUSED(imageIndex) )
+{
+ wxListItem info;
+ info.m_text = label;
+ info.m_mask = wxLIST_MASK_TEXT;
+ info.m_itemId = index;
+ return InsertItem(info);
+}
+
+void wxCheckedListCtrl::Check(long item, bool checked)
+{
+ // NB: the "statemask" is not the "mask" of a list item;
+ // in the "mask" you use the wxLIST_MASK_XXXX defines;
+ // in the "statemask" you use the wxLIST_STATE_XXX defines
+ // to set a specific bit of the wxListInfo::m_state var
+ if (checked)
+ // the 2nd parameter says: activate the STATE bit relative to
CHECK feature
+ // the 3rd parameter says: set only *that* bit
+ SetItemState(item, wxLIST_STATE_CHECKED, wxLIST_STATE_CHECKED);
+ else
+ SetItemState(item, 0, wxLIST_STATE_CHECKED);
+}
+
+void wxCheckedListCtrl::Enable(long item, bool enable)
+{
+ if (enable)
+ // the 2nd parameter says: activate the STATE bit relative to
ENABLE feature
+ // the 3rd parameter says: set only *that* bit
+ SetItemState(item, wxLIST_STATE_ENABLED, wxLIST_STATE_ENABLED);
+ else
+ SetItemState(item, 0, wxLIST_STATE_ENABLED);
+}
+
+void wxCheckedListCtrl::EnableAll(bool enable)
+{
+ for (int i=0; i < GetItemCount(); i++)
+ Enable(i, enable);
+}
+
+void wxCheckedListCtrl::CheckAll(bool check)
+{
+ for (int i=0; i < GetItemCount(); i++)
+ Check(i, check);
+}
+
+bool wxCheckedListCtrl::DeleteItem(long item)
+{
+ // shift our additional state array
+ //for (int i=item,max=GetItemCount(); i < max-1; i++)
+ // m_stateList[i] = m_stateList[i+1];
+ m_stateList.RemoveAt(item, 1);
+
+ return wxListCtrl::DeleteItem(item);
+}
+
+int wxCheckedListCtrl::GetCheckedItemCount() const
+{
+ int res = 0;
+ for (int i=0; i<GetItemCount(); i++)
+ if (IsChecked(i))
+ res++;
+
+ return res;
+}
+
+// event handlers
+
+void wxCheckedListCtrl::OnMouseEvent(wxMouseEvent& event)
+{
+ if (!event.LeftDown()) {
+ event.Skip();
+ return;
+ }
+
+ int flags;
+ long item = HitTest(event.GetPosition(), flags);
+ if (item == wxNOT_FOUND || !IsEnabled(item)) {
+
+ // skip this item
+ event.Skip();
+ return;
+ }
+
+ // user clicked exactly on the checkbox or on the item row ?
+ bool processcheck = (flags & wxLIST_HITTEST_ONITEMICON) ||
+ ((GetWindowStyle() & wxCLC_CHECK_WHEN_SELECTING) &&
+ (flags & wxLIST_HITTEST_ONITEM));
+
+ if (processcheck) {
+
+ wxListEvent ev(wxEVT_NULL, GetId());
+ ev.m_itemIndex = item;
+
+ // send the check event
+ if (IsChecked(item)) {
+
+ ev.SetEventType(wxEVT_COMMAND_LIST_ITEM_UNCHECKED);
+ Check(item, FALSE);
+ AddPendingEvent(ev);
+
+ } else {
+
+ ev.SetEventType(wxEVT_COMMAND_LIST_ITEM_CHECKED);
+ Check(item, TRUE);
+ AddPendingEvent(ev);
+ }
+ }
+
+ event.Skip();
+}
Added: trunk/source/installer/checkedlistctrl.h
===================================================================
--- trunk/source/installer/checkedlistctrl.h (rev 0)
+++ trunk/source/installer/checkedlistctrl.h 2011-01-17 09:52:46 UTC (rev
1573)
@@ -0,0 +1,161 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: checkedlistctrl.h
+// Purpose: wxCheckedListCtrl
+// Author: Uknown ? (found at
http://wiki.wxwidgets.org/wiki.pl?WxListCtrl)
+// Modified by: Francesco Montorsi
+// Created: 2005/06/29
+// RCS-ID: $Id: checkedlistctrl.h,v 1.13 2005/10/20 16:06:01 frm Exp $
+// Copyright: (c) 2005 Francesco Montorsi
+// Licence: wxWidgets licence
+/////////////////////////////////////////////////////////////////////////////
+
+
+#ifndef _WX_CHECKEDLISTCTRL_H_
+#define _WX_CHECKEDLISTCTRL_H_
+
+// wxWidgets headers
+#include <wx/listctrl.h>
+#include <wx/imaglist.h>
+
+// image indexes (used internally by wxCheckedListCtrl)
+#define wxCLC_UNCHECKED_IMGIDX 0 //
unchecked & enabled
+#define wxCLC_CHECKED_IMGIDX 1 //
checked & enabled
+#define wxCLC_DISABLED_UNCHECKED_IMGIDX 2 //
unchecked & disabled
+#define wxCLC_DISABLED_CHECKED_IMGIDX 3 // checked &
disabled
+
+// additional state flags (wx's defines should end at 0x0100; see listbase.h)
+#define wxLIST_STATE_CHECKED 0x010000
+#define wxLIST_STATE_ENABLED 0x100000
+
+// additional wxCheckedListCtrl style flags
+// (wx's defines should at 0x8000; see listbase.h)
+#define wxCLC_CHECK_WHEN_SELECTING 0x10000
+
+
+// -------------------------
+// wxCheckedListCtrl events
+// -------------------------
+
+//DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBUPDATE,
wxEVT_COMMAND_LIST_ITEM_CHECKED, -1);
+//DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBUPDATE,
wxEVT_COMMAND_LIST_ITEM_UNCHECKED, -1);
+
+#define EVT_LIST_ITEM_CHECKED(id, fn) \
+ DECLARE_EVENT_TABLE_ENTRY( \
+ wxEVT_COMMAND_LIST_ITEM_CHECKED, id, -1, \
+ (wxObjectEventFunction)(wxEventFunction)(wxListEventFunction)&fn, \
+ (wxObject *) NULL \
+ ),
+
+#define EVT_LIST_ITEM_UNCHECKED(id, fn) \
+ DECLARE_EVENT_TABLE_ENTRY( \
+ wxEVT_COMMAND_LIST_ITEM_UNCHECKED, id, -1, \
+ (wxObjectEventFunction)(wxEventFunction)(wxListEventFunction)&fn, \
+ (wxObject *) NULL \
+ ),
+
+
+
+//! This is the class which performs all transactions with the server.
+//! It uses the wxSocket facilities.
+class wxCheckedListCtrl : public wxListCtrl
+{
+protected:
+
+ // we have to keep a different array to keep track of the additional
+ // states we support....
+ wxArrayInt m_stateList;
+
+ // our set of checkbox images...
+ wxImageList m_imageList;
+
+public:
+ wxCheckedListCtrl()
+ : wxListCtrl(), m_imageList(16, 16, TRUE) {}
+
+ wxCheckedListCtrl(wxWindow *parent, wxWindowID id = -1,
+ const wxPoint& pt =
wxDefaultPosition,
+ const wxSize& sz =
wxDefaultSize,
+ long style =
wxCLC_CHECK_WHEN_SELECTING,
+ const wxValidator& validator =
wxDefaultValidator,
+ const wxString& name =
wxListCtrlNameStr)
+ : wxListCtrl(), m_imageList(16,
16, TRUE)
+ { Create(parent, id, pt, sz, style, validator, name); }
+
+ bool Create(wxWindow *parent, wxWindowID id = -1,
+ const wxPoint& pt =
wxDefaultPosition,
+ const wxSize& sz =
wxDefaultSize,
+ long style =
wxCLC_CHECK_WHEN_SELECTING,
+ const wxValidator& validator =
wxDefaultValidator,
+ const wxString& name =
wxListCtrlNameStr);
+
+ virtual ~wxCheckedListCtrl() {}
+
+
+public: // utilities
+
+ // core overloads (i.e. the most generic overloads)
+ bool GetItem(wxListItem& info) const;
+ bool SetItem(wxListItem& info);
+ long InsertItem(wxListItem& info);
+ bool DeleteItem(long item);
+ bool DeleteAllItems()
+ { m_stateList.Clear(); return wxListCtrl::DeleteAllItems(); }
+
+ bool SortItems(wxListCtrlCompare, long)
+ { wxASSERT_MSG(0, wxT("Not implemented yet ! sorry... "));
return FALSE; }
+
+ // shortcuts to the SetItemState function
+ void Check(long item, bool checked);
+ void Enable(long item, bool enable);
+ void CheckAll(bool checked = true);
+ void EnableAll(bool enable = true);
+
+ // this needs to be redeclared otherwise it's hidden by our other
Enable() function.
+ // However you should use #EnableAll instead of this function if you
want to get
+ // good graphics (try to understand)
+ virtual bool Enable(bool enable = true)
+ { return wxListCtrl::Enable(enable); }
+
+ // shortcuts to the GetItemState function
+ bool IsChecked(long item) const
+ { return GetItemState(item, wxLIST_STATE_CHECKED) != 0; }
+ bool IsEnabled(long item) const
+ { return GetItemState(item, wxLIST_STATE_ENABLED) != 0; }
+
+ // this needs to be redeclared otherwise it's hidden by our other
IsEnabled() function.
+ bool IsEnabled() const
+ { return wxWindow::IsEnabled(); }
+
+ //! Returns the number of checked items in the control.
+ int GetCheckedItemCount() const;
+
+ // we overload these so we are sure they will use our
+ // #GetItem and #SetItem functions...
+ bool SetItemState(long item, long state, long stateMask);
+ int GetItemState(long item, long stateMask) const;
+ long InsertItem( long index, const wxString& label, int imageIndex = -1);
+ long SetItem(long index, int col, const wxString& label, int imageId =
-1);
+
+ // the image associated with an element is already in used by
wxCheckedListCtrl
+ // itself to show the checkbox and it cannot be handled by the user !
+ bool SetItemImage(long, int)
+ { wxASSERT_MSG(0, wxT("This function cannot be used with
wxCheckedListCtrl !")); return FALSE; }
+
+protected: // event handlers
+
+ void OnMouseEvent(wxMouseEvent& event);
+
+protected: // internal utilities
+
+ static int GetItemImageFromAdditionalState(int addstate);
+ static int GetAndRemoveAdditionalState(long *state, int statemask);
+ wxColour GetBgColourFromAdditionalState(int additionalstate);
+
+private:
+ DECLARE_CLASS(wxCheckedListCtrl)
+ DECLARE_EVENT_TABLE()
+};
+
+
+#endif // _WX_CHECKEDLISTCTRL_H_
+
Added: trunk/source/installer/unchecked.xpm
===================================================================
--- trunk/source/installer/unchecked.xpm (rev 0)
+++ trunk/source/installer/unchecked.xpm 2011-01-17 09:52:46 UTC (rev
1573)
@@ -0,0 +1,24 @@
+/* XPM */
+static char * unchecked_xpm[] = {
+"16 16 5 1",
+" c None",
+". c #808080",
+"X c Black",
+"o c #c0c0c0",
+"w c White",
+" ",
+" ",
+" ............ ",
+" .XXXXXXXXXXo ",
+" .Xwwwwwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .Xwwwwwwwwwo ",
+" .ooooooooooo ",
+" ",
+" "};
Added: trunk/source/installer/unchecked_dis.xpm
===================================================================
--- trunk/source/installer/unchecked_dis.xpm (rev 0)
+++ trunk/source/installer/unchecked_dis.xpm 2011-01-17 09:52:46 UTC (rev
1573)
@@ -0,0 +1,23 @@
+/* XPM */
+static char * unchecked_dis_xpm[] = {
+"16 16 4 1",
+" c None",
+". c #808080",
+"X c Black",
+"o c #c0c0c0",
+" ",
+" ",
+" ............ ",
+" .XXXXXXXXXXo ",
+" .Xoooooooooo ",
+" .Xoooooooooo ",
+" .Xoooooooooo ",
+" .Xoooooooooo ",
+" .Xoooooooooo ",
+" .Xoooooooooo ",
+" .Xoooooooooo ",
+" .Xoooooooooo ",
+" .Xoooooooooo ",
+" .ooooooooooo ",
+" ",
+" "};
Modified: trunk/source/installer/wizard.cpp
===================================================================
--- trunk/source/installer/wizard.cpp 2011-01-16 21:34:19 UTC (rev 1572)
+++ trunk/source/installer/wizard.cpp 2011-01-17 09:52:46 UTC (rev 1573)
@@ -73,6 +73,7 @@
#include "action.xpm"
#include "download.xpm"
#include "finished.xpm"
+#include "checkedlistctrl.h"
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#include <shlobj.h> // for the special path functions
@@ -217,12 +218,14 @@
CONFIG->checkForNewUpdater();
PresentationPage *presentation = new PresentationPage(this);
+ ConfirmationPage *confirm = new ConfirmationPage(this);
DownloadPage *download = new DownloadPage(this);
LastPage *last = new LastPage(this);
m_page1 = presentation;
wxWizardPageSimple::Chain(presentation, download);
+ //wxWizardPageSimple::Chain(confirm, download);
wxWizardPageSimple::Chain(download, last);
if ( useSizer )
@@ -281,6 +284,12 @@
//// PresentationPage
PresentationPage::PresentationPage(wxWizard *parent) :
wxWizardPageSimple(parent)
{
+
+ wxString a = conv(CONFIG->readVersionInfo());
+ CONFIG->getCurrentVersionInfo();
+ wxString b = conv(CONFIG->getOnlineVersion());
+
+
m_bitmap = wxBitmap(welcome_xpm);
wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
wxStaticText *tst;
@@ -297,13 +306,101 @@
tst->Wrap(TXTWRAP);
mainSizer->Add(tst=new wxStaticText(this, wxID_ANY, _T("If you are
using a firewall, please allow this program to access the Internet.\n")), 0,
wxALL, 5);
tst->Wrap(TXTWRAP);
- mainSizer->Add(tst=new wxStaticText(this, wxID_ANY, _T("Click on Next
to continue.\n")), 0, wxALL, 5);
+
+ mainSizer->Add(tst=new wxStaticText(this, wxID_ANY, _T("Installed
Version: ") + a), 0, wxALL, 5);
+ dfont=tst->GetFont();
+ dfont.SetWeight(wxFONTWEIGHT_BOLD);
+ dfont.SetPointSize(dfont.GetPointSize()+4);
+ tst->SetFont(dfont);
tst->Wrap(TXTWRAP);
+ mainSizer->Add(tst=new wxStaticText(this, wxID_ANY, _T("Online Version:
") + b), 0, wxALL, 5);
+ dfont=tst->GetFont();
+ dfont.SetWeight(wxFONTWEIGHT_BOLD);
+ dfont.SetPointSize(dfont.GetPointSize()+4);
+ tst->SetFont(dfont);
+ tst->Wrap(TXTWRAP);
+
+ if(a == b)
+ {
+ mainSizer->Add(tst=new wxStaticText(this, wxID_ANY, _T("Already
up to date, no need to update")), 0, wxALL, 5);
+ dfont=tst->GetFont();
+ dfont.SetWeight(wxFONTWEIGHT_BOLD);
+ dfont.SetPointSize(dfont.GetPointSize()+4);
+ tst->SetFont(dfont);
+ tst->Wrap(TXTWRAP);
+
+ setControlEnable(parent, wxID_FORWARD, false);
+ setControlEnable(parent, wxID_BACKWARD, false);
+
+ } else
+ {
+ mainSizer->Add(tst=new wxStaticText(this, wxID_ANY, _T("Click
on Next to continue.\n")), 0, wxALL, 5);
+ tst->Wrap(TXTWRAP);
+ }
+
SetSizer(mainSizer);
mainSizer->Fit(this);
}
+//// ConfirmationPage
+ConfirmationPage::ConfirmationPage(wxWizard *parent) :
wxWizardPageSimple(parent)
+{
+ // TBD!
+ wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
+
+ wxCheckedListCtrl *m_item_list = new wxCheckedListCtrl(this, wxID_ANY,
wxDefaultPosition, wxDefaultSize, wxLC_REPORT);
+
+ // Add first column
+ wxListItem col0;
+ col0.SetId(0);
+ col0.SetText( _("Foo") );
+ col0.SetWidth(50);
+ m_item_list->InsertColumn(0, col0);
+
+ // Add second column
+ wxListItem col1;
+ col1.SetId(1);
+ col1.SetText( _("Name") );
+ m_item_list->InsertColumn(1, col1);
+
+ // Add thirs column
+ wxListItem col2;
+ col2.SetId(2);
+ col2.SetText( _("Comments") );
+ m_item_list->InsertColumn(2, col2);
+
+
+ const int item_amount = 5; //getItemAmount();
+ for (int n=0; n<item_amount; n++)
+ {
+ //Item* curritem = getItem(n);
+
+ wxListItem item;
+ item.SetId(n);
+ item.SetText( "F00bar" );
+
+ m_item_list->InsertItem( item );
+
+ // set value in first column
+ //if (!curritem->isFoo())
+ {
+ m_item_list->SetItem(n, 0, wxT("Foo"));
+ }
+
+ // set value in second column
+ m_item_list->SetItem(n, 1, "Voo");
+
+ // set value in third column
+ m_item_list->SetItem(n, 2, "Doo");
+
+ }
+
+ mainSizer->Add(m_item_list,1, wxEXPAND | wxALL, 10);
+ SetSizer(mainSizer);
+ mainSizer->Fit(this);
+}
+
//// DownloadPage
DownloadPage::DownloadPage(wxWizard *parent) : wxWizardPageSimple(parent),
wizard(parent)
{
Modified: trunk/source/installer/wizard.h
===================================================================
--- trunk/source/installer/wizard.h 2011-01-16 21:34:19 UTC (rev 1572)
+++ trunk/source/installer/wizard.h 2011-01-17 09:52:46 UTC (rev 1573)
@@ -100,6 +100,12 @@
PresentationPage(wxWizard *parent);
};
+class ConfirmationPage : public wxWizardPageSimple, public EnterLeavePage
+{
+public:
+ ConfirmationPage(wxWizard *parent);
+};
+
class DownloadPage : public wxWizardPageSimple, public EnterLeavePage
{
friend class WsyncThread;
Modified: trunk/source/installer/wthread.cpp
===================================================================
--- trunk/source/installer/wthread.cpp 2011-01-16 21:34:19 UTC (rev 1572)
+++ trunk/source/installer/wthread.cpp 2011-01-17 09:52:46 UTC (rev 1573)
@@ -53,36 +53,36 @@
case MSE_DOWNLOAD_START:
{
dlStatus[jobID].status = 1;
- LOG("DLFile-TP-%04d| MSE_DOWNLOAD_START\n", jobID );
+ //LOG("DLFile-TP-%04d| MSE_DOWNLOAD_START\n", jobID );
// we do this here, since its getting overwritten on the start
only
updateCallback(MSE_UPDATE_TEXT, dlStatus[jobID].path + " (" +
formatFilesize(dlStatus[jobID].filesize) + ") ...");
break;
}
case MSE_DOWNLOAD_PROGRESS:
- LOG("DLFile-TP-%04d| MSE_DOWNLOAD_PROGRESS\n", jobID );
+ //LOG("DLFile-TP-%04d| MSE_DOWNLOAD_PROGRESS\n", jobID );
dlStatus[jobID].status = 1;
dlStatus[jobID].percent = ev.GetProgress();
updateCallback(MSE_DOWNLOAD_PROGRESS, dlStatus[jobID].path,
ev.GetProgress());
break;
case MSE_DOWNLOAD_TIME:
- LOG("DLFile-TP-%04d| MSE_DOWNLOAD_TIME\n", jobID );
+ //LOG("DLFile-TP-%04d| MSE_DOWNLOAD_TIME\n", jobID );
dlStatus[jobID].time = ev.GetProgress();
break;
case MSE_DOWNLOAD_TIME_LEFT:
- LOG("DLFile-TP-%04d| MSE_DOWNLOAD_TIME_LEFT\n", jobID );
+ //LOG("DLFile-TP-%04d| MSE_DOWNLOAD_TIME_LEFT\n", jobID );
dlStatus[jobID].time_remaining = ev.GetProgress();
break;
case MSE_DOWNLOAD_SPEED:
- LOG("DLFile-TP-%04d| MSE_DOWNLOAD_SPEED\n", jobID );
+ //LOG("DLFile-TP-%04d| MSE_DOWNLOAD_SPEED\n", jobID );
dlStatus[jobID].speed = ev.GetProgress();
break;
case MSE_DOWNLOAD_DOWNLOADED:
- LOG("DLFile-TP-%04d| MSE_DOWNLOAD_DOWNLOADED\n", jobID);
+ //LOG("DLFile-TP-%04d| MSE_DOWNLOAD_DOWNLOADED\n", jobID);
dlStatus[jobID].downloaded = (boost::uintmax_t)ev.GetProgress();
break;
case MSE_DOWNLOAD_DONE:
- LOG("DLFile-TP-%04d| MSE_DOWNLOAD_DONE\n", jobID );
+ //LOG("DLFile-TP-%04d| MSE_DOWNLOAD_DONE\n", jobID );
updateCallback(MSE_DOWNLOAD_DONE, dlStatus[jobID].path);
dlStatus[jobID].status = 3;
break;
@@ -98,7 +98,7 @@
void WsyncThread::reportProgress()
{
- LOG("DLFile-TP| reportProgress\n");
+ //LOG("DLFile-TP| reportProgress\n");
boost::uintmax_t downloadedSize=0;
boost::uintmax_t speedSum=0;
float timerunning = dlStartTime.elapsed();
@@ -184,19 +184,19 @@
updateCallback(MSE_UPDATE_PATH, ipath.string());
- LOG("DLFile-TP| getSyncData\n");
+ //LOG("DLFile-TP| getSyncData\n");
getSyncData();
updateCallback(MSE_UPDATE_TITLE, "Downloading ...");
- LOG("DLFile-TP| sync\n");
+ //LOG("DLFile-TP| sync\n");
sync();
- LOG("DLFile-TP| recordDataUsage\n");
+ //LOG("DLFile-TP| recordDataUsage\n");
recordDataUsage();
updateCallback(MSE_UPDATE_TITLE, "Finished!");
- LOG("DLFile-TP| DONE\n");
+ //LOG("DLFile-TP| DONE\n");
return (WsyncThread::ExitCode)0; // success
}
@@ -834,7 +834,7 @@
void WsyncThread::addJob(wxString localFile, wxString remoteDir, wxString
remoteServer, wxString remoteFile, wxString hashRemoteFile, wxString
localFilename, boost::uintmax_t filesize)
{
- LOG("DLFile-TP| addJob %d = %s, %s\n", dlNum, conv(localFile).c_str(),
conv(remoteFile).c_str());
+ //LOG("DLFile-TP| addJob %d = %s, %s\n", dlNum,
conv(localFile).c_str(), conv(remoteFile).c_str());
dlStatus[dlNum].downloaded=0;
dlStatus[dlNum].percent=0;
dlStatus[dlNum].speed=0;
Modified: trunk/source/installer/wthread.h
===================================================================
--- trunk/source/installer/wthread.h 2011-01-16 21:34:19 UTC (rev 1572)
+++ trunk/source/installer/wthread.h 2011-01-17 09:52:46 UTC (rev 1573)
@@ -27,7 +27,7 @@
#define API_MIRROR_NOGEO "/getwsyncmirror/?ignoregeo"
#define API_RECORDTRAFFIC "/reporttraffic/?mirror=%s&bytes=%d"
#define API_REPOSEARCH "/reposearch/"
-#define API_CHINSTALLER "/checkinstallerupdate/?h=%s&platform=%s"
+#define API_CHINSTALLER
"/checkinstallerupdate2/?h=%s&platform=%s&version=%s"
#define REPO_DOWNLOAD "/files/mirror/geoselect/"
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Rigsofrods-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel