Usermode/AxWin4 - Added text rendering (very hacky using VGA font)
[tpg/acess2.git] / Usermode / Applications / axwin4_src / Server / CClient.cpp
1 /*
2  * Acess2 GUI v4
3  * - By John Hodge (thePowersGang)
4  *
5  * CClient.cpp
6  * - IPC Client
7  */
8 #include <CClient.hpp>
9 #include <IIPCChannel.hpp>
10 #include <ipc.hpp>
11 #include <draw_text.hpp>        // for the fonts
12
13 namespace AxWin {
14
15 CClient::CClient(::AxWin::IIPCChannel& channel):
16         m_channel(channel),
17         m_id(0)
18 {
19         
20 }
21
22 CClient::~CClient()
23 {
24         ::AxWin::IPC::DeregisterClient(*this);
25 }
26
27 CWindow* CClient::GetWindow(int ID)
28 {
29         try {
30                 return m_windows.at(ID);
31         }
32         catch(const std::exception& e) {
33                 return NULL;
34         }
35 }
36
37 void CClient::SetWindow(int ID, CWindow* window)
38 {
39         //_SysDebug("SetWindow(ID=%i,window=%p)", ID, window);
40         auto it = m_windows.find(ID);
41         if( it != m_windows.end() ) {
42                 _SysDebug("CLIENT BUG: Window ID %i is already used by %p", ID, it->second);
43         }
44         else {
45                 m_windows[ID] = window;
46         }
47 }
48
49 IFontFace& CClient::GetFont(unsigned int id)
50 {
51         static CFontFallback    fallback_font;
52         if( id == 0 ) {
53                 _SysDebug("GetFont: %i = %p", id, &fallback_font);
54                 return fallback_font;
55         }
56         assert(!"TODO: CClient::GetFont id != 0");
57 }
58
59 void CClient::HandleMessage(CDeserialiser& message)
60 {
61         try {
62                 IPC::HandleMessage(*this, message);
63                 if( !message.IsConsumed() )
64                 {
65                         _SysDebug("NOTICE - CClient::HandleMessage - Trailing data in message");
66                 }
67         }
68         catch( const ::std::exception& e )
69         {
70                 _SysDebug("ERROR - Exception while processing message from client: %s", e.what());
71         }
72         catch( ... )
73         {
74                 _SysDebug("ERROR - Unknown exception while processing message from client");
75         }
76 }
77
78 };      // namespace AxWin
79

UCC git Repository :: git.ucc.asn.au