TIFFTranslator: Style fixes to TIFFView
This commit is contained in:
@@ -30,6 +30,9 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "TIFFView.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -46,7 +49,6 @@
|
|||||||
#include "TIFFTranslator.h"
|
#include "TIFFTranslator.h"
|
||||||
#include "TranslatorSettings.h"
|
#include "TranslatorSettings.h"
|
||||||
|
|
||||||
#include "TIFFView.h"
|
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
#define B_TRANSLATION_CONTEXT "TIFFView"
|
#define B_TRANSLATION_CONTEXT "TIFFView"
|
||||||
@@ -66,22 +68,11 @@ add_menu_item(BMenu* menu,
|
|||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// Constructor
|
TIFFView::TIFFView(const char* name, uint32 flags,
|
||||||
//
|
TranslatorSettings* settings)
|
||||||
// Sets up the view settings
|
:
|
||||||
//
|
BView(name, flags)
|
||||||
// Preconditions:
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
TIFFView::TIFFView(const char *name, uint32 flags,
|
|
||||||
TranslatorSettings *settings)
|
|
||||||
: BView(name, flags)
|
|
||||||
{
|
{
|
||||||
fSettings = settings;
|
fSettings = settings;
|
||||||
|
|
||||||
@@ -102,12 +93,12 @@ TIFFView::TIFFView(const char *name, uint32 flags,
|
|||||||
int16 i = 1;
|
int16 i = 1;
|
||||||
fLibTIFF[0] = new BStringView(NULL, B_TRANSLATE("TIFF Library:"));
|
fLibTIFF[0] = new BStringView(NULL, B_TRANSLATE("TIFF Library:"));
|
||||||
char libtiff[] = TIFFLIB_VERSION_STR;
|
char libtiff[] = TIFFLIB_VERSION_STR;
|
||||||
char *tok = strtok(libtiff, "\n");
|
char* tok = strtok(libtiff, "\n");
|
||||||
while (i < 5 && tok) {
|
while (i < 5 && tok) {
|
||||||
fLibTIFF[i] = new BStringView(NULL, tok);
|
fLibTIFF[i] = new BStringView(NULL, tok);
|
||||||
tok = strtok(NULL, "\n");
|
tok = strtok(NULL, "\n");
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
BPopUpMenu* menu = new BPopUpMenu("pick compression");
|
BPopUpMenu* menu = new BPopUpMenu("pick compression");
|
||||||
|
|
||||||
@@ -123,66 +114,54 @@ TIFFView::TIFFView(const char *name, uint32 flags,
|
|||||||
add_menu_item(menu, COMPRESSION_LZW, B_TRANSLATE("LZW"),
|
add_menu_item(menu, COMPRESSION_LZW, B_TRANSLATE("LZW"),
|
||||||
currentCompression);
|
currentCompression);
|
||||||
|
|
||||||
// TODO: the disabled compression modes are not configured in libTIFF
|
// TODO: the disabled compression modes are not configured in libTIFF
|
||||||
// menu->AddSeparatorItem();
|
// menu->AddSeparatorItem();
|
||||||
// add_menu_item(menu, COMPRESSION_JPEG, "JPEG", currentCompression);
|
// add_menu_item(menu, COMPRESSION_JPEG, "JPEG", currentCompression);
|
||||||
// TODO ? - strip encoding is not implemented in libTIFF for this compression
|
// TODO ? - strip encoding is not implemented in libTIFF for this compression
|
||||||
// add_menu_item(menu, COMPRESSION_JP2000, "JPEG2000", currentCompression);
|
// add_menu_item(menu, COMPRESSION_JP2000, "JPEG2000", currentCompression);
|
||||||
|
|
||||||
fCompressionMF = new BMenuField(B_TRANSLATE("Use Compression:"), menu);
|
fCompressionMF = new BMenuField(B_TRANSLATE("Use Compression:"), menu);
|
||||||
|
|
||||||
// Build the layout
|
// Build the layout
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 7)
|
BLayoutBuilder::Group<>(this, B_VERTICAL, 7)
|
||||||
.SetInsets(5)
|
.SetInsets(5)
|
||||||
.Add(fTitle)
|
.Add(fTitle)
|
||||||
.Add(fDetail)
|
.Add(fDetail)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(fCompressionMF)
|
.Add(fCompressionMF)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(fLibTIFF[0])
|
.Add(fLibTIFF[0])
|
||||||
.Add(fLibTIFF[1])
|
.Add(fLibTIFF[1])
|
||||||
.Add(fLibTIFF[2])
|
.Add(fLibTIFF[2])
|
||||||
.Add(fLibTIFF[3])
|
.Add(fLibTIFF[3])
|
||||||
// Theses 4 adding above work because we know there are 4 strings
|
// Theses 4 adding above work because we know there are 4 strings
|
||||||
// but it's fragile: one string less in the library version and the application breaks
|
// but it's fragile: one string less in the library version and the
|
||||||
|
// application breaks
|
||||||
.AddGlue();
|
.AddGlue();
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
SetExplicitPreferredSize(BSize((font.Size() * 350)/12, (font.Size() * 200)/12));
|
SetExplicitPreferredSize(
|
||||||
|
BSize((font.Size() * 350)/12, (font.Size() * 200)/12));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// Destructor
|
|
||||||
//
|
|
||||||
// Does nothing
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
TIFFView::~TIFFView()
|
TIFFView::~TIFFView()
|
||||||
{
|
{
|
||||||
fSettings->Release();
|
fSettings->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// MessageReceived
|
void
|
||||||
//
|
TIFFView::AllAttached()
|
||||||
// Handles state changes of the Compression menu field
|
{
|
||||||
//
|
fCompressionMF->Menu()->SetTargetForItems(this);
|
||||||
// Preconditions:
|
fCompressionMF->SetDivider(
|
||||||
//
|
fCompressionMF->StringWidth(fCompressionMF->Label()) + 3);
|
||||||
// Parameters: area, not used
|
fCompressionMF->ResizeToPreferred();
|
||||||
//
|
}
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
void
|
void
|
||||||
TIFFView::MessageReceived(BMessage* message)
|
TIFFView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -199,26 +178,3 @@ TIFFView::MessageReceived(BMessage* message)
|
|||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// AllAttached
|
|
||||||
//
|
|
||||||
// sets the target for the controls controlling the configuration
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
//
|
|
||||||
// Parameters: area, not used
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
void
|
|
||||||
TIFFView::AllAttached()
|
|
||||||
{
|
|
||||||
fCompressionMF->Menu()->SetTargetForItems(this);
|
|
||||||
fCompressionMF->SetDivider(fCompressionMF->StringWidth(fCompressionMF->Label()) + 3);
|
|
||||||
fCompressionMF->ResizeToPreferred();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,39 +28,40 @@
|
|||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#ifndef TIFFVIEW_H
|
#ifndef TIFFVIEW_H
|
||||||
#define TIFFVIEW_H
|
#define TIFFVIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include "TranslatorSettings.h"
|
#include "TranslatorSettings.h"
|
||||||
|
|
||||||
|
|
||||||
class TIFFView : public BView {
|
class TIFFView : public BView {
|
||||||
public:
|
public:
|
||||||
TIFFView(const char *name, uint32 flags, TranslatorSettings *settings);
|
TIFFView(const char* name, uint32 flags, TranslatorSettings* settings);
|
||||||
// sets up the view
|
// sets up the view
|
||||||
|
|
||||||
~TIFFView();
|
~TIFFView();
|
||||||
// releases the TIFFTranslator settings
|
// releases the TIFFTranslator settings
|
||||||
|
|
||||||
virtual void AllAttached();
|
virtual void AllAttached();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_COMPRESSION_CHANGED = 'cmch',
|
MSG_COMPRESSION_CHANGED = 'cmch',
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BStringView* fTitle;
|
BStringView* fTitle;
|
||||||
BStringView* fDetail;
|
BStringView* fDetail;
|
||||||
BStringView* fLibTIFF[5];
|
BStringView* fLibTIFF[5];
|
||||||
BMenuField* fCompressionMF;
|
BMenuField* fCompressionMF;
|
||||||
|
|
||||||
TranslatorSettings *fSettings;
|
TranslatorSettings* fSettings;
|
||||||
// the actual settings for the translator,
|
// the actual settings for the translator, shared with the translator
|
||||||
// shared with the translator
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // #ifndef TIFFVIEW_H
|
#endif // #ifndef TIFFVIEW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user