Basic Shell for CD Player.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8298 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f9e85e394b
commit
ced91261db
25
src/apps/cdplayer/CDPlayer.h
Normal file
25
src/apps/cdplayer/CDPlayer.h
Normal file
@ -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
|
BIN
src/apps/cdplayer/CDPlayer.rsrc
Normal file
BIN
src/apps/cdplayer/CDPlayer.rsrc
Normal file
Binary file not shown.
22
src/apps/cdplayer/CDPlayerConstants.h
Normal file
22
src/apps/cdplayer/CDPlayerConstants.h
Normal file
@ -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
|
35
src/apps/cdplayer/CDPlayerView.cpp
Normal file
35
src/apps/cdplayer/CDPlayerView.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
|
||||
CDPlayer View
|
||||
|
||||
Author: Sikosis
|
||||
|
||||
(C)2004 Haiku - http://haiku-os.org/
|
||||
|
||||
*/
|
||||
|
||||
// Includes ------------------------------------------------------------------------------------------ //
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Screen.h>
|
||||
#include <stdio.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------- //
|
24
src/apps/cdplayer/CDPlayerViews.h
Normal file
24
src/apps/cdplayer/CDPlayerViews.h
Normal file
@ -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
|
134
src/apps/cdplayer/CDPlayerWindow.cpp
Normal file
134
src/apps/cdplayer/CDPlayerWindow.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
|
||||
CDPlayerWindow
|
||||
|
||||
Author: Sikosis
|
||||
|
||||
(C)2004 Haiku - http://haiku-os.org/
|
||||
|
||||
*/
|
||||
|
||||
// Includes ------------------------------------------------------------------------------------------ //
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Button.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Path.h>
|
||||
#include <Screen.h>
|
||||
#include <ScrollView.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <TextControl.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
34
src/apps/cdplayer/CDPlayerWindows.h
Normal file
34
src/apps/cdplayer/CDPlayerWindows.h
Normal file
@ -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
|
5
src/apps/cdplayer/Jamfile
Normal file
5
src/apps/cdplayer/Jamfile
Normal file
@ -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 ;
|
Loading…
Reference in New Issue
Block a user