changed many of the variable names to more descriptive ones, made the code better match the OpenTracker guidelines

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@544 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2002-07-31 16:24:12 +00:00
parent 7220bfdf74
commit d4bad2fdb8
@@ -56,40 +56,46 @@ main()
{ {
BApplication app("application/x-vnd.obos-bmp-translator"); BApplication app("application/x-vnd.obos-bmp-translator");
BMPTranslator *ptranslator = new BMPTranslator; BMPTranslator *ptranslator = new BMPTranslator;
BView *v = NULL; BView *view = NULL;
BRect r(0,0,225,175); BRect rect(0, 0, 225, 175);
if (ptranslator->MakeConfigurationView(NULL, &v, &r)) { if (ptranslator->MakeConfigurationView(NULL, &view, &rect)) {
BAlert *err = new BAlert("Error", "Something is wrong with the BMPTranslator!", "OK"); BAlert *err = new BAlert("Error",
"Unable to create the BMPTranslator view.", "OK");
err->Go(); err->Go();
return 1; return 1;
} }
// release the translator even though I never really used it anyway // release the translator even though I never really used it anyway
ptranslator->Release(); ptranslator->Release();
ptranslator = NULL; ptranslator = NULL;
BMPWindow *w = new BMPWindow(r); BMPWindow *wnd = new BMPWindow(rect);
v->ResizeTo(r.Width(), r.Height()); view->ResizeTo(rect.Width(), rect.Height());
w->AddChild(v); wnd->AddChild(view);
BPoint o = B_ORIGIN; BPoint wndpt = B_ORIGIN;
{ {
BScreen scrn; BScreen scrn;
BRect f = scrn.Frame(); BRect frame = scrn.Frame();
f.InsetBy(10,23); frame.InsetBy(10, 23);
/* if not in a good place, start where the cursor is */ // if the point is outside of the screen frame,
if (!f.Contains(o)) { // use the mouse location to find a better point
uint32 i; if (!frame.Contains(wndpt)) {
v->GetMouse(&o, &i, false); uint32 dummy;
o.x -= r.Width()/2; view->GetMouse(&wndpt, &dummy, false);
o.y -= r.Height()/2; wndpt.x -= rect.Width() / 2;
/* clamp location to screen */ wndpt.y -= rect.Height() / 2;
if (o.x < f.left) o.x = f.left; // clamp location to screen
if (o.y < f.top) o.y = f.top; if (wndpt.x < frame.left)
if (o.x > f.right) o.x = f.right; wndpt.x = frame.left;
if (o.y > f.bottom) o.y = f.bottom; if (wndpt.y < frame.top)
wndpt.y = frame.top;
if (wndpt.x > frame.right)
wndpt.x = frame.right;
if (wndpt.y > frame.bottom)
wndpt.y = frame.bottom;
} }
} }
w->MoveTo(o); wnd->MoveTo(wndpt);
w->Show(); wnd->Show();
app.Run(); app.Run();
return 0; return 0;