-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptionsWindow.cpp
151 lines (133 loc) · 4.48 KB
/
OptionsWindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*******************************************************
* ImageShow©
*
* This is hopefully going to be a realy nice image
* viewer. Not like there are a 100 of them out there
* or anything.
*
* @author YNOP (ynop@acm.org)
* @version beta
* @date Sept 18 1999
*******************************************************/
#include <InterfaceKit.h>
#include <TranslationKit.h>
#include <TranslationUtils.h>
//#include <stdio.h>
#include "Globals.h"
#include "OptionsWindow.h"
#include "YLanguageClass.h"
#include "BugOutDef.h"
extern BugOut db;
rgb_color Black = {0,0,0,0};
rgb_color White = {255,255,255,0};
rgb_color Default = { 51,102,152,255 };
rgb_color LightBlue = { 155,155,250 };
rgb_color green = { 0,255,0,255 };
rgb_color darkgreen = { 0,180,0,255 };
/*******************************************************
* Our wonderful BWindow, ya its kewl like that.
* we dont do much here but set up the menubar and
* let the view take over. We also nead some message
* redirection and handling
*******************************************************/
OptionsWindow::OptionsWindow(BWindow *win):BWindow(BRect(50,50,250,150),Language.get("OPTIONS"),B_TITLED_WINDOW_LOOK,B_FLOATING_APP_WINDOW_FEEL,B_ASYNCHRONOUS_CONTROLS|B_NOT_RESIZABLE|B_NOT_ZOOMABLE){
BRect r;
r = Bounds();
theApp = win;
BView *View = new BView(r,"",B_FOLLOW_ALL,0);
View->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
r.top -= 1;
r.left -= 1;
r.right +=1;
r.bottom +=1;
BBox *Bb = new BBox(r,"",B_FOLLOW_ALL_SIDES);
View->AddChild(Bb);
r = Bb->Bounds();
r.InsetBy(3,3);
slide = new BSlider(r,Language.get("THUMB_SIZE"),"",new BMessage(THUMB_SIZE),10,200);
slide->SetModificationMessage(new BMessage(THUMB_SIZE));
Bb->AddChild(slide);
slide->SetLimitLabels(Language.get("THUMB_SIZE"), "");
slide->SetHashMarks(B_HASH_MARKS_TOP);
slide->SetHashMarkCount(5);
slide->SetKeyIncrementValue(1);
slide->SetBarColor(Default);
slide->UseFillColor(true, &LightBlue);
BRect size(10,65,0,0);
BRadioButton *sixteen = new BRadioButton(size,"","16",new BMessage(SET_TO_16),B_FOLLOW_LEFT);
sixteen->ResizeToPreferred();
Bb->AddChild(sixteen);
size.left = 50;
BRadioButton *thirtytwo = new BRadioButton(size,"","32",new BMessage(SET_TO_32),B_FOLLOW_LEFT);
thirtytwo->ResizeToPreferred();
Bb->AddChild(thirtytwo);
size.left = 100;
BRadioButton *sixtyfour = new BRadioButton(size,"","64",new BMessage(SET_TO_64),B_FOLLOW_LEFT);
sixtyfour->ResizeToPreferred();
Bb->AddChild(sixtyfour);
size.left = 150;
BRadioButton *nintysix = new BRadioButton(size,"","96",new BMessage(SET_TO_96),B_FOLLOW_LEFT);
nintysix->ResizeToPreferred();
Bb->AddChild(nintysix);
AddChild(View);
Run();
}
/*******************************************************
* To make things a little nicer and more organized
* we are gona let View be the message handler for
* the whole app. All messages that are ours send to
* View for redistribution. But we must handle our
* own BWindow messages or else (crash)
*******************************************************/
void OptionsWindow::MessageReceived(BMessage* msg){
int s;
switch(msg->what){
case CHANGE_LANGUAGE:
slide->SetLimitLabels(Language.get("THUMB_SIZE"), "");
break;
case THUMB_SIZE:
s = slide->Value();
msg->AddInt32("IconSize",s);
theApp->PostMessage(msg);
break;
case SET_TO_16:
slide->SetValue(16);
s = 16;
msg->what = THUMB_SIZE;
msg->AddInt32("IconSize",s);
theApp->PostMessage(msg);
break;
case SET_TO_32:
slide->SetValue(32);
s = 32;
msg->what = THUMB_SIZE;
msg->AddInt32("IconSize",s);
theApp->PostMessage(msg);
break;
case SET_TO_64:
slide->SetValue(64);
s = 64;
msg->what = THUMB_SIZE;
msg->AddInt32("IconSize",s);
theApp->PostMessage(msg);
break;
case SET_TO_96:
slide->SetValue(96);
s = 96;
msg->what = THUMB_SIZE;
msg->AddInt32("IconSize",s);
theApp->PostMessage(msg);
break;
default:
BWindow::MessageReceived(msg);
}
}
/*******************************************************
* Someone asked us nicely to quit. I gess we should
* so clean up. save our setings (position size of win)
* and tell the main be_app to shut it all down .. bye
*******************************************************/
bool OptionsWindow::QuitRequested(){
Hide();
return false;
}