xref: /haiku/src/apps/deskcalc/CalcOptions.cpp (revision 3be9edf8da228afd9fec0390f408c964766122aa)
1 /*
2  * Copyright 2006-2009 Haiku, Inc. All Rights Reserved.
3  * Copyright 1997, 1998 R3 Software Ltd. All Rights Reserved.
4  * Distributed under the terms of the MIT License.
5  *
6  * Authors:
7  *		Timothy Wayper <timmy@wunderbear.com>
8  *		Stephan Aßmus <superstippi@gmx.de>
9  */
10 
11 #include "CalcOptions.h"
12 
13 #include <stdlib.h>
14 #include <stdio.h>
15 
16 #include <Message.h>
17 
18 
19 CalcOptions::CalcOptions()
20 	:
21 	auto_num_lock(false),
22 	audio_feedback(false),
23 	show_keypad(true)
24 {
25 }
26 
27 
28 void
29 CalcOptions::LoadSettings(const BMessage* archive)
30 {
31 	bool option;
32 
33 	if (archive->FindBool("auto num lock", &option) == B_OK)
34 		auto_num_lock = option;
35 
36 	if (archive->FindBool("audio feedback", &option) == B_OK)
37 		audio_feedback = option;
38 
39 	if (archive->FindBool("show keypad", &option) == B_OK)
40 		show_keypad = option;
41 }
42 
43 
44 status_t
45 CalcOptions::SaveSettings(BMessage* archive) const
46 {
47 	status_t ret = archive->AddBool("auto num lock", auto_num_lock);
48 
49 	if (ret == B_OK)
50 		ret = archive->AddBool("audio feedback", audio_feedback);
51 
52 	if (ret == B_OK)
53 		ret = archive->AddBool("show keypad", show_keypad);
54 
55 	return ret;
56 }
57 
58