xref: /haiku/src/apps/poorman/PoorManWindow.h (revision 25a7b01d15612846f332751841da3579db313082)
14af8c448SPhil Greenway /* PoorManWindow.h
24af8c448SPhil Greenway  *
34af8c448SPhil Greenway  *	Philip Harrison
44af8c448SPhil Greenway  *	Started: 4/25/2004
54af8c448SPhil Greenway  *	Version: 0.1
64af8c448SPhil Greenway  */
74af8c448SPhil Greenway 
84af8c448SPhil Greenway #ifndef POOR_MAN_WINDOW_H
94af8c448SPhil Greenway #define POOR_MAN_WINDOW_H
104af8c448SPhil Greenway 
11000fe088SStephan Aßmus #include <pthread.h>
124af8c448SPhil Greenway 
13000fe088SStephan Aßmus #include <SupportDefs.h>
14000fe088SStephan Aßmus #include <Window.h>
15000fe088SStephan Aßmus #include <String.h>
16000fe088SStephan Aßmus 
17000fe088SStephan Aßmus class BPoint;
18000fe088SStephan Aßmus class BFilePanel;
19000fe088SStephan Aßmus class BMessage;
20000fe088SStephan Aßmus class BMenuBar;
21000fe088SStephan Aßmus class BMenu;
22000fe088SStephan Aßmus class BTextView;
23000fe088SStephan Aßmus class BStringView;
24000fe088SStephan Aßmus class BScrollView;
25000fe088SStephan Aßmus class BRect;
26000fe088SStephan Aßmus class BFile;
27000fe088SStephan Aßmus class BFont;
28000fe088SStephan Aßmus 
29000fe088SStephan Aßmus class PoorManView;
30000fe088SStephan Aßmus class PoorManPreferencesWindow;
31000fe088SStephan Aßmus class PoorManServer;
324af8c448SPhil Greenway 
334af8c448SPhil Greenway class PoorManWindow: public BWindow
344af8c448SPhil Greenway {
354af8c448SPhil Greenway public:
364af8c448SPhil Greenway 							PoorManWindow(BRect frame);
37000fe088SStephan Aßmus 	virtual					~PoorManWindow();
384af8c448SPhil Greenway 	virtual	void			MessageReceived(BMessage* message);
394af8c448SPhil Greenway 
40000fe088SStephan Aßmus 	virtual void			FrameMoved(BPoint origin);
414af8c448SPhil Greenway 	virtual	void			FrameResized(float width, float height);
424af8c448SPhil Greenway 	virtual	bool			QuitRequested();
434af8c448SPhil Greenway 	virtual	void			Zoom(BPoint origin, float width, float height);
444af8c448SPhil Greenway 
454af8c448SPhil Greenway 	// -------------------------------------------
464af8c448SPhil Greenway 	// Public PoorMan Window Methods
474af8c448SPhil Greenway 			void			SetDirLabel(const char* name);
48000fe088SStephan Aßmus 			void			SetHits(uint32 num);
GetHits()49a1ae8022SAlex Wilson 			uint32			GetHits() { return fHits; }
504af8c448SPhil Greenway 			status_t		SaveConsole(BMessage* message, bool);
514af8c448SPhil Greenway 
52000fe088SStephan Aßmus 			status_t		SaveSettings();
53000fe088SStephan Aßmus 			status_t		ReadSettings();
54000fe088SStephan Aßmus 			void			DefaultSettings();
55000fe088SStephan Aßmus 
56000fe088SStephan Aßmus 			status_t		StartServer();
57000fe088SStephan Aßmus 			status_t		StopServer();
58000fe088SStephan Aßmus 
GetServer()59000fe088SStephan Aßmus 			PoorManServer* 	GetServer() const { return fServer;}
604af8c448SPhil Greenway 	// -------------------------------------------
614af8c448SPhil Greenway 	// Preferences and Settings
624af8c448SPhil Greenway 		// Site Tab
DirListFlag()63a1ae8022SAlex Wilson 	bool DirListFlag()
64*0a96da93SAlex Wilson 	{
65*0a96da93SAlex Wilson 		return fDirListFlag;
66*0a96da93SAlex Wilson 	}
67*0a96da93SAlex Wilson 
SetDirListFlag(bool flag)68a1ae8022SAlex Wilson 	void SetDirListFlag(bool flag)
69*0a96da93SAlex Wilson 	{
70*0a96da93SAlex Wilson 		fDirListFlag = flag;
71*0a96da93SAlex Wilson 	}
72*0a96da93SAlex Wilson 
IndexFileName()73a1ae8022SAlex Wilson 	const char* IndexFileName()
74*0a96da93SAlex Wilson 	{
75*0a96da93SAlex Wilson 		return fIndexFileName.String();
76*0a96da93SAlex Wilson 	}
77*0a96da93SAlex Wilson 
SetIndexFileName(const char * str)78a1ae8022SAlex Wilson 	void SetIndexFileName(const char* str)
79*0a96da93SAlex Wilson 	{
80*0a96da93SAlex Wilson 		fIndexFileName.SetTo(str);
81*0a96da93SAlex Wilson 	}
82*0a96da93SAlex Wilson 
WebDir()83a1ae8022SAlex Wilson 	const char*	WebDir()
84*0a96da93SAlex Wilson 	{
85*0a96da93SAlex Wilson 		return fWebDirectory.String();
86*0a96da93SAlex Wilson 	}
87*0a96da93SAlex Wilson 
SetWebDir(const char * str)88a1ae8022SAlex Wilson 	void SetWebDir(const char* str)
89*0a96da93SAlex Wilson 	{
90*0a96da93SAlex Wilson 		fWebDirectory.SetTo(str);
91*0a96da93SAlex Wilson 	}
92*0a96da93SAlex Wilson 
934af8c448SPhil Greenway 	// Logging Tab
94*0a96da93SAlex Wilson 
LogConsoleFlag()95a1ae8022SAlex Wilson 	bool LogConsoleFlag()
96*0a96da93SAlex Wilson 	{
97*0a96da93SAlex Wilson 		return fLogConsoleFlag;
98*0a96da93SAlex Wilson 	}
99*0a96da93SAlex Wilson 
SetLogConsoleFlag(bool flag)100a1ae8022SAlex Wilson 	void SetLogConsoleFlag(bool flag)
101*0a96da93SAlex Wilson 	{
102*0a96da93SAlex Wilson  		fLogConsoleFlag = flag;
103*0a96da93SAlex Wilson 	}
104*0a96da93SAlex Wilson 
LogFileFlag()105a1ae8022SAlex Wilson 	bool LogFileFlag()
106*0a96da93SAlex Wilson 	{
107*0a96da93SAlex Wilson 		return fLogFileFlag;
108*0a96da93SAlex Wilson 	}
109*0a96da93SAlex Wilson 
SetLogFileFlag(bool flag)110a1ae8022SAlex Wilson 	void SetLogFileFlag(bool flag)
111*0a96da93SAlex Wilson 	{
112*0a96da93SAlex Wilson 		fLogFileFlag = flag;
113*0a96da93SAlex Wilson 	}
114*0a96da93SAlex Wilson 
LogPath()115a1ae8022SAlex Wilson 	const char* LogPath()
116*0a96da93SAlex Wilson 	{
117*0a96da93SAlex Wilson 		return fLogPath.String();
118*0a96da93SAlex Wilson 	}
119*0a96da93SAlex Wilson 
120000fe088SStephan Aßmus 			void SetLogPath(const char* str);
121*0a96da93SAlex Wilson 
1224af8c448SPhil Greenway 	// Advanced Tab
MaxConnections()123a1ae8022SAlex Wilson 	int16 MaxConnections()
124*0a96da93SAlex Wilson 	{
125*0a96da93SAlex Wilson  		return fMaxConnections;
126*0a96da93SAlex Wilson 	}
127*0a96da93SAlex Wilson 
SetMaxConnections(int16 num)128a1ae8022SAlex Wilson 	void SetMaxConnections(int16 num)
129*0a96da93SAlex Wilson 	{
130*0a96da93SAlex Wilson 		fMaxConnections = num;
131*0a96da93SAlex Wilson 	}
1324af8c448SPhil Greenway 
1334af8c448SPhil Greenway private:
1344af8c448SPhil Greenway 	// -------------------------------------------
1354af8c448SPhil Greenway 	// PoorMan Window Methods
136000fe088SStephan Aßmus 			void			UpdateStatusLabelAndMenuItem();
1374af8c448SPhil Greenway 			void			UpdateHitsLabel();
1384af8c448SPhil Greenway 
1394af8c448SPhil Greenway private:
1404af8c448SPhil Greenway 	// -------------------------------------------
1414af8c448SPhil Greenway 	// Build Menu Methods
1424af8c448SPhil Greenway 			BMenu*			BuildFileMenu() const;
1434af8c448SPhil Greenway 			BMenu*			BuildEditMenu() const;
1444af8c448SPhil Greenway 			BMenu*			BuildControlsMenu() const;
1454af8c448SPhil Greenway 
1464af8c448SPhil Greenway 	// --------------------------------------------
1474af8c448SPhil Greenway 	// MenuBar & Menu items
148a1ae8022SAlex Wilson 			BMenuBar*		fFileMenuBar;
149a1ae8022SAlex Wilson 			BMenu*			fFileMenu;
150a1ae8022SAlex Wilson 			BMenu*			fEditMenu;
151a1ae8022SAlex Wilson 			BMenu*			fControlsMenu;
1524af8c448SPhil Greenway 
1534af8c448SPhil Greenway 	// --------------------------------------------
1544af8c448SPhil Greenway 	// Status, Hits, Directory
155a1ae8022SAlex Wilson 			BStringView*	fStatusView;
156a1ae8022SAlex Wilson 			BStringView*	fHitsView;
157a1ae8022SAlex Wilson 			BStringView*	fDirView;
1584af8c448SPhil Greenway 
159a1ae8022SAlex Wilson 			bool			fStatus;
160a1ae8022SAlex Wilson 			uint32			fHits;
161a1ae8022SAlex Wilson 			char			fHitsLabel[25];
1624af8c448SPhil Greenway 
1634af8c448SPhil Greenway 	// --------------------------------------------
1644af8c448SPhil Greenway 	// Logging View
165a1ae8022SAlex Wilson 			BScrollView*	fScrollView;
166a1ae8022SAlex Wilson 			BTextView*		fLoggingView;
1674af8c448SPhil Greenway 	// use asctime() for format of [Date/Time]:
1684af8c448SPhil Greenway 
1694af8c448SPhil Greenway 
1704af8c448SPhil Greenway 	// -------------------------------------------
1714af8c448SPhil Greenway 	// PoorMan Preference Window
172a1ae8022SAlex Wilson 			PoorManPreferencesWindow * fPrefWindow;
1734af8c448SPhil Greenway 
1744af8c448SPhil Greenway 	// site tab
175a1ae8022SAlex Wilson 			BString			fWebDirectory;
176a1ae8022SAlex Wilson 			BString			fIndexFileName;
177a1ae8022SAlex Wilson 			bool			fDirListFlag;
1784af8c448SPhil Greenway 
1794af8c448SPhil Greenway 	// logging tab
180a1ae8022SAlex Wilson 			bool			fLogConsoleFlag;
181a1ae8022SAlex Wilson 			bool			fLogFileFlag;
182a1ae8022SAlex Wilson 			BString			fLogPath;
183000fe088SStephan Aßmus 
1844af8c448SPhil Greenway 	// advanced tab
185a1ae8022SAlex Wilson 			int16			fMaxConnections;
1864af8c448SPhil Greenway 
187a1ae8022SAlex Wilson 			bool			fIsZoomed;
188a1ae8022SAlex Wilson 			float			fLastWidth;
189a1ae8022SAlex Wilson 			float			fLastHeight;
190a1ae8022SAlex Wilson 			BRect			fFrame;
191a1ae8022SAlex Wilson 			BRect			fSetwindowFrame;
1924af8c448SPhil Greenway 
1934af8c448SPhil Greenway 	// File Panels
194a1ae8022SAlex Wilson 			BFilePanel*		fSaveConsoleFilePanel;
195a1ae8022SAlex Wilson 			BFilePanel*		fSaveConsoleSelectionFilePanel;
1964af8c448SPhil Greenway 
197000fe088SStephan Aßmus 			BFile* 			fLogFile;
198000fe088SStephan Aßmus 
199000fe088SStephan Aßmus 			PoorManServer*	fServer;
200000fe088SStephan Aßmus 
201000fe088SStephan Aßmus 			pthread_rwlock_t fLogFileLock;
2024af8c448SPhil Greenway };
2034af8c448SPhil Greenway 
2044af8c448SPhil Greenway #endif
205