From ca699cf3d45e8d092e59b9002954913f35d6af1e Mon Sep 17 00:00:00 2001 From: Matthew Wilber Date: Fri, 20 Jun 2003 22:23:58 +0000 Subject: [PATCH] initial check in for Inspector - image viewer (and later on, hopefully documents in general viewer) for developers of Translators and users of the Translation Kit in general git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3588 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tools/translation/inspector/Constants.h | 47 +++ src/tools/translation/inspector/ImageView.cpp | 328 ++++++++++++++++++ src/tools/translation/inspector/ImageView.h | 66 ++++ .../translation/inspector/ImageWindow.cpp | 122 +++++++ src/tools/translation/inspector/ImageWindow.h | 51 +++ .../translation/inspector/Inspector.rsrc | Bin 0 -> 3441 bytes .../translation/inspector/InspectorApp.cpp | 66 ++++ .../translation/inspector/InspectorApp.h | 44 +++ src/tools/translation/inspector/Jamfile | 12 + .../translation/inspector/StatusCheck.cpp | 49 +++ src/tools/translation/inspector/StatusCheck.h | 49 +++ 11 files changed, 834 insertions(+) create mode 100644 src/tools/translation/inspector/Constants.h create mode 100644 src/tools/translation/inspector/ImageView.cpp create mode 100644 src/tools/translation/inspector/ImageView.h create mode 100644 src/tools/translation/inspector/ImageWindow.cpp create mode 100644 src/tools/translation/inspector/ImageWindow.h create mode 100644 src/tools/translation/inspector/Inspector.rsrc create mode 100644 src/tools/translation/inspector/InspectorApp.cpp create mode 100644 src/tools/translation/inspector/InspectorApp.h create mode 100644 src/tools/translation/inspector/Jamfile create mode 100644 src/tools/translation/inspector/StatusCheck.cpp create mode 100644 src/tools/translation/inspector/StatusCheck.h diff --git a/src/tools/translation/inspector/Constants.h b/src/tools/translation/inspector/Constants.h new file mode 100644 index 0000000000..e6ea4e2592 --- /dev/null +++ b/src/tools/translation/inspector/Constants.h @@ -0,0 +1,47 @@ +/*****************************************************************************/ +// Constants +// Written by Michael Wilber, OBOS Translation Kit Team +// +// Constants.h +// +// Global include file containing BMessage 'what' constants and other constants +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#ifndef MESSAGES_H +#define MESSAGES_H + +// BMessage 'what' values + +#define M_OPEN_IMAGE 'opim' +#define M_SAVE_IMAGE 'saim' +#define M_OPEN_FILE_PANEL 'ofpl' + + +// String constants + +#define APP_SIG "application/x-vnd.OBOS-Inspector" +#define IMAGEWINDOW_TITLE "Inspector" + + +#endif // #ifndef MESSAGES_H diff --git a/src/tools/translation/inspector/ImageView.cpp b/src/tools/translation/inspector/ImageView.cpp new file mode 100644 index 0000000000..1452890dea --- /dev/null +++ b/src/tools/translation/inspector/ImageView.cpp @@ -0,0 +1,328 @@ +/*****************************************************************************/ +// ImageView +// Written by Michael Wilber, OBOS Translation Kit Team +// +// ImageView.cpp +// +// BView class for showing images. Images can be dropped on this view +// from the tracker and images viewed in this view can be dragged +// to the tracker to be saved. +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + + +#include "ImageView.h" +#include "Constants.h" +#include "StatusCheck.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ImageView::ImageView(BRect rect, const char *name) + : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS) +{ + fpbitmap = NULL; + fpmsgFromTracker = NULL; + fbdragFromTracker = false; + + SetViewColor(255, 255, 255); + SetHighColor(255, 255, 255); +} + +ImageView::~ImageView() +{ + delete fpbitmap; + fpbitmap = NULL; +} + +void +ImageView::AttachedToWindow() +{ + AdjustScrollBars(); +} + +void +ImageView::Draw(BRect rect) +{ + // Force view setting changes to be local + // to this function + PushState(); + + // calculate highlight rectangle + BRect bounds = Bounds(); + bounds.right--; + bounds.bottom--; + + if (HasImage()) + DrawBitmap(fpbitmap, BPoint(0, 0)); + else if (!fbdragFromTracker) { + SetHighColor(255, 255, 255); + SetPenSize(2.0); + StrokeRect(bounds); + } + + if (fbdragFromTracker) { + SetHighColor(0, 0, 229); + SetPenSize(2.0); + StrokeRect(bounds); + } + + PopState(); +} + +void +ImageView::FrameResized(float width, float height) +{ + AdjustScrollBars(); + + // If there is a bitmap, draw it. + // If not, invalidate the entire view so that + // the advice text will be displayed + if (HasImage()) + ReDraw(); + else + Invalidate(); +} + +void +ImageView::MouseDown(BPoint point) +{ + if (!HasImage()) + return; + + // Tell BeOS to setup a Drag/Drop operation + BMessage msg(B_SIMPLE_DATA); + msg.AddInt32("be:actions", B_COPY_TARGET); + msg.AddString("be:filetypes", "application/octet-stream"); + msg.AddString("be:types", "application/octet-stream"); + msg.AddString("be:clip_name", "Bitmap"); + + DragMessage(&msg, Bounds()); +} + +void +ImageView::MouseMoved(BPoint point, uint32 state, const BMessage *pmsg) +{ + if (state == B_EXITED_VIEW) { + // If the cursor was dragged over, + // then off of this view, turn off + // drag/drop border highlighting and + // forget the last drag/drop BMessage + // from the tracker + fbdragFromTracker = false; + fpmsgFromTracker = NULL; + ReDraw(); + return; + } + + if (!pmsg || pmsg->what != B_SIMPLE_DATA) + // if there is no message (nothing being dragged) + // or the message contains uninteresting data, + // exit this function + return; + + if (pmsg != fpmsgFromTracker) { + fpmsgFromTracker = pmsg; + + entry_ref ref; + if (pmsg->FindRef("refs", 0, &ref) != B_OK) + return; + + BNode node(&ref); + if (node.InitCheck() != B_OK) + return; + BNodeInfo nodeinfo(&node); + if (nodeinfo.InitCheck() != B_OK) + return; + char mime[B_MIME_TYPE_LENGTH]; + if (nodeinfo.GetType(mime) != B_OK) + return; + + if (strstr(mime, "image/") != NULL) { + fbdragFromTracker = true; + ReDraw(); + } + } +} + +void +ImageView::MouseUp(BPoint point) +{ +} + +void +ImageView::MessageReceived(BMessage *pmsg) +{ + switch (pmsg->what) { + case B_COPY_TARGET: + SaveImageAtDropLocation(pmsg); + break; + + default: + BView::MessageReceived(pmsg); + break; + } +} + +void +ImageView::SaveImageAtDropLocation(BMessage *pmsg) +{ + // Find the location and name of the drop and + // write the image file there + + BBitmapStream stream(fpbitmap); + + StatusCheck chk; + // throw an exception if this is assigned + // anything other than B_OK + try { + entry_ref dirref; + chk = pmsg->FindRef("directory", &dirref); + const char *filename; + chk = pmsg->FindString("name", &filename); + + BDirectory dir(&dirref); + BFile file(&dir, filename, B_WRITE_ONLY | B_CREATE_FILE); + chk = file.InitCheck(); + + BTranslatorRoster *proster = BTranslatorRoster::Default(); + chk = proster->Translate(&stream, NULL, NULL, &file, B_TGA_FORMAT); + + } catch (StatusNotOKException) { + BAlert *palert = new BAlert(NULL, + "Sorry, unable to write the image file.", "OK"); + palert->Go(); + } + + stream.DetachBitmap(&fpbitmap); +} + +void +ImageView::AdjustScrollBars() +{ + BRect rctview = Bounds(), rctbitmap(0, 0, 0, 0); + if (HasImage()) + rctbitmap = fpbitmap->Bounds(); + + float prop, range; + BScrollBar *psb = ScrollBar(B_HORIZONTAL); + if (psb) { + range = rctbitmap.Width() - rctview.Width(); + if (range < 0) range = 0; + prop = rctview.Width() / rctbitmap.Width(); + if (prop > 1.0f) prop = 1.0f; + psb->SetRange(0, range); + psb->SetProportion(prop); + psb->SetSteps(10, 100); + } + psb = ScrollBar(B_VERTICAL); + if (psb) { + range = rctbitmap.Height() - rctview.Height(); + if (range < 0) range = 0; + prop = rctview.Height() / rctbitmap.Height(); + if (prop > 1.0f) prop = 1.0f; + psb->SetRange(0, range); + psb->SetProportion(prop); + psb->SetSteps(10, 100); + } +} + +void +ImageView::SetImage(BMessage *pmsg) +{ + // Replace current image with the image + // specified in the given BMessage + + fbdragFromTracker = false; + entry_ref ref; + if (pmsg->FindRef("refs", &ref) != B_OK) + return; + + BBitmap *pbitmap = BTranslationUtils::GetBitmap(&ref); + if (pbitmap) { + delete fpbitmap; + fpbitmap = pbitmap; + + // Set the name of the Window to reflect the file name + BWindow *pwin = Window(); + BEntry entry(&ref); + if (entry.InitCheck() == B_OK) { + BPath path(&entry); + if (path.InitCheck() == B_OK) + pwin->SetTitle(path.Leaf()); + else + pwin->SetTitle(IMAGEWINDOW_TITLE); + } else + pwin->SetTitle(IMAGEWINDOW_TITLE); + + // Resize parent window and set size limits to + // reflect the size of the new bitmap + float width, height; + BMenuBar *pbar = pwin->KeyMenuBar(); + width = fpbitmap->Bounds().Width() + B_V_SCROLL_BAR_WIDTH; + height = fpbitmap->Bounds().Height() + + pbar->Bounds().Height() + B_H_SCROLL_BAR_HEIGHT + 1; + + BScreen *pscreen = new BScreen(pwin); + BRect rctscreen = pscreen->Frame(); + if (width > rctscreen.Width()) + width = rctscreen.Width(); + if (height > rctscreen.Height()) + height = rctscreen.Height(); + pwin->SetSizeLimits(B_V_SCROLL_BAR_WIDTH * 4, width, + pbar->Bounds().Height() + (B_H_SCROLL_BAR_HEIGHT * 4) + 1, height); + pwin->SetZoomLimits(width, height); + + AdjustScrollBars(); + + pwin->Zoom(); + // Perform all of the hard work of resizing the + // window while taking into account the size of + // the screen, the tab and borders of the window + // + // HACK: Works well enough, but not exactly how I would like + + // repaint view + FillRect(Bounds()); + ReDraw(); + } else { + BAlert *palert = new BAlert(NULL, + "Sorry, unable to load the image.", "OK"); + palert->Go(); + } +} + diff --git a/src/tools/translation/inspector/ImageView.h b/src/tools/translation/inspector/ImageView.h new file mode 100644 index 0000000000..be3b1f88e4 --- /dev/null +++ b/src/tools/translation/inspector/ImageView.h @@ -0,0 +1,66 @@ +/*****************************************************************************/ +// ImageView +// Written by Michael Wilber, OBOS Translation Kit Team +// +// ImageView.h +// +// BView class for showing images. Images can be dropped on this view +// from the tracker and images viewed in this view can be dragged +// to the tracker to be saved. +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#ifndef IMAGEVIEW_H +#define IMAGEVIEW_H + +#include +#include +#include + +class ImageView : public BView { +public: + ImageView(BRect rect, const char *name); + ~ImageView(); + + void AttachedToWindow(); + void Draw(BRect rect); + void FrameResized(float width, float height); + void MouseDown(BPoint point); + void MouseMoved(BPoint point, uint32 state, const BMessage *pmsg); + void MouseUp(BPoint point); + void MessageReceived(BMessage *pmsg); + + void SetImage(BMessage *pmsg); + bool HasImage() { return fpbitmap ? true : false; }; + +private: + void ReDraw() { Draw(Bounds()); }; + void AdjustScrollBars(); + void SaveImageAtDropLocation(BMessage *pmsg); + + BBitmap *fpbitmap; + const BMessage *fpmsgFromTracker; + bool fbdragFromTracker; +}; + +#endif // #ifndef IMAGEVIEW_H diff --git a/src/tools/translation/inspector/ImageWindow.cpp b/src/tools/translation/inspector/ImageWindow.cpp new file mode 100644 index 0000000000..224c06f47c --- /dev/null +++ b/src/tools/translation/inspector/ImageWindow.cpp @@ -0,0 +1,122 @@ +/*****************************************************************************/ +// ImageWindow +// Written by Michael Wilber, OBOS Translation Kit Team +// +// ImageWindow.cpp +// +// BWindow class for displaying an image. Uses ImageView class for its +// view. +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + + +#include "ImageWindow.h" +#include "Constants.h" +#include +#include +#include +#include +#include +#include + +ImageWindow::ImageWindow(BRect rect, const char *name) + : BWindow(rect, name, B_DOCUMENT_WINDOW, 0) +{ + // Setup menu bar + BRect rctbar(0, 0, 100, 10); + BMenuBar *pbar = new BMenuBar(rctbar, "MenuBar"); + BMenu *pmnufile = new BMenu("File"); + + BMenuItem *pitmopen = new BMenuItem("Open...", new BMessage(M_OPEN_IMAGE), 'O', 0); + BMenuItem *pitmsave = new BMenuItem("Save...", new BMessage(M_SAVE_IMAGE), 'S', 0); + BMenuItem *pitmquit = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q', 0); + + pmnufile->AddItem(pitmopen); + pmnufile->AddItem(pitmsave); + pmnufile->AddSeparatorItem(); + pmnufile->AddItem(pitmquit); + pbar->AddItem(pmnufile); + AddChild(pbar); + + // Setup image view + BRect rctview = Bounds(); + rctview.top = pbar->Frame().bottom + 1; + rctview.right -= B_V_SCROLL_BAR_WIDTH; + rctview.bottom -= B_H_SCROLL_BAR_HEIGHT; + + fpimageView = new ImageView(rctview, "ImageView"); + AddChild(new BScrollView("ImageScroll", fpimageView, B_FOLLOW_ALL_SIDES, 0, true, true)); + + // Setup file open panel + fpopenPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL, 0, false, + new BMessage(M_OPEN_FILE_PANEL), NULL, false, true); + + SetSizeLimits(200, 10000, 150, 10000); +} + +ImageWindow::~ImageWindow() +{ + delete fpopenPanel; + fpopenPanel = NULL; +} + +void +ImageWindow::MessageReceived(BMessage *pmsg) +{ + switch (pmsg->what) { + case M_OPEN_IMAGE: + fpopenPanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE); + fpopenPanel->Show(); + break; + + case M_SAVE_IMAGE: + if (fpimageView->HasImage()) { + BAlert *palert = new BAlert(NULL, "Save feature not implemented yet.", "Bummer"); + palert->Go(); + } else { + BAlert *palert = new BAlert(NULL, "No image available to save.", "OK"); + palert->Go(); + } + break; + + case M_OPEN_FILE_PANEL: + case B_SIMPLE_DATA: + fpimageView->SetImage(pmsg); + break; + + case B_CANCEL: + break; + + default: + BWindow::MessageReceived(pmsg); + break; + } +} + +bool +ImageWindow::QuitRequested() +{ + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} + diff --git a/src/tools/translation/inspector/ImageWindow.h b/src/tools/translation/inspector/ImageWindow.h new file mode 100644 index 0000000000..131d8d6df8 --- /dev/null +++ b/src/tools/translation/inspector/ImageWindow.h @@ -0,0 +1,51 @@ +/*****************************************************************************/ +// ImageWindow +// Written by Michael Wilber, OBOS Translation Kit Team +// +// ImageWindow.h +// +// BWindow class for displaying an image. Uses ImageView class for its +// view. +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#ifndef IMAGEWINDOW_H +#define IMAGEWINDOW_H + +#include +#include +#include "ImageView.h" + +class ImageWindow : public BWindow { +public: + ImageWindow(BRect rec, const char *name); + ~ImageWindow(); + void MessageReceived(BMessage *pmsg); + bool QuitRequested(); + +private: + BFilePanel *fpopenPanel; + ImageView *fpimageView; +}; + +#endif // #ifndef IMAGEWINDOW_H diff --git a/src/tools/translation/inspector/Inspector.rsrc b/src/tools/translation/inspector/Inspector.rsrc new file mode 100644 index 0000000000000000000000000000000000000000..77f5f68d7e6552b288e7247f519b3c6f44f86482 GIT binary patch literal 3441 zcmeHKTS~)F5WPOo4;8xw7f}80Pw2yzK+_cCx24pA1!;>GaWO8zkFG>;0WQE*)N^KT zlAELzRO(j-ZgOYNnKP5gr6pI9F{To>_Hk=*9pLf{W3EB&=bmcZ?dYE26^!w1?B9=# zd4VwXUk{DpbI_L9$IkKyd-OwFf`6u4xo)#J7AW;~*yS9`Ih1FhJOkw!_}dxa-xz23 zujauv6(r`NsdWUw2of(y*hIyO1W}bRrRilAMAr!k!Rdmy1B-;)gw1y{Rw997V&Y^a z3OF;8BHFNL(?!hbTT!sHI2byBjkplNVIek<&sPOON!^6YD89p~`%_$tA0^C6^p33`%0rGN(cEDWTW~G_J8e*J|Lstd)*S zZ0VkB=3!lpk4VHc~Sq;4&`ZVmiq*h^VWKOl>rFP0S)SyA8zEXJ>o SleA#ucM_qun-6??81n`H(PfSR literal 0 HcmV?d00001 diff --git a/src/tools/translation/inspector/InspectorApp.cpp b/src/tools/translation/inspector/InspectorApp.cpp new file mode 100644 index 0000000000..16484ff1e1 --- /dev/null +++ b/src/tools/translation/inspector/InspectorApp.cpp @@ -0,0 +1,66 @@ +/*****************************************************************************/ +// InspectorApp +// Written by Michael Wilber, OBOS Translation Kit Team +// +// InspectorApp.cpp +// +// BApplication object for the Inspector application. The purpose of +// Inspector is to provide the user with as much relevant information as +// possible about the currently open document. +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#include "InspectorApp.h" +#include "Constants.h" +#include "ImageWindow.h" +#include + +InspectorApp::InspectorApp() + : BApplication(APP_SIG) +{ + // Show application window + BRect rect(100, 100, 500, 400); + ImageWindow *pwin = new ImageWindow(rect, IMAGEWINDOW_TITLE); + pwin->Show(); +} + +void +InspectorApp::RefsReceived(BMessage *pmsg) +{ + pmsg->what = M_OPEN_FILE_PANEL; + BWindow *pwin = WindowAt(0); + if (pwin) + pwin->PostMessage(pmsg); +} + +int main(int argc, char **argv) +{ + InspectorApp *papp = new InspectorApp(); + papp->Run(); + + delete papp; + papp = NULL; + + return 0; +} + diff --git a/src/tools/translation/inspector/InspectorApp.h b/src/tools/translation/inspector/InspectorApp.h new file mode 100644 index 0000000000..aeb263be5c --- /dev/null +++ b/src/tools/translation/inspector/InspectorApp.h @@ -0,0 +1,44 @@ +/*****************************************************************************/ +// InspectorApp +// Written by Michael Wilber, OBOS Translation Kit Team +// +// InspectorApp.h +// +// BApplication object for the Inspector application. The purpose of +// Inspector is to provide the user with as much relevant information as +// possible about the currently open document. +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#ifndef INSPECTORAPP_H +#define INSPECTORAPP_H + +#include + +class InspectorApp : public BApplication { +public: + InspectorApp(); + void RefsReceived(BMessage *pmsg); +}; + +#endif // #ifndef INSPECTORAPP_H diff --git a/src/tools/translation/inspector/Jamfile b/src/tools/translation/inspector/Jamfile new file mode 100644 index 0000000000..50b9bf09c9 --- /dev/null +++ b/src/tools/translation/inspector/Jamfile @@ -0,0 +1,12 @@ +SubDir OBOS_TOP src tools translation inspector ; + +AddResources Inspector : Inspector.rsrc ; + +App Inspector : + StatusCheck.cpp + ImageView.cpp + ImageWindow.cpp + InspectorApp.cpp ; + +LinkSharedOSLibs Inspector : be tracker translation ; + diff --git a/src/tools/translation/inspector/StatusCheck.cpp b/src/tools/translation/inspector/StatusCheck.cpp new file mode 100644 index 0000000000..9734a82420 --- /dev/null +++ b/src/tools/translation/inspector/StatusCheck.cpp @@ -0,0 +1,49 @@ +/*****************************************************************************/ +// StatusCheck +// Written by Michael Wilber, OBOS Translation Kit Team +// +// StatusCheck.cpp +// +// Class is used to throw exceptions when values other than B_OK are +// returned as statuses +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#include "StatusCheck.h" + +StatusCheck::StatusCheck() +{ +} + +// If the StatusCheck object is assigned +// a status_t value that is not B_OK, +// the StatusNotOKException is thrown. +// Otherwise, it does nothing +const StatusCheck & +StatusCheck::operator=(status_t ret) +{ + if (ret != B_OK) + throw StatusNotOKException(); + + return *this; +} diff --git a/src/tools/translation/inspector/StatusCheck.h b/src/tools/translation/inspector/StatusCheck.h new file mode 100644 index 0000000000..3cb345996f --- /dev/null +++ b/src/tools/translation/inspector/StatusCheck.h @@ -0,0 +1,49 @@ +/*****************************************************************************/ +// StatusCheck +// Written by Michael Wilber, OBOS Translation Kit Team +// +// StatusCheck.h +// +// Class is used to throw exceptions when values other than B_OK are +// returned as statuses +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#ifndef STATUSCHECK_H +#define STATUSCHECK_H + +#include + // for status_t + +class StatusNotOKException { +public: + StatusNotOKException() { }; +}; + +class StatusCheck { +public: + StatusCheck(); + const StatusCheck &operator=(status_t ret); +}; + +#endif // #ifndef STATUSCHECK_H