From b8e20ea38bcaf763321163ed738a5a7b4e2cb979 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann Date: Thu, 12 Nov 2020 13:10:39 -0600 Subject: [PATCH] Some sad attempts at a GUI >w>' --- Makefile | 1 + src/App.cpp | 5 +++- src/PrefWindow.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++ src/PrefWindow.h | 21 +++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/PrefWindow.cpp create mode 100644 src/PrefWindow.h diff --git a/Makefile b/Makefile index e2f521c..aa038ef 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,7 @@ SRCS = \ src/Entry.cpp, \ src/AtomFeed.cpp, \ src/RssFeed.cpp, \ + src/PrefWindow.cpp, \ src/ProtocolListener.cpp, \ src/Mimetypes.cpp, \ src/Config.cpp, \ diff --git a/src/App.cpp b/src/App.cpp index b7eb354..ba6b177 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -9,6 +9,7 @@ #include "Config.h" #include "Util.h" #include "App.h" +#include "PrefWindow.h" #include "Invocation.h" @@ -23,7 +24,7 @@ main ( int argc, char** argv ) main_cfg->Load(); - if ( argc == 0 ) + if ( argc == 1 ) app->Run(); else cliStart( argc, argv ); @@ -47,6 +48,8 @@ cliStart ( int argc, char** argv ) App::App ( ) : BApplication("application/x-vnd.Pogger") { +// PrefWindow* prefWin = new PrefWindow(); +// prefWin->Show(); } diff --git a/src/PrefWindow.cpp b/src/PrefWindow.cpp new file mode 100644 index 0000000..56a16ef --- /dev/null +++ b/src/PrefWindow.cpp @@ -0,0 +1,66 @@ +#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 new file mode 100644 index 0000000..769218a --- /dev/null +++ b/src/PrefWindow.h @@ -0,0 +1,21 @@ +#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