xref: /haiku/src/apps/poorman/PoorManLoggingView.cpp (revision bc3955fea5b07e2e94a27fc05e4bb58fe6f0319b)
1 /* PoorManLoggingView.cpp
2  *
3  *	Philip Harrison
4  *	Started: 5/12/2004
5  *	Version: 0.1
6  */
7 
8 #include <Box.h>
9 
10 #include "constants.h"
11 #include "PoorManWindow.h"
12 #include "PoorManApplication.h"
13 #include "PoorManLoggingView.h"
14 
15 PoorManLoggingView::PoorManLoggingView(BRect rect, const char *name)
16 	: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
17 {
18 	PoorManWindow	*	win;
19 	win = ((PoorManApplication *)be_app)->GetPoorManWindow();
20 
21 	SetViewColor(BACKGROUND_COLOR);
22 
23 	// Console Logging BBox
24 	BRect consoleLoggingRect;
25 	consoleLoggingRect = rect;
26 	consoleLoggingRect.top -= 5.0;
27 	consoleLoggingRect.left -= 5.0;
28 	consoleLoggingRect.right -= 7.0;
29 	consoleLoggingRect.bottom -= 118.0;
30 
31 	BBox * consoleLogging = new BBox(consoleLoggingRect, "Console Logging");
32 	consoleLogging->SetLabel(STR_BBX_CONSOLE_LOGGING);
33 	AddChild(consoleLogging);
34 
35 
36 	// File Logging BBox
37 	BRect fileLoggingRect;
38 	fileLoggingRect = consoleLoggingRect;
39 	fileLoggingRect.top = consoleLoggingRect.bottom + 10.0;
40 	fileLoggingRect.bottom = fileLoggingRect.top + 100.0;
41 
42 	BBox * fileLogging = new BBox(fileLoggingRect, "File Logging");
43 	fileLogging->SetLabel(STR_BBX_FILE_LOGGING);
44 	AddChild(fileLogging);
45 
46 	float left = 10.0;
47 	float top = 20.0;
48 	float box_size = 13.0;
49 	BRect tempRect(left, top, consoleLoggingRect.Width() - 5.0, top + box_size);
50 
51 	// Console Logging
52 	logConsole = new BCheckBox(tempRect, "Log To Console", STR_CBX_LOG_CONSOLE, new BMessage(MSG_PREF_LOG_CBX_CONSOLE));
53 	// set the checkbox to the value the program has
54 	SetLogConsoleValue(win->LogConsoleFlag());
55 	consoleLogging->AddChild(logConsole);
56 
57 	// File Logging
58 	logFile = new BCheckBox(tempRect, "Log To File", STR_CBX_LOG_FILE, new BMessage(MSG_PREF_LOG_CBX_FILE));
59 	// set the checkbox to the value the program has
60 	SetLogFileValue(win->LogFileFlag());
61 	fileLogging->AddChild(logFile);
62 
63 	// File Name
64 	tempRect.top = tempRect.bottom + 10.0;
65 	tempRect.bottom = tempRect.top + box_size;
66 	tempRect.right -= 5.0;
67 
68 	logFileName = new BTextControl(tempRect, "File Name", STR_TXT_LOG_FILE_NAME, NULL, NULL);
69 	logFileName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
70 	logFileName->SetDivider(73.0);
71 	SetLogFileName(win->LogPath());
72 	fileLogging->AddChild(logFileName);
73 
74 	// Create Log File
75 	BRect createLogFileRect;
76 	createLogFileRect.top = tempRect.bottom + 13.0;
77 	createLogFileRect.right = tempRect.right + 2.0;
78 	createLogFileRect.left = createLogFileRect.right - 87.0;
79 	createLogFileRect.bottom = createLogFileRect.top + 19.0;
80 
81 	createLogFile = new BButton(createLogFileRect, "Create Log File", STR_BTN_CREATE_LOG_FILE, new BMessage(MSG_PREF_LOG_BTN_CREATE_FILE));
82 	fileLogging->AddChild(createLogFile);
83 
84 }
85