Basic Sounds pref app. i forgot to include the Jamfile and the resource file.
Sorry but the app has only the features from R5. Extra features may come later. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5479 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f5ac08241f
commit
e482b42659
@ -1,53 +0,0 @@
|
|||||||
//Useful until be gets around to making these sorts of things
|
|
||||||
//globals akin to be_plain_font, etc.
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SGB_COLORS_H_
|
|
||||||
#define _SGB_COLORS_H_
|
|
||||||
|
|
||||||
|
|
||||||
//******************************************************************************************************
|
|
||||||
//**** SYSTEM HEADER FILES
|
|
||||||
//******************************************************************************************************
|
|
||||||
#include <GraphicsDefs.h>
|
|
||||||
|
|
||||||
|
|
||||||
//******************************************************************************************************
|
|
||||||
//**** CONSTANT DEFINITIONS
|
|
||||||
//******************************************************************************************************
|
|
||||||
//Be standard UI colors
|
|
||||||
const rgb_color BeBackgroundGrey = {216,216,216, 255};
|
|
||||||
const rgb_color BeInactiveControlGrey = {240,240,240, 255};
|
|
||||||
const rgb_color BeFocusBlue = {0, 0, 229, 255};
|
|
||||||
const rgb_color BeHighlight = {255,255,255, 255};
|
|
||||||
const rgb_color BeShadow = {152,152,152, 255};
|
|
||||||
const rgb_color BeDarkShadow = {108,108,108, 255};
|
|
||||||
const rgb_color BeLightShadow = {194,194,194, 255};
|
|
||||||
const rgb_color BeButtonGrey = {232,232,232, 255};
|
|
||||||
const rgb_color BeInactiveGrey = {127,127,127, 255};
|
|
||||||
const rgb_color BeListSelectGrey = {178,178,178, 255};
|
|
||||||
const rgb_color BeTitleBarYellow = {255,203,0, 255};
|
|
||||||
|
|
||||||
//Other colors
|
|
||||||
const rgb_color Black = {0, 0, 0, 255};
|
|
||||||
const rgb_color White = {255,255,255, 255};
|
|
||||||
const rgb_color Red = {255,0, 0, 255};
|
|
||||||
const rgb_color Green = {0, 167,0, 255};
|
|
||||||
const rgb_color LightGreen = {90, 240,90, 255};
|
|
||||||
const rgb_color Blue = {49, 61, 225, 255};
|
|
||||||
const rgb_color LightBlue = {64, 162,255, 255};
|
|
||||||
const rgb_color Purple = {144,64, 221, 255};
|
|
||||||
const rgb_color LightPurple = {166,74, 255, 255};
|
|
||||||
const rgb_color Lavender = {193,122,255, 255};
|
|
||||||
const rgb_color Yellow = {255,203,0, 255};
|
|
||||||
const rgb_color Orange = {255,163,0, 255};
|
|
||||||
const rgb_color Flesh = {255,231,186, 255};
|
|
||||||
const rgb_color Tan = {208,182,121, 255};
|
|
||||||
const rgb_color Brown = {154,110,45, 255};
|
|
||||||
const rgb_color Grey = {200,200,200, 255};
|
|
||||||
const rgb_color LightMetallicBlue = {143,166,240, 255};
|
|
||||||
const rgb_color MedMetallicBlue = {75, 96, 154, 255};
|
|
||||||
const rgb_color DarkMetallicBlue = {78, 89, 126, 255};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,7 +1,21 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003, OpenBeOS
|
||||||
|
//
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: HApp.cpp
|
||||||
|
// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu
|
||||||
|
// Description: Sounds Preferences
|
||||||
|
// Created : November 24, 2003
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
|
#include <Alert.h>
|
||||||
#include "HApp.h"
|
#include "HApp.h"
|
||||||
#include "HWindow.h"
|
#include "HWindow.h"
|
||||||
#include "HAboutWindow.h"
|
|
||||||
#include "RectUtils.h"
|
|
||||||
|
|
||||||
#define APP_SIG "application/x-vnd.openSounds"
|
#define APP_SIG "application/x-vnd.openSounds"
|
||||||
|
|
||||||
@ -11,13 +25,9 @@
|
|||||||
HApp::HApp() :BApplication(APP_SIG)
|
HApp::HApp() :BApplication(APP_SIG)
|
||||||
{
|
{
|
||||||
BRect rect;
|
BRect rect;
|
||||||
RectUtils utils;
|
rect.Set(200,150,500,450);
|
||||||
if(utils.LoadRectFromApp("window_rect",&rect) == false)
|
|
||||||
{
|
|
||||||
rect.Set(50,50,450,400);
|
|
||||||
}
|
|
||||||
|
|
||||||
HWindow *win = new HWindow(rect,"OpenSounds");
|
HWindow *win = new HWindow(rect,"Sounds");
|
||||||
win->Show();
|
win->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,9 +45,18 @@ HApp::~HApp()
|
|||||||
void
|
void
|
||||||
HApp::AboutRequested()
|
HApp::AboutRequested()
|
||||||
{
|
{
|
||||||
(new HAboutWindow("openSounds",
|
(new BAlert("About Sounds", "Sounds\n"
|
||||||
__DATE__,
|
" Brought to you by :\n"
|
||||||
"Created by Atsushi Takamatsu @ Sapporo,Japan.\nOpenBeOS Development by Oliver Ruiz Dorantes @ Tarragona,Spain",
|
" Oliver Ruiz Dorantes\n"
|
||||||
"http://anas.worldonline.es/urnenfel/beos/openbeos",
|
" Jérôme DUVAL.\n"
|
||||||
"E-Mail: urnenfelder@worldonline.es"))->Show();
|
" Original work from Atsushi Takamatsu.\n"
|
||||||
|
"OpenBeOS, 2003","OK"))->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
HApp app;
|
||||||
|
app.Run();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003, OpenBeOS
|
||||||
|
//
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: HApp.h
|
||||||
|
// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu
|
||||||
|
// Description: Sounds Preferences
|
||||||
|
// Created : November 24, 2003
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
#ifndef __HAPP_H__
|
#ifndef __HAPP_H__
|
||||||
#define __HAPP_H__
|
#define __HAPP_H__
|
||||||
|
|
||||||
|
@ -1,6 +1,19 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003, OpenBeOS
|
||||||
|
//
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: HEventItem.cpp
|
||||||
|
// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu
|
||||||
|
// Description: Sounds Preferences
|
||||||
|
// Created : November 24, 2003
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
#include "HEventItem.h"
|
#include "HEventItem.h"
|
||||||
#include "ResourceUtils.h"
|
|
||||||
#include <Bitmap.h>
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
@ -11,16 +24,10 @@
|
|||||||
/***********************************************************
|
/***********************************************************
|
||||||
* Constructor
|
* Constructor
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
HEventItem::HEventItem(const char* name,const char* path)
|
HEventItem::HEventItem(const char* name, const char* path)
|
||||||
:CLVEasyItem(0,false,false,20)
|
: BListItem(),
|
||||||
,fName(name)
|
fName(name)
|
||||||
{
|
{
|
||||||
//BBitmap* bitmap = new BBitmap(BRect(0,0,15,15),B_COLOR_8_BIT);
|
|
||||||
BBitmap *bitmap = ResourceUtils().GetBitmapResource('BBMP',"Sound Bitmap");
|
|
||||||
SetColumnContent(0,bitmap,false);
|
|
||||||
SetColumnContent(1,fName.String(),false,false);
|
|
||||||
SetColumnContent(2,"",false,false);
|
|
||||||
delete bitmap;
|
|
||||||
SetPath(path);
|
SetPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,45 +45,53 @@ void
|
|||||||
HEventItem::SetPath(const char* in_path)
|
HEventItem::SetPath(const char* in_path)
|
||||||
{
|
{
|
||||||
fPath = in_path;
|
fPath = in_path;
|
||||||
BPath path(in_path);
|
|
||||||
BPath parent;
|
|
||||||
BMediaFiles mfiles;
|
|
||||||
entry_ref ref;
|
|
||||||
|
|
||||||
if(path.InitCheck() == B_OK)
|
|
||||||
{
|
|
||||||
SetColumnContent(2,path.Leaf(),false,false);
|
|
||||||
::get_ref_for_path(path.Path(),&ref);
|
|
||||||
if(mfiles.SetRefFor(BMediaFiles::B_SOUNDS,Name(),ref) != B_OK)
|
|
||||||
(new BAlert("","Error","OK"))->Go();
|
|
||||||
path.GetParent(&parent);
|
|
||||||
SetColumnContent(3,parent.Path(),false,false);// falta
|
|
||||||
}else{
|
|
||||||
SetColumnContent(2,"<none>",false,false);
|
|
||||||
//if(mfiles.RemoveRefFor(BMediaFiles::B_SOUNDS,Name(),ref) != B_OK)
|
|
||||||
// (new BAlert("","Entry not found","OK"))->Go();
|
|
||||||
mfiles.RemoveItem(BMediaFiles::B_SOUNDS,Name());
|
|
||||||
::add_system_beep_event(Name());
|
|
||||||
SetColumnContent(3,"<none>",false,false);// falta
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* Remove
|
* Remove
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
void
|
void
|
||||||
HEventItem::Remove()
|
HEventItem::Remove(const char *type)
|
||||||
{
|
{
|
||||||
BMediaFiles mfiles;
|
BMediaFiles().RemoveItem(type, Name());
|
||||||
|
|
||||||
mfiles.RemoveItem(BMediaFiles::B_SOUNDS,Name());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
*
|
* DrawItem
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
const char*
|
void
|
||||||
HEventItem::Path() const
|
HEventItem::DrawItem(BView *owner, BRect itemRect, bool complete)
|
||||||
{
|
{
|
||||||
return fPath.String();
|
rgb_color kBlack = { 0,0,0,0 };
|
||||||
|
rgb_color kHighlight = { 206,207,206,0 };
|
||||||
|
|
||||||
|
if (IsSelected() || complete) {
|
||||||
|
rgb_color color;
|
||||||
|
if (IsSelected())
|
||||||
|
color = kHighlight;
|
||||||
|
else
|
||||||
|
color = owner->ViewColor();
|
||||||
|
|
||||||
|
owner->SetHighColor(color);
|
||||||
|
owner->SetLowColor(color);
|
||||||
|
owner->FillRect(itemRect);
|
||||||
|
owner->SetHighColor(kBlack);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
owner->SetLowColor(owner->ViewColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
BPoint point = itemRect.LeftTop() + BPoint(5, 10);
|
||||||
|
|
||||||
|
owner->SetHighColor(kBlack);
|
||||||
|
owner->SetFont(be_plain_font);
|
||||||
|
owner->MovePenTo(point);
|
||||||
|
owner->DrawString(Name());
|
||||||
|
|
||||||
|
point += BPoint(100, 0);
|
||||||
|
BPath path(Path());
|
||||||
|
owner->MovePenTo(point);
|
||||||
|
owner->DrawString(path.Leaf() ? path.Leaf() : "<none>");
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,37 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003, OpenBeOS
|
||||||
|
//
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: HEventItem.h, Oliver Ruiz Dorantes, Atsushi Takamatsu
|
||||||
|
// Author: Jérôme Duval
|
||||||
|
// Description: Sounds Preferences
|
||||||
|
// Created : November 24, 2003
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
#ifndef __HEVENTITEM_H__
|
#ifndef __HEVENTITEM_H__
|
||||||
#define __HEVENTITEM_H__
|
#define __HEVENTITEM_H__
|
||||||
|
|
||||||
#include "CLVEasyItem.h"
|
#include <ListItem.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
|
||||||
|
|
||||||
class HEventItem :public CLVEasyItem {
|
class HEventItem : public BListItem {
|
||||||
public:
|
public:
|
||||||
HEventItem(const char* event_name
|
HEventItem(const char* event_name
|
||||||
,const char* path);
|
,const char* path);
|
||||||
virtual ~HEventItem();
|
virtual ~HEventItem();
|
||||||
|
virtual void DrawItem(BView *owner, BRect itemRect,
|
||||||
|
bool drawEverything = false);
|
||||||
|
|
||||||
const char* Name()const {return fName.String();}
|
const char* Name()const { return fName.String();}
|
||||||
const char* Path()const;
|
const char* Path()const { return fPath.String();}
|
||||||
void Remove();
|
void Remove(const char *type);
|
||||||
void SetPath(const char* path);
|
void SetPath(const char* path);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -1,9 +1,23 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003, OpenBeOS
|
||||||
|
//
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: HEventList.cpp
|
||||||
|
// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu
|
||||||
|
// Description: Sounds Preferences
|
||||||
|
// Created : November 24, 2003
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
#include "HEventList.h"
|
#include "HEventList.h"
|
||||||
#include "HEventItem.h"
|
#include "HEventItem.h"
|
||||||
|
|
||||||
#include "HWindow.h"
|
#include "HWindow.h"
|
||||||
#include "IconMenuItem.h"
|
#include <Bitmap.h>
|
||||||
|
|
||||||
#include <ClassInfo.h>
|
#include <ClassInfo.h>
|
||||||
#include <MediaFiles.h>
|
#include <MediaFiles.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
@ -19,26 +33,12 @@
|
|||||||
/***********************************************************
|
/***********************************************************
|
||||||
* Constructor
|
* Constructor
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
HEventList::HEventList(BRect rect
|
HEventList::HEventList(BRect rect, const char* name)
|
||||||
,CLVContainerView** ContainerView
|
: BListView(rect, name, B_SINGLE_SELECTION_LIST,
|
||||||
,const char* name)
|
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE),
|
||||||
:ColumnListView(rect
|
fType(NULL)
|
||||||
,ContainerView
|
|
||||||
,name
|
|
||||||
,B_FOLLOW_ALL
|
|
||||||
,B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE
|
|
||||||
,B_SINGLE_SELECTION_LIST
|
|
||||||
,false
|
|
||||||
,false
|
|
||||||
,true)
|
|
||||||
{
|
{
|
||||||
AddColumn(new CLVColumn(NULL,20,CLV_LOCK_AT_BEGINNING|CLV_NOT_MOVABLE|
|
|
||||||
CLV_NOT_RESIZABLE|CLV_PUSH_PASS|CLV_MERGE_WITH_RIGHT));
|
|
||||||
AddColumn(new CLVColumn("Event",100,CLV_SORT_KEYABLE));
|
|
||||||
AddColumn( new CLVColumn("Sound",130,CLV_SORT_KEYABLE));
|
|
||||||
AddColumn( new CLVColumn("Path",200,CLV_SORT_KEYABLE));
|
|
||||||
SetSortKey(1);
|
|
||||||
SetSortFunction(CLVEasyItem::CompareItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
@ -46,6 +46,8 @@ HEventList::HEventList(BRect rect
|
|||||||
***********************************************************/
|
***********************************************************/
|
||||||
HEventList::~HEventList()
|
HEventList::~HEventList()
|
||||||
{
|
{
|
||||||
|
RemoveAll();
|
||||||
|
delete fType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
@ -57,14 +59,15 @@ HEventList::SetType(const char* type)
|
|||||||
RemoveAll();
|
RemoveAll();
|
||||||
BMediaFiles mfiles;
|
BMediaFiles mfiles;
|
||||||
mfiles.RewindRefs(type);
|
mfiles.RewindRefs(type);
|
||||||
|
delete fType;
|
||||||
|
fType = strdup(type);
|
||||||
|
|
||||||
BString name;
|
BString name;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
while(mfiles.GetNextRef(&name,&ref) == B_OK)
|
while(mfiles.GetNextRef(&name,&ref) == B_OK) {
|
||||||
{
|
BPath path(&ref);
|
||||||
AddItem(new HEventItem(name.String(),BPath(&ref).Path()));
|
AddItem(new HEventItem(name.String(), path.Path()));
|
||||||
}
|
}
|
||||||
SortItems();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
@ -73,32 +76,12 @@ HEventList::SetType(const char* type)
|
|||||||
void
|
void
|
||||||
HEventList::RemoveAll()
|
HEventList::RemoveAll()
|
||||||
{
|
{
|
||||||
int32 count = CountItems();
|
BListItem *item;
|
||||||
while(count> 0)
|
while((item = RemoveItem((int32)0))!=NULL)
|
||||||
delete fPointerList.RemoveItem(--count);
|
delete item;
|
||||||
MakeEmpty();
|
MakeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* Add event item
|
|
||||||
***********************************************************/
|
|
||||||
void
|
|
||||||
HEventList::AddEvent(HEventItem *item)
|
|
||||||
{
|
|
||||||
fPointerList.AddItem(item);
|
|
||||||
AddItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* Remove event item
|
|
||||||
***********************************************************/
|
|
||||||
void
|
|
||||||
HEventList::RemoveEvent(HEventItem *item)
|
|
||||||
{
|
|
||||||
item->Remove();
|
|
||||||
fPointerList.RemoveItem(item);
|
|
||||||
RemoveItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* Selection Changed
|
* Selection Changed
|
||||||
@ -106,12 +89,28 @@ HEventList::RemoveEvent(HEventItem *item)
|
|||||||
void
|
void
|
||||||
HEventList::SelectionChanged()
|
HEventList::SelectionChanged()
|
||||||
{
|
{
|
||||||
|
BListView::SelectionChanged();
|
||||||
|
|
||||||
int32 sel = CurrentSelection();
|
int32 sel = CurrentSelection();
|
||||||
if(sel >= 0)
|
if(sel >= 0)
|
||||||
{
|
{
|
||||||
HEventItem *item = cast_as(ItemAt(sel),HEventItem);
|
HEventItem *item = cast_as(ItemAt(sel),HEventItem);
|
||||||
if(!item)
|
if(!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
entry_ref ref;
|
||||||
|
BMediaFiles().GetRefFor(fType, item->Name(), &ref);
|
||||||
|
|
||||||
|
BPath path(&ref);
|
||||||
|
if((path.InitCheck()==B_OK) || (ref.name == NULL) || (strcmp(ref.name, "")==0)) {
|
||||||
|
item->SetPath(path.Path());
|
||||||
|
InvalidateItem(sel);
|
||||||
|
} else {
|
||||||
|
printf("name %s\n", ref.name);
|
||||||
|
BMediaFiles().RemoveRefFor(fType, item->Name(), ref);
|
||||||
|
(new BAlert("alert", "No such file or directory", "Ok"))->Go();
|
||||||
|
return;
|
||||||
|
}
|
||||||
BMessage msg(M_EVENT_CHANGED);
|
BMessage msg(M_EVENT_CHANGED);
|
||||||
msg.AddString("name",item->Name());
|
msg.AddString("name",item->Name());
|
||||||
|
|
||||||
@ -121,122 +120,23 @@ HEventList::SelectionChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* MouseDown
|
* SetPath
|
||||||
***********************************************************/
|
***********************************************************/
|
||||||
void
|
void
|
||||||
HEventList::MouseDown(BPoint pos)
|
HEventList::SetPath(const char* path)
|
||||||
{
|
{
|
||||||
BPoint point = pos;
|
int32 sel = CurrentSelection();
|
||||||
int32 buttons;
|
if(sel >= 0) {
|
||||||
|
HEventItem *item = cast_as(ItemAt(sel),HEventItem);
|
||||||
|
if(!item)
|
||||||
|
return;
|
||||||
|
|
||||||
Window()->CurrentMessage()->FindInt32("buttons", &buttons);
|
entry_ref ref;
|
||||||
this->MakeFocus(true);
|
BEntry entry(path);
|
||||||
|
entry.GetRef(&ref);
|
||||||
|
BMediaFiles().SetRefFor(fType, item->Name(), ref);
|
||||||
|
|
||||||
// 右クリックのハンドリング
|
item->SetPath(path);
|
||||||
if(buttons == B_SECONDARY_MOUSE_BUTTON)
|
InvalidateItem(sel);
|
||||||
{
|
}
|
||||||
int32 sel = IndexOf(pos);
|
|
||||||
if(sel >= 0)
|
|
||||||
Select(sel);
|
|
||||||
else
|
|
||||||
DeselectAll();
|
|
||||||
sel = CurrentSelection();
|
|
||||||
bool enabled = (sel >= 0)?true:false;
|
|
||||||
|
|
||||||
BPopUpMenu *theMenu = new BPopUpMenu("RIGHT_CLICK",false,false);
|
|
||||||
BFont font(be_plain_font);
|
|
||||||
font.SetSize(10);
|
|
||||||
theMenu->SetFont(&font);
|
|
||||||
/* HWindow *parent = cast_as(Window(),HWindow);
|
|
||||||
|
|
||||||
BMenuField *menufield = cast_as(parent->FindView("filemenu"),BMenuField);
|
|
||||||
BMenu *old_menu = menufield->Menu();
|
|
||||||
|
|
||||||
int32 menus = old_menu->CountItems();
|
|
||||||
|
|
||||||
for(register int32 i = 0;i < menus-3;i++)
|
|
||||||
{
|
|
||||||
BMenuItem *old_item = old_menu->ItemAt(i);
|
|
||||||
if(!old_item)
|
|
||||||
continue;
|
|
||||||
BMessage *old_msg = old_item->Message();
|
|
||||||
BMessage *msg = new BMessage(*old_msg );
|
|
||||||
BMenuItem *new_item = new BMenuItem(old_item->Label(),msg);
|
|
||||||
new_item->SetEnabled(enabled);
|
|
||||||
theMenu->AddItem(new_item);
|
|
||||||
}
|
|
||||||
theMenu->AddSeparatorItem();
|
|
||||||
theMenu->AddItem(new BMenuItem("<none>",new BMessage(M_NONE_MESSAGE)));
|
|
||||||
theMenu->AddItem(new BMenuItem("Other…",new BMessage(M_OTHER_MESSAGE)));
|
|
||||||
theMenu->FindItem(M_NONE_MESSAGE)->SetEnabled(enabled);
|
|
||||||
theMenu->FindItem(M_OTHER_MESSAGE)->SetEnabled(enabled);
|
|
||||||
*/
|
|
||||||
BMenu *submenu = new BMenu("Open With…");
|
|
||||||
submenu->SetFont(&font);
|
|
||||||
BMimeType mime("audio");
|
|
||||||
|
|
||||||
if(enabled)
|
|
||||||
{
|
|
||||||
HEventItem *item = cast_as(this->ItemAt(sel),HEventItem);
|
|
||||||
const char* path = item->Path();
|
|
||||||
BFile file(path,B_READ_ONLY);
|
|
||||||
BNodeInfo ninfo(&file);
|
|
||||||
char type[B_MIME_TYPE_LENGTH+1];
|
|
||||||
ninfo.GetType(type);
|
|
||||||
mime.SetTo(type);
|
|
||||||
}
|
|
||||||
BMessage message;
|
|
||||||
mime.GetSupportingApps(&message);
|
|
||||||
/* int32 sub;
|
|
||||||
int32 supers;
|
|
||||||
message.FindInt32("be:subs", &sub);
|
|
||||||
message.FindInt32("be:supers", &supers);
|
|
||||||
*/
|
|
||||||
for (int32 index =0; ; index++)
|
|
||||||
{
|
|
||||||
const char *signature;
|
|
||||||
int32 length;
|
|
||||||
|
|
||||||
if (message.FindData("applications", 'CSTR', index, (const void **)&signature,
|
|
||||||
&length) != B_OK)
|
|
||||||
break;
|
|
||||||
|
|
||||||
entry_ref ref;
|
|
||||||
if(be_roster->FindApp(signature,&ref) != B_OK)
|
|
||||||
continue;
|
|
||||||
BMessage *msg = new BMessage(M_OPEN_WITH);
|
|
||||||
msg->AddRef("refs",&ref);
|
|
||||||
msg->AddString("sig",signature);
|
|
||||||
|
|
||||||
BBitmap *icon = new BBitmap(BRect(0,0,15,15),B_COLOR_8_BIT);
|
|
||||||
BNodeInfo::GetTrackerIcon(&ref,icon,B_MINI_ICON);
|
|
||||||
|
|
||||||
submenu->AddItem(new IconMenuItem(BPath(&ref).Leaf(),msg,0,0,icon));
|
|
||||||
// push each of the supporting apps signature uniquely
|
|
||||||
//queryIterator->PushUniqueSignature(signature);
|
|
||||||
}
|
|
||||||
|
|
||||||
theMenu->AddItem(submenu);
|
|
||||||
theMenu->AddSeparatorItem();
|
|
||||||
theMenu->AddItem(new BMenuItem("Remove Event",new BMessage(M_REMOVE_EVENT)));
|
|
||||||
//theMenu->FindItem(M_OPEN_WITH)->SetEnabled(enabled);
|
|
||||||
theMenu->FindItem(M_REMOVE_EVENT)->SetEnabled(enabled);
|
|
||||||
submenu->SetEnabled(enabled);
|
|
||||||
BRect r;
|
|
||||||
ConvertToScreen(&pos);
|
|
||||||
r.top = pos.y - 5;
|
|
||||||
r.bottom = pos.y + 5;
|
|
||||||
r.left = pos.x - 5;
|
|
||||||
r.right = pos.x + 5;
|
|
||||||
|
|
||||||
BMenuItem *theItem = theMenu->Go(pos, false,true,r);
|
|
||||||
if(theItem)
|
|
||||||
{
|
|
||||||
BMessage* aMessage = theItem->Message();
|
|
||||||
if(aMessage)
|
|
||||||
this->Window()->PostMessage(aMessage);
|
|
||||||
}
|
|
||||||
delete theMenu;
|
|
||||||
}else
|
|
||||||
ColumnListView::MouseDown(point);
|
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,39 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003, OpenBeOS
|
||||||
|
//
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: HEventList.h
|
||||||
|
// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu
|
||||||
|
// Description: Sounds Preferences
|
||||||
|
// Created : November 24, 2003
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
#ifndef __HEVENTLIST_H__
|
#ifndef __HEVENTLIST_H__
|
||||||
#define __HEVENTLIST_H__
|
#define __HEVENTLIST_H__
|
||||||
|
|
||||||
#include "ColumnListView.h"
|
#include <ListView.h>
|
||||||
|
#include "HEventItem.h"
|
||||||
class HEventItem;
|
|
||||||
|
|
||||||
enum{
|
enum{
|
||||||
M_EVENT_CHANGED = 'SCAG'
|
M_EVENT_CHANGED = 'SCAG'
|
||||||
};
|
};
|
||||||
|
|
||||||
class HEventList :public ColumnListView {
|
class HEventList : public BListView {
|
||||||
public:
|
public:
|
||||||
HEventList(BRect rect
|
HEventList(BRect rect
|
||||||
,CLVContainerView** ContainerView
|
, const char* name="EventList");
|
||||||
,const char* name="EventList");
|
|
||||||
virtual ~HEventList();
|
virtual ~HEventList();
|
||||||
void RemoveAll();
|
void RemoveAll();
|
||||||
void AddEvent(HEventItem *item);
|
|
||||||
void RemoveEvent(HEventItem *item);
|
|
||||||
|
|
||||||
void SetType(const char* type);
|
void SetType(const char* type);
|
||||||
|
void SetPath(const char* path);
|
||||||
protected:
|
protected:
|
||||||
virtual void MouseDown(BPoint point);
|
|
||||||
virtual void SelectionChanged();
|
virtual void SelectionChanged();
|
||||||
private:
|
private:
|
||||||
BList fPointerList;
|
char *fType;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
#ifndef __HTYPELIST_H__
|
|
||||||
#define __HTYPELIST_H__
|
|
||||||
|
|
||||||
#include <ListView.h>
|
|
||||||
|
|
||||||
enum{
|
|
||||||
M_TYPE_CHANGED = 'TCHD'
|
|
||||||
};
|
|
||||||
|
|
||||||
class HTypeList :public BListView{
|
|
||||||
public:
|
|
||||||
HTypeList(BRect rect,const char* name = "TypeList");
|
|
||||||
virtual ~HTypeList();
|
|
||||||
protected:
|
|
||||||
void AddType(const char* name);
|
|
||||||
void Init();
|
|
||||||
void RemoveAll();
|
|
||||||
virtual void SelectionChanged();
|
|
||||||
private:
|
|
||||||
BList fPointerList;
|
|
||||||
};
|
|
||||||
#endif
|
|
@ -1,11 +1,23 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003, OpenBeOS
|
||||||
|
//
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: HWindow.cpp
|
||||||
|
// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu
|
||||||
|
// Description: Sounds Preferences
|
||||||
|
// Created : November 24, 2003
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
#include "HWindow.h"
|
#include "HWindow.h"
|
||||||
#include "HEventList.h"
|
#include "HEventList.h"
|
||||||
#include "HEventItem.h"
|
#include "HEventItem.h"
|
||||||
#include "HTypeList.h"
|
#include <ScrollView.h>
|
||||||
#include "BetterScrollView.h"
|
#include <StringView.h>
|
||||||
#include "RectUtils.h"
|
|
||||||
#include "TextEntryAlert.h"
|
|
||||||
|
|
||||||
#include <ClassInfo.h>
|
#include <ClassInfo.h>
|
||||||
#include <MediaFiles.h>
|
#include <MediaFiles.h>
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
@ -32,13 +44,17 @@ HWindow::HWindow(BRect rect ,const char* name)
|
|||||||
,fFilePanel(NULL)
|
,fFilePanel(NULL)
|
||||||
,fPlayer(NULL)
|
,fPlayer(NULL)
|
||||||
{
|
{
|
||||||
InitMenu();
|
|
||||||
InitGUI();
|
InitGUI();
|
||||||
float min_width,min_height,max_width,max_height;
|
float min_width,min_height,max_width,max_height;
|
||||||
GetSizeLimits(&min_width,&max_width,&min_height,&max_height);
|
GetSizeLimits(&min_width,&max_width,&min_height,&max_height);
|
||||||
min_width = 320;
|
min_width = 300;
|
||||||
min_height = 150;
|
min_height = 200;
|
||||||
SetSizeLimits(min_width,max_width,min_height,max_height);
|
SetSizeLimits(min_width,max_width,min_height,max_height);
|
||||||
|
|
||||||
|
fFilePanel = new BFilePanel();
|
||||||
|
fFilePanel->SetTarget(this);
|
||||||
|
|
||||||
|
fEventList->Select(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
@ -57,64 +73,47 @@ void
|
|||||||
HWindow::InitGUI()
|
HWindow::InitGUI()
|
||||||
{
|
{
|
||||||
BRect rect = Bounds();
|
BRect rect = Bounds();
|
||||||
rect.top = KeyMenuBar()->Bounds().Height()+1;
|
rect.bottom -= 106;
|
||||||
|
BView *view = new BView(rect,"",B_FOLLOW_ALL, B_WILL_DRAW|B_PULSE_NEEDED);
|
||||||
|
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
AddChild(view);
|
||||||
|
|
||||||
|
BRect stringRect(16, 5, 60, 22);
|
||||||
|
BStringView *stringView = new BStringView(stringRect, "event", "Event");
|
||||||
|
stringView->SetFont(be_bold_font);
|
||||||
|
view->AddChild(stringView);
|
||||||
|
|
||||||
|
stringRect.OffsetBy(100, 0);
|
||||||
|
stringView = new BStringView(stringRect, "sound", "Sound");
|
||||||
|
stringView->SetFont(be_bold_font);
|
||||||
|
view->AddChild(stringView);
|
||||||
|
|
||||||
|
rect.left += 13;
|
||||||
|
rect.right -= B_V_SCROLL_BAR_WIDTH + 13;
|
||||||
|
rect.top += 28;
|
||||||
|
rect.bottom -= 7;
|
||||||
|
fEventList = new HEventList(rect);
|
||||||
|
fEventList->SetType(BMediaFiles::B_SOUNDS);
|
||||||
|
|
||||||
/*fTypeList = new HTypeList(rect);
|
|
||||||
BScrollView *scrollView = new BScrollView(""
|
BScrollView *scrollView = new BScrollView(""
|
||||||
,fTypeList
|
,fEventList
|
||||||
,B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM
|
,B_FOLLOW_ALL
|
||||||
,0
|
,0
|
||||||
,false
|
,false
|
||||||
,true);
|
,true);
|
||||||
AddChild(scrollView);
|
view->AddChild(scrollView);
|
||||||
*/
|
|
||||||
//rect.left = rect.right + B_V_SCROLL_BAR_WIDTH+3;
|
|
||||||
rect.right -= B_V_SCROLL_BAR_WIDTH;
|
|
||||||
rect.bottom = Bounds().bottom - B_H_SCROLL_BAR_HEIGHT - 80;
|
|
||||||
BetterScrollView *betterScrollView;
|
|
||||||
fEventList = new HEventList(rect,(CLVContainerView**)&betterScrollView);
|
|
||||||
fEventList->SetType(BMediaFiles::B_SOUNDS);
|
|
||||||
AddChild(betterScrollView);
|
|
||||||
|
|
||||||
app_info info;
|
rect = Bounds();
|
||||||
be_app->GetAppInfo(&info);
|
rect.top = rect.bottom - 105;
|
||||||
BEntry entry(&info.ref);
|
view = new BView(rect,"",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM,B_WILL_DRAW|B_PULSE_NEEDED);
|
||||||
float width;
|
|
||||||
BFile appfile(&entry,B_WRITE_ONLY);
|
|
||||||
attr_info ainfo;
|
|
||||||
|
|
||||||
if(appfile.GetAttrInfo("event_width",&ainfo) == B_OK)
|
|
||||||
{
|
|
||||||
appfile.ReadAttr("event_width",B_FLOAT_TYPE,0,&width,sizeof(float));
|
|
||||||
CLVColumn *col = fEventList->ColumnAt(1);
|
|
||||||
if(col)
|
|
||||||
col->SetWidth(width);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(appfile.GetAttrInfo("sound_width",&ainfo) == B_OK)
|
|
||||||
{
|
|
||||||
appfile.ReadAttr("sound_width",B_FLOAT_TYPE,0,&width,sizeof(float));
|
|
||||||
CLVColumn *col = fEventList->ColumnAt(2);
|
|
||||||
if(col)
|
|
||||||
col->SetWidth(width);
|
|
||||||
}
|
|
||||||
|
|
||||||
rect.top = rect.bottom +1;
|
|
||||||
rect.bottom = Bounds().bottom;
|
|
||||||
rect.right = Bounds().right;
|
|
||||||
BView *view = new BView(rect,"",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM,B_WILL_DRAW|B_PULSE_NEEDED);
|
|
||||||
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
AddChild(view);
|
AddChild(view);
|
||||||
rect = view->Bounds();
|
rect = view->Bounds().InsetBySelf(12, 12);
|
||||||
rect.top += 10;
|
|
||||||
rect.bottom -= 10;
|
|
||||||
rect.left += 10;
|
|
||||||
rect.right -= 10;
|
|
||||||
BBox *box = new BBox(rect,"",B_FOLLOW_ALL);
|
BBox *box = new BBox(rect,"",B_FOLLOW_ALL);
|
||||||
view->AddChild(box);
|
view->AddChild(box);
|
||||||
rect = box->Bounds();
|
rect = box->Bounds();
|
||||||
rect.top += 10;
|
rect.top += 10;
|
||||||
rect.left += 10;
|
rect.left += 15;
|
||||||
rect.right -= 10;
|
rect.right -= 10;
|
||||||
rect.bottom = rect.top + 20;
|
rect.bottom = rect.top + 20;
|
||||||
BMenu *menu = new BMenu("file");
|
BMenu *menu = new BMenu("file");
|
||||||
@ -129,68 +128,30 @@ HWindow::InitGUI()
|
|||||||
,"Sound File:"
|
,"Sound File:"
|
||||||
,menu
|
,menu
|
||||||
,B_FOLLOW_TOP|B_FOLLOW_LEFT);
|
,B_FOLLOW_TOP|B_FOLLOW_LEFT);
|
||||||
menuField->SetDivider(menuField->StringWidth("Media Files:")+3);
|
menuField->SetDivider(menuField->StringWidth("Sound File:")+10);
|
||||||
box->AddChild(menuField);
|
box->AddChild(menuField);
|
||||||
rect.OffsetBy(0,25);
|
rect.OffsetBy(-2,38);
|
||||||
rect.left = rect.right - 80;
|
rect.left = rect.right - 80;
|
||||||
BButton *button = new BButton(rect
|
BButton *button = new BButton(rect
|
||||||
,"play"
|
,"stop"
|
||||||
,"Play"
|
,"Stop"
|
||||||
,new BMessage(M_PLAY_MESSAGE)
|
,new BMessage(M_STOP_MESSAGE)
|
||||||
,B_FOLLOW_RIGHT|B_FOLLOW_TOP);
|
,B_FOLLOW_RIGHT|B_FOLLOW_TOP);
|
||||||
box->AddChild(button);
|
box->AddChild(button);
|
||||||
|
|
||||||
rect.OffsetBy(-90,0);
|
rect.OffsetBy(-90,0);
|
||||||
button = new BButton(rect
|
button = new BButton(rect
|
||||||
,"stop"
|
,"play"
|
||||||
,"Stop"
|
,"Play"
|
||||||
,new BMessage(M_STOP_MESSAGE)
|
,new BMessage(M_PLAY_MESSAGE)
|
||||||
,B_FOLLOW_RIGHT|B_FOLLOW_TOP);
|
,B_FOLLOW_RIGHT|B_FOLLOW_TOP);
|
||||||
box->AddChild(button);
|
box->AddChild(button);
|
||||||
|
|
||||||
rect.OffsetBy(-110,0);
|
|
||||||
button = new BButton(rect
|
|
||||||
,"setsystem"
|
|
||||||
,"As System event"
|
|
||||||
,NULL
|
|
||||||
,B_FOLLOW_RIGHT|B_FOLLOW_TOP);
|
|
||||||
button->ResizeToPreferred();
|
|
||||||
box->AddChild(button);
|
|
||||||
|
|
||||||
// setup file menu
|
// setup file menu
|
||||||
SetupMenuField();
|
SetupMenuField();
|
||||||
menu->FindItem("<none>")->SetMarked(true);
|
menu->FindItem("<none>")->SetMarked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* Initalize Menus
|
|
||||||
***********************************************************/
|
|
||||||
void
|
|
||||||
HWindow::InitMenu()
|
|
||||||
{
|
|
||||||
BMenuBar *menuBar = new BMenuBar(Bounds(),"MENUBAR");
|
|
||||||
BMenu *menu;
|
|
||||||
BMenuItem *item;
|
|
||||||
|
|
||||||
menu = new BMenu("File");
|
|
||||||
item = new BMenuItem("Add New Event…",new BMessage(M_ADD_EVENT),'A');
|
|
||||||
item->SetTarget(this);
|
|
||||||
menu->AddItem(item);
|
|
||||||
|
|
||||||
item = new BMenuItem("Remove Event",new BMessage(M_REMOVE_EVENT),'R');
|
|
||||||
item->SetTarget(this);
|
|
||||||
menu->AddItem(item);
|
|
||||||
|
|
||||||
menu->AddSeparatorItem();
|
|
||||||
item = new BMenuItem("About openSounds…",new BMessage(B_ABOUT_REQUESTED),0,0);
|
|
||||||
item->SetTarget(be_app);
|
|
||||||
menu->AddItem(item);
|
|
||||||
menu->AddSeparatorItem();
|
|
||||||
item = new BMenuItem("Quit",new BMessage(B_QUIT_REQUESTED),'Q',0);
|
|
||||||
menu->AddItem(item);
|
|
||||||
menuBar->AddItem(menu);
|
|
||||||
this->AddChild(menuBar);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* MessageReceived
|
* MessageReceived
|
||||||
@ -198,64 +159,35 @@ HWindow::InitMenu()
|
|||||||
void
|
void
|
||||||
HWindow::MessageReceived(BMessage *message)
|
HWindow::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
switch(message->what)
|
switch(message->what) {
|
||||||
{
|
|
||||||
case M_OPEN_WITH:
|
|
||||||
{
|
|
||||||
entry_ref app_ref;
|
|
||||||
if(message->FindRef("refs",&app_ref) == B_OK)
|
|
||||||
{
|
|
||||||
BMessage msg(B_REFS_RECEIVED);
|
|
||||||
int32 sel = fEventList->CurrentSelection();
|
|
||||||
if(sel < 0)
|
|
||||||
break;
|
|
||||||
HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem);
|
|
||||||
const char* path = item->Path();
|
|
||||||
entry_ref ref;
|
|
||||||
::get_ref_for_path(path,&ref);
|
|
||||||
msg.AddRef("refs",&ref);
|
|
||||||
be_roster->Launch(&app_ref,&msg);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case M_REMOVE_EVENT:
|
|
||||||
{
|
|
||||||
RemoveEvent();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case M_ADD_EVENT:
|
|
||||||
{
|
|
||||||
char new_Event[20];
|
|
||||||
(new BAlert("Add an event","Note that to use this event, applications should call him by the function:\n status_t system_beep(const char *eventName);\n declared on be/support/Beep.h","OK",NULL,NULL,
|
|
||||||
B_WIDTH_AS_USUAL,B_WARNING_ALERT))->Go();
|
|
||||||
if (((new TextEntryAlert("Add an event ...","Type name: ", "new event name",
|
|
||||||
"Create","Cancel",true,120,1,B_WIDTH_AS_USUAL,false,
|
|
||||||
NULL,B_FLOATING_WINDOW_LOOK)
|
|
||||||
)->Go(new_Event,20))==0){
|
|
||||||
add_system_beep_event(new_Event);
|
|
||||||
|
|
||||||
BMediaFiles mfiles;
|
|
||||||
mfiles.RewindRefs("Sound");
|
|
||||||
entry_ref ref;
|
|
||||||
mfiles.GetRefFor("Sound",new_Event,&ref);
|
|
||||||
fEventList->AddEvent(new HEventItem(new_Event,BPath(&ref).Path()));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case M_OTHER_MESSAGE:
|
case M_OTHER_MESSAGE:
|
||||||
{
|
{
|
||||||
if(!fFilePanel)
|
BMenuField *menufield = cast_as(FindView("filemenu"),BMenuField);
|
||||||
fFilePanel = new BFilePanel();
|
BMenu *menu = menufield->Menu();
|
||||||
fFilePanel->SetTarget(this);
|
|
||||||
|
int32 sel = fEventList->CurrentSelection();
|
||||||
|
if(sel >= 0) {
|
||||||
|
HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem);
|
||||||
|
BPath path(item->Path());
|
||||||
|
if(path.InitCheck() != B_OK) {
|
||||||
|
BMenuItem *item = menu->FindItem("<none>");
|
||||||
|
if(item)
|
||||||
|
item->SetMarked(true);
|
||||||
|
} else{
|
||||||
|
BMenuItem *item = menu->FindItem(path.Leaf());
|
||||||
|
if(item)
|
||||||
|
item->SetMarked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
fFilePanel->Show();
|
fFilePanel->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case B_SIMPLE_DATA:
|
||||||
case B_REFS_RECEIVED:
|
case B_REFS_RECEIVED:
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
int32 sel = fEventList->CurrentSelection();
|
int32 sel = fEventList->CurrentSelection();
|
||||||
if(message->FindRef("refs",&ref) == B_OK && sel >= 0)
|
if(message->FindRef("refs",&ref) == B_OK && sel >= 0) {
|
||||||
{
|
|
||||||
BMenuField *menufield = cast_as(FindView("filemenu"),BMenuField);
|
BMenuField *menufield = cast_as(FindView("filemenu"),BMenuField);
|
||||||
BMenu *menu = menufield->Menu();
|
BMenu *menu = menufield->Menu();
|
||||||
// check audio file
|
// check audio file
|
||||||
@ -266,8 +198,7 @@ HWindow::MessageReceived(BMessage *message)
|
|||||||
BMimeType mtype(type);
|
BMimeType mtype(type);
|
||||||
BMimeType superType;
|
BMimeType superType;
|
||||||
mtype.GetSupertype(&superType);
|
mtype.GetSupertype(&superType);
|
||||||
if(strcmp(superType.Type(),"audio") != 0)
|
if(strcmp(superType.Type(),"audio") != 0) {
|
||||||
{
|
|
||||||
beep();
|
beep();
|
||||||
(new BAlert("","This is not a audio file.","OK",NULL,NULL,
|
(new BAlert("","This is not a audio file.","OK",NULL,NULL,
|
||||||
B_WIDTH_AS_USUAL,B_STOP_ALERT))->Go();
|
B_WIDTH_AS_USUAL,B_STOP_ALERT))->Go();
|
||||||
@ -277,14 +208,12 @@ HWindow::MessageReceived(BMessage *message)
|
|||||||
BMessage *msg = new BMessage(M_ITEM_MESSAGE);
|
BMessage *msg = new BMessage(M_ITEM_MESSAGE);
|
||||||
BPath path(&ref);
|
BPath path(&ref);
|
||||||
msg->AddRef("refs",&ref);
|
msg->AddRef("refs",&ref);
|
||||||
if(!(menu->FindItem(path.Leaf())))
|
|
||||||
menu->AddItem(new BMenuItem(path.Leaf(),msg),0);
|
|
||||||
// refresh item
|
|
||||||
HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem);
|
|
||||||
item->SetPath(path.Path());
|
|
||||||
fEventList->InvalidateItem(sel);
|
|
||||||
// check file menu
|
|
||||||
BMenuItem *menuitem = menu->FindItem(path.Leaf());
|
BMenuItem *menuitem = menu->FindItem(path.Leaf());
|
||||||
|
if(!menuitem)
|
||||||
|
menu->AddItem(menuitem = new BMenuItem(path.Leaf(),msg),0);
|
||||||
|
// refresh item
|
||||||
|
fEventList->SetPath(BPath(&ref).Path());
|
||||||
|
// check file menu
|
||||||
if(menuitem)
|
if(menuitem)
|
||||||
menuitem->SetMarked(true);
|
menuitem->SetMarked(true);
|
||||||
}
|
}
|
||||||
@ -296,21 +225,11 @@ HWindow::MessageReceived(BMessage *message)
|
|||||||
if(sel >= 0)
|
if(sel >= 0)
|
||||||
{
|
{
|
||||||
HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem);
|
HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem);
|
||||||
//system_beep(item->Name());
|
|
||||||
const char* path = item->Path();
|
const char* path = item->Path();
|
||||||
if(path)
|
if(path)
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
::get_ref_for_path(path,&ref);
|
::get_ref_for_path(path,&ref);
|
||||||
/*BSound *sound = new BSound(&ref);
|
|
||||||
if(sound->InitCheck() == B_OK)
|
|
||||||
{
|
|
||||||
fSoundPlayer.Start();
|
|
||||||
fId = fSoundPlayer.StartPlaying(sound);
|
|
||||||
sound->ReleaseRef();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//fSoundHandle = ::play_sound(&ref,false,false,true);
|
|
||||||
delete fPlayer;
|
delete fPlayer;
|
||||||
fPlayer = new BFileGameSound(&ref,false);
|
fPlayer = new BFileGameSound(&ref,false);
|
||||||
fPlayer->StartPlaying();
|
fPlayer->StartPlaying();
|
||||||
@ -320,7 +239,6 @@ HWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
case M_STOP_MESSAGE:
|
case M_STOP_MESSAGE:
|
||||||
{
|
{
|
||||||
//::stop_sound(fSoundHandle);
|
|
||||||
if(!fPlayer)
|
if(!fPlayer)
|
||||||
break;
|
break;
|
||||||
if(fPlayer->IsPlaying())
|
if(fPlayer->IsPlaying())
|
||||||
@ -337,15 +255,13 @@ HWindow::MessageReceived(BMessage *message)
|
|||||||
BMenuField *menufield = cast_as(FindView("filemenu"),BMenuField);
|
BMenuField *menufield = cast_as(FindView("filemenu"),BMenuField);
|
||||||
BMenu *menu = menufield->Menu();
|
BMenu *menu = menufield->Menu();
|
||||||
|
|
||||||
if(message->FindString("path",&path) == B_OK)
|
if(message->FindString("path",&path) == B_OK) {
|
||||||
{
|
|
||||||
BPath path(path);
|
BPath path(path);
|
||||||
if(path.InitCheck() != B_OK)
|
if(path.InitCheck() != B_OK) {
|
||||||
{
|
|
||||||
BMenuItem *item = menu->FindItem("<none>");
|
BMenuItem *item = menu->FindItem("<none>");
|
||||||
if(item)
|
if(item)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
}else{
|
} else {
|
||||||
BMenuItem *item = menu->FindItem(path.Leaf());
|
BMenuItem *item = menu->FindItem(path.Leaf());
|
||||||
if(item)
|
if(item)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
@ -356,27 +272,14 @@ HWindow::MessageReceived(BMessage *message)
|
|||||||
case M_ITEM_MESSAGE:
|
case M_ITEM_MESSAGE:
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
if(message->FindRef("refs",&ref) == B_OK)
|
if(message->FindRef("refs",&ref) == B_OK) {
|
||||||
{
|
fEventList->SetPath(BPath(&ref).Path());
|
||||||
int32 sel = fEventList->CurrentSelection();
|
|
||||||
if(sel >= 0)
|
|
||||||
{
|
|
||||||
HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem);
|
|
||||||
item->SetPath(BPath(&ref).Path());
|
|
||||||
fEventList->InvalidateItem(sel);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case M_NONE_MESSAGE:
|
case M_NONE_MESSAGE:
|
||||||
{
|
{
|
||||||
int32 sel = fEventList->CurrentSelection();
|
fEventList->SetPath(NULL);
|
||||||
if(sel >= 0)
|
|
||||||
{
|
|
||||||
HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem);
|
|
||||||
item->SetPath(NULL);
|
|
||||||
fEventList->InvalidateItem(sel);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -393,16 +296,15 @@ HWindow::SetupMenuField()
|
|||||||
BMenuField *menufield = cast_as(FindView("filemenu"),BMenuField);
|
BMenuField *menufield = cast_as(FindView("filemenu"),BMenuField);
|
||||||
BMenu *menu = menufield->Menu();
|
BMenu *menu = menufield->Menu();
|
||||||
int32 count = fEventList->CountItems();
|
int32 count = fEventList->CountItems();
|
||||||
for(register int32 i = 0;i < count;i++)
|
for(int32 i = 0; i < count; i++) {
|
||||||
{
|
HEventItem *item = cast_as(fEventList->ItemAt(i), HEventItem);
|
||||||
HEventItem *item = cast_as(fEventList->ItemAt(i),HEventItem);
|
|
||||||
if(!item)
|
if(!item)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BPath path(item->Path());
|
BPath path(item->Path());
|
||||||
if(path.InitCheck() != B_OK)
|
if(path.InitCheck() != B_OK)
|
||||||
continue;
|
continue;
|
||||||
if( menu->FindItem(path.Leaf()) )
|
if(menu->FindItem(path.Leaf()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BMessage *msg = new BMessage(M_ITEM_MESSAGE);
|
BMessage *msg = new BMessage(M_ITEM_MESSAGE);
|
||||||
@ -478,33 +380,6 @@ HWindow::SetupMenuField()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* Remove Event
|
|
||||||
***********************************************************/
|
|
||||||
void
|
|
||||||
HWindow::RemoveEvent()
|
|
||||||
{
|
|
||||||
int32 sel = fEventList->CurrentSelection();
|
|
||||||
if(sel < 0)
|
|
||||||
return;
|
|
||||||
// check system beep event
|
|
||||||
HEventItem *item = cast_as(fEventList->ItemAt(sel),HEventItem);
|
|
||||||
if(::strcmp(item->Name(),"Beep") == 0
|
|
||||||
||::strcmp(item->Name(),"Startup")==0
|
|
||||||
||::strcmp(item->Name(),"New E-mail") == 0)
|
|
||||||
{
|
|
||||||
beep();
|
|
||||||
(new BAlert("","This is a system beep event.","OK"))->Go();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
int32 index = (new BAlert("","Would you like to remove this event?","OK","Cancel"))->Go();
|
|
||||||
if(index == 0)
|
|
||||||
{
|
|
||||||
if(item)
|
|
||||||
fEventList->RemoveEvent(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* Pulse
|
* Pulse
|
||||||
@ -519,21 +394,19 @@ HWindow::Pulse()
|
|||||||
|
|
||||||
if(!menufield)
|
if(!menufield)
|
||||||
return;
|
return;
|
||||||
if(sel >=0)
|
if(sel >=0) {
|
||||||
{
|
|
||||||
menufield->SetEnabled(true);
|
menufield->SetEnabled(true);
|
||||||
button->SetEnabled(true);
|
button->SetEnabled(true);
|
||||||
}else{
|
} else {
|
||||||
menufield->SetEnabled(false);
|
menufield->SetEnabled(false);
|
||||||
button->SetEnabled(false);
|
button->SetEnabled(false);
|
||||||
}
|
}
|
||||||
if(fPlayer)
|
if(fPlayer) {
|
||||||
{
|
|
||||||
if(fPlayer->IsPlaying())
|
if(fPlayer->IsPlaying())
|
||||||
stop->SetEnabled(true);
|
stop->SetEnabled(true);
|
||||||
else
|
else
|
||||||
stop->SetEnabled(false);
|
stop->SetEnabled(false);
|
||||||
}else
|
} else
|
||||||
stop->SetEnabled(false);
|
stop->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,24 +428,7 @@ HWindow::DispatchMessage(BMessage *message,BHandler *handler)
|
|||||||
bool
|
bool
|
||||||
HWindow::QuitRequested()
|
HWindow::QuitRequested()
|
||||||
{
|
{
|
||||||
RectUtils utils;
|
|
||||||
CLVColumn *col = fEventList->ColumnAt(1);
|
|
||||||
float width = col->Width();
|
|
||||||
|
|
||||||
app_info info;
|
|
||||||
be_app->GetAppInfo(&info);
|
|
||||||
BEntry entry(&info.ref);
|
|
||||||
|
|
||||||
BFile appfile(&entry,B_WRITE_ONLY);
|
|
||||||
appfile.WriteAttr("event_width",B_FLOAT_TYPE,0,&width,sizeof(float));
|
|
||||||
|
|
||||||
col = fEventList->ColumnAt(2);
|
|
||||||
width = col->Width();
|
|
||||||
appfile.WriteAttr("sound_width",B_FLOAT_TYPE,0,&width,sizeof(float));
|
|
||||||
|
|
||||||
fEventList->RemoveAll();
|
fEventList->RemoveAll();
|
||||||
|
|
||||||
utils.SaveRectToApp("window_rect",this->Frame());
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
//
|
||||||
|
// Copyright (c) 2003, OpenBeOS
|
||||||
|
//
|
||||||
|
// This software is part of the OpenBeOS distribution and is covered
|
||||||
|
// by the OpenBeOS license.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// File: HWindow.h
|
||||||
|
// Author: Jérôme Duval, Oliver Ruiz Dorantes, Atsushi Takamatsu
|
||||||
|
// Description: Sounds Preferences
|
||||||
|
// Created : November 24, 2003
|
||||||
|
//
|
||||||
|
// ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
|
||||||
|
|
||||||
#ifndef __HWINDOW_H__
|
#ifndef __HWINDOW_H__
|
||||||
#define __HWINDOW_H__
|
#define __HWINDOW_H__
|
||||||
|
|
||||||
@ -30,10 +45,8 @@ protected:
|
|||||||
virtual void DispatchMessage(BMessage *message
|
virtual void DispatchMessage(BMessage *message
|
||||||
,BHandler *handler);
|
,BHandler *handler);
|
||||||
void InitGUI();
|
void InitGUI();
|
||||||
void InitMenu();
|
|
||||||
void SetupMenuField();
|
void SetupMenuField();
|
||||||
void Pulse();
|
void Pulse();
|
||||||
void RemoveEvent();
|
|
||||||
private:
|
private:
|
||||||
//HTypeList* fTypeList;
|
//HTypeList* fTypeList;
|
||||||
HEventList* fEventList;
|
HEventList* fEventList;
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1,8 +0,0 @@
|
|||||||
#include "HApp.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
HApp app;
|
|
||||||
app.Run();
|
|
||||||
return 0;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user