* fix probable memory leaks, not in the image but anyway...

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27850 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich 2008-10-03 11:35:28 +00:00
parent fffc7e3e42
commit ebf84359c4
2 changed files with 72 additions and 70 deletions

View File

@ -4,7 +4,7 @@
* Started: 4/27/2004
* Version: 0.1
*/
#include <Window.h>
#include <Box.h>
#include <Directory.h>
@ -17,59 +17,61 @@
PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name)
: BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
: BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
webDirFilePanel(NULL),
logFilePanel(NULL)
{
frame = Bounds();
prefView = new PoorManView(frame, STR_WIN_NAME_PREF);
//prefView->SetViewColor(216,216,216,255);
prefView->SetViewColor(BACKGROUND_COLOR);
AddChild(prefView);
// Button View
BRect buttonRect;
buttonRect = Bounds();
buttonRect.top = buttonRect.bottom - 30;
buttonView = new PoorManView(buttonRect, "Button View");
buttonView->SetViewColor(BACKGROUND_COLOR);
prefView->AddChild(buttonView);
// Buttons
float buttonTop = 0.0f;
// Buttons
float buttonTop = 0.0f;
float buttonWidth = 52.0f;
float buttonHeight = 26.0f;
float buttonLeft = 265.0f;
BRect button1;
button1 = buttonView->Bounds();
button1.Set(buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight);
cancelButton = new BButton(button1, "Cancel Button", "Cancel", new BMessage(MSG_PREF_BTN_CANCEL));
button1.Set(buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight);
cancelButton = new BButton(button1, "Cancel Button", "Cancel", new BMessage(MSG_PREF_BTN_CANCEL));
buttonLeft = 325.0f;
BRect button2;
button2 = buttonView->Bounds();
button2.Set(buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight);
doneButton = new BButton(button2, "Done Button", "Done", new BMessage(MSG_PREF_BTN_DONE));
button2.Set(buttonLeft, buttonTop, buttonLeft + buttonWidth, buttonTop + buttonHeight);
doneButton = new BButton(button2, "Done Button", "Done", new BMessage(MSG_PREF_BTN_DONE));
buttonView->AddChild(cancelButton);
buttonView->AddChild(doneButton);
buttonView->AddChild(cancelButton);
buttonView->AddChild(doneButton);
// Create tabs
BRect r;
r = Bounds();
//r.InsetBy(5, 5);
r.top += 8.0;
r.bottom -= 38.0;
prefTabView = new BTabView(r, "Pref Tab View");
prefTabView->SetViewColor(BACKGROUND_COLOR);
prefTabView->SetViewColor(BACKGROUND_COLOR);
r = prefTabView->Bounds();
r.InsetBy(5, 5);
r.bottom -= prefTabView->TabHeight();
@ -79,63 +81,61 @@ PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name)
siteView = new PoorManSiteView(r, "Site View");
prefTabView->AddTab(siteView, siteTab);
siteTab->SetLabel(STR_TAB_SITE);
// Logging Tab
loggingTab = new BTab();
loggingView = new PoorManLoggingView(r, "Logging View");
prefTabView->AddTab(loggingView, loggingTab);
loggingTab->SetLabel(STR_TAB_LOGGING);
// Advanced Tab
advancedTab = new BTab();
advancedView = new PoorManAdvancedView(r, "Advanced View");
prefTabView->AddTab(advancedView, advancedTab);
advancedTab->SetLabel(STR_TAB_ADVANCED);
prefView->AddChild(prefTabView);
prefView->AddChild(prefTabView);
// FilePanels
BWindow * change_title;
webDirFilePanel = new BFilePanel(
B_OPEN_PANEL,
new BMessenger(this),
NULL,
B_DIRECTORY_NODE,
false,
new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR)
);
BMessenger messenger(this);
BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR);
webDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL,
B_DIRECTORY_NODE, false, &message);
webDirFilePanel->SetPanelDirectory(new BDirectory("/boot/home/public_html"));
webDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, "Select");
change_title = webDirFilePanel->Window();
change_title->SetTitle(STR_FILEPANEL_SELECT_WEB_DIR);
logFilePanel = new BFilePanel(
B_SAVE_PANEL,
new BMessenger(this),
NULL,
B_FILE_NODE,
false,
new BMessage(MSG_FILE_PANEL_CREATE_LOG_FILE)
);
message.what = MSG_FILE_PANEL_CREATE_LOG_FILE;
logFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL,
B_FILE_NODE, false, &message);
logFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, "Create");
change_title = logFilePanel->Window();
change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE);
Show();
}
void
PoorManPreferencesWindow::~PoorManPreferencesWindow()
{
delete logFilePanel;
delete webDirFilePanel;
}
void
PoorManPreferencesWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case MSG_PREF_BTN_DONE:
PoorManWindow * win;
win = ((PoorManApplication *)be_app)->GetPoorManWindow();
std::cout << "Pref Window: sendDir CheckBox: " << siteView->SendDirValue() << std::endl;
win->SetDirListFlag(siteView->SendDirValue());
std::cout << "Pref Window: indexFileName TextControl: " << siteView->IndexFileName() << std::endl;
@ -150,10 +150,10 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message)
win->SetLogFileFlag(loggingView->LogFileValue());
std::cout << "Pref Window: logFileName: " << loggingView->LogFileName() << std::endl;
win->SetLogPath(loggingView->LogFileName());
std::cout << "Pref Window: MaxConnections Slider: " << advancedView->MaxSimultaneousConnections() << std::endl;
win->SetMaxConnections(advancedView->MaxSimultaneousConnections());
if (Lock())
Quit();
@ -183,7 +183,7 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message)
break;
case MSG_PREF_ADV_SLD_MAX_CONNECTION:
max_connections = advancedView->MaxSimultaneousConnections();
std::cout << "Max Connections: " << max_connections << std::endl;
std::cout << "Max Connections: " << max_connections << std::endl;
break;
default:
@ -192,15 +192,15 @@ PoorManPreferencesWindow::MessageReceived(BMessage* message)
}
}
void
void
PoorManPreferencesWindow::SelectWebDir(BMessage * message)
{
entry_ref ref;
entry_ref ref;
const char * name;
BPath path;
BEntry entry;
status_t err = B_OK;
err = message->FindRef("refs", &ref) != B_OK;
//if (err = message->FindRef("directory", &ref) != B_OK)
//return err;
@ -211,20 +211,20 @@ PoorManPreferencesWindow::SelectWebDir(BMessage * message)
//if (err = entry.SetTo(&ref) != B_OK)
// ;//return err;
entry.GetPath(&path);
std::cout << "DIR: " << path.Path() << std::endl;
siteView->SetWebDir(path.Path());
}
void
void
PoorManPreferencesWindow::CreateLogFile(BMessage * message)
{
entry_ref ref;
entry_ref ref;
const char * name;
BPath path;
BEntry entry;
status_t err = B_OK;
err = message->FindRef("directory", &ref) != B_OK;
//if (err = message->FindRef("directory", &ref) != B_OK)
//return err;
@ -237,12 +237,12 @@ PoorManPreferencesWindow::CreateLogFile(BMessage * message)
entry.GetPath(&path);
path.Append(name);
std::cout << "Log File: " << path.Path() << std::endl;
if (err == B_OK)
{
loggingView->SetLogFileName(path.Path());
loggingView->SetLogFileValue(true);
}
// mark the checkbox
}

