diff --git a/src/App.cpp b/src/App.cpp index 6e6e0c6..5aa662e 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -9,7 +9,7 @@ #include "Config.h" #include "Util.h" #include "App.h" -#include "PrefWindow.h" +#include "MainWindow.h" #include "Invocation.h" @@ -48,8 +48,8 @@ cliStart ( int argc, char** argv ) App::App ( ) : BApplication("application/x-vnd.Pogger") { -// PrefWindow* prefWin = new PrefWindow(); -// prefWin->Show(); + MainWindow* mainWin = new MainWindow(); + mainWin->Show(); } diff --git a/src/FeedView.cpp b/src/FeedView.cpp new file mode 100644 index 0000000..56bf341 --- /dev/null +++ b/src/FeedView.cpp @@ -0,0 +1,42 @@ +/* + * Copyright 2020, Jaidyn Levesque + * All rights reserved. Distributed under the terms of the MIT license. + */ + +#include "FeedView.h" + +#include +#include +#include + + +FeedView::FeedView(const char* name) + : + BGroupView(name, B_VERTICAL, B_USE_DEFAULT_SPACING) +{ + _InitInterface(); +} + + +void +FeedView::MessageReceived(BMessage* msg) +{ +} + + +void +FeedView::_InitInterface() +{ + fTestButton = new BButton("stest", "Do Nothing!", + new BMessage('pppq')); + fTestButton->SetTarget(this); + fTestButton->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); + + BLayoutBuilder::Group<>(this, B_VERTICAL, 0) + .SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0) + .Add(fTestButton) + .SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING); +} + + diff --git a/src/FeedView.h b/src/FeedView.h new file mode 100644 index 0000000..1c5848d --- /dev/null +++ b/src/FeedView.h @@ -0,0 +1,29 @@ +/* + * Copyright 2020, Jaidyn Levesque + * All rights reserved. Distributed under the terms of the MIT license. + */ +#ifndef FEEDVIEW_H +#define FEEDVIEW_H + + +#include +#include +#include + + +class BMessage; + + +class FeedView : public BGroupView { +public: + FeedView(const char* name); + + void MessageReceived(BMessage* msg); +private: + void _InitInterface(); + + BButton* fTestButton; +}; + + +#endif // FEEDVIEW_H diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp new file mode 100644 index 0000000..b242178 --- /dev/null +++ b/src/MainWindow.cpp @@ -0,0 +1,79 @@ +/* + * Copyright 2020, Jaidyn Levesque + * All rights reserved. Distributed under the terms of the MIT license. + */ + +#include "MainWindow.h" + +#include +#include +#include +#include +#include +#include + +#include "App.h" + + +enum { M_BUTTON_CLICKED = 'btcl' }; + + +MainWindow::MainWindow (void) + : + BWindow(BRect(0,0,0,0), "Pogger", B_TITLED_WINDOW, B_NOT_RESIZABLE + | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE) +{ + _InitInterface(); + MoveTo(BPoint(-1000.0,-1000.0)); + MoveOnScreen(); +} + + +void +MainWindow::MessageReceived(BMessage *msg) +{ + switch (msg->what) + { + case M_BUTTON_CLICKED: + { + BString labelString("Clicks: "); + labelString << "DAD"; + SetTitle(labelString.String()); + break; + } + default: + { + BWindow::MessageReceived(msg); + break; + } + } +} + + +void +MainWindow::_InitInterface() +{ + fBaseView = new BGroupView("baseView"); + fTabView = new BTabView("tabView", B_WIDTH_FROM_WIDEST); + fFeedView = new FeedView("Feeds"); + + fTabView->AddTab(fFeedView); + fTabView->SetBorder(B_NO_BORDER); + fBaseView->AddChild(fTabView); + + fServiceToggleButton = new BButton("stoggle", "Start Service", + new BMessage('pppp')); +// fRevertButton->SetEnabled(false); + fServiceToggleButton->SetTarget(this); + fServiceToggleButton->SetExplicitAlignment( + BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); + + BLayoutBuilder::Group<>(this, B_VERTICAL, 0) + .SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0) + .Add(fBaseView) + .Add(new BSeparatorView(B_HORIZONTAL)) + .AddGroup(B_HORIZONTAL) + .Add(fServiceToggleButton) + .SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING, B_USE_WINDOW_SPACING); +} diff --git a/src/MainWindow.h b/src/MainWindow.h new file mode 100644 index 0000000..8245040 --- /dev/null +++ b/src/MainWindow.h @@ -0,0 +1,30 @@ +#ifndef PREFWINDOW_H +#define PREFWINDOW_H + + +#include + +#include "FeedView.h" + +class BButton; +class BGroupView; +class BTabView; + +class MainWindow : public BWindow { +public: + MainWindow(); + + void MessageReceived(BMessage*); + +private: + void _InitInterface(); + + BGroupView* fBaseView; + BTabView* fTabView; + FeedView* fFeedView; + + BButton* fServiceToggleButton; +}; + + +#endif diff --git a/src/PrefWindow.cpp b/src/PrefWindow.cpp deleted file mode 100644 index 56a16ef..0000000 --- a/src/PrefWindow.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "PrefWindow.h" -#include -#include -#include - -enum -{ - - M_BUTTON_CLICKED = 'btcl' -}; - - -PrefWindow::PrefWindow ( void ) - : BWindow( BRect(100,100,300,200),"Pogger",B_TITLED_WINDOW, - B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE ) -{ - BButton *button = new BButton( BRect(10,10,11,11),"button", "Click Me!", - new BMessage(M_BUTTON_CLICKED) ); - AddChild(button); - button->ResizeToPreferred(); - -BView *view = new BView(BRect(100,100,300,200), "colorview", B_FOLLOW_ALL, B_WILL_DRAW); -//view->AddChild(button); -//AddChild(view); -view->SetViewColor(255,255,255); -view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); -view->Invalidate(); -} - -void -PrefWindow::MessageReceived ( BMessage *msg ) -{ - - // The way that BMessages are identified is by the public property - // 'what'. - switch (msg->what) - { - - // If the message was the one sent to the window by the - // button - case M_BUTTON_CLICKED: - { - - BString labelString("Clicks: "); - - // This converts fCount to a string and appends it to - // the end of labelString. More on this next lesson. - labelString << "DAD"; - - // Set the window's title to the new string we've made - SetTitle(labelString.String()); - break; - } - default: - { - // If the message doesn't match one of the ones we - // explicitly define, it must be some sort of system - // message, so we will call the BWindow version of - // MessageReceived() so that it can handle them. THIS - // IS REQUIRED if you want your window to act - // the way that you expect it to. - BWindow::MessageReceived(msg); - break; - } - } -} diff --git a/src/PrefWindow.h b/src/PrefWindow.h deleted file mode 100644 index 769218a..0000000 --- a/src/PrefWindow.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef PREFWINDOW_H -#define PREFWINDOW_H - -#include - -class PrefWindow : public BWindow -{ -public: - PrefWindow ( void ); - -// void MessageRecieved ( BMessage* ); -void MessageReceived(BMessage*); - -private: - -BView* fMainView; -void _InitInterface ( void ); - -}; - -#endif