initial checkin for STXTTranslator (StyledEdit files). does nothing yet, but should compile
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2255 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8efc7be48e
commit
be4c146060
103
src/add-ons/translators/stxttranslator/STXTMain.cpp
Normal file
103
src/add-ons/translators/stxttranslator/STXTMain.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
/*****************************************************************************/
|
||||
// STXTTranslator
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// Version: 1.0.0 Beta
|
||||
//
|
||||
// This translator opens and writes StyledEdit (STXT) files.
|
||||
//
|
||||
//
|
||||
// This application and all source files used in its construction, except
|
||||
// where noted, are licensed under the MIT License, and have been written
|
||||
// and are:
|
||||
//
|
||||
// Copyright (c) 2002 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 <Application.h>
|
||||
#include <Screen.h>
|
||||
#include <Alert.h>
|
||||
#include "STXTTranslator.h"
|
||||
#include "STXTWindow.h"
|
||||
#include "STXTView.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// main
|
||||
//
|
||||
// Creates a BWindow for displaying info about the STXTTranslator
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
int
|
||||
main()
|
||||
{
|
||||
BApplication app("application/x-vnd.obos-bmp-translator");
|
||||
STXTTranslator *ptranslator = new STXTTranslator;
|
||||
BView *view = NULL;
|
||||
BRect rect(0, 0, 225, 175);
|
||||
if (ptranslator->MakeConfigurationView(NULL, &view, &rect)) {
|
||||
BAlert *err = new BAlert("Error",
|
||||
"Unable to create the STXTTranslator view.", "OK");
|
||||
err->Go();
|
||||
return 1;
|
||||
}
|
||||
// release the translator even though I never really used it anyway
|
||||
ptranslator->Release();
|
||||
ptranslator = NULL;
|
||||
|
||||
STXTWindow *wnd = new STXTWindow(rect);
|
||||
view->ResizeTo(rect.Width(), rect.Height());
|
||||
wnd->AddChild(view);
|
||||
BPoint wndpt = B_ORIGIN;
|
||||
{
|
||||
BScreen scrn;
|
||||
BRect frame = scrn.Frame();
|
||||
frame.InsetBy(10, 23);
|
||||
// if the point is outside of the screen frame,
|
||||
// use the mouse location to find a better point
|
||||
if (!frame.Contains(wndpt)) {
|
||||
uint32 dummy;
|
||||
view->GetMouse(&wndpt, &dummy, false);
|
||||
wndpt.x -= rect.Width() / 2;
|
||||
wndpt.y -= rect.Height() / 2;
|
||||
// clamp location to screen
|
||||
if (wndpt.x < frame.left)
|
||||
wndpt.x = frame.left;
|
||||
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;
|
||||
}
|
||||
}
|
||||
wnd->MoveTo(wndpt);
|
||||
wnd->Show();
|
||||
app.Run();
|
||||
|
||||
return 0;
|
||||
}
|
386
src/add-ons/translators/stxttranslator/STXTTranslator.cpp
Normal file
386
src/add-ons/translators/stxttranslator/STXTTranslator.cpp
Normal file
@ -0,0 +1,386 @@
|
||||
/*****************************************************************************/
|
||||
// STXTTranslator
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// STXTTranslator.cpp
|
||||
//
|
||||
// This BTranslator based object is for opening and writing
|
||||
// StyledEdit (STXT) files.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 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 <string.h>
|
||||
#include <stdio.h>
|
||||
#include "STXTTranslator.h"
|
||||
#include "STXTView.h"
|
||||
|
||||
#define min(x,y) ((x < y) ? x : y)
|
||||
#define max(x,y) ((x > y) ? x : y)
|
||||
|
||||
// The input formats that this translator supports.
|
||||
translation_format gInputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_TEXT,
|
||||
B_TRANSLATOR_TEXT,
|
||||
TEXT_IN_QUALITY,
|
||||
TEXT_IN_CAPABILITY,
|
||||
"text/plain",
|
||||
"Plain text file"
|
||||
},
|
||||
{
|
||||
B_STYLED_TEXT_FORMAT,
|
||||
B_TRANSLATOR_TEXT,
|
||||
STXT_IN_QUALITY,
|
||||
STXT_IN_CAPABILITY,
|
||||
"text/x-vnd.Be-stxt",
|
||||
"Be styled text file"
|
||||
}
|
||||
};
|
||||
|
||||
// The output formats that this translator supports.
|
||||
translation_format gOutputFormats[] = {
|
||||
{
|
||||
B_TRANSLATOR_BITMAP,
|
||||
B_TRANSLATOR_TEXT,
|
||||
TEXT_OUT_QUALITY,
|
||||
TEXT_OUT_CAPABILITY,
|
||||
"text/plain",
|
||||
"Plain text file"
|
||||
},
|
||||
{
|
||||
B_STYLED_TEXT_FORMAT,
|
||||
B_TRANSLATOR_TEXT,
|
||||
STXT_OUT_QUALITY,
|
||||
STXT_OUT_CAPABILITY,
|
||||
"text/x-vnd.Be-stxt",
|
||||
"Be styled text file"
|
||||
}
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// make_nth_translator
|
||||
//
|
||||
// Creates a STXTTranslator object to be used by BTranslatorRoster
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: n, The translator to return. Since
|
||||
// STXTTranslator only publishes one
|
||||
// translator, it only returns a
|
||||
// STXTTranslator if n == 0
|
||||
//
|
||||
// you, The image_id of the add-on that
|
||||
// contains code (not used).
|
||||
//
|
||||
// flags, Has no meaning yet, should be 0.
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: NULL if n is not zero,
|
||||
// a new STXTTranslator if n is zero
|
||||
// ---------------------------------------------------------------
|
||||
BTranslator *
|
||||
make_nth_translator(int32 n, image_id you, uint32 flags, ...)
|
||||
{
|
||||
if (!n)
|
||||
return new STXTTranslator();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Sets up the version info and the name of the translator so that
|
||||
// these values can be returned when they are requested.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
STXTTranslator::STXTTranslator()
|
||||
: BTranslator()
|
||||
{
|
||||
strcpy(fName, "StyledEdit Files");
|
||||
sprintf(fInfo, "StyledEdit file translator v%d.%d.%d %s",
|
||||
STXT_TRANSLATOR_VERSION / 100, (STXT_TRANSLATOR_VERSION / 10) % 10,
|
||||
STXT_TRANSLATOR_VERSION % 10, __DATE__);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Does nothing
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
STXTTranslator::~STXTTranslator()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// TranslatorName
|
||||
//
|
||||
// Returns the short name of the translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: a const char * to the short name of the translator
|
||||
// ---------------------------------------------------------------
|
||||
const char *
|
||||
STXTTranslator::TranslatorName() const
|
||||
{
|
||||
return fName;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// TranslatorInfo
|
||||
//
|
||||
// Returns a more verbose name for the translator than the one
|
||||
// TranslatorName() returns. This usually includes version info.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: a const char * to the verbose name of the translator
|
||||
// ---------------------------------------------------------------
|
||||
const char *
|
||||
STXTTranslator::TranslatorInfo() const
|
||||
{
|
||||
return fInfo;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// TranslatorVersion
|
||||
//
|
||||
// Returns the integer representation of the current version of
|
||||
// this translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
int32
|
||||
STXTTranslator::TranslatorVersion() const
|
||||
{
|
||||
return STXT_TRANSLATOR_VERSION;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// InputFormats
|
||||
//
|
||||
// Returns a list of input formats supported by this translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: out_count, The number of input formats
|
||||
// support is returned here.
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: the list of input formats and the number of input
|
||||
// formats through the out_count parameter
|
||||
// ---------------------------------------------------------------
|
||||
const translation_format *
|
||||
STXTTranslator::InputFormats(int32 *out_count) const
|
||||
{
|
||||
if (out_count)
|
||||
*out_count = 2;
|
||||
|
||||
return gInputFormats;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// OutputFormats
|
||||
//
|
||||
// Returns a list of output formats supported by this translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: out_count, The number of output formats
|
||||
// support is returned here.
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: the list of output formats and the number of output
|
||||
// formats through the out_count parameter
|
||||
// ---------------------------------------------------------------
|
||||
const translation_format *
|
||||
STXTTranslator::OutputFormats(int32 *out_count) const
|
||||
{
|
||||
if (out_count)
|
||||
*out_count = 2;
|
||||
|
||||
return gOutputFormats;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Identify
|
||||
//
|
||||
// Examines the data from inSource and determines if it is in a
|
||||
// format that this translator knows how to work with.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: inSource, where the data to examine is
|
||||
//
|
||||
// inFormat, a hint about the data in inSource,
|
||||
// it is ignored since it is only a hint
|
||||
//
|
||||
// ioExtension, configuration settings for the
|
||||
// translator
|
||||
//
|
||||
// outInfo, information about what data is in
|
||||
// inSource and how well this translator
|
||||
// can handle that data is stored here
|
||||
//
|
||||
// outType, The format that the user wants
|
||||
// the data in inSource to be
|
||||
// converted to
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: B_NO_TRANSLATOR, if this translator can't handle
|
||||
// the data in inSource
|
||||
//
|
||||
// B_ERROR, if there was an error converting the data to the host
|
||||
// format
|
||||
//
|
||||
// B_BAD_VALUE, if the settings in ioExtension are bad
|
||||
//
|
||||
// B_OK, if this translator understand the data and there were
|
||||
// no errors found
|
||||
// ---------------------------------------------------------------
|
||||
status_t
|
||||
STXTTranslator::Identify(BPositionIO *inSource,
|
||||
const translation_format *inFormat, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 outType)
|
||||
{
|
||||
if (!outType)
|
||||
outType = B_TRANSLATOR_TEXT;
|
||||
if (outType != B_TRANSLATOR_TEXT && outType != B_STYLED_TEXT_FORMAT)
|
||||
return B_NO_TRANSLATOR;
|
||||
|
||||
return B_NO_TRANSLATOR;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Translate
|
||||
//
|
||||
// Translates the data in inSource to the type outType and stores
|
||||
// the translated data in outDestination.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: inSource, the data to be translated
|
||||
//
|
||||
// inInfo, hint about the data in inSource (not used)
|
||||
//
|
||||
// ioExtension, configuration options for the
|
||||
// translator
|
||||
//
|
||||
// outType, the type to convert inSource to
|
||||
//
|
||||
// outDestination, where the translated data is
|
||||
// put
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns: B_BAD_VALUE, if the options in ioExtension are bad
|
||||
//
|
||||
// B_NO_TRANSLATOR, if this translator doesn't understand the data
|
||||
//
|
||||
// B_ERROR, if there was an error allocating memory or converting
|
||||
// data
|
||||
//
|
||||
// B_OK, if all went well
|
||||
// ---------------------------------------------------------------
|
||||
status_t
|
||||
STXTTranslator::Translate(BPositionIO *inSource,
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
uint32 outType, BPositionIO *outDestination)
|
||||
{
|
||||
if (!outType)
|
||||
outType = B_TRANSLATOR_TEXT;
|
||||
if (outType != B_TRANSLATOR_TEXT && outType != B_STYLED_TEXT_FORMAT)
|
||||
return B_NO_TRANSLATOR;
|
||||
|
||||
return B_NO_TRANSLATOR;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// MakeConfigurationView
|
||||
//
|
||||
// Makes a BView object for configuring / displaying info about
|
||||
// this translator.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: ioExtension, configuration options for the
|
||||
// translator
|
||||
//
|
||||
// outView, the view to configure the
|
||||
// translator is stored here
|
||||
//
|
||||
// outExtent, the bounds of the view are
|
||||
// stored here
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
status_t
|
||||
STXTTranslator::MakeConfigurationView(BMessage *ioExtension, BView **outView,
|
||||
BRect *outExtent)
|
||||
{
|
||||
if (!outView || !outExtent)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
STXTView *view = new STXTView(BRect(0, 0, 225, 175),
|
||||
"STXTTranslator Settings", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
*outView = view;
|
||||
*outExtent = view->Bounds();
|
||||
|
||||
return B_OK;
|
||||
}
|
114
src/add-ons/translators/stxttranslator/STXTTranslator.h
Normal file
114
src/add-ons/translators/stxttranslator/STXTTranslator.h
Normal file
@ -0,0 +1,114 @@
|
||||
/*****************************************************************************/
|
||||
// STXTTranslator
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// STXTTranslator.h
|
||||
//
|
||||
// This BTranslator based object is for opening and writing
|
||||
// StyledEdit (STXT) files.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 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 STXT_TRANSLATOR_H
|
||||
#define STXT_TRANSLATOR_H
|
||||
|
||||
#include <Translator.h>
|
||||
#include <TranslatorFormats.h>
|
||||
#include <TranslationDefs.h>
|
||||
#include <GraphicsDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <DataIO.h>
|
||||
#include <ByteOrder.h>
|
||||
|
||||
#define STXT_TRANSLATOR_VERSION 100
|
||||
#define STXT_IN_QUALITY 0.5
|
||||
// high in quality becuase this code supports all STXT features
|
||||
#define STXT_IN_CAPABILITY 0.5
|
||||
// high in capability because this code opens basically all STXTs
|
||||
#define STXT_OUT_QUALITY 0.5
|
||||
// high out quality because this code outputs fully standard STXTs
|
||||
#define STXT_OUT_CAPABILITY 0.5
|
||||
// medium out capability because RLE compression is not an option
|
||||
|
||||
#define TEXT_IN_QUALITY 0.4
|
||||
// medium in quality because only most common features are supported
|
||||
#define TEXT_IN_CAPABILITY 0.6
|
||||
// high in capability because most variations are supported
|
||||
#define TEXT_OUT_QUALITY 0.4
|
||||
// medium out quality because only most common features are supported
|
||||
#define TEXT_OUT_CAPABILITY 0.6
|
||||
// high out capability because most variations are supported
|
||||
|
||||
class STXTTranslator : public BTranslator {
|
||||
public:
|
||||
STXTTranslator();
|
||||
|
||||
virtual const char *TranslatorName() const;
|
||||
// returns the short name of the translator
|
||||
|
||||
virtual const char *TranslatorInfo() const;
|
||||
// returns a verbose name/description for the translator
|
||||
|
||||
virtual int32 TranslatorVersion() const;
|
||||
// returns the version of the translator
|
||||
|
||||
virtual const translation_format *InputFormats(int32 *out_count)
|
||||
const;
|
||||
// returns the input formats and the count of input formats
|
||||
// that this translator supports
|
||||
|
||||
virtual const translation_format *OutputFormats(int32 *out_count)
|
||||
const;
|
||||
// returns the output formats and the count of output formats
|
||||
// that this translator supports
|
||||
|
||||
virtual status_t Identify(BPositionIO *inSource,
|
||||
const translation_format *inFormat, BMessage *ioExtension,
|
||||
translator_info *outInfo, uint32 outType);
|
||||
// determines whether or not this translator can convert the
|
||||
// data in inSource to the type outType
|
||||
|
||||
virtual status_t Translate(BPositionIO *inSource,
|
||||
const translator_info *inInfo, BMessage *ioExtension,
|
||||
uint32 outType, BPositionIO *outDestination);
|
||||
// this function is the whole point of the Translation Kit,
|
||||
// it translates the data in inSource to outDestination
|
||||
// using the format outType
|
||||
|
||||
virtual status_t MakeConfigurationView(BMessage *ioExtension,
|
||||
BView **outView, BRect *outExtent);
|
||||
// creates and returns the view for displaying information
|
||||
// about this translator
|
||||
|
||||
protected:
|
||||
virtual ~STXTTranslator();
|
||||
// this is protected because the object is deleted by the
|
||||
// Release() function instead of being deleted directly by
|
||||
// the user
|
||||
|
||||
private:
|
||||
char fName[30];
|
||||
char fInfo[100];
|
||||
};
|
||||
|
||||
#endif // #ifndef STXT_TRANSLATOR_H
|
115
src/add-ons/translators/stxttranslator/STXTView.cpp
Normal file
115
src/add-ons/translators/stxttranslator/STXTView.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
/*****************************************************************************/
|
||||
// STXTView
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// STXTView.cpp
|
||||
//
|
||||
// This BView based object displays information about the STXTTranslator.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include "STXTView.h"
|
||||
#include "STXTTranslator.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Sets up the view settings
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
STXTView::STXTView(const BRect &frame, const char *name,
|
||||
uint32 resize, uint32 flags)
|
||||
: BView(frame, name, resize, flags)
|
||||
{
|
||||
SetViewColor(220,220,220,0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Does nothing
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
STXTView::~STXTView()
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Draw
|
||||
//
|
||||
// Draws information about the STXTTranslator to this view.
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: area, not used
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
void
|
||||
STXTView::Draw(BRect area)
|
||||
{
|
||||
SetFont(be_bold_font);
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
float xbold, ybold;
|
||||
xbold = fh.descent + 1;
|
||||
ybold = fh.ascent + fh.descent * 2 + fh.leading;
|
||||
|
||||
char title[] = "OpenBeOS StyledEdit Files Translator";
|
||||
DrawString(title, BPoint(xbold, ybold));
|
||||
|
||||
SetFont(be_plain_font);
|
||||
font_height plainh;
|
||||
GetFontHeight(&plainh);
|
||||
float yplain;
|
||||
yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;
|
||||
|
||||
char detail[100];
|
||||
sprintf(detail, "Version %d.%d.%d %s",
|
||||
STXT_TRANSLATOR_VERSION / 100, (STXT_TRANSLATOR_VERSION / 10) % 10,
|
||||
STXT_TRANSLATOR_VERSION % 10, __DATE__);
|
||||
DrawString(detail, BPoint(xbold, yplain + ybold));
|
||||
/* char copyright[] = "© 2002 OpenBeOS Project";
|
||||
DrawString(copyright, BPoint(xbold, yplain * 2 + ybold));
|
||||
*/
|
||||
char writtenby[] = "Written by the OBOS Translation Kit Team";
|
||||
DrawString(writtenby, BPoint(xbold, yplain * 7 + ybold));
|
||||
}
|
51
src/add-ons/translators/stxttranslator/STXTView.h
Normal file
51
src/add-ons/translators/stxttranslator/STXTView.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*****************************************************************************/
|
||||
// STXTView
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// STXTView.h
|
||||
//
|
||||
// This BView based object displays information about the STXTTranslator.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 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 STXTVIEW_H
|
||||
#define STXTVIEW_H
|
||||
|
||||
#include <View.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
|
||||
class STXTView : public BView {
|
||||
public:
|
||||
STXTView(const BRect &frame, const char *name, uint32 resize,
|
||||
uint32 flags);
|
||||
// sets up the view
|
||||
|
||||
~STXTView();
|
||||
// does nothing
|
||||
|
||||
virtual void Draw(BRect area);
|
||||
// draws information about the STXTTranslator
|
||||
};
|
||||
|
||||
#endif // #ifndef STXTVIEW_H
|
69
src/add-ons/translators/stxttranslator/STXTWindow.cpp
Normal file
69
src/add-ons/translators/stxttranslator/STXTWindow.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*****************************************************************************/
|
||||
// STXTWindow
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// STXTWindow.cpp
|
||||
//
|
||||
// This BWindow based object is used to hold the STXTView object when the
|
||||
// user runs the STXTTranslator as an application.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 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 "STXTWindow.h"
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Constructor
|
||||
//
|
||||
// Sets up the BWindow for holding a STXTView
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters: area, The bounds of the window
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
STXTWindow::STXTWindow(BRect area)
|
||||
: BWindow(area, "STXTTranslator", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
|
||||
{
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Destructor
|
||||
//
|
||||
// Posts a quit message so that the application is close properly
|
||||
//
|
||||
// Preconditions:
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// Postconditions:
|
||||
//
|
||||
// Returns:
|
||||
// ---------------------------------------------------------------
|
||||
STXTWindow::~STXTWindow()
|
||||
{
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
48
src/add-ons/translators/stxttranslator/STXTWindow.h
Normal file
48
src/add-ons/translators/stxttranslator/STXTWindow.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*****************************************************************************/
|
||||
// STXTWindow
|
||||
// Written by Michael Wilber, OBOS Translation Kit Team
|
||||
//
|
||||
// STXTWindow.h
|
||||
//
|
||||
// This BWindow based object is used to hold the STXTView object when the
|
||||
// user runs the STXTTranslator as an application.
|
||||
//
|
||||
//
|
||||
// Copyright (c) 2002 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 STXTWINDOW_H
|
||||
#define STXTWINDOW_H
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
|
||||
class STXTWindow : public BWindow {
|
||||
public:
|
||||
STXTWindow(BRect area);
|
||||
// Sets up a BWindow with bounds area
|
||||
|
||||
~STXTWindow();
|
||||
// Posts a quit message so that the application closes properly
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user