initial check in
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@469 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
b055a362cb
commit
ee10eff360
49
src/add-ons/translators/bmptranslator/BMPMain.cpp
Normal file
49
src/add-ons/translators/bmptranslator/BMPMain.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
// BMPMain.cpp
|
||||
|
||||
#include <Application.h>
|
||||
#include <Screen.h>
|
||||
#include <Alert.h>
|
||||
#include "BMPTranslator.h"
|
||||
#include "BMPWindow.h"
|
||||
#include "BMPView.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
BApplication app("application/x-vnd.obos-bmp-translator");
|
||||
BMPTranslator *ptranslator = new BMPTranslator;
|
||||
BView *v = NULL;
|
||||
BRect r(0,0,200,100);
|
||||
if (ptranslator->MakeConfigurationView(NULL, &v, &r)) {
|
||||
BAlert *err = new BAlert("Error", "Something is wrong with the BMPTranslator!", "OK");
|
||||
err->Go();
|
||||
return 1;
|
||||
}
|
||||
ptranslator->Release();
|
||||
// release the translator even though I never really used it anyway
|
||||
BMPWindow *w = new BMPWindow(r);
|
||||
v->ResizeTo(r.Width(), r.Height());
|
||||
w->AddChild(v);
|
||||
BPoint o = B_ORIGIN;
|
||||
{
|
||||
BScreen scrn;
|
||||
BRect f = scrn.Frame();
|
||||
f.InsetBy(10,23);
|
||||
/* if not in a good place, start where the cursor is */
|
||||
if (!f.Contains(o)) {
|
||||
uint32 i;
|
||||
v->GetMouse(&o, &i, false);
|
||||
o.x -= r.Width()/2;
|
||||
o.y -= r.Height()/2;
|
||||
/* clamp location to screen */
|
||||
if (o.x < f.left) o.x = f.left;
|
||||
if (o.y < f.top) o.y = f.top;
|
||||
if (o.x > f.right) o.x = f.right;
|
||||
if (o.y > f.bottom) o.y = f.bottom;
|
||||
}
|
||||
}
|
||||
w->MoveTo(o);
|
||||
w->Show();
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
25
src/add-ons/translators/bmptranslator/BMPView.cpp
Normal file
25
src/add-ons/translators/bmptranslator/BMPView.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
// BMPView.cpp
|
||||
|
||||
#include <stdio.h>
|
||||
#include "BMPView.h"
|
||||
#include "BMPTranslator.h"
|
||||
|
||||
BMPView::BMPView(const BRect &frame, const char *name, uint32 resize, uint32 flags) :
|
||||
BView(frame, name, resize, flags)
|
||||
{
|
||||
SetViewColor(220,220,220,0);
|
||||
}
|
||||
|
||||
BMPView::~BMPView()
|
||||
{
|
||||
}
|
||||
|
||||
void BMPView::Draw(BRect area)
|
||||
{
|
||||
SetFont(be_bold_font);
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
char str[100];
|
||||
sprintf(str, "BMPTranslator %.2f", (float) BMP_TRANSLATOR_VERSION / 100.0);
|
||||
DrawString(str, BPoint(fh.descent + 1, fh.ascent + fh.descent * 2 + fh.leading));
|
||||
}
|
22
src/add-ons/translators/bmptranslator/BMPView.h
Normal file
22
src/add-ons/translators/bmptranslator/BMPView.h
Normal file
@ -0,0 +1,22 @@
|
||||
// BMPView.h
|
||||
|
||||
#ifndef BMPVIEW_H
|
||||
#define BMPVIEW_H
|
||||
|
||||
#include <View.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
|
||||
class BMPView : public BView
|
||||
{
|
||||
public:
|
||||
BMPView(const BRect &frame, const char *name, uint32 resize, uint32 flags);
|
||||
~BMPView();
|
||||
|
||||
virtual void Draw(BRect area);
|
||||
|
||||
private:
|
||||
void SelectColorSpace(color_space space);
|
||||
};
|
||||
|
||||
#endif // #ifndef BMPVIEW_H
|
13
src/add-ons/translators/bmptranslator/BMPWindow.cpp
Normal file
13
src/add-ons/translators/bmptranslator/BMPWindow.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
// BMPWindow.cpp
|
||||
|
||||
#include "BMPWindow.h"
|
||||
|
||||
BMPWindow::BMPWindow(BRect area) :
|
||||
BWindow(area, "BMPTranslator", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
}
|
||||
|
||||
BMPWindow::~BMPWindow()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
16
src/add-ons/translators/bmptranslator/BMPWindow.h
Normal file
16
src/add-ons/translators/bmptranslator/BMPWindow.h
Normal file
@ -0,0 +1,16 @@
|
||||
// BMPWindow.h
|
||||
|
||||
#ifndef BMPWINDOW_H
|
||||
#define BMPWINDOW_H
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
class BMPWindow : public BWindow {
|
||||
public:
|
||||
BMPWindow(BRect area);
|
||||
~BMPWindow();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user