1 /* 2 * Copyright 2003, Michael Phipps. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef SCREEN_SAVER_WINDOW_H 6 #define SCREEN_SAVER_WINDOW_H 7 8 9 #include "ScreenSaver.h" 10 11 #include <DirectWindow.h> 12 #include <MessageFilter.h> 13 14 15 const static uint32 kMsgEnableFilter = 'eflt'; 16 17 18 class ScreenSaverFilter : public BMessageFilter { 19 public: 20 ScreenSaverFilter() 21 : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), 22 fEnabled(true) {} 23 24 virtual filter_result Filter(BMessage* message, BHandler** target); 25 26 void SetEnabled(bool enabled); 27 28 private: 29 bool fEnabled; 30 }; 31 32 33 class ScreenSaverWindow : public BDirectWindow { 34 public: 35 ScreenSaverWindow(BRect frame); 36 ~ScreenSaverWindow(); 37 38 void SetSaver(BScreenSaver *saver); 39 40 virtual void MessageReceived(BMessage *message); 41 virtual bool QuitRequested(); 42 virtual void DirectConnected(direct_buffer_info *info); 43 44 private: 45 BView *fTopView; 46 BScreenSaver *fSaver; 47 ScreenSaverFilter *fFilter; 48 }; 49 50 #endif // SCREEN_SAVER_WINDOW_H 51