xref: /haiku/src/apps/poorman/PoorManLoggingView.cpp (revision c302a243e15e640fae0f689e32cdf0c18749afee)
1 /* PoorManLoggingView.cpp
2  *
3  *	Philip Harrison
4  *	Started: 5/12/2004
5  *	Version: 0.1
6  */
7 
8 #include <Box.h>
9 #include <Catalog.h>
10 #include <LayoutBuilder.h>
11 #include <Locale.h>
12 
13 #include "constants.h"
14 #include "PoorManWindow.h"
15 #include "PoorManApplication.h"
16 #include "PoorManLoggingView.h"
17 
18 
19 #undef B_TRANSLATION_CONTEXT
20 #define B_TRANSLATION_CONTEXT "PoorMan"
21 
22 
PoorManLoggingView(const char * name)23 PoorManLoggingView::PoorManLoggingView(const char* name)
24 	:
25 	BView(name, B_WILL_DRAW, NULL)
26 {
27 	PoorManWindow* win;
28 	win = ((PoorManApplication*)be_app)->GetPoorManWindow();
29 
30 	BBox* consoleLogging = new BBox(B_TRANSLATE("Console Logging"));
31 	consoleLogging->SetLabel(STR_BBX_CONSOLE_LOGGING);
32 
33 	// File Logging BBox
34 	BBox* fileLogging = new BBox(B_TRANSLATE("File Logging"));
35 	fileLogging->SetLabel(STR_BBX_FILE_LOGGING);
36 
37 	// Console Logging
38 	fLogConsole = new BCheckBox(B_TRANSLATE("Log To Console"),
39 		STR_CBX_LOG_CONSOLE, new BMessage(MSG_PREF_LOG_CBX_CONSOLE));
40 	// set the checkbox to the value the program has
41 	SetLogConsoleValue(win->LogConsoleFlag());
42 
43 	// File Logging
44 	fLogFile = new BCheckBox(B_TRANSLATE("Log To File"), STR_CBX_LOG_FILE,
45 		new BMessage(MSG_PREF_LOG_CBX_FILE));
46 	// set the checkbox to the value the program has
47 	SetLogFileValue(win->LogFileFlag());
48 
49 	// File Name
50 	fLogFileName = new BTextControl(B_TRANSLATE("File Name"),
51 		STR_TXT_LOG_FILE_NAME, NULL, NULL);
52 	SetLogFileName(win->LogPath());
53 
54 	// Create Log File
55 	fCreateLogFile = new BButton(B_TRANSLATE("Create Log File"),
56 		STR_BTN_CREATE_LOG_FILE, new BMessage(MSG_PREF_LOG_BTN_CREATE_FILE));
57 
58 	BGroupLayout* consoleLoggingLayout = new BGroupLayout(B_VERTICAL, 0);
59 	consoleLogging->SetLayout(consoleLoggingLayout);
60 
61 	BGroupLayout* fileLoggingLayout = new BGroupLayout(B_VERTICAL,
62 		B_USE_SMALL_SPACING);
63 	fileLogging->SetLayout(fileLoggingLayout);
64 
65 	BLayoutBuilder::Group<>(this, B_VERTICAL)
66 		.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
67 			B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
68 		.AddGroup(consoleLoggingLayout)
69 			.SetInsets(B_USE_ITEM_INSETS)
70 			.AddGroup(B_HORIZONTAL)
71 				.SetInsets(0, B_USE_ITEM_INSETS, 0, 0)
72 				.Add(fLogConsole)
73 				.AddGlue()
74 				.End()
75 			.End()
76 		.AddGroup(fileLoggingLayout)
77 			.SetInsets(B_USE_ITEM_INSETS)
78 			.AddGrid(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
79 				.SetInsets(0, B_USE_ITEM_INSETS, 0, 0)
80 				.Add(fLogFile, 0, 0)
81 				.AddTextControl(fLogFileName, 0, 1, B_ALIGN_LEFT, 1, 2)
82 				.Add(fCreateLogFile, 2, 2);
83 }
84