I shouldn't push my luck too much, so I'm commiting these WIP changes:
* Removed unmaintained makefile. * Renamed TPreferences to SettingsMessage, which better describes the beast. * Renamed setter functions in SettingsMessage for more convenient use. * Added getter functions which take a default value argument that is returned when there is no value for the given key. * Cleanup in Settings.[h|cpp], made things simpler and more convenient. Removed redundant saving of the settings/message, which SettingsMessage already takes care of. Added a global instance of the application settings. * Some cleanup in FileReadWrite and Playlist. * Reimplemented the SettingsWindow with the new layout API, the old code is still in place for compiling for BeOS. * Added two more check boxen for the overlay and bilinear scaling option I intend to add eventually. * Refactored the rest of the code in SettingsWindow to use the new global settings instance and also support a Revert feature. All the new controls are only available in Haiku though. * Enabled the Settings... menu entry in the Settings window for access to the SettingsWindow. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27154 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -84,13 +84,13 @@ Application MediaPlayer :
|
|||||||
CommandStack.cpp
|
CommandStack.cpp
|
||||||
Event.cpp
|
Event.cpp
|
||||||
EventQueue.cpp
|
EventQueue.cpp
|
||||||
|
FileReadWrite.cpp
|
||||||
Listener.cpp
|
Listener.cpp
|
||||||
ListenerAdapter.cpp
|
ListenerAdapter.cpp
|
||||||
MessageEvent.cpp
|
MessageEvent.cpp
|
||||||
Notifier.cpp
|
Notifier.cpp
|
||||||
RWLocker.cpp
|
RWLocker.cpp
|
||||||
FileReadWrite.cpp
|
SettingsMessage.cpp
|
||||||
TPreferences.cpp
|
|
||||||
|
|
||||||
# .
|
# .
|
||||||
Controller.cpp
|
Controller.cpp
|
||||||
|
|||||||
@@ -949,9 +949,9 @@ MainWin::_CreateMenu()
|
|||||||
new BMessage(M_TOGGLE_NO_CONTROLS), 'C'));
|
new BMessage(M_TOGGLE_NO_CONTROLS), 'C'));
|
||||||
fSettingsMenu->AddItem(new BMenuItem("Always on Top",
|
fSettingsMenu->AddItem(new BMenuItem("Always on Top",
|
||||||
new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T'));
|
new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T'));
|
||||||
// fSettingsMenu->AddSeparatorItem();
|
fSettingsMenu->AddSeparatorItem();
|
||||||
// fSettingsMenu->AddItem(new BMenuItem("Settings"B_UTF8_ELLIPSIS,
|
fSettingsMenu->AddItem(new BMenuItem("Settings"B_UTF8_ELLIPSIS,
|
||||||
// new BMessage(M_SETTINGS), 'S'));
|
new BMessage(M_SETTINGS), 'S'));
|
||||||
|
|
||||||
// fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.00000:1",
|
// fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.00000:1",
|
||||||
// new BMessage(M_ASPECT_100000_1)));
|
// new BMessage(M_ASPECT_100000_1)));
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
DEBUG = yes
|
|
||||||
#DEBUG = no
|
|
||||||
|
|
||||||
TARGET = HaikuMediaPlayer
|
|
||||||
SOURCES = Controller.cpp \
|
|
||||||
ControllerView.cpp \
|
|
||||||
DrawingTidbits.cpp \
|
|
||||||
SoundOutput.cpp \
|
|
||||||
TransportButton.cpp \
|
|
||||||
TransportControlGroup.cpp \
|
|
||||||
MainApp.cpp \
|
|
||||||
MainWin.cpp \
|
|
||||||
Playlist.cpp \
|
|
||||||
SeekSlider.cpp \
|
|
||||||
VideoNode.cpp \
|
|
||||||
VideoView.cpp \
|
|
||||||
VolumeSlider.cpp
|
|
||||||
|
|
||||||
CPPFLAGS = -Wall -Wno-multichar -Wmissing-prototypes -Wpointer-arith -Wcast-align -Wsign-compare
|
|
||||||
|
|
||||||
LDFLAGS = -lmedia -lbe -ltracker
|
|
||||||
|
|
||||||
ARCHIVES =
|
|
||||||
|
|
||||||
CC=g++
|
|
||||||
|
|
||||||
OBJECTS = $(patsubst %.cpp, obj/%.o, $(SOURCES))
|
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(DEBUG), yes)
|
|
||||||
CPPFLAGS += -g -O0 -DDEBUG=1
|
|
||||||
LDFLAGS += -g
|
|
||||||
else
|
|
||||||
# Application crashed when O1 or higher
|
|
||||||
CPPFLAGS += -O0
|
|
||||||
endif
|
|
||||||
|
|
||||||
CPPFLAGS +=
|
|
||||||
|
|
||||||
all: $(TARGET)
|
|
||||||
|
|
||||||
obj:
|
|
||||||
@[ -d obj ] || mkdir obj > /dev/null 2>&1
|
|
||||||
|
|
||||||
#obj/%.o: %.cpp obj
|
|
||||||
obj/%.o: %.cpp
|
|
||||||
$(CC) -c $< $(INCLUDES) $(CPPFLAGS) -o $@
|
|
||||||
|
|
||||||
$(TARGET): $(OBJECTS)
|
|
||||||
$(CC) -o $@ $(LDFLAGS) $(OBJECTS) $(ARCHIVES)
|
|
||||||
chmod 0777 $@
|
|
||||||
|
|
||||||
run: $(TARGET)
|
|
||||||
./$(TARGET) &
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f ./$(TARGET)
|
|
||||||
rm -f ./obj/*.o
|
|
||||||
|
|
||||||
@@ -263,7 +263,7 @@ Playlist::GetRefAt(int32 index, entry_ref* _ref) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - navigation
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -5,103 +5,87 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
* Fredrik Modéen <[email protected]>
|
* Fredrik Modéen <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <Autolock.h>
|
||||||
|
|
||||||
#include <String.h>
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
#include <File.h>
|
|
||||||
|
|
||||||
#include "TPreferences.h"
|
Settings::Settings(const char* filename)
|
||||||
|
: BLocker("settings lock"),
|
||||||
Settings::Settings(const char *filename)
|
fSettingsMessage(B_USER_CONFIG_DIRECTORY, filename)
|
||||||
: fTPreferences(TPreferences(B_USER_CONFIG_DIRECTORY, filename))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Settings::LoadSettings(mpSettings &settings)
|
Settings::LoadSettings(mpSettings& settings) const
|
||||||
{
|
{
|
||||||
BPath path;
|
BAutolock _(const_cast<Settings*>(this));
|
||||||
|
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK)
|
settings.autostart = fSettingsMessage.GetValue("autostart", true);
|
||||||
return;
|
settings.closeWhenDonePlayingMovie
|
||||||
|
= fSettingsMessage.GetValue("closeWhenDonePlayingMovie", false);
|
||||||
path.Append(SETTINGSFILENAME);
|
settings.closeWhenDonePlayingSound
|
||||||
|
= fSettingsMessage.GetValue("closeWhenDonePlayingSound", false);
|
||||||
BFile settingsFile(path.Path(), B_READ_ONLY);
|
settings.loopMovie = fSettingsMessage.GetValue("loopMovie", false);
|
||||||
|
settings.loopSound = fSettingsMessage.GetValue("loopSound", false);
|
||||||
if (settingsFile.InitCheck() != B_OK) {
|
|
||||||
_SetDefault(settings);
|
settings.useOverlays = fSettingsMessage.GetValue("useOverlays", true);
|
||||||
return;
|
settings.scaleBilinear = fSettingsMessage.GetValue("scaleBilinear", false);
|
||||||
}
|
|
||||||
|
settings.backgroundMovieVolumeMode
|
||||||
fTPreferences.Unflatten(&settingsFile);
|
= fSettingsMessage.GetValue("bgMovieVolumeMode",
|
||||||
memset(&settings, 0, sizeof(settings));
|
(uint32)mpSettings::BG_MOVIES_MUTED);
|
||||||
|
|
||||||
fTPreferences.FindInt8("autostart", (int8 *)&settings.autostart);
|
|
||||||
fTPreferences.FindInt8("closeWhenDonePlayingMovie",
|
|
||||||
(int8 *)&settings.closeWhenDonePlayingMovie);
|
|
||||||
fTPreferences.FindInt8("closeWhenDonePlayingSound",
|
|
||||||
(int8 *)&settings.closeWhenDonePlayingSound);
|
|
||||||
fTPreferences.FindInt8("loopMovie", (int8 *)&settings.loopMovie);
|
|
||||||
fTPreferences.FindInt8("loopSound", (int8 *)&settings.loopSound);
|
|
||||||
fTPreferences.FindInt8("fullVolume", (int8 *)&settings.fullVolume);
|
|
||||||
fTPreferences.FindInt8("halfVolume", (int8 *)&settings.halfVolume);
|
|
||||||
fTPreferences.FindInt8("mute", (int8 *)&settings.mute);
|
|
||||||
|
|
||||||
fTPreferences.Flatten(&settingsFile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Settings::SaveSettings(const mpSettings &settings)
|
Settings::SaveSettings(const mpSettings& settings)
|
||||||
{
|
{
|
||||||
BPath path;
|
BAutolock _(this);
|
||||||
|
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path, true) != B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
path.Append(SETTINGSFILENAME);
|
|
||||||
|
|
||||||
BFile settingsFile(path.Path(), B_READ_WRITE | B_CREATE_FILE);
|
|
||||||
|
|
||||||
fTPreferences.Unflatten(&settingsFile);
|
|
||||||
|
|
||||||
fTPreferences.SetInt8("autostart", settings.autostart);
|
fSettingsMessage.SetValue("autostart", settings.autostart);
|
||||||
fTPreferences.SetInt8("closeWhenDonePlayingMovie",
|
fSettingsMessage.SetValue("closeWhenDonePlayingMovie",
|
||||||
settings.closeWhenDonePlayingMovie);
|
settings.closeWhenDonePlayingMovie);
|
||||||
fTPreferences.SetInt8("closeWhenDonePlayingSound",
|
fSettingsMessage.SetValue("closeWhenDonePlayingSound",
|
||||||
settings.closeWhenDonePlayingSound);
|
settings.closeWhenDonePlayingSound);
|
||||||
fTPreferences.SetInt8("loopMovie", settings.loopMovie);
|
fSettingsMessage.SetValue("loopMovie", settings.loopMovie);
|
||||||
fTPreferences.SetInt8("loopSound", settings.loopSound);
|
fSettingsMessage.SetValue("loopSound", settings.loopSound);
|
||||||
fTPreferences.SetInt8("fullVolume", settings.fullVolume);
|
|
||||||
fTPreferences.SetInt8("halfVolume", settings.halfVolume);
|
|
||||||
fTPreferences.SetInt8("mute", settings.mute);
|
|
||||||
|
|
||||||
settingsFile.SetSize(0);
|
|
||||||
settingsFile.Seek(0, SEEK_SET);
|
|
||||||
|
|
||||||
fTPreferences.Flatten(&settingsFile);
|
fSettingsMessage.SetValue("useOverlays", settings.useOverlays);
|
||||||
|
fSettingsMessage.SetValue("scaleBilinear", settings.scaleBilinear);
|
||||||
|
|
||||||
|
fSettingsMessage.SetValue("bgMovieVolumeMode",
|
||||||
|
settings.backgroundMovieVolumeMode);
|
||||||
|
|
||||||
|
// Save at this point, although saving is also done on destruction,
|
||||||
|
// this will make sure the settings are saved even when the player
|
||||||
|
// crashes.
|
||||||
|
fSettingsMessage.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
// #pragma mark - static
|
||||||
Settings::_SetDefault(mpSettings &settings)
|
|
||||||
|
/*static*/ Settings
|
||||||
|
Settings::sGlobalInstance;
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/ mpSettings
|
||||||
|
Settings::CurrentSettings()
|
||||||
{
|
{
|
||||||
memset(&settings, 0, sizeof(settings));
|
mpSettings settings;
|
||||||
|
sGlobalInstance.LoadSettings(settings);
|
||||||
settings.autostart = 0;
|
return settings;
|
||||||
settings.closeWhenDonePlayingMovie = 0;
|
|
||||||
settings.closeWhenDonePlayingSound = 0;
|
|
||||||
settings.loopMovie = 0;
|
|
||||||
settings.loopSound = 0;
|
|
||||||
settings.fullVolume = 0;
|
|
||||||
settings.halfVolume = 0;
|
|
||||||
settings.mute = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/ Settings*
|
||||||
|
Settings::Default()
|
||||||
|
{
|
||||||
|
return &sGlobalInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,33 +6,46 @@
|
|||||||
* Fredrik Modéen <[email protected]>
|
* Fredrik Modéen <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SETTINGS_H__
|
#ifndef SETTINGS_H
|
||||||
#define __SETTINGS_H__
|
#define SETTINGS_H
|
||||||
|
|
||||||
#include <Message.h>
|
#include <Locker.h>
|
||||||
#include <Path.h>
|
|
||||||
|
|
||||||
#include "TPreferences.h"
|
#include "SettingsMessage.h"
|
||||||
|
|
||||||
struct mpSettings {
|
struct mpSettings {
|
||||||
int8
|
bool autostart;
|
||||||
autostart, closeWhenDonePlayingMovie, closeWhenDonePlayingSound,
|
bool closeWhenDonePlayingMovie;
|
||||||
loopMovie, loopSound, fullVolume, halfVolume, mute;
|
bool closeWhenDonePlayingSound;
|
||||||
|
bool loopMovie;
|
||||||
|
bool loopSound;
|
||||||
|
bool useOverlays;
|
||||||
|
bool scaleBilinear;
|
||||||
|
enum {
|
||||||
|
BG_MOVIES_FULL_VOLUME = 0,
|
||||||
|
BG_MOVIES_HALF_VLUME = 1,
|
||||||
|
BG_MOVIES_MUTED = 2
|
||||||
|
};
|
||||||
|
uint32 backgroundMovieVolumeMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SETTINGSFILENAME "MediaPlayerSettings"
|
#define SETTINGS_FILENAME "MediaPlayerSettings"
|
||||||
|
|
||||||
class Settings {
|
class Settings : public BLocker {
|
||||||
public:
|
public:
|
||||||
Settings(const char *filename = SETTINGSFILENAME);
|
Settings(
|
||||||
|
const char* filename = SETTINGS_FILENAME);
|
||||||
void LoadSettings(mpSettings &settings);
|
|
||||||
void SaveSettings(const mpSettings &settings);
|
void LoadSettings(mpSettings& settings) const;
|
||||||
|
void SaveSettings(const mpSettings& settings);
|
||||||
private:
|
|
||||||
void _SetDefault(mpSettings &settings);
|
static mpSettings CurrentSettings();
|
||||||
|
static Settings* Default();
|
||||||
TPreferences fTPreferences;
|
|
||||||
|
private:
|
||||||
|
SettingsMessage fSettingsMessage;
|
||||||
|
|
||||||
|
static Settings sGlobalInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __SETTINGS_H__
|
#endif // SETTINGS_H
|
||||||
|
|||||||
@@ -18,17 +18,28 @@
|
|||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
# include <GridLayoutBuilder.h>
|
||||||
|
# include <GroupLayout.h>
|
||||||
|
# include <GroupLayoutBuilder.h>
|
||||||
|
# include <SpaceLayoutItem.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
M_AUTOSTART = 0x3000,
|
M_AUTOSTART = 0x3000,
|
||||||
M_CLOSE_WINDOW_MOVIE,
|
M_CLOSE_WINDOW_MOVIE,
|
||||||
M_CLOSE_WINDOW_SOUNDS,
|
M_CLOSE_WINDOW_SOUNDS,
|
||||||
M_LOOP_MOVIE,
|
M_LOOP_MOVIE,
|
||||||
M_LOOP_SOUND,
|
M_LOOP_SOUND,
|
||||||
|
M_USE_OVERLAYS,
|
||||||
|
M_SCALE_BILINEAR,
|
||||||
M_START_FULL_VOLUME,
|
M_START_FULL_VOLUME,
|
||||||
M_START_HALF_VOLUME,
|
M_START_HALF_VOLUME,
|
||||||
M_START_MUTE_VOLUME,
|
M_START_MUTE_VOLUME,
|
||||||
|
|
||||||
M_SETTINGS_SAVE,
|
M_SETTINGS_SAVE,
|
||||||
M_SETTINGS_CANCEL,
|
M_SETTINGS_CANCEL,
|
||||||
|
M_SETTINGS_REVERT
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SPACE 10
|
#define SPACE 10
|
||||||
@@ -36,12 +47,137 @@ enum {
|
|||||||
#define BUTTONHEIGHT 20
|
#define BUTTONHEIGHT 20
|
||||||
|
|
||||||
SettingsWindow::SettingsWindow(BRect frame)
|
SettingsWindow::SettingsWindow(BRect frame)
|
||||||
: BWindow(frame, "Settings", B_MODAL_WINDOW, B_NOT_CLOSABLE | B_NOT_ZOOMABLE
|
: BWindow(frame, "MediaPlayer Settings", B_TITLED_WINDOW_LOOK,
|
||||||
| B_NOT_RESIZABLE)
|
B_NORMAL_WINDOW_FEEL,
|
||||||
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
| B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
|
#else
|
||||||
|
)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
fSettingsObj = new Settings();
|
#ifdef __HAIKU__
|
||||||
fSettingsObj->LoadSettings(fSettings);
|
|
||||||
|
BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL);
|
||||||
|
BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, 5);
|
||||||
|
settingsBox->SetLayout(settingsLayout);
|
||||||
|
BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
|
||||||
|
BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, 5);
|
||||||
|
buttonBox->SetLayout(buttonLayout);
|
||||||
|
|
||||||
|
BStringView* playModeLabel = new BStringView("stringViewPlayMode",
|
||||||
|
"Play mode");
|
||||||
|
BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions",
|
||||||
|
"View options");
|
||||||
|
BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg",
|
||||||
|
"Play background movies at");
|
||||||
|
BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
|
||||||
|
playModeLabel->SetExplicitAlignment(alignment);
|
||||||
|
playModeLabel->SetFont(be_bold_font);
|
||||||
|
viewOptionsLabel->SetExplicitAlignment(alignment);
|
||||||
|
viewOptionsLabel->SetFont(be_bold_font);
|
||||||
|
bgMoviesModeLabel->SetExplicitAlignment(alignment);
|
||||||
|
bgMoviesModeLabel->SetFont(be_bold_font);
|
||||||
|
|
||||||
|
fAutostartCB = new BCheckBox("chkboxAutostart",
|
||||||
|
"Automatically start playing", new BMessage(M_AUTOSTART));
|
||||||
|
|
||||||
|
fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies",
|
||||||
|
"Close window when done playing movies",
|
||||||
|
new BMessage(M_CLOSE_WINDOW_MOVIE));
|
||||||
|
fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds",
|
||||||
|
"Close window when done playing sounds",
|
||||||
|
new BMessage(M_CLOSE_WINDOW_SOUNDS));
|
||||||
|
|
||||||
|
fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie",
|
||||||
|
"Loop movies by default", new BMessage(M_LOOP_MOVIE));
|
||||||
|
fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds",
|
||||||
|
"Loop sounds by default", new BMessage(M_LOOP_SOUND));
|
||||||
|
|
||||||
|
fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays",
|
||||||
|
"Use hardware video overlays if available",
|
||||||
|
new BMessage(M_USE_OVERLAYS));
|
||||||
|
fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear",
|
||||||
|
"Scale movies smoothly (non-overlay mode)",
|
||||||
|
new BMessage(M_SCALE_BILINEAR));
|
||||||
|
|
||||||
|
fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
|
||||||
|
"Full volume", new BMessage(M_START_FULL_VOLUME));
|
||||||
|
|
||||||
|
fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume",
|
||||||
|
"Half volume", new BMessage(M_START_HALF_VOLUME));
|
||||||
|
|
||||||
|
fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
|
||||||
|
"Muted", new BMessage(M_START_MUTE_VOLUME));
|
||||||
|
|
||||||
|
BButton* revertButton = new BButton("revert", "Revert",
|
||||||
|
new BMessage(M_SETTINGS_REVERT));
|
||||||
|
|
||||||
|
BButton* cancelButton = new BButton("cancel", "Cancel",
|
||||||
|
new BMessage(M_SETTINGS_CANCEL));
|
||||||
|
|
||||||
|
BButton* okButton = new BButton("ok", "Ok",
|
||||||
|
new BMessage(M_SETTINGS_SAVE));
|
||||||
|
okButton->MakeDefault(true);
|
||||||
|
|
||||||
|
|
||||||
|
// Build the layout
|
||||||
|
SetLayout(new BGroupLayout(B_HORIZONTAL));
|
||||||
|
|
||||||
|
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
|
.Add(BGroupLayoutBuilder(settingsLayout)
|
||||||
|
.Add(playModeLabel)
|
||||||
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
||||||
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
|
||||||
|
.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
|
.Add(fAutostartCB)
|
||||||
|
.Add(BGridLayoutBuilder(5, 0)
|
||||||
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 0)
|
||||||
|
.Add(fCloseWindowMoviesCB, 1, 0)
|
||||||
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1)
|
||||||
|
.Add(fCloseWindowSoundsCB, 1, 1)
|
||||||
|
)
|
||||||
|
.Add(fLoopMoviesCB)
|
||||||
|
.Add(fLoopSoundsCB)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
||||||
|
|
||||||
|
.Add(viewOptionsLabel)
|
||||||
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
||||||
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
|
||||||
|
.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
|
.Add(fUseOverlaysCB)
|
||||||
|
.Add(fScaleBilinearCB)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
||||||
|
|
||||||
|
.Add(bgMoviesModeLabel)
|
||||||
|
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
|
||||||
|
.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
|
||||||
|
.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
|
||||||
|
.Add(fFullVolumeBGMoviesRB)
|
||||||
|
.Add(fHalfVolumeBGMoviesRB)
|
||||||
|
.Add(fMutedVolumeBGMoviesRB)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.Add(BSpaceLayoutItem::CreateVerticalStrut(5))
|
||||||
|
|
||||||
|
.SetInsets(5, 5, 15, 5)
|
||||||
|
)
|
||||||
|
.Add(BGroupLayoutBuilder(buttonLayout)
|
||||||
|
.Add(revertButton)
|
||||||
|
.AddGlue()
|
||||||
|
.Add(cancelButton)
|
||||||
|
.Add(okButton)
|
||||||
|
.SetInsets(5, 5, 5, 5)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
frame = Bounds();
|
frame = Bounds();
|
||||||
BView* view = new BView(frame,"SettingsView",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
BView* view = new BView(frame,"SettingsView",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
|
||||||
view->SetViewColor(216, 216, 216);
|
view->SetViewColor(216, 216, 216);
|
||||||
@@ -72,23 +208,23 @@ SettingsWindow::SettingsWindow(BRect frame)
|
|||||||
bbox->AddChild(new BStringView(rect, "stringViewPlayMode", str.String()));
|
bbox->AddChild(new BStringView(rect, "stringViewPlayMode", str.String()));
|
||||||
|
|
||||||
rect.OffsetBy(0, rect.Height());
|
rect.OffsetBy(0, rect.Height());
|
||||||
bbox->AddChild(fChkboxAutostart = new BCheckBox(rect, "chkboxAutostart",
|
bbox->AddChild(fAutostartCB = new BCheckBox(rect, "chkboxAutostart",
|
||||||
"Automatically start playing", new BMessage(M_AUTOSTART)));
|
"Automatically start playing", new BMessage(M_AUTOSTART)));
|
||||||
|
|
||||||
rect.OffsetBy(SPACE, rect.Height() + SPACEING);
|
rect.OffsetBy(SPACE, rect.Height() + SPACEING);
|
||||||
bbox->AddChild(fChkBoxCloseWindowMovies = new BCheckBox(rect, "chkBoxCloseWindowMovies",
|
bbox->AddChild(fCloseWindowMoviesCB = new BCheckBox(rect, "chkBoxCloseWindowMovies",
|
||||||
"Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE)));
|
"Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE)));
|
||||||
|
|
||||||
rect.OffsetBy(0, rect.Height() + SPACEING);
|
rect.OffsetBy(0, rect.Height() + SPACEING);
|
||||||
bbox->AddChild(fChkBoxCloseWindowSounds = new BCheckBox(rect, "chkBoxCloseWindowSounds",
|
bbox->AddChild(fCloseWindowSoundsCB = new BCheckBox(rect, "chkBoxCloseWindowSounds",
|
||||||
"Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS)));
|
"Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS)));
|
||||||
|
|
||||||
rect.OffsetBy(-SPACE, rect.Height() + SPACEING);
|
rect.OffsetBy(-SPACE, rect.Height() + SPACEING);
|
||||||
bbox->AddChild(fChkBoxLoopMovie = new BCheckBox(rect, "chkBoxLoopMovie", "Loop movies by default",
|
bbox->AddChild(fLoopMoviesCB = new BCheckBox(rect, "chkBoxLoopMovie", "Loop movies by default",
|
||||||
new BMessage(M_LOOP_MOVIE)));
|
new BMessage(M_LOOP_MOVIE)));
|
||||||
|
|
||||||
rect.OffsetBy(0, rect.Height() + SPACEING);
|
rect.OffsetBy(0, rect.Height() + SPACEING);
|
||||||
bbox->AddChild(fChkBoxLoopSounds = new BCheckBox(rect, "chkBoxLoopSounds", "Loop sounds by default",
|
bbox->AddChild(fLoopSoundsCB = new BCheckBox(rect, "chkBoxLoopSounds", "Loop sounds by default",
|
||||||
new BMessage(M_LOOP_SOUND)));
|
new BMessage(M_LOOP_SOUND)));
|
||||||
|
|
||||||
rect.OffsetBy(0, rect.Height() + SPACE + SPACEING);
|
rect.OffsetBy(0, rect.Height() + SPACE + SPACEING);
|
||||||
@@ -96,24 +232,27 @@ SettingsWindow::SettingsWindow(BRect frame)
|
|||||||
"Play backgrounds movies at:"));
|
"Play backgrounds movies at:"));
|
||||||
|
|
||||||
rect.OffsetBy(SPACE, rect.Height() + SPACEING);
|
rect.OffsetBy(SPACE, rect.Height() + SPACEING);
|
||||||
fRdbtnfullvolume = new BRadioButton(rect, "rdbtnfullvolume",
|
fFullVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume",
|
||||||
"Full Volume", new BMessage(M_START_FULL_VOLUME));
|
"Full Volume", new BMessage(M_START_FULL_VOLUME));
|
||||||
bbox->AddChild(fRdbtnfullvolume);
|
bbox->AddChild(fFullVolumeBGMoviesRB);
|
||||||
|
|
||||||
rect.OffsetBy(0, rect.Height() + SPACEING);
|
rect.OffsetBy(0, rect.Height() + SPACEING);
|
||||||
fRdbtnhalfvolume = new BRadioButton(rect, "rdbtnhalfvolume",
|
fHalfVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnhalfvolume",
|
||||||
"Half Volume", new BMessage(M_START_HALF_VOLUME));
|
"Half Volume", new BMessage(M_START_HALF_VOLUME));
|
||||||
bbox->AddChild(fRdbtnhalfvolume);
|
bbox->AddChild(fHalfVolumeBGMoviesRB);
|
||||||
|
|
||||||
rect.OffsetBy(0, rect.Height() + SPACEING);
|
rect.OffsetBy(0, rect.Height() + SPACEING);
|
||||||
fRdbtnmutevolume = new BRadioButton(rect, "rdbtnfullvolume", "Muted",
|
fMutedVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", "Muted",
|
||||||
new BMessage(M_START_MUTE_VOLUME));
|
new BMessage(M_START_MUTE_VOLUME));
|
||||||
bbox->AddChild(fRdbtnmutevolume);
|
bbox->AddChild(fMutedVolumeBGMoviesRB);
|
||||||
|
|
||||||
SetSettings();
|
|
||||||
|
|
||||||
view->AddChild(bbox);
|
view->AddChild(bbox);
|
||||||
AddChild(view);
|
AddChild(view);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// disable currently unsupported features
|
||||||
|
fLoopMoviesCB->SetEnabled(false);
|
||||||
|
fLoopSoundsCB->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,16 +262,13 @@ SettingsWindow::~SettingsWindow()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SettingsWindow::SetSettings()
|
SettingsWindow::Show()
|
||||||
{
|
{
|
||||||
fChkboxAutostart->SetValue(fSettings.autostart);
|
Settings::Default()->LoadSettings(fLastSettings);
|
||||||
fChkBoxCloseWindowMovies->SetValue(fSettings.closeWhenDonePlayingMovie);
|
fSettings = fLastSettings;
|
||||||
fChkBoxCloseWindowSounds->SetValue(fSettings.closeWhenDonePlayingSound);
|
AdoptSettings();
|
||||||
fChkBoxLoopMovie->SetValue(fSettings.loopMovie);
|
|
||||||
fChkBoxLoopSounds->SetValue(fSettings.loopSound);
|
BWindow::Show();
|
||||||
fRdbtnfullvolume->SetValue(fSettings.fullVolume);
|
|
||||||
fRdbtnhalfvolume->SetValue(fSettings.halfVolume);
|
|
||||||
fRdbtnmutevolume->SetValue(fSettings.mute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -153,30 +289,93 @@ SettingsWindow::MessageReceived(BMessage* message)
|
|||||||
case M_CLOSE_WINDOW_SOUNDS:
|
case M_CLOSE_WINDOW_SOUNDS:
|
||||||
case M_LOOP_MOVIE:
|
case M_LOOP_MOVIE:
|
||||||
case M_LOOP_SOUND:
|
case M_LOOP_SOUND:
|
||||||
|
case M_USE_OVERLAYS:
|
||||||
|
case M_SCALE_BILINEAR:
|
||||||
case M_START_FULL_VOLUME:
|
case M_START_FULL_VOLUME:
|
||||||
case M_START_HALF_VOLUME:
|
case M_START_HALF_VOLUME:
|
||||||
case M_START_MUTE_VOLUME:
|
case M_START_MUTE_VOLUME:
|
||||||
fSettings.autostart = fChkboxAutostart->Value();
|
ApplySettings();
|
||||||
fSettings.closeWhenDonePlayingMovie = fChkBoxCloseWindowMovies->Value();
|
break;
|
||||||
fSettings.closeWhenDonePlayingSound = fChkBoxCloseWindowSounds->Value();
|
|
||||||
fSettings.loopMovie = fChkBoxLoopMovie->Value();
|
|
||||||
fSettings.loopSound = fChkBoxLoopSounds->Value();
|
|
||||||
fSettings.fullVolume = fRdbtnfullvolume->Value();
|
|
||||||
fSettings.halfVolume = fRdbtnhalfvolume->Value();
|
|
||||||
fSettings.mute = fRdbtnmutevolume->Value();
|
|
||||||
case B_KEY_DOWN:
|
case B_KEY_DOWN:
|
||||||
int32 index;
|
int32 index;
|
||||||
if(message->FindInt32("key", &index) == B_NO_ERROR)
|
if (message->FindInt32("key", &index) == B_OK && index == 1)
|
||||||
if(index == 1)
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
break;
|
||||||
break;
|
|
||||||
case M_SETTINGS_SAVE:
|
case M_SETTINGS_REVERT:
|
||||||
fSettingsObj->SaveSettings(fSettings);
|
Revert();
|
||||||
|
break;
|
||||||
|
|
||||||
case M_SETTINGS_CANCEL:
|
case M_SETTINGS_CANCEL:
|
||||||
|
Revert();
|
||||||
|
// fall through
|
||||||
|
case M_SETTINGS_SAVE:
|
||||||
PostMessage(B_QUIT_REQUESTED);
|
PostMessage(B_QUIT_REQUESTED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsWindow::AdoptSettings()
|
||||||
|
{
|
||||||
|
fAutostartCB->SetValue(fSettings.autostart);
|
||||||
|
fCloseWindowMoviesCB->SetValue(fSettings.closeWhenDonePlayingMovie);
|
||||||
|
fCloseWindowSoundsCB->SetValue(fSettings.closeWhenDonePlayingSound);
|
||||||
|
fLoopMoviesCB->SetValue(fSettings.loopMovie);
|
||||||
|
fLoopSoundsCB->SetValue(fSettings.loopSound);
|
||||||
|
|
||||||
|
fUseOverlaysCB->SetValue(fSettings.useOverlays);
|
||||||
|
fScaleBilinearCB->SetValue(fSettings.scaleBilinear);
|
||||||
|
|
||||||
|
fFullVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
|
||||||
|
== mpSettings::BG_MOVIES_FULL_VOLUME);
|
||||||
|
fHalfVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
|
||||||
|
== mpSettings::BG_MOVIES_HALF_VLUME);
|
||||||
|
fMutedVolumeBGMoviesRB->SetValue(fSettings.backgroundMovieVolumeMode
|
||||||
|
== mpSettings::BG_MOVIES_MUTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsWindow::ApplySettings()
|
||||||
|
{
|
||||||
|
fSettings.autostart = fAutostartCB->Value() == B_CONTROL_ON;
|
||||||
|
fSettings.closeWhenDonePlayingMovie
|
||||||
|
= fCloseWindowMoviesCB->Value() == B_CONTROL_ON;
|
||||||
|
fSettings.closeWhenDonePlayingSound
|
||||||
|
= fCloseWindowSoundsCB->Value() == B_CONTROL_ON;
|
||||||
|
fSettings.loopMovie = fLoopMoviesCB->Value() == B_CONTROL_ON;
|
||||||
|
fSettings.loopSound = fLoopSoundsCB->Value() == B_CONTROL_ON;
|
||||||
|
|
||||||
|
fSettings.useOverlays = fUseOverlaysCB->Value() == B_CONTROL_ON;
|
||||||
|
fSettings.scaleBilinear = fScaleBilinearCB->Value() == B_CONTROL_ON;
|
||||||
|
|
||||||
|
if (fFullVolumeBGMoviesRB->Value() == B_CONTROL_ON) {
|
||||||
|
fSettings.backgroundMovieVolumeMode
|
||||||
|
= mpSettings::BG_MOVIES_FULL_VOLUME;
|
||||||
|
} else if (fHalfVolumeBGMoviesRB->Value() == B_CONTROL_ON) {
|
||||||
|
fSettings.backgroundMovieVolumeMode
|
||||||
|
= mpSettings::BG_MOVIES_HALF_VLUME;
|
||||||
|
} else if (fMutedVolumeBGMoviesRB->Value() == B_CONTROL_ON) {
|
||||||
|
fSettings.backgroundMovieVolumeMode
|
||||||
|
= mpSettings::BG_MOVIES_MUTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings::Default()->SaveSettings(fSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SettingsWindow::Revert()
|
||||||
|
{
|
||||||
|
fSettings = fLastSettings;
|
||||||
|
AdoptSettings();
|
||||||
|
Settings::Default()->SaveSettings(fSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,24 +16,35 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
class SettingsWindow : public BWindow {
|
class SettingsWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
SettingsWindow(BRect frame);
|
SettingsWindow(BRect frame);
|
||||||
virtual ~SettingsWindow();
|
virtual ~SettingsWindow();
|
||||||
void SetSettings();
|
|
||||||
virtual bool QuitRequested();
|
virtual void Show();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual bool QuitRequested();
|
||||||
private:
|
virtual void MessageReceived(BMessage* message);
|
||||||
Settings* fSettingsObj;
|
|
||||||
mpSettings fSettings;
|
void AdoptSettings();
|
||||||
|
void ApplySettings();
|
||||||
|
void Revert();
|
||||||
|
bool IsRevertable();
|
||||||
|
|
||||||
|
private:
|
||||||
|
mpSettings fSettings;
|
||||||
|
mpSettings fLastSettings;
|
||||||
|
|
||||||
BCheckBox* fChkboxAutostart;
|
BCheckBox* fAutostartCB;
|
||||||
BCheckBox* fChkBoxCloseWindowMovies;
|
BCheckBox* fCloseWindowMoviesCB;
|
||||||
BCheckBox* fChkBoxCloseWindowSounds;
|
BCheckBox* fCloseWindowSoundsCB;
|
||||||
BCheckBox* fChkBoxLoopMovie;
|
BCheckBox* fLoopMoviesCB;
|
||||||
BCheckBox* fChkBoxLoopSounds;
|
BCheckBox* fLoopSoundsCB;
|
||||||
BRadioButton* fRdbtnfullvolume;
|
|
||||||
BRadioButton* fRdbtnhalfvolume;
|
BCheckBox* fUseOverlaysCB;
|
||||||
BRadioButton* fRdbtnmutevolume;
|
BCheckBox* fScaleBilinearCB;
|
||||||
|
|
||||||
|
BRadioButton* fFullVolumeBGMoviesRB;
|
||||||
|
BRadioButton* fHalfVolumeBGMoviesRB;
|
||||||
|
BRadioButton* fMutedVolumeBGMoviesRB;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,15 +6,17 @@
|
|||||||
* Michael Pfeiffer <[email protected]>
|
* Michael Pfeiffer <[email protected]>
|
||||||
* Fredrik Modéen <[email protected]>
|
* Fredrik Modéen <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FileReadWrite.h"
|
#include "FileReadWrite.h"
|
||||||
|
|
||||||
#include <UTF8.h>
|
#include <UTF8.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
|
||||||
FileReadWrite::FileReadWrite(BFile *file, int32 sourceEncoding)
|
|
||||||
|
FileReadWrite::FileReadWrite(BFile* file, int32 sourceEncoding)
|
||||||
: fFile(file),
|
: fFile(file),
|
||||||
fSourceEncoding(sourceEncoding)
|
fSourceEncoding(sourceEncoding),
|
||||||
|
fPositionInBuffer(0),
|
||||||
|
fAmtRead(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@@ -26,27 +28,27 @@ FileReadWrite::SetEncoding(int32 sourceEncoding)
|
|||||||
|
|
||||||
|
|
||||||
uint32
|
uint32
|
||||||
FileReadWrite::GetEncoding()
|
FileReadWrite::GetEncoding() const
|
||||||
{
|
{
|
||||||
return fSourceEncoding;
|
return fSourceEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
FileReadWrite::Write(const BString& contents)const
|
FileReadWrite::Write(const BString& contents) const
|
||||||
{
|
{
|
||||||
ssize_t sz = fFile->Write(contents.String(), contents.Length());
|
ssize_t written = fFile->Write(contents.String(), contents.Length());
|
||||||
if (sz != contents.Length())
|
if (written != contents.Length())
|
||||||
return sz < 0 ? sz : B_IO_ERROR;
|
return written < 0 ? (status_t)written : B_IO_ERROR;
|
||||||
else
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
FileReadWrite::Next(BString& string)
|
FileReadWrite::Next(BString& string)
|
||||||
{
|
{
|
||||||
// Fill up the buffer with the first chunk of code
|
// Fill up the buffer with the first chunk of data
|
||||||
if (fPositionInBuffer == 0)
|
if (fPositionInBuffer == 0)
|
||||||
fAmtRead = fFile->Read(&fBuffer, sizeof(fBuffer));
|
fAmtRead = fFile->Read(&fBuffer, sizeof(fBuffer));
|
||||||
while (fAmtRead > 0) {
|
while (fAmtRead > 0) {
|
||||||
@@ -54,13 +56,15 @@ FileReadWrite::Next(BString& string)
|
|||||||
// Return true if we hit a newline or the end of the file
|
// Return true if we hit a newline or the end of the file
|
||||||
if (fBuffer[fPositionInBuffer] == '\n') {
|
if (fBuffer[fPositionInBuffer] == '\n') {
|
||||||
fPositionInBuffer++;
|
fPositionInBuffer++;
|
||||||
//Convert begin
|
// Convert begin
|
||||||
int32 state = 0;
|
int32 state = 0;
|
||||||
int32 bufferLen = string.Length();
|
int32 bufferLen = string.Length();
|
||||||
int32 destBufferLen = bufferLen;
|
int32 destBufferLen = bufferLen;
|
||||||
char destination[destBufferLen];
|
char destination[destBufferLen];
|
||||||
if (fSourceEncoding)
|
if (fSourceEncoding) {
|
||||||
convert_to_utf8(fSourceEncoding, string.String(), &bufferLen, destination, &destBufferLen, &state);
|
convert_to_utf8(fSourceEncoding, string.String(),
|
||||||
|
&bufferLen, destination, &destBufferLen, &state);
|
||||||
|
}
|
||||||
string = destination;
|
string = destination;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,34 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008, Haiku.
|
* Copyright 2008, Haiku. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Michael Pfeiffer <[email protected]>
|
* Michael Pfeiffer <[email protected]>
|
||||||
* Fredrik Modéen <[email protected]>
|
* Fredrik Modéen <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
#ifndef FILE_READ_WRITE_H
|
||||||
#ifndef _FILEREADRWITE_
|
#define FILE_READ_WRITE_H
|
||||||
#define _FILEREADRWITE_
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
class FileReadWrite {
|
|
||||||
public:
|
|
||||||
// -1 defult encoding
|
|
||||||
FileReadWrite(BFile *file, int32 sourceEncoding = -1);
|
|
||||||
bool Next(BString& string);
|
|
||||||
status_t Write(const BString& contents)const;
|
|
||||||
void SetEncoding(int32 sourceEncoding);
|
|
||||||
uint32 GetEncoding();
|
|
||||||
|
|
||||||
private:
|
class FileReadWrite {
|
||||||
BFile* fFile;
|
public:
|
||||||
int32 fSourceEncoding;
|
FileReadWrite(BFile* file,
|
||||||
char fBuffer[4096];
|
int32 sourceEncoding = -1);
|
||||||
off_t fPositionInBuffer;
|
// -1 means "default" encoding
|
||||||
ssize_t fAmtRead;
|
bool Next(BString& string);
|
||||||
|
status_t Write(const BString& contents) const;
|
||||||
|
void SetEncoding(int32 sourceEncoding);
|
||||||
|
uint32 GetEncoding() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BFile* fFile;
|
||||||
|
int32 fSourceEncoding;
|
||||||
|
char fBuffer[4096];
|
||||||
|
off_t fPositionInBuffer;
|
||||||
|
ssize_t fAmtRead;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_FILEREADRWITE_
|
#endif //FILE_READ_WRITE_H
|
||||||
|
|||||||
@@ -0,0 +1,316 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Stephan Aßmus <[email protected]>.
|
||||||
|
* Copyright 1998 Eric Shepherd.
|
||||||
|
* All rights reserved. Distributed under the terms of the Be Sample Code
|
||||||
|
* license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! Be Newsletter Volume II, Issue 35; September 2, 1998 (Eric Shepherd)
|
||||||
|
|
||||||
|
#include "SettingsMessage.h"
|
||||||
|
|
||||||
|
#include <File.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
|
SettingsMessage::SettingsMessage(directory_which directory,
|
||||||
|
const char* filename)
|
||||||
|
: BMessage('pref')
|
||||||
|
{
|
||||||
|
fStatus = find_directory(directory, &fPath);
|
||||||
|
|
||||||
|
if (fStatus == B_OK)
|
||||||
|
fStatus = fPath.Append(filename);
|
||||||
|
|
||||||
|
if (fStatus == B_OK)
|
||||||
|
fStatus = Load();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SettingsMessage::~SettingsMessage()
|
||||||
|
{
|
||||||
|
Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::InitCheck() const
|
||||||
|
{
|
||||||
|
return fStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::Load()
|
||||||
|
{
|
||||||
|
BFile file(fPath.Path(), B_READ_ONLY);
|
||||||
|
status_t status = file.InitCheck();
|
||||||
|
|
||||||
|
if (status == B_OK)
|
||||||
|
status = Unflatten(&file);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::Save() const
|
||||||
|
{
|
||||||
|
BFile file(fPath.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
|
||||||
|
status_t status = file.InitCheck();
|
||||||
|
|
||||||
|
if (status == B_OK)
|
||||||
|
status = Flatten(&file);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, bool value)
|
||||||
|
{
|
||||||
|
if (ReplaceBool(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddBool(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, int8 value)
|
||||||
|
{
|
||||||
|
if (ReplaceInt8(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddInt8(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, int16 value)
|
||||||
|
{
|
||||||
|
if (ReplaceInt16(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddInt16(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, int32 value)
|
||||||
|
{
|
||||||
|
if (ReplaceInt32(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddInt32(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, uint32 value)
|
||||||
|
{
|
||||||
|
if (ReplaceInt32(name, (int32)value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddInt32(name, (int32)value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, int64 value)
|
||||||
|
{
|
||||||
|
if (ReplaceInt64(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddInt64(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, float value)
|
||||||
|
{
|
||||||
|
if (ReplaceFloat(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddFloat(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, double value)
|
||||||
|
{
|
||||||
|
if (ReplaceDouble(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddDouble(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, const char* value)
|
||||||
|
{
|
||||||
|
if (ReplaceString(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddString(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, const BString& value)
|
||||||
|
{
|
||||||
|
return SetValue(name, value.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, BPoint value)
|
||||||
|
{
|
||||||
|
if (ReplacePoint(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddPoint(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, BRect value)
|
||||||
|
{
|
||||||
|
if (ReplaceRect(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddRect(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, const BMessage* value)
|
||||||
|
{
|
||||||
|
if (ReplaceMessage(name, value) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddMessage(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
SettingsMessage::SetValue(const char* name, const BFlattenable* value)
|
||||||
|
{
|
||||||
|
if (ReplaceFlat(name, const_cast<BFlattenable*>(value)) == B_OK)
|
||||||
|
return B_OK;
|
||||||
|
return AddFlat(name, const_cast<BFlattenable*>(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
bool
|
||||||
|
SettingsMessage::GetValue(const char* name, bool defaultValue) const
|
||||||
|
{
|
||||||
|
bool value;
|
||||||
|
if (FindBool(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int8
|
||||||
|
SettingsMessage::GetValue(const char* name, int8 defaultValue) const
|
||||||
|
{
|
||||||
|
int8 value;
|
||||||
|
if (FindInt8(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int16
|
||||||
|
SettingsMessage::GetValue(const char* name, int16 defaultValue) const
|
||||||
|
{
|
||||||
|
int16 value;
|
||||||
|
if (FindInt16(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
SettingsMessage::GetValue(const char* name, int32 defaultValue) const
|
||||||
|
{
|
||||||
|
int32 value;
|
||||||
|
if (FindInt32(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32
|
||||||
|
SettingsMessage::GetValue(const char* name, uint32 defaultValue) const
|
||||||
|
{
|
||||||
|
int32 value;
|
||||||
|
if (FindInt32(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return (uint32)value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int64
|
||||||
|
SettingsMessage::GetValue(const char* name, int64 defaultValue) const
|
||||||
|
{
|
||||||
|
int64 value;
|
||||||
|
if (FindInt64(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
SettingsMessage::GetValue(const char* name, float defaultValue) const
|
||||||
|
{
|
||||||
|
float value;
|
||||||
|
if (FindFloat(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double
|
||||||
|
SettingsMessage::GetValue(const char* name, double defaultValue) const
|
||||||
|
{
|
||||||
|
double value;
|
||||||
|
if (FindDouble(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BString
|
||||||
|
SettingsMessage::GetValue(const char* name, const BString& defaultValue) const
|
||||||
|
{
|
||||||
|
BString value;
|
||||||
|
if (FindString(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BPoint
|
||||||
|
SettingsMessage::GetValue(const char *name, BPoint defaultValue) const
|
||||||
|
{
|
||||||
|
BPoint value;
|
||||||
|
if (FindPoint(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect
|
||||||
|
SettingsMessage::GetValue(const char* name, BRect defaultValue) const
|
||||||
|
{
|
||||||
|
BRect value;
|
||||||
|
if (FindRect(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BMessage
|
||||||
|
SettingsMessage::GetValue(const char* name, const BMessage& defaultValue) const
|
||||||
|
{
|
||||||
|
BMessage value;
|
||||||
|
if (FindMessage(name, &value) != B_OK)
|
||||||
|
return defaultValue;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008 Stephan Aßmus <superstippi@gmx.de>.
|
||||||
|
* Copyright 1998 Eric Shepherd.
|
||||||
|
* All rights reserved. Distributed under the terms of the Be Sample Code
|
||||||
|
* license.
|
||||||
|
*/
|
||||||
|
#ifndef SETTINGS_MESSAGE_H
|
||||||
|
#define SETTINGS_MESSAGE_H
|
||||||
|
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
|
class BString;
|
||||||
|
|
||||||
|
class SettingsMessage : public BMessage {
|
||||||
|
public:
|
||||||
|
SettingsMessage(directory_which directory,
|
||||||
|
const char* filename);
|
||||||
|
virtual ~SettingsMessage();
|
||||||
|
|
||||||
|
|
||||||
|
status_t InitCheck() const;
|
||||||
|
status_t Load();
|
||||||
|
status_t Save() const;
|
||||||
|
|
||||||
|
status_t SetValue(const char* name, bool value);
|
||||||
|
status_t SetValue(const char* name, int8 value);
|
||||||
|
status_t SetValue(const char* name, int16 value);
|
||||||
|
status_t SetValue(const char* name, int32 value);
|
||||||
|
status_t SetValue(const char* name, uint32 value);
|
||||||
|
status_t SetValue(const char* name, int64 value);
|
||||||
|
status_t SetValue(const char* name, float value);
|
||||||
|
status_t SetValue(const char* name, double value);
|
||||||
|
status_t SetValue(const char* name,
|
||||||
|
const char* value);
|
||||||
|
status_t SetValue(const char* name,
|
||||||
|
const BString& value);
|
||||||
|
status_t SetValue(const char *name, BPoint value);
|
||||||
|
status_t SetValue(const char* name, BRect value);
|
||||||
|
status_t SetValue(const char* name,
|
||||||
|
const BMessage* value);
|
||||||
|
status_t SetValue(const char* name,
|
||||||
|
const BFlattenable* value);
|
||||||
|
|
||||||
|
bool GetValue(const char* name,
|
||||||
|
bool defaultValue) const;
|
||||||
|
int8 GetValue(const char* name,
|
||||||
|
int8 defaultValue) const;
|
||||||
|
int16 GetValue(const char* name,
|
||||||
|
int16 defaultValue) const;
|
||||||
|
int32 GetValue(const char* name,
|
||||||
|
int32 defaultValue) const;
|
||||||
|
uint32 GetValue(const char* name,
|
||||||
|
uint32 defaultValue) const;
|
||||||
|
int64 GetValue(const char* name,
|
||||||
|
int64 defaultValue) const;
|
||||||
|
float GetValue(const char* name,
|
||||||
|
float defaultValue) const;
|
||||||
|
double GetValue(const char* name,
|
||||||
|
double defaultValue) const;
|
||||||
|
BString GetValue(const char* name,
|
||||||
|
const BString& defaultValue) const;
|
||||||
|
BPoint GetValue(const char *name,
|
||||||
|
BPoint defaultValue) const;
|
||||||
|
BRect GetValue(const char* name,
|
||||||
|
BRect defaultValue) const;
|
||||||
|
BMessage GetValue(const char* name,
|
||||||
|
const BMessage& defaultValue) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BPath fPath;
|
||||||
|
status_t fStatus;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SETTINGS_MESSAGE_H
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
//Volume II, Issue 35; September 2, 1998 (Eric Shepherd)
|
|
||||||
|
|
||||||
#include "TPreferences.h"
|
|
||||||
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
#include <File.h>
|
|
||||||
|
|
||||||
TPreferences::TPreferences(directory_which directory, const char *filename)
|
|
||||||
:BMessage('pref')
|
|
||||||
{
|
|
||||||
BFile file;
|
|
||||||
fStatus = find_directory(directory, &fPath);
|
|
||||||
|
|
||||||
if (fStatus != B_OK)
|
|
||||||
return;
|
|
||||||
|
|
||||||
fPath.Append(filename);
|
|
||||||
fStatus = file.SetTo(fPath.Path(), B_READ_ONLY);
|
|
||||||
|
|
||||||
if (fStatus == B_OK)
|
|
||||||
fStatus = Unflatten(&file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
TPreferences::~TPreferences()
|
|
||||||
{
|
|
||||||
BFile file;
|
|
||||||
if (file.SetTo(fPath.Path(), B_WRITE_ONLY | B_CREATE_FILE) == B_OK)
|
|
||||||
Flatten(&file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetBool(const char *name, bool b)
|
|
||||||
{
|
|
||||||
if (HasBool(name))
|
|
||||||
return ReplaceBool(name, 0, b);
|
|
||||||
return AddBool(name, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetInt8(const char *name, int8 i)
|
|
||||||
{
|
|
||||||
if (HasInt8(name))
|
|
||||||
return ReplaceInt8(name, 0, i);
|
|
||||||
return AddInt8(name, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetInt16(const char *name, int16 i)
|
|
||||||
{
|
|
||||||
if (HasInt16(name))
|
|
||||||
return ReplaceInt16(name, 0, i);
|
|
||||||
return AddInt16(name, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetInt32(const char *name, int32 i)
|
|
||||||
{
|
|
||||||
if (HasInt32(name))
|
|
||||||
return ReplaceInt32(name, 0, i);
|
|
||||||
return AddInt32(name, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetInt64(const char *name, int64 i)
|
|
||||||
{
|
|
||||||
if (HasInt64(name))
|
|
||||||
return ReplaceInt64(name, 0, i);
|
|
||||||
return AddInt64(name, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetFloat(const char *name, float f)
|
|
||||||
{
|
|
||||||
if (HasFloat(name))
|
|
||||||
return ReplaceFloat(name, 0, f);
|
|
||||||
return AddFloat(name, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetDouble(const char *name, double f)
|
|
||||||
{
|
|
||||||
if (HasDouble(name))
|
|
||||||
return ReplaceDouble(name, 0, f);
|
|
||||||
return AddDouble(name, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetString(const char *name, const char *s)
|
|
||||||
{
|
|
||||||
if (HasString(name))
|
|
||||||
return ReplaceString(name, 0, s);
|
|
||||||
return AddString(name, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetPoint(const char *name, BPoint p)
|
|
||||||
{
|
|
||||||
if (HasPoint(name))
|
|
||||||
return ReplacePoint(name, 0, p);
|
|
||||||
return AddPoint(name, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetRect(const char *name, BRect r)
|
|
||||||
{
|
|
||||||
if (HasRect(name))
|
|
||||||
return ReplaceRect(name, 0, r);
|
|
||||||
return AddRect(name, r);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetMessage(const char *name, const BMessage *message)
|
|
||||||
{
|
|
||||||
if (HasMessage(name))
|
|
||||||
return ReplaceMessage(name, 0, message);
|
|
||||||
return AddMessage(name, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
TPreferences::SetFlat(const char *name, const BFlattenable *obj)
|
|
||||||
{
|
|
||||||
if (HasFlat(name, obj))
|
|
||||||
return ReplaceFlat(name, 0, (BFlattenable *) obj);
|
|
||||||
return AddFlat(name, (BFlattenable *) obj);
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
#ifndef __TPREFS_H__
|
|
||||||
#define __TPREFS_H__
|
|
||||||
|
|
||||||
//Volume II, Issue 35; September 2, 1998 (Eric Shepherd)
|
|
||||||
/*
|
|
||||||
Usage
|
|
||||||
TPreferences prefs("PrefsSample_prefs"); // Preferences
|
|
||||||
if (prefs.InitCheck() != B_OK) {
|
|
||||||
prefs.SetInt64("last_used", real_time_clock());
|
|
||||||
prefs.SetInt32("use_count", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Then we call PrintToStream() to print out the contents of the TPreferences object:
|
|
||||||
|
|
||||||
prefs.PrintToStream();
|
|
||||||
|
|
||||||
Finally, we update the preferences:
|
|
||||||
|
|
||||||
int32 count;
|
|
||||||
if (prefs.FindInt32("use_count", &count) != B_OK) {
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
prefs.SetInt64("last_used", real_time_clock());
|
|
||||||
prefs.SetInt32("use_count", ++count);
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Path.h>
|
|
||||||
#include <FindDirectory.h>
|
|
||||||
|
|
||||||
class TPreferences : public BMessage {
|
|
||||||
public:
|
|
||||||
TPreferences(directory_which directory, const char* filename);
|
|
||||||
virtual ~TPreferences();
|
|
||||||
|
|
||||||
|
|
||||||
status_t InitCheck(void);
|
|
||||||
status_t SetBool(const char *name, bool b);
|
|
||||||
status_t SetInt8(const char *name, int8 i);
|
|
||||||
status_t SetInt16(const char *name, int16 i);
|
|
||||||
status_t SetInt32(const char *name, int32 i);
|
|
||||||
status_t SetInt64(const char *name, int64 i);
|
|
||||||
status_t SetFloat(const char *name, float f);
|
|
||||||
status_t SetDouble(const char *name, double d);
|
|
||||||
status_t SetString(const char *name,
|
|
||||||
const char *string);
|
|
||||||
status_t SetPoint(const char *name, BPoint p);
|
|
||||||
status_t SetRect(const char *name, BRect r);
|
|
||||||
status_t SetMessage(const char *name,
|
|
||||||
const BMessage *message);
|
|
||||||
status_t SetFlat(const char *name,
|
|
||||||
const BFlattenable *obj);
|
|
||||||
private:
|
|
||||||
BPath fPath;
|
|
||||||
status_t fStatus;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline
|
|
||||||
status_t TPreferences::InitCheck(void)
|
|
||||||
{
|
|
||||||
return fStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __POWERPC__
|
|
||||||
#pragma export off
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __TPREFS_H__
|
|
||||||
Reference in New Issue
Block a user