00001 #include <os/OS.h>
00002 #include <gui/GUI.h>
00003
00004 using namespace SkyGI;
00005 class TestView : public View
00006 {
00007 public:
00008 TestView(Window *pParent, const Rect &rFrame, unsigned int nWindowLayoutFlags);
00009 };
00010
00011 TestView::TestView(Window *pParent, const Rect &rFrame, unsigned int nWindowLayoutFlags) : View(pParent, rFrame, nWindowLayoutFlags)
00012 {
00013 }
00014
00015 class MyApp : public Application
00016 {
00017 public:
00018 MyApp(int argc, char *argv[]);
00019
00020 void ReceivedMessage(DesktopCommunicationInterface* pInterface, DesktopCommunicationMessage* pMessage)
00021 {
00022 printf("Received a DesktopCommunicationMessage!\n");
00023 }
00024
00025 void StdinAvailable(int iFd, unsigned int uiFlags)
00026 {
00027 char ch;
00028 int iSize = 0;
00029
00030
00031
00032 fcntl(iFd, F_SETFL, O_NONBLOCK);
00033
00034 while (read(iFd, &ch, 1)>0) iSize++;
00035
00036 printf("Stdin data avilable! (%d byte)\n",iSize);
00037 }
00038
00039 private:
00040 };
00041
00042
00043 MyApp::MyApp(int argc, char *argv[]) : Application("sink", argc, argv)
00044 {
00045 Rect r(Point(100, 100), Point(500, 440));
00046 int fd = 0;
00047
00048
00049
00050
00051 DesktopCommunicationInterface *pInterface = new DesktopCommunicationInterface("test", true);
00052 pInterface->Received.Connect(this, &MyApp::ReceivedMessage);
00053
00054 EventSourceDesktopCommunication *pEventSourceDesktopCommunication = new EventSourceDesktopCommunication(pInterface);
00055 Application::GetInstance()->GetEventQueue()->AddSource(pEventSourceDesktopCommunication );
00056
00057
00058
00059
00060 EventSourceFile *pEventSourceFile = new EventSourceFile(fd, EVENT_SOURCE_FILE_READ);
00061 pEventSourceFile->Available.Connect(this, &MyApp::StdinAvailable);
00062 Application::GetInstance()->GetEventQueue()->AddSource(pEventSourceFile);
00063
00064
00065 ApplicationWindow* pApplicationWindow = new ApplicationWindow(r, "DesktopCommunicationTest", WINDOW_LAYOUT_NOTHING, APPLICATION_WINDOW_NO_VIEW);
00066
00067 pApplicationWindow->GetTitleWindow()->SetFlags( (TitleWindowFlags)(pApplicationWindow->GetTitleWindow()->GetFlags() ));
00068 pApplicationWindow->AttachView(new TestView(pApplicationWindow, pApplicationWindow->GetClientRect(), WINDOW_LAYOUT_NOTHING));
00069 pApplicationWindow->Show();
00070 }
00071
00072 int main(int argc, char *argv[])
00073 {
00074 MyApp pApp(argc, argv);
00075
00076 return pApp.Run();
00077
00078
00079 }
00080