diff --git a/src/add-ons/translators/bmptranslator/BMPMain.cpp b/src/add-ons/translators/bmptranslator/BMPMain.cpp new file mode 100644 index 0000000000..01141ddaf4 --- /dev/null +++ b/src/add-ons/translators/bmptranslator/BMPMain.cpp @@ -0,0 +1,49 @@ +// BMPMain.cpp + +#include +#include +#include +#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; +} \ No newline at end of file diff --git a/src/add-ons/translators/bmptranslator/BMPView.cpp b/src/add-ons/translators/bmptranslator/BMPView.cpp new file mode 100644 index 0000000000..ebee69935d --- /dev/null +++ b/src/add-ons/translators/bmptranslator/BMPView.cpp @@ -0,0 +1,25 @@ +// BMPView.cpp + +#include +#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)); +} \ No newline at end of file diff --git a/src/add-ons/translators/bmptranslator/BMPView.h b/src/add-ons/translators/bmptranslator/BMPView.h new file mode 100644 index 0000000000..5c03bfea1b --- /dev/null +++ b/src/add-ons/translators/bmptranslator/BMPView.h @@ -0,0 +1,22 @@ +// BMPView.h + +#ifndef BMPVIEW_H +#define BMPVIEW_H + +#include +#include +#include + +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 diff --git a/src/add-ons/translators/bmptranslator/BMPWindow.cpp b/src/add-ons/translators/bmptranslator/BMPWindow.cpp new file mode 100644 index 0000000000..69320fcbbc --- /dev/null +++ b/src/add-ons/translators/bmptranslator/BMPWindow.cpp @@ -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); +} \ No newline at end of file diff --git a/src/add-ons/translators/bmptranslator/BMPWindow.h b/src/add-ons/translators/bmptranslator/BMPWindow.h new file mode 100644 index 0000000000..8bd09ca9a1 --- /dev/null +++ b/src/add-ons/translators/bmptranslator/BMPWindow.h @@ -0,0 +1,16 @@ +// BMPWindow.h + +#ifndef BMPWINDOW_H +#define BMPWINDOW_H + +#include +#include +#include + +class BMPWindow : public BWindow { +public: + BMPWindow(BRect area); + ~BMPWindow(); +}; + +#endif \ No newline at end of file