From ced91261dbce57c2766c0d135a59727b2fcc31cc Mon Sep 17 00:00:00 2001 From: Phil Greenway Date: Mon, 5 Jul 2004 10:43:06 +0000 Subject: [PATCH] Basic Shell for CD Player. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8298 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/cdplayer/CDPlayer.h | 25 +++++ src/apps/cdplayer/CDPlayer.rsrc | Bin 0 -> 4252 bytes src/apps/cdplayer/CDPlayerConstants.h | 22 +++++ src/apps/cdplayer/CDPlayerView.cpp | 35 +++++++ src/apps/cdplayer/CDPlayerViews.h | 24 +++++ src/apps/cdplayer/CDPlayerWindow.cpp | 134 ++++++++++++++++++++++++++ src/apps/cdplayer/CDPlayerWindows.h | 34 +++++++ src/apps/cdplayer/Jamfile | 5 + 8 files changed, 279 insertions(+) create mode 100644 src/apps/cdplayer/CDPlayer.h create mode 100644 src/apps/cdplayer/CDPlayer.rsrc create mode 100644 src/apps/cdplayer/CDPlayerConstants.h create mode 100644 src/apps/cdplayer/CDPlayerView.cpp create mode 100644 src/apps/cdplayer/CDPlayerViews.h create mode 100644 src/apps/cdplayer/CDPlayerWindow.cpp create mode 100644 src/apps/cdplayer/CDPlayerWindows.h create mode 100644 src/apps/cdplayer/Jamfile diff --git a/src/apps/cdplayer/CDPlayer.h b/src/apps/cdplayer/CDPlayer.h new file mode 100644 index 0000000000..93b7f5ca0f --- /dev/null +++ b/src/apps/cdplayer/CDPlayer.h @@ -0,0 +1,25 @@ +/* + +CDPlayer Header + +Author: Sikosis + +(C)2004 Haiku - http://haiku-os.org/ + +*/ + +#ifndef __CDPLAYER_H__ +#define __CDPLAYER_H__ + +extern const char *APP_SIGNATURE; + +class CDPlayer : public BApplication +{ + public: + CDPlayer(); + virtual void MessageReceived(BMessage *message); + private: + +}; + +#endif diff --git a/src/apps/cdplayer/CDPlayer.rsrc b/src/apps/cdplayer/CDPlayer.rsrc new file mode 100644 index 0000000000000000000000000000000000000000..fac96e5132bd2b6d49323e611f1f0966cc02a0a2 GIT binary patch literal 4252 zcmeHK&rcIU6n;Rdi6F~RW3!vIS>nZus0opT%Le+(8fqJtka*aT4VKtQfPfk~^x(-u z{}GdV(Lca{MXp}Fw;{pry_sDKmP$;}%g$zI-^};DAM@t5(>~ohnm=eBZl9!b4^PpE z(&I!liMe}{%HQLTd8$~S#f#GDMZD1es&f(YqVZ2!wm#w=DO_{R*O7D}42DRHG8Nf#|IKUAM>H)l* z!EpC-2H>v#C4f=9vZelB zXB&pVaLxgNGI#*13?Wpwk;4HDJfF{#M;23V!$Y^*?FWKm75;4K+Ys?UUjgq2f|J+p z_et#AG=&E|w$CtGrwkKuw~vndive_P*@!}!wfFjs1 z&b)Zo_Br^xje*c4`DS1*Vk1B!3md=KOdJC9#(r;N1KI~oX-9<;Tf+w9 z+LJ}8w-|;MPIJs5UHQ=prcy%SFa=Xr;kUhFCE_U`F@Ym`IMke@=q6#{^YwTr2L84!WA4wqq literal 0 HcmV?d00001 diff --git a/src/apps/cdplayer/CDPlayerConstants.h b/src/apps/cdplayer/CDPlayerConstants.h new file mode 100644 index 0000000000..1c57592e93 --- /dev/null +++ b/src/apps/cdplayer/CDPlayerConstants.h @@ -0,0 +1,22 @@ +/* + +CDPlayer Constants + +Author: Sikosis + +(C)2004 Haiku - http://haiku-os.org/ + +*/ + +#ifndef __CDPLAYERCONSTANTS_H__ +#define __CDPLAYERCONSTANTS_H__ + +// Pointers to BWindows +extern CDPlayerWindow* ptrCDPlayerWindow; + +// Product Name and Properties +const char projtitle[]="CDPlayer"; +const char projversion[]="v0.1"; +const char projauthor[]="Sikosis"; + +#endif diff --git a/src/apps/cdplayer/CDPlayerView.cpp b/src/apps/cdplayer/CDPlayerView.cpp new file mode 100644 index 0000000000..3a63209b7e --- /dev/null +++ b/src/apps/cdplayer/CDPlayerView.cpp @@ -0,0 +1,35 @@ +/* + +CDPlayer View + +Author: Sikosis + +(C)2004 Haiku - http://haiku-os.org/ + +*/ + +// Includes ------------------------------------------------------------------------------------------ // +#include +#include +#include +#include +#include +#include + +#include "CDPlayerWindows.h" +#include "CDPlayerViews.h" +// -------------------------------------------------------------------------------------------------- // + +// CDPlayerView - Constructor +CDPlayerView::CDPlayerView (BRect frame) : BView (frame, "CDPlayerView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW ) +{ + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); +} +// ------------------------------------------------------------------------------------------------- // + +void CDPlayerView::Draw(BRect /*updateRect*/) +{ + BRect r; + r = Bounds(); +} +// ------------------------------------------------------------------------------------------------- // diff --git a/src/apps/cdplayer/CDPlayerViews.h b/src/apps/cdplayer/CDPlayerViews.h new file mode 100644 index 0000000000..504229d503 --- /dev/null +++ b/src/apps/cdplayer/CDPlayerViews.h @@ -0,0 +1,24 @@ +/* + +CDPlayer Views Header + +Author: Sikosis + +(C)2004 Haiku - http://haiku-os.org/ + +*/ + +#ifndef __CDPlayerVIEWS_H__ +#define __CDPlayerVIEWS_H__ + +#include "CDPlayer.h" +#include "CDPlayerWindows.h" + +class CDPlayerView : public BView +{ + public: + CDPlayerView(BRect frame); + virtual void Draw(BRect updateRect); +}; + +#endif diff --git a/src/apps/cdplayer/CDPlayerWindow.cpp b/src/apps/cdplayer/CDPlayerWindow.cpp new file mode 100644 index 0000000000..f11f42533a --- /dev/null +++ b/src/apps/cdplayer/CDPlayerWindow.cpp @@ -0,0 +1,134 @@ +/* + +CDPlayerWindow + +Author: Sikosis + +(C)2004 Haiku - http://haiku-os.org/ + +*/ + +// Includes ------------------------------------------------------------------------------------------ // +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "CDPlayer.h" +#include "CDPlayerWindows.h" +#include "CDPlayerViews.h" +// -------------------------------------------------------------------------------------------------- // + +// CenterWindowOnScreen -- Centers the BWindow to the Current Screen +static void CenterWindowOnScreen(BWindow* w) +{ + BRect screenFrame = (BScreen(B_MAIN_SCREEN_ID).Frame()); BPoint pt; + pt.x = screenFrame.Width()/2 - w->Bounds().Width()/2; + pt.y = screenFrame.Height()/2 - w->Bounds().Height()/2; + + if (screenFrame.Contains(pt)) + w->MoveTo(pt); +} +// -------------------------------------------------------------------------------------------------- // + +// CDPlayerWindow - Constructor +CDPlayerWindow::CDPlayerWindow(BRect frame) : BWindow (frame, "CD Player", B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL , 0) +{ + InitWindow(); + CenterWindowOnScreen(this); + + // Load User Settings + BPath path; + find_directory(B_USER_SETTINGS_DIRECTORY,&path); + path.Append("CDPlayer_Settings",true); + BFile file(path.Path(),B_READ_ONLY); + BMessage msg; + msg.Unflatten(&file); + LoadSettings (&msg); + + Show(); +} +// -------------------------------------------------------------------------------------------------- // + + +// CDPlayerWindow - Destructor +CDPlayerWindow::~CDPlayerWindow() +{ + //exit(0); - this is bad i seem to remember someone telling me ... +} +// -------------------------------------------------------------------------------------------------- // + + +// CDPlayerWindow::InitWindow -- Initialization Commands here +void CDPlayerWindow::InitWindow(void) +{ + BRect r; + r = Bounds(); // the whole view + + // Create the Views + AddChild(ptrCDPlayerView = new CDPlayerView(r)); +} +// -------------------------------------------------------------------------------------------------- // + + +// CDPlayerWindow::QuitRequested -- Post a message to the app to quit +bool CDPlayerWindow::QuitRequested() +{ + SaveSettings(); + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} +// -------------------------------------------------------------------------------------------------- // + + +// CDPlayerWindow::LoadSettings -- Loads your current settings +void CDPlayerWindow::LoadSettings(BMessage *msg) +{ + BRect frame; + + if (B_OK == msg->FindRect("windowframe",&frame)) { + MoveTo(frame.left,frame.top); + ResizeTo(frame.right-frame.left,frame.bottom-frame.top); + } +} +// -------------------------------------------------------------------------------------------------- // + + +// CDPlayerWindow::SaveSettings -- Saves the Users settings +void CDPlayerWindow::SaveSettings(void) +{ + BMessage msg; + msg.AddRect("windowframe",Frame()); + + BPath path; + status_t result = find_directory(B_USER_SETTINGS_DIRECTORY,&path); + if (result == B_OK) { + path.Append("CDPlayer_Settings",true); + BFile file(path.Path(),B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); + msg.Flatten(&file); + } +} +// -------------------------------------------------------------------------------------------------- // + + +// CDPlayerWindow::MessageReceived -- receives messages +void CDPlayerWindow::MessageReceived (BMessage *message) +{ + switch(message->what) + { + default: + BWindow::MessageReceived(message); + break; + } +} +// -------------------------------------------------------------------------------------------------- // + diff --git a/src/apps/cdplayer/CDPlayerWindows.h b/src/apps/cdplayer/CDPlayerWindows.h new file mode 100644 index 0000000000..20d8456fad --- /dev/null +++ b/src/apps/cdplayer/CDPlayerWindows.h @@ -0,0 +1,34 @@ +/* + +CDPlayer Windows Header + +Author: Sikosis + +(C)2004 Haiku - http://haiku-os.org/ + +*/ + +#ifndef __CDPLAYERWINDOWS_H__ +#define __CDPLAYERWINDOWS_H__ + +#include "CDPlayer.h" +#include "CDPlayerViews.h" + +class CDPlayerView; + +class CDPlayerWindow : public BWindow +{ + public: + CDPlayerWindow(BRect frame); + ~CDPlayerWindow(); + virtual bool QuitRequested(); + virtual void MessageReceived(BMessage *message); + private: + void InitWindow(void); + + void LoadSettings(BMessage *msg); + void SaveSettings(void); + CDPlayerView* ptrCDPlayerView; +}; + +#endif diff --git a/src/apps/cdplayer/Jamfile b/src/apps/cdplayer/Jamfile new file mode 100644 index 0000000000..823077a40f --- /dev/null +++ b/src/apps/cdplayer/Jamfile @@ -0,0 +1,5 @@ +SubDir OBOS_TOP src apps cdplayer ; + +AddResources CDPlayer : CDPlayer.rsrc ; +App CDPlayer : CDPlayer.cpp CDPlayerWindow.cpp CDPlayerView.cpp ; +LinkSharedOSLibs CDPlayer : be ;