Ticket #3787: poorman.2.diff

File poorman.2.diff, 65.8 KB (added by mks, 12 years ago)

Updated patch against hrev44240

  • src/apps/poorman/PoorManAdvancedView.cpp

    diff --git a/src/apps/poorman/PoorManAdvancedView.cpp b/src/apps/poorman/PoorManAdvancedView.cpp
    index 10ef09a..e817428 100644
    a b  
    77
    88#include <Box.h>
    99#include <Catalog.h>
     10#include <GroupLayoutBuilder.h>
    1011#include <Locale.h>
    1112
    1213#include "constants.h"
     
    1920#define B_TRANSLATION_CONTEXT "PoorMan"
    2021
    2122
    22 PoorManAdvancedView::PoorManAdvancedView(BRect rect, const char *name)
    23     : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
     23PoorManAdvancedView::PoorManAdvancedView(const char* name)
     24    :
     25    BView(name, B_WILL_DRAW, NULL)
    2426{
    25     PoorManWindow   *   win;
    26     win = ((PoorManApplication *)be_app)->GetPoorManWindow();
     27    PoorManWindow* win;
     28    win = ((PoorManApplication*)be_app)->GetPoorManWindow();
    2729
    28     SetViewColor(BACKGROUND_COLOR);
     30    SetLayout(new BGroupLayout(B_VERTICAL));
    2931
    30     // Console Logging BBox
    31     BRect maxRect;
    32     maxRect = rect;
    33     maxRect.top -= 5.0;
    34     maxRect.left -= 5.0;
    35     maxRect.right -= 7.0;
    36     maxRect.bottom -= 118.0;
    37 
    38     BBox * connectionOptions = new BBox(maxRect, B_TRANSLATE("Connections"));
     32    BBox* connectionOptions = new BBox(B_TRANSLATE("Connections"));
    3933    connectionOptions->SetLabel(STR_BBX_CONNECTION);
    40     AddChild(connectionOptions);
    41 
    42     BRect sliderRect;
    43     sliderRect = connectionOptions->Bounds();
    44     sliderRect.InsetBy(10.0f, 10.0f);
    45     sliderRect.top += 10;
    46     sliderRect.bottom = sliderRect.top + 50.0;
    4734
    48     maxConnections = new StatusSlider(sliderRect, "Max Slider", STR_SLD_LABEL,
    49         STR_SLD_STATUS_LABEL, new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200);
     35    fMaxConnections = new StatusSlider("Max Slider", STR_SLD_LABEL,
     36        STR_SLD_STATUS_LABEL,
     37        new BMessage(MSG_PREF_ADV_SLD_MAX_CONNECTION), 1, 200);
    5038
    5139    // labels below the slider 1 and 200
    52     maxConnections->SetLimitLabels("1", "200");
     40    fMaxConnections->SetLimitLabels("1", "200");
    5341    SetMaxSimutaneousConnections(win->MaxConnections());
    54     connectionOptions->AddChild(maxConnections);
     42   
     43    connectionOptions->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     44        .Add(fMaxConnections)
     45        .SetInsets(5, 5, 5, 5));
     46       
     47    AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     48        .Add(connectionOptions)
     49        .AddGlue()
     50        .SetInsets(5, 5, 5, 5));
    5551}
    5652
    5753void
    5854PoorManAdvancedView::SetMaxSimutaneousConnections(int32 num)
    5955{
    6056    if (num <= 0 || num > 200)
    61         maxConnections->SetValue(32);
     57        fMaxConnections->SetValue(32);
    6258    else
    63         maxConnections->SetValue(num);
     59        fMaxConnections->SetValue(num);
    6460}
  • src/apps/poorman/PoorManAdvancedView.h

    diff --git a/src/apps/poorman/PoorManAdvancedView.h b/src/apps/poorman/PoorManAdvancedView.h
    index fd693a7..9b6dc58 100644
    a b  
    1313#include "StatusSlider.h"
    1414
    1515
    16 class PoorManAdvancedView: public BView
    17 {
     16class PoorManAdvancedView: public BView {
    1817public:
    19                 PoorManAdvancedView(BRect, const char *name);
    20         int32   MaxSimultaneousConnections() { return maxConnections->Value(); }
    21         void    SetMaxSimutaneousConnections(int32 num);
     18                            PoorManAdvancedView(const char *name);
     19
     20            int32           MaxSimultaneousConnections()
     21                                { return fMaxConnections->Value(); }
     22            void            SetMaxSimutaneousConnections(int32 num);
    2223private:
    23         // Advanced Tab
     24            // Advanced Tab
    2425            // Connections Options
    25             StatusSlider    *   maxConnections;
     26            StatusSlider*   fMaxConnections;
    2627};
    2728
    2829#endif
  • src/apps/poorman/PoorManLoggingView.cpp

    diff --git a/src/apps/poorman/PoorManLoggingView.cpp b/src/apps/poorman/PoorManLoggingView.cpp
    index 2f52c40..2d06194 100644
    a b  
    77 
    88#include <Box.h>
    99#include <Catalog.h>
     10#include <GroupLayoutBuilder.h>
    1011#include <Locale.h>
    1112
    1213#include "constants.h"
     
    1920#define B_TRANSLATION_CONTEXT "PoorMan"
    2021
    2122
    22 PoorManLoggingView::PoorManLoggingView(BRect rect, const char *name)
    23     : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
     23PoorManLoggingView::PoorManLoggingView(const char* name)
     24    :
     25    BView(name, B_WILL_DRAW, NULL)
    2426{
    25     PoorManWindow   *   win;
    26     win = ((PoorManApplication *)be_app)->GetPoorManWindow();
     27    PoorManWindow* win;
     28    win = ((PoorManApplication*)be_app)->GetPoorManWindow();
    2729   
    28     SetViewColor(BACKGROUND_COLOR);
     30    SetLayout(new BGroupLayout(B_VERTICAL));
    2931   
    30     // Console Logging BBox
    31     BRect consoleLoggingRect;
    32     consoleLoggingRect = rect;
    33     consoleLoggingRect.top -= 5.0;
    34     consoleLoggingRect.left -= 5.0;
    35     consoleLoggingRect.right -= 7.0;
    36     consoleLoggingRect.bottom -= 118.0;
    37    
    38     BBox * consoleLogging = new BBox(consoleLoggingRect,
    39         B_TRANSLATE("Console Logging"));
     32    BBox* consoleLogging = new BBox(B_TRANSLATE("Console Logging"));
    4033    consoleLogging->SetLabel(STR_BBX_CONSOLE_LOGGING);
    41     AddChild(consoleLogging);
    42 
    4334   
    4435    // File Logging BBox
    45     BRect fileLoggingRect;
    46     fileLoggingRect = consoleLoggingRect;
    47     fileLoggingRect.top = consoleLoggingRect.bottom + 10.0;
    48     fileLoggingRect.bottom = fileLoggingRect.top + 100.0;
    49 
    50     BBox * fileLogging = new BBox(fileLoggingRect,
    51         B_TRANSLATE("File Logging"));
     36    BBox* fileLogging = new BBox(B_TRANSLATE("File Logging"));
    5237    fileLogging->SetLabel(STR_BBX_FILE_LOGGING);
    53     AddChild(fileLogging);
    54    
    55     float left = 10.0;
    56     float top = 20.0;
    57     float box_size = 13.0;
    58     BRect tempRect(left, top, consoleLoggingRect.Width() - 5.0, top + box_size);
    59    
     38       
    6039    // Console Logging
    61     logConsole = new BCheckBox(tempRect, B_TRANSLATE("Log To Console"),
     40    fLogConsole = new BCheckBox(B_TRANSLATE("Log To Console"),
    6241        STR_CBX_LOG_CONSOLE, new BMessage(MSG_PREF_LOG_CBX_CONSOLE));
    6342    // set the checkbox to the value the program has
    6443    SetLogConsoleValue(win->LogConsoleFlag());
    65     consoleLogging->AddChild(logConsole);
    6644   
    6745    // File Logging
    68     logFile = new BCheckBox(tempRect, B_TRANSLATE("Log To File"),
    69         STR_CBX_LOG_FILE, new BMessage(MSG_PREF_LOG_CBX_FILE));
     46    fLogFile = new BCheckBox(B_TRANSLATE("Log To File"), STR_CBX_LOG_FILE,
     47        new BMessage(MSG_PREF_LOG_CBX_FILE));
    7048    // set the checkbox to the value the program has
    7149    SetLogFileValue(win->LogFileFlag());
    72     fileLogging->AddChild(logFile);
    7350   
    7451    // File Name
    75     tempRect.top = tempRect.bottom + 10.0;
    76     tempRect.bottom = tempRect.top + box_size;
    77     tempRect.right -= 5.0;
    78    
    79     logFileName = new BTextControl(tempRect, B_TRANSLATE("File Name"),
     52    fLogFileName = new BTextControl(B_TRANSLATE("File Name"),
    8053        STR_TXT_LOG_FILE_NAME, NULL, NULL);
    81     logFileName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    82     logFileName->SetDivider(fileLogging->StringWidth(STR_TXT_LOG_FILE_NAME) + 8.0f);
    8354    SetLogFileName(win->LogPath());
    84     fileLogging->AddChild(logFileName);
    8555   
    8656    // Create Log File
    87     BRect createLogFileRect;
    88     createLogFileRect.top = tempRect.bottom + 13.0;
    89     createLogFileRect.right = tempRect.right + 2.0;
    90     createLogFileRect.left = createLogFileRect.right
    91         - fileLogging->StringWidth(B_TRANSLATE("Create Log File")) - 24.0;
    92     createLogFileRect.bottom = createLogFileRect.top + 19.0;
    93    
    94     createLogFile = new BButton(createLogFileRect, B_TRANSLATE("Create Log File"),
     57    fCreateLogFile = new BButton(B_TRANSLATE("Create Log File"),
    9558        STR_BTN_CREATE_LOG_FILE, new BMessage(MSG_PREF_LOG_BTN_CREATE_FILE));
    96     fileLogging->AddChild(createLogFile);
    9759
     60    consoleLogging->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     61        .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
     62            .Add(fLogConsole)
     63            .AddGlue())
     64        .SetInsets(5, 5, 5, 5));
     65       
     66    fileLogging->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     67        .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
     68            .Add(fLogFile)
     69            .AddGlue())
     70        .Add(fLogFileName)
     71        .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
     72            .AddGlue()
     73            .Add(fCreateLogFile))
     74        .SetInsets(5, 5, 5, 5));
     75
     76    AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     77        .Add(consoleLogging)
     78        .Add(fileLogging)
     79        .SetInsets(5, 5, 5, 5));
    9880}
  • src/apps/poorman/PoorManLoggingView.h

    diff --git a/src/apps/poorman/PoorManLoggingView.h b/src/apps/poorman/PoorManLoggingView.h
    index 2ffa367..9648f08 100644
    a b  
    1414#include <CheckBox.h>
    1515
    1616
    17 class PoorManLoggingView: public BView
    18 {
     17class PoorManLoggingView: public BView {
    1918public:
    20                 PoorManLoggingView(BRect, const char *name);
     19                            PoorManLoggingView(const char* name);
    2120               
    22         void    SetLogConsoleValue(bool state) {if (state) logConsole->SetValue(B_CONTROL_ON);
    23                                                 else logConsole->SetValue(B_CONTROL_OFF); }
    24         bool    LogConsoleValue() { return (logConsole->Value() == B_CONTROL_ON) ? true : false; }
    25         void    SetLogFileValue(bool state) {if (state) logFile->SetValue(B_CONTROL_ON);
    26                                                 else logFile->SetValue(B_CONTROL_OFF); }
    27         bool    LogFileValue() { return (logFile->Value() == B_CONTROL_ON) ? true : false; }
    28 const   char *  LogFileName() { return logFileName->Text(); }
    29         void    SetLogFileName(const char * log) { logFileName->SetText(log); }
    30 private:
    31         // Logging Tab
     21            void            SetLogConsoleValue(bool state)
     22                                { if (state)
     23                                    fLogConsole->SetValue(B_CONTROL_ON);
     24                                    else fLogConsole->SetValue(B_CONTROL_OFF); }
     25            bool            LogConsoleValue()
     26                                { return (fLogConsole->Value() == B_CONTROL_ON)
     27                                    ? true : false; }
     28            void            SetLogFileValue(bool state)
     29                                { if (state) fLogFile->SetValue(B_CONTROL_ON);
     30                                    else fLogFile->SetValue(B_CONTROL_OFF); }
     31            bool            LogFileValue()
     32                                { return (fLogFile->Value() == B_CONTROL_ON)
     33                                    ? true : false; }
     34            const char*     LogFileName()
     35                                { return fLogFileName->Text(); }
     36            void            SetLogFileName(const char* log)
     37                                { fLogFileName->SetText(log); }
    3238
     39private:
     40            // Logging Tab
    3341            // Console Logging
    34             BCheckBox       *   logConsole;
     42            BCheckBox*      fLogConsole;
    3543            // File Logging
    36             BCheckBox       *   logFile;
    37             BTextControl    *   logFileName;
    38             BButton         *   createLogFile;
     44            BCheckBox*      fLogFile;
     45            BTextControl*   fLogFileName;
     46            BButton *       fCreateLogFile;
    3947};
    4048
    4149#endif
  • src/apps/poorman/PoorManPreferencesWindow.cpp

    diff --git a/src/apps/poorman/PoorManPreferencesWindow.cpp b/src/apps/poorman/PoorManPreferencesWindow.cpp
    index 21a7137..a09475d 100644
    a b  
    99#include <Catalog.h>
    1010#include <Debug.h>
    1111#include <Directory.h>
     12#include <GroupLayoutBuilder.h>
     13#include <GroupView.h>
    1214#include <Locale.h>
     15#include <SpaceLayoutItem.h>
    1316#include <Window.h>
    1417
    1518#include "constants.h"
     
    2528
    2629PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name)
    2730    : BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE
    28         | B_CLOSE_ON_ESCAPE),
    29     webDirFilePanel(NULL),
    30     logFilePanel(NULL)
     31        | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS),
     32    fWebDirFilePanel(NULL),
     33    fLogFilePanel(NULL)
    3134{
    32     frame = Bounds();
     35    SetLayout(new BGroupLayout(B_VERTICAL));
    3336
    34     prefView = new PoorManView(frame, STR_WIN_NAME_PREF);
    35     //prefView->SetViewColor(216,216,216,255);
    36     prefView->SetViewColor(BACKGROUND_COLOR);
    37     AddChild(prefView);
    38 
    39 
    40     // Button View
    41     BRect buttonRect;
    42     buttonRect = Bounds();
    43     buttonRect.top = buttonRect.bottom - 30;
    44 
    45     buttonView = new PoorManView(buttonRect, "Button View");
    46     buttonView->SetViewColor(BACKGROUND_COLOR);
    47     prefView->AddChild(buttonView);
    48 
    49     // Buttons
    50     float buttonTop = 0.0f;
    51     float buttonHeight = 26.0f;
    52 
    53     float widthCancel = prefView->StringWidth(B_TRANSLATE("Cancel")) + 24.0f;
    54     float widthDone = prefView->StringWidth(B_TRANSLATE("Done")) + 24.0f;
    55 
    56     float gap = 5.0f;
    57 
    58     BRect button1(prefView->Bounds().Width() - 2 * gap - widthCancel
    59         - widthDone, buttonTop, prefView->Bounds().Width() - 2 * gap - widthDone,
    60         buttonTop + buttonHeight);
    61     cancelButton = new BButton(button1, "Cancel Button", B_TRANSLATE("Cancel"),
     37    fCancelButton = new BButton("Cancel Button", B_TRANSLATE("Cancel"),
    6238        new BMessage(MSG_PREF_BTN_CANCEL));
    63 
    64     BRect button2(prefView->Bounds().Width() - gap - widthDone, buttonTop,
    65         prefView->Bounds().Width() - gap, buttonTop + buttonHeight);
    66     doneButton = new BButton(button2, "Done Button", B_TRANSLATE("Done"),
     39    fDoneButton = new BButton("Done Button", B_TRANSLATE("Done"),
    6740        new BMessage(MSG_PREF_BTN_DONE));
    6841
    69     buttonView->AddChild(cancelButton);
    70     buttonView->AddChild(doneButton);
    71 
    72     // Create tabs
    73     BRect r;
    74     r = Bounds();
    75     //r.InsetBy(5, 5);
    76     r.top    += 8.0;
    77     r.bottom -= 38.0;
    78 
    79     prefTabView = new BTabView(r, "Pref Tab View");
    80     prefTabView->SetViewColor(BACKGROUND_COLOR);
    81 
    82     r = prefTabView->Bounds();
    83     r.InsetBy(5, 5);
    84     r.bottom -= prefTabView->TabHeight();
     42    fPrefTabView = new BTabView("Pref Tab View");
    8543
    8644    // Site Tab
    87     siteTab = new BTab();
    88     siteView = new PoorManSiteView(r, "Site View");
    89     prefTabView->AddTab(siteView, siteTab);
    90     siteTab->SetLabel(STR_TAB_SITE);
     45    fSiteTab = new BTab();
     46    fSiteView = new PoorManSiteView("Site View");
     47    fPrefTabView->AddTab(fSiteView, fSiteTab);
     48    fSiteTab->SetLabel(STR_TAB_SITE);
    9149
    9250    // Logging Tab
    93     loggingTab = new BTab();
    94     loggingView = new PoorManLoggingView(r, "Logging View");
    95     prefTabView->AddTab(loggingView, loggingTab);
    96     loggingTab->SetLabel(STR_TAB_LOGGING);
     51    fLoggingTab = new BTab();
     52    fLoggingView = new PoorManLoggingView("Logging View");
     53    fPrefTabView->AddTab(fLoggingView, fLoggingTab);
     54    fLoggingTab->SetLabel(STR_TAB_LOGGING);
    9755
    9856    // Advanced Tab
    99     advancedTab = new BTab();
    100     advancedView = new PoorManAdvancedView(r, "Advanced View");
    101     prefTabView->AddTab(advancedView, advancedTab);
    102     advancedTab->SetLabel(STR_TAB_ADVANCED);
    103 
    104     prefView->AddChild(prefTabView);
     57    fAdvancedTab = new BTab();
     58    fAdvancedView = new PoorManAdvancedView("Advanced View");
     59    fPrefTabView->AddTab(fAdvancedView, fAdvancedTab);
     60    fAdvancedTab->SetLabel(STR_TAB_ADVANCED);
    10561
    10662    // FilePanels
    10763    BWindow * change_title;
    10864
    10965    BMessenger messenger(this);
    11066    BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR);
    111     webDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL,
     67    fWebDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL,
    11268        B_DIRECTORY_NODE, false, &message, NULL, true);
    11369
    114     webDirFilePanel->SetPanelDirectory(new BDirectory("/boot/home/public_html"));
    115     webDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select"));
    116     change_title = webDirFilePanel->Window();
     70    fWebDirFilePanel->SetPanelDirectory(
     71        new BDirectory("/boot/home/public_html"));
     72    fWebDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select"));
     73    change_title = fWebDirFilePanel->Window();
    11774    change_title->SetTitle(STR_FILEPANEL_SELECT_WEB_DIR);
    11875
    11976    message.what = MSG_FILE_PANEL_CREATE_LOG_FILE;
    120     logFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL,
     77    fLogFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL,
    12178        B_FILE_NODE, false, &message);
    122     logFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create"));
    123     change_title = logFilePanel->Window();
     79    fLogFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create"));
     80    change_title = fLogFilePanel->Window();
    12481    change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE);
     82   
     83    AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     84        .Add(fPrefTabView)
     85        .Add(BGroupLayoutBuilder(B_HORIZONTAL)
     86            .AddGlue()
     87            .Add(fCancelButton)
     88            .Add(fDoneButton))
     89        .SetInsets(5, 5, 5, 5));
    12590}
    12691
    12792
    12893PoorManPreferencesWindow::~PoorManPreferencesWindow()
    12994{
    130     delete logFilePanel;
    131     delete webDirFilePanel;
     95    delete fLogFilePanel;
     96    delete fWebDirFilePanel;
    13297}
    13398
    13499
    PoorManPreferencesWindow::MessageReceived(BMessage* message)  
    139104        case MSG_PREF_BTN_DONE:
    140105            PoorManWindow* win;
    141106            PoorManServer* server;
    142             win = ((PoorManApplication *)be_app)->GetPoorManWindow();
     107            win = ((PoorManApplication*)be_app)->GetPoorManWindow();
    143108            server = win->GetServer();
    144109   
    145110            PRINT(("Pref Window: sendDir CheckBox: %d\n",
    146                 siteView->SendDirValue()));
    147             server->SetListDir(siteView->SendDirValue());
    148             win->SetDirListFlag(siteView->SendDirValue());
     111                fSiteView->SendDirValue()));
     112            server->SetListDir(fSiteView->SendDirValue());
     113            win->SetDirListFlag(fSiteView->SendDirValue());
    149114            PRINT(("Pref Window: indexFileName TextControl: %s\n",
    150                 siteView->IndexFileName()));
    151             if (server->SetIndexName(siteView->IndexFileName()) == B_OK)
    152                 win->SetIndexFileName(siteView->IndexFileName());
    153             PRINT(("Pref Window: webDir: %s\n", siteView->WebDir()));
    154             if (server->SetWebDir(siteView->WebDir()) == B_OK) {
    155                 win->SetWebDir(siteView->WebDir());
    156                 win->SetDirLabel(siteView->WebDir());
     115                fSiteView->IndexFileName()));
     116            if (server->SetIndexName(fSiteView->IndexFileName()) == B_OK)
     117                win->SetIndexFileName(fSiteView->IndexFileName());
     118            PRINT(("Pref Window: webDir: %s\n", fSiteView->WebDir()));
     119            if (server->SetWebDir(fSiteView->WebDir()) == B_OK) {
     120                win->SetWebDir(fSiteView->WebDir());
     121                win->SetDirLabel(fSiteView->WebDir());
    157122            }
    158123
    159124            PRINT(("Pref Window: logConsole CheckBox: %d\n",
    160                 loggingView->LogConsoleValue()));
    161             win->SetLogConsoleFlag(loggingView->LogConsoleValue());
     125                fLoggingView->LogConsoleValue()));
     126            win->SetLogConsoleFlag(fLoggingView->LogConsoleValue());
    162127            PRINT(("Pref Window: logFile CheckBox: %d\n",
    163                 loggingView->LogFileValue()));
    164             win->SetLogFileFlag(loggingView->LogFileValue());
     128                fLoggingView->LogFileValue()));
     129            win->SetLogFileFlag(fLoggingView->LogFileValue());
    165130            PRINT(("Pref Window: logFileName: %s\n",
    166                 loggingView->LogFileName()));
    167             win->SetLogPath(loggingView->LogFileName());
     131                fLoggingView->LogFileName()));
     132            win->SetLogPath(fLoggingView->LogFileName());
    168133   
    169134            PRINT(("Pref Window: MaxConnections Slider: %ld\n",
    170                 advancedView->MaxSimultaneousConnections()));
    171             server->SetMaxConns(advancedView->MaxSimultaneousConnections());
     135                fAdvancedView->MaxSimultaneousConnections()));
     136            server->SetMaxConns(fAdvancedView->MaxSimultaneousConnections());
    172137            win->SetMaxConnections(
    173                 (int16)advancedView->MaxSimultaneousConnections());
     138                (int16)fAdvancedView->MaxSimultaneousConnections());
    174139   
    175140            if (Lock())
    176141                Quit();
    PoorManPreferencesWindow::MessageReceived(BMessage* message)  
    181146            break;
    182147        case MSG_PREF_SITE_BTN_SELECT:
    183148            // Select the Web Directory, root directory to look in.
    184             webDirFilePanel->SetTarget(this);
    185             webDirFilePanel->SetMessage(new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR));
    186             if (!webDirFilePanel->IsShowing())
    187                 webDirFilePanel->Show();
     149            fWebDirFilePanel->SetTarget(this);
     150            fWebDirFilePanel->SetMessage(new BMessage(MSG_FILE_PANEL_SELECT_WEB_DIR));
     151            if (!fWebDirFilePanel->IsShowing())
     152                fWebDirFilePanel->Show();
    188153            break;
    189154        case MSG_FILE_PANEL_SELECT_WEB_DIR:
    190155            // handle the open BMessage from the Select Web Directory File Panel
    PoorManPreferencesWindow::MessageReceived(BMessage* message)  
    193158            break;
    194159        case MSG_PREF_LOG_BTN_CREATE_FILE:
    195160            // Create the Log File
    196             logFilePanel->Show();
     161            fLogFilePanel->Show();
    197162            break;
    198163        case MSG_FILE_PANEL_CREATE_LOG_FILE:
    199164            // handle the save BMessage from the Create Log File Panel
    PoorManPreferencesWindow::MessageReceived(BMessage* message)  
    201166            CreateLogFile(message);
    202167            break;
    203168        case MSG_PREF_ADV_SLD_MAX_CONNECTION:
    204             max_connections = advancedView->MaxSimultaneousConnections();
    205             PRINT(("Max Connections: %ld\n", max_connections));
     169            fMaxConnections = fAdvancedView->MaxSimultaneousConnections();
     170            PRINT(("Max Connections: %ld\n", fMaxConnections));
    206171            break;
    207172        default:
    208173            BWindow::MessageReceived(message);
    PoorManPreferencesWindow::MessageReceived(BMessage* message)  
    212177
    213178
    214179void
    215 PoorManPreferencesWindow::SelectWebDir(BMessage * message)
     180PoorManPreferencesWindow::SelectWebDir(BMessage* message)
    216181{
    217182    entry_ref   ref;
    218     const char  * name;
     183    const char* name;
    219184    BPath       path;
    220185    BEntry      entry;
    221186
    PoorManPreferencesWindow::SelectWebDir(BMessage * message)  
    227192    entry.GetPath(&path);
    228193
    229194    PRINT(("DIR: %s\n", path.Path()));
    230     siteView->SetWebDir(path.Path());
     195    fSiteView->SetWebDir(path.Path());
    231196   
    232197    bool temp;
    233198    if (message->FindBool("Default Dialog", &temp) == B_OK) {
    234199        PoorManWindow* win = ((PoorManApplication *)be_app)->GetPoorManWindow();
    235200        win->StartServer();
    236         if (win->GetServer()->SetWebDir(siteView->WebDir()) == B_OK) {
    237             win->SetWebDir(siteView->WebDir());
    238             win->SetDirLabel(siteView->WebDir());
     201        if (win->GetServer()->SetWebDir(fSiteView->WebDir()) == B_OK) {
     202            win->SetWebDir(fSiteView->WebDir());
     203            win->SetDirLabel(fSiteView->WebDir());
    239204            win->SaveSettings();
    240205            win->Show();       
    241206        }
    PoorManPreferencesWindow::SelectWebDir(BMessage * message)  
    246211
    247212
    248213void
    249 PoorManPreferencesWindow::CreateLogFile(BMessage * message)
     214PoorManPreferencesWindow::CreateLogFile(BMessage* message)
    250215{
    251216    entry_ref   ref;
    252217    const char  * name;
    PoorManPreferencesWindow::CreateLogFile(BMessage * message)  
    268233    PRINT(("Log File: %s\n", path.Path()));
    269234
    270235    if (err == B_OK) {
    271         loggingView->SetLogFileName(path.Path());
    272         loggingView->SetLogFileValue(true);
     236        fLoggingView->SetLogFileName(path.Path());
     237        fLoggingView->SetLogFileValue(true);
    273238    }
    274239
    275240    // mark the checkbox
    PoorManPreferencesWindow::ShowWebDirFilePanel()  
    283248    BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR);
    284249    message.AddBool("Default Dialog", true);
    285250
    286     webDirFilePanel->SetTarget(be_app);
    287     webDirFilePanel->SetMessage(&message);
    288     if (!webDirFilePanel->IsShowing())
    289         webDirFilePanel->Show();
     251    fWebDirFilePanel->SetTarget(be_app);
     252    fWebDirFilePanel->SetMessage(&message);
     253    if (!fWebDirFilePanel->IsShowing())
     254        fWebDirFilePanel->Show();
    290255}
  • src/apps/poorman/PoorManPreferencesWindow.h

    diff --git a/src/apps/poorman/PoorManPreferencesWindow.h b/src/apps/poorman/PoorManPreferencesWindow.h
    index 2aaace8..7758799 100644
    a b  
    2222#include "PoorManAdvancedView.h"
    2323
    2424
     25class PoorManPreferencesWindow: public BWindow {
     26public:
     27                            PoorManPreferencesWindow(BRect frame, char* name);
     28                            ~PoorManPreferencesWindow();
    2529
     30    virtual void            MessageReceived(BMessage* message);
    2631
    27 class PoorManPreferencesWindow: public BWindow
    28 {
    29 private:
    30 
    31                 PoorManView *   prefView;
    32                 PoorManView *   buttonView;
    33 
    34                 // ------------------------------------------------
    35                 // Tabs
    36                 BTabView    *   prefTabView;
    37                 BTab        *   siteTab;
    38                 BTab        *   loggingTab;
    39                 BTab        *   advancedTab;
    40                 // Tab Views
    41                 PoorManSiteView     *   siteView;
    42                 PoorManLoggingView  *   loggingView;
    43                 PoorManAdvancedView *   advancedView;
    44 
    45                 // ------------------------------------------------
    46                 // Buttons
    47                 BButton     *   cancelButton;
    48                 BButton     *   doneButton;
     32            void            ShowWebDirFilePanel();
     33            void            SelectWebDir(BMessage* message);
     34            void            CreateLogFile(BMessage* message);
    4935
    50                 // ------------------------------------------------
    51                 // FilePanels
    52                 BFilePanel  *   webDirFilePanel;
    53                 BFilePanel  *   logFilePanel;
     36private:
     37            PoorManView*    fPrefView;
     38            PoorManView*    fButtonView;
     39
     40            // ------------------------------------------------
     41            // Tabs
     42            BTabView*       fPrefTabView;
     43            BTab*           fSiteTab;
     44            BTab*           fLoggingTab;
     45            BTab*           fAdvancedTab;
     46            // Tab Views
     47            PoorManSiteView*        fSiteView;
     48            PoorManLoggingView*     fLoggingView;
     49            PoorManAdvancedView*    fAdvancedView;
     50
     51            // ------------------------------------------------
     52            // Buttons
     53            BButton*        fCancelButton;
     54            BButton*        fDoneButton;
     55
     56            // ------------------------------------------------
     57            // FilePanels
     58            BFilePanel*     fWebDirFilePanel;
     59            BFilePanel*     fLogFilePanel;
    5460
    5561
    5662                // ------------------------------------------------
    57                 // temporary preference variables used to save and
    58                 // set the application to
    59                 // site tab
    60                 char        web_directory[B_FILE_NAME_LENGTH];
    61                 char        index_file_name[64];
    62                 bool        send_dir;
    63                 // logging tab
    64                 bool        log_to_console;
    65                 bool        log_to_file;
    66                 char        log_file_name[B_FILE_NAME_LENGTH];
    67                 // advanced tab
    68                 int32       max_connections;
    69 public:
    70                 PoorManPreferencesWindow(BRect frame, char * name);
    71                 ~PoorManPreferencesWindow();
    72 
    73 virtual void    MessageReceived(BMessage * message);
    74 
    75         void    ShowWebDirFilePanel();
    76         void    SelectWebDir(BMessage * message);
    77         void    CreateLogFile(BMessage * message);
     63            // temporary preference variables used to save and
     64            // set the application to
     65            // site tab
     66            char            fWebDirectory[B_FILE_NAME_LENGTH];
     67            char            fIndexFileName[64];
     68            bool            fSendDir;
     69            // logging tab
     70            bool            flogToConsole;
     71            bool            fLogToFile;
     72            char            fLogFileName[B_FILE_NAME_LENGTH];
     73            // advanced tab
     74            int32           fMaxConnections;
    7875};
    7976
    8077#endif
  • src/apps/poorman/PoorManSiteView.cpp

    diff --git a/src/apps/poorman/PoorManSiteView.cpp b/src/apps/poorman/PoorManSiteView.cpp
    index 4214d6c..532c0e6 100644
    a b  
    66 */
    77 
    88#include <Box.h>
     9#include <GroupLayoutBuilder.h>
    910
    1011#include "constants.h"
    1112#include "PoorManSiteView.h"
    1213#include "PoorManWindow.h"
    1314#include "PoorManApplication.h"
    1415
    15 PoorManSiteView::PoorManSiteView(BRect rect, const char *name)
    16     : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
     16PoorManSiteView::PoorManSiteView(const char* name)
     17    : BView(name, B_WILL_DRAW, NULL)
    1718{
    18     PoorManWindow   *   win;
     19    PoorManWindow* win;
    1920    win = ((PoorManApplication *)be_app)->GetPoorManWindow();
    2021
    21     SetViewColor(BACKGROUND_COLOR);
     22    SetLayout(new BGroupLayout(B_VERTICAL));
    2223
    2324    // Web Site Location BBox
    24     BRect webLocationRect;
    25     webLocationRect = rect;
    26     webLocationRect.top -= 5.0;
    27     webLocationRect.left -= 5.0;
    28     webLocationRect.right -= 7.0;
    29     webLocationRect.bottom -= 98.0;
    30 
    31     BBox * webSiteLocation = new BBox(webLocationRect, "Web Location");
     25    BBox* webSiteLocation = new BBox("Web Location");
    3226    webSiteLocation->SetLabel(STR_BBX_LOCATION);
    33     AddChild(webSiteLocation);
    3427   
    3528    // Web Site Options BBox
    36     BRect webOptionsRect;
    37     webOptionsRect = webLocationRect;
    38     webOptionsRect.top = webOptionsRect.bottom + 10.0;
    39     webOptionsRect.bottom = webOptionsRect.top + 80.0;
    40 
    41     BBox * webSiteOptions = new BBox(webOptionsRect, "Web Options");
     29    BBox* webSiteOptions = new BBox("Web Options");
    4230    webSiteOptions->SetLabel(STR_BBX_OPTIONS);
    43     AddChild(webSiteOptions);
    4431
    4532    // Send Directory List if No Index
    46     float left = 10.0;
    47     float top = 20.0;
    48     float box_size = 13.0;
    49     BRect sendDirRect(left, top, webOptionsRect.Width() - 5.0, top + box_size);
    50     sendDir = new BCheckBox(sendDirRect, "Send Dir", STR_CBX_DIR_LIST_LABEL, new BMessage(MSG_PREF_SITE_CBX_INDEX));
     33    fSendDir = new BCheckBox("Send Dir", STR_CBX_DIR_LIST_LABEL,
     34        new BMessage(MSG_PREF_SITE_CBX_INDEX));
    5135    // set the checkbox to the value the program has
    5236    SetSendDirValue(win->DirListFlag());
    53     webSiteOptions->AddChild(sendDir);
    54 
    5537
    56     // Finish the Web Site Location Section
    57     BRect webSiteLocationRect;
    58     webSiteLocationRect = webLocationRect;
    59     webSiteLocationRect.InsetBy(10.0, 7.0);
    60     webSiteLocationRect.top += 13.0;
    61     webSiteLocationRect.bottom = webSiteLocationRect.top + 19.0;
    62    
    6338    // Web Directory Text Control
    64     webDir = new BTextControl(webSiteLocationRect, "Web Dir",
    65         STR_TXT_DIRECTORY, NULL, NULL);
    66     webDir->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    67     webDir->SetDivider(80.0);
     39    fWebDir = new BTextControl("Web Dir", STR_TXT_DIRECTORY, NULL);
    6840    SetWebDir(win->WebDir());
    69     webSiteLocation->AddChild(webDir);
    7041   
    7142    // Select Web Directory Button
    72     BRect selectWebDirRect;
    73 
    74     selectWebDirRect.top = webSiteLocationRect.bottom + 5.0;
    75     selectWebDirRect.right = webSiteLocationRect.right + 2.0;
    76     selectWebDirRect.left = selectWebDirRect.right
    77         - webSiteLocation->StringWidth("Select Web Dir") - 24.0;
    78     selectWebDirRect.bottom = selectWebDirRect.top + 19.0;
    79    
    80     selectWebDir = new BButton(selectWebDirRect, "Select Web Dir",
    81         STR_BTN_DIRECTORY, new BMessage(MSG_PREF_SITE_BTN_SELECT));
    82     webSiteLocation->AddChild(selectWebDir);
     43    fSelectWebDir = new BButton("Select Web Dir", STR_BTN_DIRECTORY,
     44        new BMessage(MSG_PREF_SITE_BTN_SELECT));
    8345   
    8446    // Index File Name Text Control
    85     //webDirRect.InsetBy(10.0, 7.0);
    86     webSiteLocationRect.top += 63.0;
    87     webSiteLocationRect.bottom = webSiteLocationRect.top + 19.0;
    88    
    89     indexFileName = new BTextControl(webSiteLocationRect,
    90         "Index File Name", STR_TXT_INDEX, NULL, NULL);
    91     indexFileName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
    92     indexFileName->SetDivider(80.0);
     47    fIndexFileName = new BTextControl("Index File Name", STR_TXT_INDEX, NULL);
    9348    SetIndexFileName(win->IndexFileName());
    94     webSiteLocation->AddChild(indexFileName);
    9549   
     50    webSiteOptions->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     51        .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
     52            .Add(fSendDir)
     53            .AddGlue())
     54        .SetInsets(5, 5, 5, 5));
     55   
     56    webSiteLocation->AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     57        .Add(fWebDir)
     58        .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
     59            .AddGlue()
     60            .Add(fSelectWebDir))
     61        .Add(fIndexFileName)
     62        .SetInsets(5, 5, 5, 5));
     63   
     64    AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
     65        .Add(webSiteLocation)
     66        .Add(webSiteOptions)
     67        .SetInsets(5, 5, 5, 5));
    9668}
  • src/apps/poorman/PoorManSiteView.h

    diff --git a/src/apps/poorman/PoorManSiteView.h b/src/apps/poorman/PoorManSiteView.h
    index 2fecd8f..8bd8716 100644
    a b  
    1414#include <CheckBox.h>
    1515
    1616
    17 class PoorManSiteView: public BView
    18 {
     17class PoorManSiteView: public BView {
    1918public:
    20                 PoorManSiteView(BRect, const char *name);
    21         void    SetSendDirValue(bool state) {if (state) sendDir->SetValue(B_CONTROL_ON);
    22                                                 else sendDir->SetValue(B_CONTROL_OFF); }
    23         bool    SendDirValue()  { return (sendDir->Value() == B_CONTROL_ON) ? true : false; }
    24 const   char *  IndexFileName() { return indexFileName->Text(); }
    25         void    SetIndexFileName(const char * name) { indexFileName->SetText(name); }
    26 const   char *  WebDir()        { return webDir->Text(); }
    27         void    SetWebDir(const char * dir) { webDir->SetText(dir); }
     19                            PoorManSiteView(const char *name);
     20
     21            void            SetSendDirValue(bool state)
     22                                { if (state) fSendDir->SetValue(B_CONTROL_ON);
     23                                    else fSendDir->SetValue(B_CONTROL_OFF); }
     24            bool            SendDirValue()
     25                                { return (fSendDir->Value() == B_CONTROL_ON)
     26                                    ? true : false; }
     27            const char*     IndexFileName()
     28                                { return fIndexFileName->Text(); }
     29            void            SetIndexFileName(const char* name)
     30                                { fIndexFileName->SetText(name); }
     31            const char*     WebDir()
     32                                { return fWebDir->Text(); }
     33            void            SetWebDir(const char* dir)
     34                                { fWebDir->SetText(dir); }
     35
    2836private:
    2937        // Site Tab
    3038            // Web Site Location
    31             BTextControl    *   webDir;
    32             BTextControl    *   indexFileName;
    33             BButton         *   selectWebDir;
     39            BTextControl*   fWebDir;
     40            BTextControl*   fIndexFileName;
     41            BButton*        fSelectWebDir;
    3442           
    3543            // Web Site Options
    36             BCheckBox       *   sendDir;
     44            BCheckBox*      fSendDir;
    3745           
    3846};
    3947
  • src/apps/poorman/PoorManView.cpp

    diff --git a/src/apps/poorman/PoorManView.cpp b/src/apps/poorman/PoorManView.cpp
    index 492162c..9a27f51 100644
    a b  
    1010#endif
    1111
    1212PoorManView::PoorManView(BRect rect, const char *name)
    13     : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW )
     13    : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW)
    1414{
    1515}
    1616
  • src/apps/poorman/PoorManView.h

    diff --git a/src/apps/poorman/PoorManView.h b/src/apps/poorman/PoorManView.h
    index 724dcad..e4c40da 100644
    a b  
    1212#include <View.h>
    1313#endif
    1414
    15 class PoorManView: public BView
    16 {
     15class PoorManView: public BView {
    1716public:
    18                 PoorManView(BRect, const char *name);
    19 virtual void    AttachedToWindow();
     17                            PoorManView(BRect, const char *name);
     18
     19    virtual void        AttachedToWindow();
    2020};
    2121
    2222#endif
  • src/apps/poorman/PoorManWindow.cpp

    diff --git a/src/apps/poorman/PoorManWindow.cpp b/src/apps/poorman/PoorManWindow.cpp
    index 08eb8b8..07e5ba9 100644
    a b  
    1717#include <Directory.h>
    1818#include <File.h>
    1919#include <FindDirectory.h>
     20#include <GroupLayoutBuilder.h>
    2021#include <Locale.h>
    2122#include <Menu.h>
    2223#include <MenuBar.h>
     
    4344
    4445
    4546PoorManWindow::PoorManWindow(BRect frame)
    46     : BWindow(frame, STR_APP_NAME, B_TITLED_WINDOW, 0),
    47     status(false), hits(0), prefWindow(NULL), fLogFile(NULL), fServer(NULL)
     47    :
     48    BWindow(frame, STR_APP_NAME, B_TITLED_WINDOW, 0),
     49    fStatus(false),
     50    fHits(0),
     51    fPrefWindow(NULL),
     52    fLogFile(NULL),
     53    fServer(NULL)
    4854{
    4955    //preferences init
    50     web_directory.SetTo(STR_DEFAULT_WEB_DIRECTORY);
    51     index_file_name.SetTo("index.html");
    52     dir_list_flag = false;
     56    fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY);
     57    fIndexFileName.SetTo("index.html");
     58    fDirListFlag = false;
    5359   
    54     log_console_flag = true;
    55     log_file_flag = false;
    56     log_path.SetTo("");
     60    fLogConsoleFlag = true;
     61    fLogFileFlag = false;
     62    fLogPath.SetTo("");
    5763   
    58     max_connections = (int16)32;
     64    fMaxConnections = (int16)32;
    5965   
    60     is_zoomed = true;
    61     last_width = 318.0f;
    62     last_height = 320.0f;
    63     this->frame = frame;
    64     setwindow_frame.Set(112.0f, 60.0f, 492.0f, 340.0f);
     66    fIsZoomed = true;
     67    fLastWidth = 318.0f;
     68    fLastHeight = 320.0f;
     69    this->fFrame = frame;
     70    fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f);
    6571   
    6672    // PoorMan Window
    6773    SetSizeLimits(318, 1600, 53, 1200);
    6874    // limit the size of the size of the window
    6975   
    70     //SetZoomLimits(1024, 768);
    71    
    72     //frame.Set(30.0f, 30.0f, 355.0f, 185.0f);
    73     frame.OffsetTo(B_ORIGIN);
    74     frame = Bounds();
    75     frame.top += 19.0;
    76    
    77     mainView = new PoorManView(frame, STR_APP_NAME);
    78     mainView->SetViewColor(216,216,216,255);
    79    
    80     mainView->SetFont(be_bold_font);
    81     mainView->SetFontSize(12);
    82     AddChild(mainView);
    83    
    84     // BBox tests
    85     BRect br;
    86     br = mainView->Bounds();
    87     br.top = 1.0;
    88 
    89     BBox * bb = new BBox(br, "Background", B_FOLLOW_ALL_SIDES,
    90         B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE);
    91     bb->SetHighColor(WHITE);
    92     bb->SetLowColor(GRAY);
    93     bb->SetBorder(B_PLAIN_BORDER);
    94     mainView->AddChild(bb);
     76    SetLayout(new BGroupLayout(B_VERTICAL));
    9577
    9678    // -----------------------------------------------------------------
    9779    // Three Labels
    9880   
    9981    // Status String
    100     BRect statusRect;
    101     statusRect = Bounds();
    102     statusRect.left += 5;
    103     statusRect.top  += 3;
    104     statusRect.bottom = statusRect.top + 15;
    105     statusRect.right = statusRect.left + 100;   // make the width wide enough for the string to display
    106        
    107     statusView = new BStringView(statusRect, "Status View",
    108         B_TRANSLATE("Status: Stopped"));
    109     bb->AddChild(statusView);
     82    fStatusView = new BStringView("Status View", B_TRANSLATE("Status: Stopped"));
    11083   
    11184    // Directory String
    112     BRect dirRect;
    113     dirRect = Bounds();
    114     dirRect.top = statusRect.bottom - 1;
    115     dirRect.bottom = dirRect.top + 15;
    116     dirRect.left = statusRect.left;
    117     dirRect.right -= 5;
    118    
    119     dirView = new BStringView(dirRect, "Dir View",
    120         B_TRANSLATE("Directory: (none)"), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
    121     bb->AddChild(dirView);
     85    fDirView = new BStringView("Dir View", B_TRANSLATE("Directory: (none)"));
    12286   
    12387    // Hits String
    124     BRect hitsRect;
    125     hitsRect = bb->Bounds();
    126     hitsRect.InsetBy(5.0f, 5.0f);
    127     hitsRect.top = statusRect.top;
    128     hitsRect.bottom = statusRect.bottom;
    129     hitsRect.left = statusRect.right + 20;
    130    
    131     hitsView = new BStringView(hitsRect, "Hit View", B_TRANSLATE("Hits: 0"),
    132         B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    133     hitsView->SetAlignment(B_ALIGN_RIGHT);
    134     bb->AddChild(hitsView);
     88    fHitsView = new BStringView("Hit View", B_TRANSLATE("Hits: 0"));
    13589
    13690    // -----------------------------------------------------------------
    13791    // Logging View
    138    
    139     // logRect
    140     BRect logRect = bb->Bounds();//(5.0, 36.0, 306.0, 131.0);
    141     logRect.InsetBy(5, 5);
    142     logRect.top = 36.0f;
    143     logRect.right -= B_V_SCROLL_BAR_WIDTH;
    144    
    145     // textRect
    146     BRect textRect; //(1.0, 1.0, 175.0, 75.0);
    147     textRect = logRect;
    148     textRect.top = 0.0;
    149     textRect.left = 2.0;
    150     textRect.right = logRect.right - logRect.left - 2.0;
    151     textRect.bottom = logRect.bottom - logRect.top;
    152 
    153     fLogViewFont = new BFont(be_plain_font);
    154     fLogViewFont->SetSize(11.0);
    155 
    156     loggingView = new BTextView(logRect, STR_TXT_VIEW, textRect,
    157          fLogViewFont, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW );
    158 
    159     loggingView->MakeEditable(false);   // user cannot change the text
    160     loggingView->MakeSelectable(true);
    161     loggingView->SetViewColor(WHITE);
    162     loggingView->SetStylable(true);
     92
     93    fLoggingView = new BTextView(STR_TXT_VIEW, B_WILL_DRAW );
     94
     95    fLoggingView->MakeEditable(false);  // user cannot change the text
     96    fLoggingView->MakeSelectable(true);
     97    fLoggingView->SetViewColor(WHITE);
     98    fLoggingView->SetStylable(true);
    16399       
    164100    // create the scroll view
    165     scrollView = new BScrollView("Scroll View", loggingView, B_FOLLOW_ALL_SIDES,
    166                     B_WILL_DRAW | B_FRAME_EVENTS,
     101    fScrollView = new BScrollView("Scroll View", fLoggingView,
     102                    B_WILL_DRAW | B_FRAME_EVENTS | B_FOLLOW_ALL_SIDES,
    167103                    // Make sure articles on border do not occur when resizing
    168104                    false, true);
    169     bb->AddChild(scrollView);
    170     loggingView->MakeFocus(true);
     105    fLoggingView->MakeFocus(true);
    171106
    172107
    173108    // -----------------------------------------------------------------
    174109    // menu bar
    175     BRect menuRect;
    176     menuRect = Bounds();
    177     menuRect.bottom = 18.0f;
    178    
    179     FileMenuBar = new BMenuBar(menuRect, "File Menu Bar");
     110    fFileMenuBar = new BMenuBar("File Menu Bar");
    180111   
    181112    // menus
    182     FileMenu = BuildFileMenu();
    183     if (FileMenu)
    184         FileMenuBar->AddItem(FileMenu);
     113    fFileMenu = BuildFileMenu();
     114    if (fFileMenu)
     115        fFileMenuBar->AddItem(fFileMenu);
    185116           
    186     EditMenu = BuildEditMenu();
    187     if (EditMenu)
    188         FileMenuBar->AddItem(EditMenu);
     117    fEditMenu = BuildEditMenu();
     118    if (fEditMenu)
     119        fFileMenuBar->AddItem(fEditMenu);
    189120       
    190     ControlsMenu = BuildControlsMenu();
    191     if (ControlsMenu)
    192         FileMenuBar->AddItem(ControlsMenu);
     121    fControlsMenu = BuildControlsMenu();
     122    if (fControlsMenu)
     123        fFileMenuBar->AddItem(fControlsMenu);
    193124   
    194125    // File Panels
    195126    BWindow* change_title;
    196127   
    197     BMessenger messenger(this);
    198     saveConsoleFilePanel = new BFilePanel(
    199                         B_SAVE_PANEL,
    200                         &messenger,
    201                         NULL,
    202                         B_FILE_NODE,
    203                         false,
     128    fSaveConsoleFilePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this),
     129                        NULL, B_FILE_NODE, false,
    204130                        new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE));
    205 
    206     change_title = saveConsoleFilePanel->Window();
     131    change_title = fSaveConsoleFilePanel->Window();
    207132    change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE);
    208133   
    209     saveConsoleSelectionFilePanel = new BFilePanel(
    210                         B_SAVE_PANEL,
    211                         &messenger,
    212                         NULL,
    213                         B_FILE_NODE,
    214                         false,
     134    fSaveConsoleSelectionFilePanel = new BFilePanel(B_SAVE_PANEL,
     135                        new BMessenger(this), NULL, B_FILE_NODE, false,
    215136                        new BMessage(MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION));
    216 
    217     change_title = saveConsoleSelectionFilePanel->Window();
     137    change_title = fSaveConsoleSelectionFilePanel->Window();
    218138    change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE_SELECTION);
    219139   
    220    
    221     AddChild(FileMenuBar);
     140    AddChild(BGroupLayoutBuilder(B_VERTICAL)
     141        .Add(fFileMenuBar)
     142        .Add(BGroupLayoutBuilder(B_VERTICAL, 5)
     143            .Add(BGroupLayoutBuilder(B_HORIZONTAL)
     144                .Add(fStatusView)
     145                .AddGlue()
     146                .Add(fHitsView))
     147            .Add(BGroupLayoutBuilder(B_HORIZONTAL)
     148                .Add(fDirView)
     149                .AddGlue())
     150            .Add(fScrollView)
     151        .SetInsets(10, 10, 10, 10)));
    222152   
    223153    pthread_rwlock_init(&fLogFileLock, NULL);
    224154}
    PoorManWindow::PoorManWindow(BRect frame)  
    227157PoorManWindow::~PoorManWindow()
    228158{
    229159    delete fServer;
    230     delete fLogViewFont;
    231160    delete fLogFile;
    232161    pthread_rwlock_destroy(&fLogFileLock);
    233162}
    void  
    237166PoorManWindow::MessageReceived(BMessage* message)
    238167{
    239168    switch (message->what) {
    240     case MSG_MENU_FILE_SAVE_AS:
    241         saveConsoleFilePanel->Show();
    242         break;
    243     case MSG_FILE_PANEL_SAVE_CONSOLE:
    244         printf("FilePanel: Save console\n");
    245         SaveConsole(message, false);
    246         break;
    247     case MSG_MENU_FILE_SAVE_SELECTION:
    248         saveConsoleSelectionFilePanel->Show();
    249         break;
    250     case MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION:
    251         printf("FilePanel: Save console selection\n");
    252         SaveConsole(message, true);
    253         break;
    254     case MSG_FILE_PANEL_SELECT_WEB_DIR:     
    255         prefWindow->MessageReceived(message);
    256         break;
    257     case MSG_MENU_EDIT_PREF:
    258         prefWindow = new PoorManPreferencesWindow(
    259             setwindow_frame,
    260             STR_WIN_NAME_PREF);
    261         prefWindow->Show();
    262         break;
    263     case MSG_MENU_CTRL_RUN:
    264         if (status)
    265             StopServer();
    266         else
    267             StartServer();
    268         break;
    269     case MSG_MENU_CTRL_CLEAR_HIT:
    270         SetHits(0);
    271         //UpdateHitsLabel();
    272         break;
    273     case MSG_MENU_CTRL_CLEAR_CONSOLE:
    274         loggingView->SelectAll();
    275         loggingView->Delete();
    276         break;
    277     case MSG_MENU_CTRL_CLEAR_LOG:
    278         FILE * f;
    279         f = fopen(log_path.String(), "w");
    280         fclose(f);
    281         break;
    282     case MSG_LOG: {
    283         if (!log_console_flag && !log_file_flag)
     169        case MSG_MENU_FILE_SAVE_AS:
     170            fSaveConsoleFilePanel->Show();
     171            break;
     172        case MSG_FILE_PANEL_SAVE_CONSOLE:
     173            printf("FilePanel: Save console\n");
     174            SaveConsole(message, false);
     175            break;
     176        case MSG_MENU_FILE_SAVE_SELECTION:
     177            fSaveConsoleSelectionFilePanel->Show();
     178            break;
     179        case MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION:
     180            printf("FilePanel: Save console selection\n");
     181            SaveConsole(message, true);
     182            break;
     183        case MSG_FILE_PANEL_SELECT_WEB_DIR:     
     184            fPrefWindow->MessageReceived(message);
     185            break;
     186        case MSG_MENU_EDIT_PREF:
     187            fPrefWindow = new PoorManPreferencesWindow(fSetwindowFrame,
     188                STR_WIN_NAME_PREF);
     189            fPrefWindow->Show();
     190            break;
     191        case MSG_MENU_CTRL_RUN:
     192            if (fStatus)
     193                StopServer();
     194            else
     195                StartServer();
     196            break;
     197        case MSG_MENU_CTRL_CLEAR_HIT:
     198            SetHits(0);
     199            //UpdateHitsLabel();
     200            break;
     201        case MSG_MENU_CTRL_CLEAR_CONSOLE:
     202            fLoggingView->SelectAll();
     203            fLoggingView->Delete();
     204            break;
     205        case MSG_MENU_CTRL_CLEAR_LOG:
     206            FILE* f;
     207            f = fopen(fLogPath.String(), "w");
     208            fclose(f);
    284209            break;
     210        case MSG_LOG: {
     211            if (!fLogConsoleFlag && !fLogFileFlag)
     212                break;
    285213   
    286         time_t time;
    287         in_addr_t address;
    288         rgb_color color;
    289         const void* pointer;
    290         ssize_t size;
    291         const char* msg;
    292         BString line;
     214            time_t time;
     215            in_addr_t address;
     216            rgb_color color;
     217            const void* pointer;
     218            ssize_t size;
     219            const char* msg;
     220            BString line;
    293221       
    294         if (message->FindString("cstring", &msg) != B_OK)
    295             break;
    296         if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK)
    297             time = -1;
    298         else
    299             time = *static_cast<const time_t*>(pointer);
    300 
    301         if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK)
    302             address = INADDR_NONE;
    303         else
    304             address = *static_cast<const in_addr_t*>(pointer);
    305 
    306         if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK)
    307             color = BLACK;
    308         else
    309             color = *static_cast<const rgb_color*>(pointer);
     222            if (message->FindString("cstring", &msg) != B_OK)
     223                break;
     224            if (message->FindData("time_t", B_TIME_TYPE, &pointer, &size) != B_OK)
     225                time = -1;
     226            else
     227                time = *static_cast<const time_t*>(pointer);
     228
     229            if (message->FindData("in_addr_t", B_ANY_TYPE, &pointer, &size) != B_OK)
     230                address = INADDR_NONE;
     231            else
     232                address = *static_cast<const in_addr_t*>(pointer);
     233
     234            if (message->FindData("rgb_color", B_RGB_COLOR_TYPE, &pointer, &size) != B_OK)
     235                color = BLACK;
     236            else
     237                color = *static_cast<const rgb_color*>(pointer);
    310238       
    311         if (time != -1) {
    312             BString timeString;
    313             if (BLocale::Default()->FormatDateTime(&timeString, time,
    314                     DATE_FORMAT, TIME_FORMAT) == B_OK) {
    315                 line << '[' << timeString << "]: ";
     239            if (time != -1) {
     240                BString timeString;
     241                if (BLocale::Default()->FormatDateTime(&timeString, time,
     242                        DATE_FORMAT, TIME_FORMAT) == B_OK) {
     243                    line << '[' << timeString << "]: ";
     244                }
    316245            }
    317         }
    318246       
    319         if (address != INADDR_NONE) {
    320             char addr[INET_ADDRSTRLEN];
    321             struct in_addr sin_addr;
    322             sin_addr.s_addr = address;
    323             if (inet_ntop(AF_INET, &sin_addr, addr, sizeof(addr)) != NULL) {
    324                 addr[strlen(addr)] = '\0';
    325                 line << '(' << addr << ") ";
     247            if (address != INADDR_NONE) {
     248                char addr[INET_ADDRSTRLEN];
     249                struct in_addr sin_addr;
     250                sin_addr.s_addr = address;
     251                if (inet_ntop(AF_INET, &sin_addr, addr, sizeof(addr)) != NULL) {
     252                    addr[strlen(addr)] = '\0';
     253                    line << '(' << addr << ") ";
     254                }
    326255            }
    327         }
    328256       
    329         line << msg;
     257            line << msg;
    330258       
    331         text_run run;
    332         text_run_array runs;
     259            text_run run;
     260            text_run_array runs;
    333261       
    334         run.offset = 0;
    335         run.font = *fLogViewFont;
    336         run.color = color;
     262            run.offset = 0;
     263            run.color = color;
    337264       
    338         runs.count = 1;
    339         runs.runs[0] = run;
     265            runs.count = 1;
     266            runs.runs[0] = run;
    340267       
    341         if (Lock()) {
    342             if (log_console_flag) {
    343                 loggingView->Insert(loggingView->TextLength(),
    344                     line.String(), line.Length(), &runs);
    345                 loggingView->ScrollToOffset(loggingView->TextLength());
    346             }
     268            if (Lock()) {
     269                if (fLogConsoleFlag) {
     270                    fLoggingView->Insert(fLoggingView->TextLength(),
     271                        line.String(), line.Length(), &runs);
     272                    fLoggingView->ScrollToOffset(fLoggingView->TextLength());
     273                }
    347274       
    348             if (log_file_flag) {
    349                 if (pthread_rwlock_rdlock(&fLogFileLock) == 0) {
    350                     fLogFile->Write(line.String(), line.Length());
    351                     pthread_rwlock_unlock(&fLogFileLock);
     275                if (fLogFileFlag) {
     276                    if (pthread_rwlock_rdlock(&fLogFileLock) == 0) {
     277                        fLogFile->Write(line.String(), line.Length());
     278                        pthread_rwlock_unlock(&fLogFileLock);
     279                    }
    352280                }
    353             }
    354281           
    355             Unlock();
    356         }
     282                Unlock();
     283            }
    357284       
    358         break;
    359     }
    360     default:
    361         BWindow::MessageReceived(message);
    362         break;
     285            break;
     286        }
     287        default:
     288            BWindow::MessageReceived(message);
     289            break;
    363290    }
    364291}
    365292
    PoorManWindow::MessageReceived(BMessage* message)  
    367294void
    368295PoorManWindow::FrameMoved(BPoint origin)
    369296{
    370     frame.left = origin.x;
    371     frame.top = origin.y;
     297    fFrame.left = origin.x;
     298    fFrame.top = origin.y;
    372299}
    373300
    374301
    375302void
    376303PoorManWindow::FrameResized(float width, float height)
    377304{
    378     if (is_zoomed) {
    379         last_width  = width;
    380         last_height = height;
     305    if (fIsZoomed) {
     306        fLastWidth  = width;
     307        fLastHeight = height;
    381308    }
    382309}
    383310
    PoorManWindow::FrameResized(float width, float height)  
    385312bool
    386313PoorManWindow::QuitRequested()
    387314{
    388     if (status) {
     315    if (fStatus) {
    389316        time_t now = time(NULL);
    390317        BString timeString;
    391318        BLocale::Default()->FormatDateTime(&timeString, now,
    PoorManWindow::QuitRequested()  
    395322        line << "[" << timeString << "]: " << B_TRANSLATE("Shutting down.")
    396323            << "\n";
    397324       
    398         if (log_console_flag) {
    399                 loggingView->Insert(loggingView->TextLength(),
    400                     line, line.Length());
    401                 loggingView->ScrollToOffset(loggingView->TextLength());
     325        if (fLogConsoleFlag) {
     326            fLoggingView->Insert(fLoggingView->TextLength(),
     327                line, line.Length());
     328            fLoggingView->ScrollToOffset(fLoggingView->TextLength());
    402329        }
    403330       
    404         if (log_file_flag) {
     331        if (fLogFileFlag) {
    405332            if (pthread_rwlock_rdlock(&fLogFileLock) == 0) {
    406                     fLogFile->Write(line, line.Length());
    407                     pthread_rwlock_unlock(&fLogFileLock);
     333                fLogFile->Write(line, line.Length());
     334                pthread_rwlock_unlock(&fLogFileLock);
    408335            }
    409336        }
    410337       
    411338        fServer->Stop();
    412         status = false;
     339        fStatus = false;
    413340        UpdateStatusLabelAndMenuItem();
    414341    }
    415342   
    PoorManWindow::QuitRequested()  
    422349void
    423350PoorManWindow::Zoom(BPoint origin, float width, float height)
    424351{
    425     if (is_zoomed) {
     352    if (fIsZoomed) {
    426353        // Change to the Minimal size
    427         is_zoomed = false;
     354        fIsZoomed = false;
    428355        ResizeTo(318, 53);
    429356    } else {   
    430357        // Change to the Zoomed size
    431         is_zoomed = true;
    432         ResizeTo(last_width, last_height);
     358        fIsZoomed = true;
     359        ResizeTo(fLastWidth, fLastHeight);
    433360    }
    434361}
    435362
    PoorManWindow::Zoom(BPoint origin, float width, float height)  
    437364void
    438365PoorManWindow::SetHits(uint32 num)
    439366{
    440     hits = num;
     367    fHits = num;
    441368    UpdateHitsLabel();
    442369}
    443370
    PoorManWindow::SetHits(uint32 num)  
    445372// Private: Methods ------------------------------------------
    446373
    447374
    448 BMenu *
     375BMenu*
    449376PoorManWindow::BuildFileMenu() const
    450377{
    451     BMenu * ptrFileMenu = new BMenu(STR_MNU_FILE);
     378    BMenu* ptrFileMenu = new BMenu(STR_MNU_FILE);
    452379
    453380    ptrFileMenu->AddItem(new BMenuItem(STR_MNU_FILE_SAVE_AS,
    454381        new BMessage(MSG_MENU_FILE_SAVE_AS), CMD_FILE_SAVE_AS));
    PoorManWindow::BuildFileMenu() const  
    465392}
    466393
    467394
    468 BMenu *
     395BMenu
    469396PoorManWindow::BuildEditMenu() const
    470397{
    471     BMenu * ptrEditMenu = new BMenu(STR_MNU_EDIT);
     398    BMenu* ptrEditMenu = new BMenu(STR_MNU_EDIT);
    472399   
    473     BMenuItem * CopyMenuItem = new BMenuItem(STR_MNU_EDIT_COPY,
     400    BMenuItem* CopyMenuItem = new BMenuItem(STR_MNU_EDIT_COPY,
    474401        new BMessage(B_COPY), CMD_EDIT_COPY);
    475402
    476403    ptrEditMenu->AddItem(CopyMenuItem);
    477     CopyMenuItem->SetTarget(loggingView, NULL);
     404    CopyMenuItem->SetTarget(fLoggingView, NULL);
    478405   
    479406    ptrEditMenu->AddSeparatorItem();
    480407
    481     BMenuItem * SelectAllMenuItem = new BMenuItem(STR_MNU_EDIT_SELECT_ALL,
     408    BMenuItem* SelectAllMenuItem = new BMenuItem(STR_MNU_EDIT_SELECT_ALL,
    482409    new BMessage(B_SELECT_ALL), CMD_EDIT_SELECT_ALL);
    483410   
    484411    ptrEditMenu->AddItem(SelectAllMenuItem);
    485     SelectAllMenuItem->SetTarget(loggingView, NULL);
     412    SelectAllMenuItem->SetTarget(fLoggingView, NULL);
    486413   
    487414    ptrEditMenu->AddSeparatorItem();
    488415   
    489     BMenuItem * PrefMenuItem = new BMenuItem(STR_MNU_EDIT_PREF,
     416    BMenuItem* PrefMenuItem = new BMenuItem(STR_MNU_EDIT_PREF,
    490417        new BMessage(MSG_MENU_EDIT_PREF));
    491418    ptrEditMenu->AddItem(PrefMenuItem);
    492419   
    PoorManWindow::BuildEditMenu() const  
    494421}
    495422
    496423
    497 BMenu *
     424BMenu
    498425PoorManWindow::BuildControlsMenu() const
    499426{
    500     BMenu * ptrControlMenu = new BMenu(STR_MNU_CTRL);
     427    BMenu* ptrControlMenu = new BMenu(STR_MNU_CTRL);
    501428   
    502     BMenuItem * RunServerMenuItem = new BMenuItem(STR_MNU_CTRL_RUN_SERVER,
     429    BMenuItem* RunServerMenuItem = new BMenuItem(STR_MNU_CTRL_RUN_SERVER,
    503430        new BMessage(MSG_MENU_CTRL_RUN));
    504431    RunServerMenuItem->SetMarked(false);
    505432    ptrControlMenu->AddItem(RunServerMenuItem);
    506433   
    507     BMenuItem * ClearHitCounterMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_HIT_COUNTER,
     434    BMenuItem* ClearHitCounterMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_HIT_COUNTER,
    508435        new BMessage(MSG_MENU_CTRL_CLEAR_HIT));
    509436    ptrControlMenu->AddItem(ClearHitCounterMenuItem);
    510437
    511438    ptrControlMenu->AddSeparatorItem();
    512439
    513     BMenuItem * ClearConsoleLogMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_CONSOLE,
     440    BMenuItem* ClearConsoleLogMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_CONSOLE,
    514441        new BMessage(MSG_MENU_CTRL_CLEAR_CONSOLE));
    515442    ptrControlMenu->AddItem(ClearConsoleLogMenuItem);
    516443
    517     BMenuItem * ClearLogFileMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_LOG_FILE,
     444    BMenuItem* ClearLogFileMenuItem = new BMenuItem(STR_MNU_CTRL_CLEAR_LOG_FILE,
    518445        new BMessage(MSG_MENU_CTRL_CLEAR_LOG));
    519446    ptrControlMenu->AddItem(ClearLogFileMenuItem);
    520447   
    PoorManWindow::BuildControlsMenu() const  
    523450
    524451
    525452void
    526 PoorManWindow::SetDirLabel(const char * name)
     453PoorManWindow::SetDirLabel(const char* name)
    527454{
    528455    BString dirPath(B_TRANSLATE("Directory: "));
    529456    dirPath.Append(name);
    530457   
    531458    if (Lock()) {
    532         dirView->SetText(dirPath.String());
     459        fDirView->SetText(dirPath.String());
    533460        Unlock();
    534461    }
    535462}
    void  
    539466PoorManWindow::UpdateStatusLabelAndMenuItem()
    540467{
    541468    if (Lock()) {
    542         if (status)
    543             statusView->SetText(B_TRANSLATE("Status: Running"));
     469        if (fStatus)
     470            fStatusView->SetText(B_TRANSLATE("Status: Running"));
    544471        else
    545             statusView->SetText(B_TRANSLATE("Status: Stopped"));
    546         ControlsMenu->FindItem(STR_MNU_CTRL_RUN_SERVER)->SetMarked(status);
     472            fStatusView->SetText(B_TRANSLATE("Status: Stopped"));
     473        fControlsMenu->FindItem(STR_MNU_CTRL_RUN_SERVER)->SetMarked(fStatus);
    547474        Unlock();
    548475    }
    549476}
    void  
    553480PoorManWindow::UpdateHitsLabel()
    554481{
    555482    if (Lock()) {
    556         sprintf(hitsLabel, B_TRANSLATE("Hits: %lu"), GetHits());
    557         hitsView->SetText(hitsLabel);
     483        sprintf(fHitsLabel, B_TRANSLATE("Hits: %lu"), GetHits());
     484        fHitsView->SetText(fHitsLabel);
    558485       
    559486        Unlock();
    560487    }
    PoorManWindow::UpdateHitsLabel()  
    562489
    563490
    564491status_t
    565 PoorManWindow::SaveConsole(BMessage * message, bool selection)
     492PoorManWindow::SaveConsole(BMessage* message, bool selection)
    566493{
    567494    entry_ref   ref;
    568     const char  * name;
     495    const char* name;
    569496    BPath       path;
    570497    BEntry      entry;
    571498    status_t    err = B_OK;
    572     FILE        *f;
     499    FILE*       f;
    573500   
    574     if ((err = message->FindRef("directory", &ref)) != B_OK)
     501    err = message->FindRef("directory", &ref);
     502    if (err != B_OK)
    575503        return err;
    576504   
    577     if ((err = message->FindString("name", &name)) != B_OK)
     505    err = message->FindString("name", &name);
     506    if (err != B_OK)
    578507        return err;
    579508   
    580     if ((err = entry.SetTo(&ref)) != B_OK)
     509    err = entry.SetTo(&ref);
     510    if (err != B_OK)
    581511        return err;
    582512   
    583513    entry.GetPath(&path);
    PoorManWindow::SaveConsole(BMessage * message, bool selection)  
    588518   
    589519    if (!selection) {
    590520        // write the data to the file
    591         err = fwrite(loggingView->Text(), 1, loggingView->TextLength(), f);
     521        err = fwrite(fLoggingView->Text(), 1, fLoggingView->TextLength(), f);
    592522    } else {
    593523        // find the selected text and write it to a file
    594524        int32 start = 0, end = 0;
    595         loggingView->GetSelection(&start, &end);
     525        fLoggingView->GetSelection(&start, &end);
    596526       
    597527        BString buffer;
    598528        char * buffData = buffer.LockBuffer(end - start + 1);
    599529        // copy the selected text from the TextView to the buffer   
    600         loggingView->GetText(start, end - start, buffData);
     530        fLoggingView->GetText(start, end - start, buffData);
    601531        buffer.UnlockBuffer(end - start + 1);
    602532       
    603533        err = fwrite(buffer.String(), 1, end - start + 1, f);
    604534    }
     535   
    605536    fclose(f);
    606537   
    607538    return err;
    PoorManWindow::DefaultSettings()  
    627558            break;
    628559       
    629560        case 1:
    630             prefWindow = new PoorManPreferencesWindow(
    631                     setwindow_frame,
     561            fPrefWindow = new PoorManPreferencesWindow(
     562                    fSetwindowFrame,
    632563                    STR_WIN_NAME_PREF);
    633             prefWindow->ShowWebDirFilePanel();
     564            fPrefWindow->ShowWebDirFilePanel();
    634565            break;
    635566
    636567        case 2:
    PoorManWindow::ReadSettings()  
    674605        return B_ERROR;
    675606   
    676607    //site tab
    677     if (m.FindString("web_directory", &web_directory) != B_OK)
    678         web_directory.SetTo(STR_DEFAULT_WEB_DIRECTORY);
    679     if (m.FindString("index_file_name", &index_file_name) != B_OK)
    680         index_file_name.SetTo("index.html");
    681     if (m.FindBool("dir_list_flag", &dir_list_flag) != B_OK)
    682         dir_list_flag = false;
     608    if (m.FindString("fWebDirectory", &fWebDirectory) != B_OK)
     609        fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY);
     610    if (m.FindString("fIndexFileName", &fIndexFileName) != B_OK)
     611        fIndexFileName.SetTo("index.html");
     612    if (m.FindBool("fDirListFlag", &fDirListFlag) != B_OK)
     613        fDirListFlag = false;
    683614   
    684615    //logging tab
    685     if (m.FindBool("log_console_flag", &log_console_flag) != B_OK)
    686         log_console_flag = true;
    687     if (m.FindBool("log_file_flag", &log_file_flag) != B_OK)
    688         log_file_flag = false;
    689     if (m.FindString("log_path", &log_path) != B_OK)
    690         log_path.SetTo("");
     616    if (m.FindBool("fLogConsoleFlag", &fLogConsoleFlag) != B_OK)
     617        fLogConsoleFlag = true;
     618    if (m.FindBool("fLogFileFlag", &fLogFileFlag) != B_OK)
     619        fLogFileFlag = false;
     620    if (m.FindString("fLogPath", &fLogPath) != B_OK)
     621        fLogPath.SetTo("");
    691622   
    692623    //advance tab
    693     if (m.FindInt16("max_connections", &max_connections) != B_OK)
    694         max_connections = (int16)32;
     624    if (m.FindInt16("fMaxConnections", &fMaxConnections) != B_OK)
     625        fMaxConnections = (int16)32;
    695626   
    696627    //windows' position and size
    697     if (m.FindRect("frame", &frame) != B_OK)
    698         frame.Set(82.0f, 30.0f, 400.0f, 350.0f);
    699     if (m.FindRect("setwindow_frame", &setwindow_frame) != B_OK)
    700         setwindow_frame.Set(112.0f, 60.0f, 492.0f, 340.0f);
    701     if (m.FindBool("is_zoomed", &is_zoomed) != B_OK)
    702         is_zoomed = true;
    703     if (m.FindFloat("last_width", &last_width) != B_OK)
    704         last_width = 318.0f;
    705     if (m.FindFloat("last_height", &last_height) != B_OK)
    706         last_height = 320.0f;
    707    
    708     is_zoomed?ResizeTo(last_width, last_height):ResizeTo(318, 53);
    709     MoveTo(frame.left, frame.top);
    710    
    711     fLogFile = new BFile(log_path.String(), B_CREATE_FILE | B_WRITE_ONLY
     628    if (m.FindRect("frame", &fFrame) != B_OK)
     629        fFrame.Set(82.0f, 30.0f, 400.0f, 350.0f);
     630    if (m.FindRect("fSetwindowFrame", &fSetwindowFrame) != B_OK)
     631        fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f);
     632    if (m.FindBool("fIsZoomed", &fIsZoomed) != B_OK)
     633        fIsZoomed = true;
     634    if (m.FindFloat("fLastWidth", &fLastWidth) != B_OK)
     635        fLastWidth = 318.0f;
     636    if (m.FindFloat("fLastHeight", &fLastHeight) != B_OK)
     637        fLastHeight = 320.0f;
     638   
     639    fIsZoomed?ResizeTo(fLastWidth, fLastHeight):ResizeTo(318, 53);
     640    MoveTo(fFrame.left, fFrame.top);
     641   
     642    fLogFile = new BFile(fLogPath.String(), B_CREATE_FILE | B_WRITE_ONLY
    712643        | B_OPEN_AT_END);
    713644    if (fLogFile->InitCheck() != B_OK) {
    714         log_file_flag = false;
     645        fLogFileFlag = false;
    715646        //log it to console, "log to file unavailable."
    716647        return B_OK;
    717648    }
    718649   
    719     SetDirLabel(web_directory.String());
     650    SetDirLabel(fWebDirectory.String());
    720651   
    721652    return B_OK;
    722653}
    PoorManWindow::SaveSettings()  
    730661    BMessage m(MSG_PREF_FILE);
    731662       
    732663    //site tab
    733     m.AddString("web_directory", web_directory);
    734     m.AddString("index_file_name", index_file_name);
    735     m.AddBool("dir_list_flag", dir_list_flag);
     664    m.AddString("fWebDirectory", fWebDirectory);
     665    m.AddString("fIndexFileName", fIndexFileName);
     666    m.AddBool("fDirListFlag", fDirListFlag);
    736667   
    737668    //logging tab
    738     m.AddBool("log_console_flag", log_console_flag);
    739     m.AddBool("log_file_flag", log_file_flag);
    740     m.AddString("log_path", log_path);
     669    m.AddBool("fLogConsoleFlag", fLogConsoleFlag);
     670    m.AddBool("fLogFileFlag", fLogFileFlag);
     671    m.AddString("fLogPath", fLogPath);
    741672   
    742673    //advance tab
    743     m.AddInt16("max_connections", max_connections);
     674    m.AddInt16("fMaxConnections", fMaxConnections);
    744675   
    745676    //windows' position and size
    746     m.AddRect("frame", frame);
    747     m.AddRect("setwindow_frame", setwindow_frame);
    748     m.AddBool("is_zoomed", is_zoomed);
    749     m.AddFloat("last_width", last_width);
    750     m.AddFloat("last_height", last_height);
     677    m.AddRect("frame", fFrame);
     678    m.AddRect("fSetwindowFrame", fSetwindowFrame);
     679    m.AddBool("fIsZoomed", fIsZoomed);
     680    m.AddFloat("fLastWidth", fLastWidth);
     681    m.AddFloat("fLastHeight", fLastHeight);
    751682       
    752683    if (find_directory(B_USER_SETTINGS_DIRECTORY, &p) != B_OK)
    753684        return B_ERROR;
    status_t  
    768699PoorManWindow::StartServer()
    769700{
    770701    if (fServer == NULL)
    771         fServer = new PoorManServer(
    772             web_directory.String(),
    773             max_connections,
    774             dir_list_flag,
    775             index_file_name.String());
     702        fServer = new PoorManServer(fWebDirectory.String(), fMaxConnections,
     703            fDirListFlag, fIndexFileName.String());
    776704   
    777705    poorman_log(B_TRANSLATE("Starting up... "));
    778706    if (fServer->Run() != B_OK) {
    779707        return B_ERROR;
    780708    }
    781709
    782     status = true;
     710    fStatus = true;
    783711    UpdateStatusLabelAndMenuItem();
    784712    poorman_log(B_TRANSLATE("done.\n"), false, INADDR_NONE, GREEN);
    785713   
    PoorManWindow::StopServer()  
    795723   
    796724    poorman_log(B_TRANSLATE("Shutting down.\n"));
    797725    fServer->Stop();
    798     status = false;
     726    fStatus = false;
    799727    UpdateStatusLabelAndMenuItem();
    800728    return B_OK;
    801729}
    PoorManWindow::StopServer()  
    804732void
    805733PoorManWindow::SetLogPath(const char* str)
    806734{
    807     if (!strcmp(log_path, str))
     735    if (!strcmp(fLogPath, str))
    808736        return;
    809737   
    810738    BFile* temp = new BFile(str, B_CREATE_FILE | B_WRITE_ONLY | B_OPEN_AT_END);
    PoorManWindow::SetLogPath(const char* str)  
    823751        return;
    824752    }
    825753   
    826     log_path.SetTo(str);
     754    fLogPath.SetTo(str);
    827755}
  • src/apps/poorman/PoorManWindow.h

    diff --git a/src/apps/poorman/PoorManWindow.h b/src/apps/poorman/PoorManWindow.h
    index bdbca27..a2ddc51 100644
    a b class PoorManServer;  
    3333class PoorManWindow: public BWindow
    3434{
    3535public:
    36                     PoorManWindow(BRect frame);
    37 virtual             ~PoorManWindow();
    38 virtual void        MessageReceived(BMessage * message);
     36                            PoorManWindow(BRect frame);
     37    virtual                 ~PoorManWindow();
     38    virtual void            MessageReceived(BMessage* message);
    3939
    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);
     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);
    4444
    4545    // -------------------------------------------
    4646    // Public PoorMan Window Methods
    47         void        SetDirLabel(const char * name);
    48         void        SetHits(uint32 num);
    49         uint32      GetHits() { return hits; }
    50         status_t    SaveConsole(BMessage * message, bool);
     47            void            SetDirLabel(const char* name);
     48            void            SetHits(uint32 num);
     49            uint32          GetHits() { return fHits; }
     50            status_t        SaveConsole(BMessage* message, bool);
    5151       
    52         status_t    SaveSettings();
    53         status_t    ReadSettings();
    54         void        DefaultSettings();
     52            status_t        SaveSettings();
     53            status_t        ReadSettings();
     54            void            DefaultSettings();
    5555       
    56         status_t    StartServer();
    57         status_t    StopServer();
     56            status_t        StartServer();
     57            status_t        StopServer();
    5858       
    59         PoorManServer* GetServer()const{return fServer;}
     59            PoorManServer*  GetServer() const { return fServer;}
    6060    // ------------------------------------------- 
    6161    // Preferences and Settings
    6262        // Site Tab     
    63         bool         DirListFlag()                { return dir_list_flag; }
    64         void         SetDirListFlag(bool flag)    { dir_list_flag = flag; }
    65         const char * IndexFileName()              { return index_file_name.String(); }
    66         void         SetIndexFileName(const char * str) { index_file_name.SetTo(str); }
    67         const char * WebDir()                     { return web_directory.String(); }
    68         void         SetWebDir(const char * str)  { web_directory.SetTo(str); }
     63            bool            DirListFlag()
     64                                { return fDirListFlag; }
     65            void            SetDirListFlag(bool flag)
     66                                { fDirListFlag = flag; }
     67            const char*     IndexFileName()
     68                                { return fIndexFileName.String(); }
     69            void            SetIndexFileName(const char* str)
     70                                { fIndexFileName.SetTo(str); }
     71            const char*     WebDir()
     72                                { return fWebDirectory.String(); }
     73            void            SetWebDir(const char* str)
     74                                { fWebDirectory.SetTo(str); }
    6975        // Logging Tab
    70         bool         LogConsoleFlag()             { return log_console_flag; }
    71         void         SetLogConsoleFlag(bool flag) { log_console_flag = flag; }
    72         bool         LogFileFlag()                { return log_file_flag; }
    73         void         SetLogFileFlag(bool flag)    { log_file_flag = flag; }
    74         const char * LogPath()                    { return log_path.String(); }
    75         void         SetLogPath(const char * str);
     76            bool            LogConsoleFlag()
     77                                { return fLogConsoleFlag; }
     78            void            SetLogConsoleFlag(bool flag)
     79                                { fLogConsoleFlag = flag; }
     80            bool            LogFileFlag()
     81                                { return fLogFileFlag; }
     82            void            SetLogFileFlag(bool flag)
     83                                { fLogFileFlag = flag; }
     84            const char*     LogPath()
     85                                { return fLogPath.String(); }
     86            void            SetLogPath(const char* str);
    7687        // Advanced Tab
    77         int16        MaxConnections()             { return max_connections; }
    78         void         SetMaxConnections(int16 num) { max_connections = num;  }
    79 
     88            int16           MaxConnections()
     89                                { return fMaxConnections; }
     90            void            SetMaxConnections(int16 num)
     91                                { fMaxConnections = num;  }
    8092
    8193private:
    8294    // -------------------------------------------
    8395    // PoorMan Window Methods
    84         void        UpdateStatusLabelAndMenuItem();
    85         void        UpdateHitsLabel();
     96            void            UpdateStatusLabelAndMenuItem();
     97            void            UpdateHitsLabel();
    8698   
    8799private:
    88100    // -------------------------------------------
    89     // PoorMan Window
    90     PoorManView     * mainView;
    91    
    92     // -------------------------------------------
    93101    // Build Menu Methods
    94     BMenu *     BuildFileMenu() const;
    95     BMenu *     BuildEditMenu() const;
    96     BMenu *     BuildControlsMenu() const;
     102            BMenu*          BuildFileMenu() const;
     103            BMenu*          BuildEditMenu() const;
     104            BMenu*          BuildControlsMenu() const;
    97105   
    98106    // --------------------------------------------
    99107    // MenuBar & Menu items
    100     BMenuBar *  FileMenuBar;
    101     BMenu    *  FileMenu;
    102     BMenu    *  EditMenu;
    103     BMenu    *  ControlsMenu;
     108            BMenuBar*       fFileMenuBar;
     109            BMenu*          fFileMenu;
     110            BMenu*          fEditMenu;
     111            BMenu*          fControlsMenu;
    104112   
    105113    // --------------------------------------------
    106114    // Status, Hits, Directory
    107     BStringView *   statusView;
    108     BStringView *   hitsView;
    109     BStringView *   dirView;
     115            BStringView*    fStatusView;
     116            BStringView*    fHitsView;
     117            BStringView*    fDirView;
    110118   
    111     bool            status;
    112     uint32          hits;
    113     char            hitsLabel[25];
     119            bool            fStatus;
     120            uint32          fHits;
     121            char            fHitsLabel[25];
    114122   
    115123    // --------------------------------------------
    116124    // Logging View
    117     BScrollView *   scrollView;
    118     BTextView   *   loggingView;
     125            BScrollView*    fScrollView;
     126            BTextView*      fLoggingView;
    119127    // use asctime() for format of [Date/Time]:
    120128   
    121129
    122130    // -------------------------------------------
    123131    // PoorMan Preference Window
    124     PoorManPreferencesWindow * prefWindow;
     132            PoorManPreferencesWindow * fPrefWindow;
    125133   
    126134    // site tab
    127     BString         web_directory;
    128     BString         index_file_name;
    129     bool            dir_list_flag;
     135            BString         fWebDirectory;
     136            BString         fIndexFileName;
     137            bool            fDirListFlag;
    130138
    131139    // logging tab
    132     bool            log_console_flag;
    133     bool            log_file_flag;
    134     BString         log_path;
     140            bool            fLogConsoleFlag;
     141            bool            fLogFileFlag;
     142            BString         fLogPath;
    135143   
    136144    // advanced tab
    137     int16           max_connections;
     145            int16           fMaxConnections;
    138146       
    139     bool            is_zoomed;
    140     float           last_width;
    141     float           last_height;
    142     BRect           frame;
    143     BRect           setwindow_frame;
     147            bool            fIsZoomed;
     148            float           fLastWidth;
     149            float           fLastHeight;
     150            BRect           fFrame;
     151            BRect           fSetwindowFrame;
    144152   
    145153    // File Panels
    146     BFilePanel  *   saveConsoleFilePanel;
    147     BFilePanel  *   saveConsoleSelectionFilePanel;
     154            BFilePanel*     fSaveConsoleFilePanel;
     155            BFilePanel*     fSaveConsoleSelectionFilePanel;
    148156
    149     BFile* fLogFile;
    150     BFont* fLogViewFont;
     157            BFile*          fLogFile;
    151158   
    152     PoorManServer* fServer;
     159            PoorManServer*  fServer;
    153160   
    154     pthread_rwlock_t fLogFileLock;
     161            pthread_rwlock_t fLogFileLock;
    155162};
    156163
    157164#endif
  • src/apps/poorman/StatusSlider.cpp

    diff --git a/src/apps/poorman/StatusSlider.cpp b/src/apps/poorman/StatusSlider.cpp
    index deaa1b0..694cda0 100644
    a b  
    1111#include <stdio.h>
    1212
    1313
    14 StatusSlider::StatusSlider   (BRect frame,
    15                 const char *name,
    16                 const char *label,
    17                 char *statusPrefix,
    18                 BMessage *message,
    19                 int32 minValue,
    20                 int32 maxValue)
    21            
    22             :   BSlider(frame,
    23                         name,
    24                         label,
    25                         message,
    26                         minValue,
    27                         maxValue
    28                         ),
    29                 StatusPrefix(statusPrefix)
     14StatusSlider::StatusSlider(const char* name, const char* label,
     15    char* statusPrefix, BMessage* message, int32 minValue, int32 maxValue)
     16    :
     17    BSlider(name, label, message, minValue, maxValue, B_HORIZONTAL),
     18    fStatusPrefix(statusPrefix)
    3019{
    31     temp = str;
     20    fTemp = fStr;
    3221}
    3322               
    3423const char*
    3524StatusSlider::UpdateText() const
    3625{
    37    
    38     sprintf(temp, "%ld %s", Value(), StatusPrefix);
    39    
    40     return temp;
     26    sprintf(fTemp, "%ld %s", Value(), fStatusPrefix);
     27
     28    return fTemp;
    4129}
  • src/apps/poorman/StatusSlider.h

    diff --git a/src/apps/poorman/StatusSlider.h b/src/apps/poorman/StatusSlider.h
    index b9003d7..e7d0d27 100644
    a b  
    1313#include <Slider.h>
    1414
    1515
    16 class StatusSlider: public BSlider
    17 {
     16class StatusSlider: public BSlider {
    1817public:
    19         StatusSlider(BRect frame,
    20                     const char *name,
    21                     const char *label,
    22                     char *statusPrefix,
    23                     BMessage *message,
    24                     int32 minValue,
    25                     int32 maxValue);
    26 virtual const char* UpdateText() const;
     18                            StatusSlider(const char* name,
     19                                const char* label,
     20                                char* statusPrefix,
     21                                BMessage* message,
     22                                int32 minValue,
     23                                int32 maxValue);
     24
     25    virtual const char* UpdateText() const;
     26
    2727private:
    28     char *  StatusPrefix;
    29     char *  temp;
    30     char    str[128];
     28            char*           fStatusPrefix;
     29            char*           fTemp;
     30            char            fStr[128];
    3131};
    3232
    3333#endif