Patch level : 2.0 470
Files correlati : servers a 32 bit Ricompilazione Demo : [ ] Commento : Aggiunta gestione icona sulla task bar git-svn-id: svn://10.65.10.50/trunk@11141 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c7c053c2ea
commit
8ee98b279a
@ -19,6 +19,7 @@
|
||||
#include "BaseServ.h"
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/mimetype.h>
|
||||
#include <wx/sckstrm.h>
|
||||
#include <wx/msw/iniconf.h>
|
||||
@ -29,6 +30,11 @@
|
||||
// Utilities
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TBaseServerApp& GetServerApp()
|
||||
{
|
||||
return (TBaseServerApp&)*wxTheApp;
|
||||
}
|
||||
|
||||
wxString Date2String(const wxDateTime& date)
|
||||
{
|
||||
return date.Format("%d-%m-%Y");
|
||||
@ -89,15 +95,48 @@ THashTable::THashTable(size_t size) : m_Hash(wxKEY_STRING, size)
|
||||
m_Hash.DeleteContents(true);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TTaskbarIcon
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
BEGIN_EVENT_TABLE(TTaskBarIcon, wxTaskBarIcon)
|
||||
EVT_TASKBAR_LEFT_DOWN(TTaskBarIcon::OnTaskBarClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void TTaskBarIcon::OnTaskBarClick(wxTaskBarIconEvent& e)
|
||||
{
|
||||
wxString url;
|
||||
url << "http://127.0.0.1:" << GetServerApp().GetDefaultPort();
|
||||
::ShellExecute(0, "open", url, NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
void TTaskBarIcon::Init()
|
||||
{
|
||||
const TBaseServerApp& a = GetServerApp();
|
||||
wxIcon icon;
|
||||
|
||||
const wxString strIcon = a.GetConfigString("Icon");
|
||||
if (wxFileExists(strIcon))
|
||||
{
|
||||
wxInitAllImageHandlers();
|
||||
wxImage img(strIcon);
|
||||
img.Rescale(32,32);
|
||||
icon.CopyFromBitmap(img.ConvertToBitmap());
|
||||
}
|
||||
else
|
||||
icon.LoadFile("mondrian", wxBITMAP_TYPE_ICO_RESOURCE);
|
||||
|
||||
SetIcon(icon, a.GetAppName());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TBaseServerApp
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TBaseServerApp& GetServerApp()
|
||||
{
|
||||
return (TBaseServerApp&)*wxTheApp;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
SERVER_ID = 1001,
|
||||
@ -542,6 +581,10 @@ bool TBaseServerApp::OnInit()
|
||||
if (ok)
|
||||
ok = Initialization();
|
||||
|
||||
#ifdef WIN32
|
||||
if (ok) m_Tray.Init();
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <wx/snglinst.h>
|
||||
#include <wx/socket.h>
|
||||
#include <wx/wfstream.h>
|
||||
|
||||
#include "xml.h"
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
@ -48,6 +49,26 @@ public:
|
||||
THashTable(size_t size = 13);
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// TTaskbarIcon
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef WIN32
|
||||
#include <wx/taskbar.h>
|
||||
|
||||
class TTaskBarIcon : public wxTaskBarIcon
|
||||
{
|
||||
protected:
|
||||
void OnTaskBarClick(wxTaskBarIconEvent& e);
|
||||
|
||||
public:
|
||||
void TTaskBarIcon::Init();
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// TBaseServerApp
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -62,16 +83,18 @@ private:
|
||||
bool m_bRunning;
|
||||
int m_nTmpCounter;
|
||||
|
||||
#ifdef WIN32
|
||||
TTaskBarIcon m_Tray;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
wxSingleInstanceChecker* m_SingleInstance;
|
||||
|
||||
// Pure virtual functions!
|
||||
virtual const wxChar* GetAppName() const = 0;
|
||||
virtual void ProcessCommand(wxString cmd, wxSocketBase& outs) = 0;
|
||||
|
||||
virtual bool CanProcessCommand(wxString& cmd, wxSocketBase& outs);
|
||||
|
||||
virtual int GetDefaultPort() const; // Retrieves Port usig GetConfigInt
|
||||
virtual wxString GetDocumentRoot() const;
|
||||
|
||||
virtual TXmlItem& AddLogo(TXmlItem& td) const;
|
||||
@ -82,7 +105,9 @@ protected:
|
||||
|
||||
public:
|
||||
// Utilities
|
||||
virtual const wxChar* GetAppName() const = 0;
|
||||
virtual const wxChar* GetConfigName() const;
|
||||
virtual int GetDefaultPort() const; // Retrieves Port usig GetConfigInt
|
||||
virtual void SetConfigString(const wxChar* key, const wxChar* val, const wxChar* app = NULL) const;
|
||||
|
||||
void SetConfigInt(const wxChar* key, int val, const wxChar* app = NULL) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user