diff --git a/App.cpp b/App.cpp index de3931a..04fd55b 100644 --- a/App.cpp +++ b/App.cpp @@ -18,6 +18,7 @@ App::App() { fMainWindow = new MainWindow(); fMainWindow->Show(); + fMainWindow->Activate(); } void diff --git a/App.h b/App.h index af5b828..8b7950d 100644 --- a/App.h +++ b/App.h @@ -21,9 +21,8 @@ class App: public BApplication public: App(); void AboutRequested(); - private: - MainWindow* fMainWindow; + MainWindow* fMainWindow; }; #endif diff --git a/CategorySettingWindow.cpp b/CategorySettingWindow.cpp new file mode 100644 index 0000000..f690259 --- /dev/null +++ b/CategorySettingWindow.cpp @@ -0,0 +1,57 @@ +/* + * Copyright 2015 Your Name + * All rights reserved. Distributed under the terms of the MIT license. + */ + + +#include "CategorySettingWindow.h" + +CategorySettingWindow::CategorySettingWindow(vector vCustomApps) + : BWindow(BRect(),"Category Settings" + ,B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS ) { + + ResizeTo(400,400); + CenterOnScreen(); + buildLayout(vCustomApps); +} +void +CategorySettingWindow::buildLayout(vector vCustomApps) { + + fCategoryMenu = new BPopUpMenu("Select Category.."); + + fCategoryMenu->AddItem(new BMenuItem("Appearance", + new BMessage(kSetCategory))); + fCategoryMenu->AddItem(new BMenuItem("Input/Output", + new BMessage(kSetCategory))); + fCategoryMenu->AddItem(new BMenuItem("Connectivity", + new BMessage(kSetCategory))); + fCategoryMenu->AddItem(new BMenuItem("System", + new BMessage(kSetCategory))); + fCategoryMenu->AddItem(new BMenuItem("Uncategorized", + new BMessage(kSetCategory))); + + for(int i = 0; ic_str(), fCategoryMenu); + CategoryField->SetAlignment(B_ALIGN_RIGHT); + } + + BButton* bUpdate = new BButton("Apply Changes"); + + fWindowView = new BView("Main Window View", 0); + BLayoutBuilder::Group<>(fWindowView, B_VERTICAL) + .SetInsets(B_USE_DEFAULT_SPACING) + .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) + .Add(CategoryField) + .End() + .Add(bUpdate) + .End(); + + BLayoutBuilder::Group<>(this, B_VERTICAL, 0) + .Add(fWindowView) + .End(); +} + diff --git a/CategorySettingWindow.h b/CategorySettingWindow.h new file mode 100644 index 0000000..aa1fd1c --- /dev/null +++ b/CategorySettingWindow.h @@ -0,0 +1,28 @@ +/* + * Copyright 2015 Your Name + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef CATEGORYSETTINGWINDOW_H +#define CATEGORYSETTINGWINDOW_H + + +#include +#include "MainWindow.h" + +class CategorySettingWindow: public BWindow { + +static const uint32 kSetCategory = 'mnpl'; + +public: + CategorySettingWindow(vector vCustomApps); + void buildLayout(vector vCustomApps); +private: + BView* fWindowView; + BPopUpMenu* fCategoryMenu; + BMenuField* CategoryField; + + +}; + + +#endif // CATEGORYSETTINGWINDOW_H diff --git a/MainWindow.cpp b/MainWindow.cpp index 901b71e..0c398b3 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -22,7 +22,8 @@ MainWindow::MainWindow() fetchPreflets(); populateLayout(); mergeLayouts(); - mergeLayoutsCategory(); + mergeLayoutsCategory(); + tSearch->MakeFocus(true); } void @@ -130,6 +131,7 @@ MainWindow::populateLayout() { BButton* button = new BButton(fAppName, fAppName, mButton); button->SetFlat(true); button->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP)); + vCustomApps.push_back(fAppName); NameButton[fAppName] = button; bSetIcon(button, vSign[i]); layout = CustomLayout->AddView(button); @@ -243,7 +245,10 @@ MainWindow::buildMenubar() { mAlphabetical = new BMenuItem("Sort Alphabetically", new BMessage(kAlphabeticalwise)); fAppMenu->AddItem(mAlphabetical); mAlphabetical->SetMarked(false); - + + mAlphabetical = new BMenuItem("Set Categories..", new BMessage(kCategoryLaunch)); + fAppMenu->AddItem(mAlphabetical); + fMenuBar->AddItem(fAppMenu); fAppMenu = new BMenu("Help.."); BMenuItem* item = new BMenuItem("About..", new BMessage(B_ABOUT_REQUESTED)); @@ -349,8 +354,7 @@ MainWindow::buildLayout() { .Layout(); tSearch = new BTextControl("Search:", "Enter query here: ", NULL, NULL); - tSearch->SetModificationMessage(new BMessage(QUERY)); - tSearch->MakeFocus(true); + tSearch->SetModificationMessage(new BMessage(QUERY)); } void @@ -638,6 +642,11 @@ MainWindow::MessageReceived(BMessage* message) if(!mAlphabetical->IsMarked() && checked % 2 ==0) mergeLayoutsAlphabetical(); break; + } + case kCategoryLaunch: + { + fCategorySettingWindow = new CategorySettingWindow(vCustomApps); + fCategorySettingWindow->Show(); } } } diff --git a/MainWindow.h b/MainWindow.h index 5b4cbcf..59d560a 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -51,6 +51,9 @@ #include #include #include +#include "CategorySettingWindow.h" + +class CategorySettingWindow; enum { MSG_SIGN = 'axyz', @@ -60,6 +63,7 @@ enum { kMenuAppQuit = 0000, kAlphabeticalwise = 0001, kCategorywise = 0002, + kCategoryLaunch = 0003, }; class MainWindow : public BWindow { @@ -82,6 +86,7 @@ class MainWindow : public BWindow { void mergeLayoutsApps(); void FlatTrue(); void FlatFalse(vector& vTemp); + vector vCustomApps; private: BMessage* mMenu; BMessage* mButton; @@ -141,6 +146,7 @@ class MainWindow : public BWindow { map NameButtonApps; char* fAppSig; int checked; + CategorySettingWindow* fCategorySettingWindow; }; #endif diff --git a/Makefile b/Makefile index a3b229b..007a9be 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ APP_MIME_SIG = x-vnd.SuperPrefs # means this Makefile will not work correctly if two source files with the # same name (source.c or source.cpp) are included from different directories. # Also note that spaces in folder names do not work well with this Makefile. -SRCS = MainWindow.cpp App.cpp +SRCS = MainWindow.cpp App.cpp CategorySettingWindow.cpp # Specify the resource definition files to use. Full or relative paths can be # used.