From cdd15f847855b79ecb908fb7317fb3603128561d Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Mon, 21 Feb 2011 16:02:17 +0000 Subject: [PATCH] style tab cleanup; start using classy kMsg style BMessage vars; no functional change git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40599 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kits/net/preflet/NetworkSetupWindow.cpp | 69 +++++++++---------- .../kits/net/preflet/NetworkSetupWindow.h | 52 +++++++------- 2 files changed, 58 insertions(+), 63 deletions(-) diff --git a/src/tests/kits/net/preflet/NetworkSetupWindow.cpp b/src/tests/kits/net/preflet/NetworkSetupWindow.cpp index 8f051a1c96..7496410138 100644 --- a/src/tests/kits/net/preflet/NetworkSetupWindow.cpp +++ b/src/tests/kits/net/preflet/NetworkSetupWindow.cpp @@ -35,7 +35,7 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title) { // ---- Profiles section BMenu *profilesPopup = new BPopUpMenu(""); - _BuildProfilesMenu(profilesPopup, SELECT_PROFILE_MSG); + _BuildProfilesMenu(profilesPopup, kMsgProfileSelected); BMenuField *profilesMenuField = new BMenuField("profiles_menu", B_TRANSLATE("Profile:"), profilesPopup); @@ -51,10 +51,10 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title) bottomDivider->SetBorder(B_PLAIN_BORDER); fApplyButton = new BButton("apply", B_TRANSLATE("Apply"), - new BMessage(APPLY_NOW_MSG)); + new BMessage(kMsgApply)); fRevertButton = new BButton("revert", B_TRANSLATE("Revert"), - new BMessage(REVERT_MSG)); + new BMessage(kMsgRevert)); fRevertButton->SetEnabled(false); // Enable boxes resizing modes @@ -78,7 +78,7 @@ NetworkSetupWindow::NetworkSetupWindow(const char *title) .SetInsets(10, 10, 10, 10) ); - _BuildShowTabView(SHOW_MSG); + _BuildShowTabView(kMsgAddonShow); bottomDivider->SetExplicitMaxSize(BSize(B_SIZE_UNSET, 1)); fPanel->SetExplicitMinSize(BSize(fMinAddonViewRect.Width(), @@ -107,44 +107,43 @@ void NetworkSetupWindow::MessageReceived(BMessage* msg) { switch (msg->what) { - - case NEW_PROFILE_MSG: - break; - - case SELECT_PROFILE_MSG: { - BPath name; - const char *path; - bool is_default; - bool is_current; - - if (msg->FindString("path", &path) != B_OK) + case kMsgProfileNew: break; - name.SetTo(path); + case kMsgProfileSelected: { + BPath name; + const char *path; + bool is_default; + bool is_current; - is_default = (strcmp(name.Leaf(), "default") == 0); - is_current = (strcmp(name.Leaf(), "current") == 0); + if (msg->FindString("path", &path) != B_OK) + break; - fApplyButton->SetEnabled(!is_current); - break; - } + name.SetTo(path); - case SHOW_MSG: { - if (fAddonView) - fAddonView->RemoveSelf(); + is_default = (strcmp(name.Leaf(), "default") == 0); + is_current = (strcmp(name.Leaf(), "current") == 0); - fAddonView = NULL; - if (msg->FindPointer("addon_view", (void **) &fAddonView) != B_OK) + fApplyButton->SetEnabled(!is_current); break; + } - fPanel->AddChild(fAddonView); - fAddonView->ResizeTo(fPanel->Bounds().Width(), - fPanel->Bounds().Height()); - break; - } + case kMsgAddonShow: { + if (fAddonView) + fAddonView->RemoveSelf(); - default: - inherited::MessageReceived(msg); + fAddonView = NULL; + if (msg->FindPointer("addon_view", (void **) &fAddonView) != B_OK) + break; + + fPanel->AddChild(fAddonView); + fAddonView->ResizeTo(fPanel->Bounds().Width(), + fPanel->Bounds().Height()); + break; + } + + default: + inherited::MessageReceived(msg); } } @@ -193,9 +192,9 @@ NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, int32 msg_what) menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("New" B_UTF8_ELLIPSIS), - new BMessage(NEW_PROFILE_MSG))); + new BMessage(kMsgProfileNew))); menu->AddItem(new BMenuItem(B_TRANSLATE("Manage" B_UTF8_ELLIPSIS), - new BMessage(MANAGE_PROFILES_MSG))); + new BMessage(kMsgProfileManage))); if (strlen(current_profile)) { item = menu->FindItem(current_profile); diff --git a/src/tests/kits/net/preflet/NetworkSetupWindow.h b/src/tests/kits/net/preflet/NetworkSetupWindow.h index db0b16578c..a1f300e5bd 100644 --- a/src/tests/kits/net/preflet/NetworkSetupWindow.h +++ b/src/tests/kits/net/preflet/NetworkSetupWindow.h @@ -18,38 +18,34 @@ class BMenu; class NetworkSetupWindow : public BWindow { public: - NetworkSetupWindow(const char *title); - ~NetworkSetupWindow(); - - typedef BWindow inherited; + NetworkSetupWindow(const char *title); + ~NetworkSetupWindow(); - enum { - SELECT_PROFILE_MSG = 'prof', - MANAGE_PROFILES_MSG = 'mngp', - NEW_PROFILE_MSG = 'newp', - COPY_PROFILE_MSG = 'cpyp', - DELETE_PROFILE_MSG = 'delp', - SHOW_MSG = 'show', - HELP_MSG = 'help', - DONT_TOUCH_MSG = 'lock', - APPLY_NOW_MSG = 'aply', - REVERT_MSG = 'rvrt' - }; - - bool QuitRequested(); - void MessageReceived(BMessage* msg); + typedef BWindow inherited; + + static const uint32 kMsgAddonShow = 'show'; + static const uint32 kMsgProfileSelected = 'prof'; + static const uint32 kMsgProfileManage = 'mngp'; + static const uint32 kMsgProfileNew = 'newp'; + static const uint32 kMsgApply = 'aply'; + static const uint32 kMsgRevert = 'rvrt'; + + bool QuitRequested(); + void MessageReceived(BMessage* msg); private: - void _BuildProfilesMenu(BMenu* menu, int32 msg); - void _BuildShowTabView(int32 msg); - - BButton* fHelpButton; - BButton* fRevertButton; - BButton* fApplyButton; + void _BuildProfilesMenu(BMenu* menu, int32 msg); + void _BuildShowTabView(int32 msg); - BTabView* fPanel; - BView* fAddonView; - BRect fMinAddonViewRect; + BButton* fHelpButton; + BButton* fRevertButton; + BButton* fApplyButton; + + BTabView* fPanel; + BView* fAddonView; + BRect fMinAddonViewRect; }; + #endif // ifdef NETWORKSETUPWINDOW_H +