View File

@ -4,7 +4,7 @@
* Started: 4/27/2004
* Version: 0.1
*/
#ifndef POOR_MAN_PREFERENCES_WINDOW_H
#define POOR_MAN_PREFERENCES_WINDOW_H
@ -30,7 +30,7 @@ private:
PoorManView * prefView;
PoorManView * buttonView;
// ------------------------------------------------
// Tabs
BTabView * prefTabView;
@ -41,20 +41,20 @@ private:
PoorManSiteView * siteView;
PoorManLoggingView * loggingView;
PoorManAdvancedView * advancedView;
// ------------------------------------------------
// Buttons
BButton * cancelButton;
BButton * doneButton;
// ------------------------------------------------
// FilePanels
BFilePanel * webDirFilePanel;
BFilePanel * logFilePanel;
// ------------------------------------------------
// temporary preference variables used to save and
// temporary preference variables used to save and
// set the application to
// site tab
char web_directory[B_FILE_NAME_LENGTH];
@ -68,8 +68,10 @@ private:
int32 max_connections;
public:
PoorManPreferencesWindow(BRect frame, char * name);
~PoorManPreferencesWindow();
virtual void MessageReceived(BMessage * message);
void ShowWebDirFilePanel() { if (!webDirFilePanel->IsShowing()) webDirFilePanel->Show(); }
void SelectWebDir(BMessage * message);
void CreateLogFile(BMessage * message);