2 Copyright 1999, Be Incorporated. All Rights Reserved.
3 This file may be used under the terms of the Be Sample Code License.
7 #include <Application.h>
9 #include <LayoutBuilder.h>
11 #include <TranslatorAddOn.h>
18 #undef B_TRANSLATION_CONTEXT
19 #define B_TRANSLATION_CONTEXT "PPMMain"
22 BPoint
get_window_origin();
23 void set_window_origin(BPoint pt
);
29 PPMWindow(BRect area
) :
30 BWindow(area
, B_TRANSLATE("PPM Settings"), B_TITLED_WINDOW
,
31 B_NOT_RESIZABLE
| B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS
)
33 BLayoutBuilder::Group
<>(this, B_HORIZONTAL
);
39 set_window_origin(pt
);
40 be_app
->PostMessage(B_QUIT_REQUESTED
);
47 BApplication
app("application/x-vnd.Haiku-PPMTranslator");
50 if (MakeConfig(NULL
, &v
, &r
)) {
51 BAlert
* err
= new BAlert("Error",
52 B_TRANSLATE("Something is wrong with the PPMTranslator!"),
54 err
->SetFlags(err
->Flags() | B_CLOSE_ON_ESCAPE
);
58 PPMWindow
*w
= new PPMWindow(r
);
59 v
->ResizeTo(r
.Width(), r
.Height());
61 BPoint o
= get_window_origin();
64 BRect f
= scrn
.Frame();
66 /* if not in a good place, start where the cursor is */
69 v
->GetMouse(&o
, &i
, false);
72 /* clamp location to screen */
73 if (o
.x
< f
.left
) o
.x
= f
.left
;
74 if (o
.y
< f
.top
) o
.y
= f
.top
;
75 if (o
.x
> f
.right
) o
.x
= f
.right
;
76 if (o
.y
> f
.bottom
) o
.y
= f
.bottom
;