1 /* PoorManWindow.h 2 * 3 * Philip Harrison 4 * Started: 4/25/2004 5 * Version: 0.1 6 */ 7 8 #ifndef POOR_MAN_WINDOW_H 9 #define POOR_MAN_WINDOW_H 10 11 #include <pthread.h> 12 13 #include <SupportDefs.h> 14 #include <Window.h> 15 #include <String.h> 16 17 class BPoint; 18 class BFilePanel; 19 class BMessage; 20 class BMenuBar; 21 class BMenu; 22 class BTextView; 23 class BStringView; 24 class BScrollView; 25 class BRect; 26 class BFile; 27 class BFont; 28 29 class PoorManView; 30 class PoorManPreferencesWindow; 31 class PoorManServer; 32 33 class PoorManWindow: public BWindow 34 { 35 public: 36 PoorManWindow(BRect frame); 37 virtual ~PoorManWindow(); 38 virtual void MessageReceived(BMessage* message); 39 40 virtual void FrameMoved(BPoint origin); 41 virtual void FrameResized(float width, float height); 42 virtual bool QuitRequested(); 43 virtual void Zoom(BPoint origin, float width, float height); 44 45 // ------------------------------------------- 46 // Public PoorMan Window Methods 47 void SetDirLabel(const char* name); 48 void SetHits(uint32 num); GetHits()49 uint32 GetHits() { return fHits; } 50 status_t SaveConsole(BMessage* message, bool); 51 52 status_t SaveSettings(); 53 status_t ReadSettings(); 54 void DefaultSettings(); 55 56 status_t StartServer(); 57 status_t StopServer(); 58 GetServer()59 PoorManServer* GetServer() const { return fServer;} 60 // ------------------------------------------- 61 // Preferences and Settings 62 // Site Tab DirListFlag()63 bool DirListFlag() 64 { 65 return fDirListFlag; 66 } 67 SetDirListFlag(bool flag)68 void SetDirListFlag(bool flag) 69 { 70 fDirListFlag = flag; 71 } 72 IndexFileName()73 const char* IndexFileName() 74 { 75 return fIndexFileName.String(); 76 } 77 SetIndexFileName(const char * str)78 void SetIndexFileName(const char* str) 79 { 80 fIndexFileName.SetTo(str); 81 } 82 WebDir()83 const char* WebDir() 84 { 85 return fWebDirectory.String(); 86 } 87 SetWebDir(const char * str)88 void SetWebDir(const char* str) 89 { 90 fWebDirectory.SetTo(str); 91 } 92 93 // Logging Tab 94 LogConsoleFlag()95 bool LogConsoleFlag() 96 { 97 return fLogConsoleFlag; 98 } 99 SetLogConsoleFlag(bool flag)100 void SetLogConsoleFlag(bool flag) 101 { 102 fLogConsoleFlag = flag; 103 } 104 LogFileFlag()105 bool LogFileFlag() 106 { 107 return fLogFileFlag; 108 } 109 SetLogFileFlag(bool flag)110 void SetLogFileFlag(bool flag) 111 { 112 fLogFileFlag = flag; 113 } 114 LogPath()115 const char* LogPath() 116 { 117 return fLogPath.String(); 118 } 119 120 void SetLogPath(const char* str); 121 122 // Advanced Tab MaxConnections()123 int16 MaxConnections() 124 { 125 return fMaxConnections; 126 } 127 SetMaxConnections(int16 num)128 void SetMaxConnections(int16 num) 129 { 130 fMaxConnections = num; 131 } 132 133 private: 134 // ------------------------------------------- 135 // PoorMan Window Methods 136 void UpdateStatusLabelAndMenuItem(); 137 void UpdateHitsLabel(); 138 139 private: 140 // ------------------------------------------- 141 // Build Menu Methods 142 BMenu* BuildFileMenu() const; 143 BMenu* BuildEditMenu() const; 144 BMenu* BuildControlsMenu() const; 145 146 // -------------------------------------------- 147 // MenuBar & Menu items 148 BMenuBar* fFileMenuBar; 149 BMenu* fFileMenu; 150 BMenu* fEditMenu; 151 BMenu* fControlsMenu; 152 153 // -------------------------------------------- 154 // Status, Hits, Directory 155 BStringView* fStatusView; 156 BStringView* fHitsView; 157 BStringView* fDirView; 158 159 bool fStatus; 160 uint32 fHits; 161 char fHitsLabel[25]; 162 163 // -------------------------------------------- 164 // Logging View 165 BScrollView* fScrollView; 166 BTextView* fLoggingView; 167 // use asctime() for format of [Date/Time]: 168 169 170 // ------------------------------------------- 171 // PoorMan Preference Window 172 PoorManPreferencesWindow * fPrefWindow; 173 174 // site tab 175 BString fWebDirectory; 176 BString fIndexFileName; 177 bool fDirListFlag; 178 179 // logging tab 180 bool fLogConsoleFlag; 181 bool fLogFileFlag; 182 BString fLogPath; 183 184 // advanced tab 185 int16 fMaxConnections; 186 187 bool fIsZoomed; 188 float fLastWidth; 189 float fLastHeight; 190 BRect fFrame; 191 BRect fSetwindowFrame; 192 193 // File Panels 194 BFilePanel* fSaveConsoleFilePanel; 195 BFilePanel* fSaveConsoleSelectionFilePanel; 196 197 BFile* fLogFile; 198 199 PoorManServer* fServer; 200 201 pthread_rwlock_t fLogFileLock; 202 }; 203 204 #endif 205