1 2 #include <stdio.h> 3 4 #include <Message.h> 5 6 #include "Desktop.h" 7 8 #include "DrawView.h" 9 10 // constructor DrawView(BRect frame)11DrawView::DrawView(BRect frame) 12 : BView(frame, "desktop", B_FOLLOW_ALL, 0), 13 fDesktop(NULL) 14 { 15 SetViewColor(B_TRANSPARENT_COLOR); 16 } 17 18 // destructor ~DrawView()19DrawView::~DrawView() 20 { 21 } 22 23 // MouseDown 24 void MouseDown(BPoint where)25DrawView::MouseDown(BPoint where) 26 { 27 SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); 28 29 fDesktop->PostMessage(Window()->CurrentMessage()); 30 } 31 32 // MouseUp 33 void MouseUp(BPoint where)34DrawView::MouseUp(BPoint where) 35 { 36 fDesktop->PostMessage(Window()->CurrentMessage()); 37 } 38 39 // MouseMoved 40 void MouseMoved(BPoint where,uint32 code,const BMessage * dragMessage)41DrawView::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage) 42 { 43 fDesktop->PostMessage(Window()->CurrentMessage()); 44 } 45 46 // SetDesktop 47 void SetDesktop(Desktop * desktop)48DrawView::SetDesktop(Desktop* desktop) 49 { 50 fDesktop = desktop; 51 } 52 53 54