* Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35038 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -30,127 +30,70 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#include "TGAView.h"
|
#include "TGAView.h"
|
||||||
#include "TGATranslator.h"
|
#include "TGATranslator.h"
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// Constructor
|
|
||||||
//
|
|
||||||
// Sets up the view settings
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
TGAView::TGAView(const BRect &frame, const char *name,
|
|
||||||
uint32 resize, uint32 flags, TranslatorSettings *settings)
|
|
||||||
: BView(frame, name, resize, flags)
|
|
||||||
{
|
|
||||||
fSettings = settings;
|
|
||||||
|
|
||||||
|
TGAView::TGAView(const BRect& frame, const char* name, uint32 resize,
|
||||||
|
uint32 flags, TranslatorSettings* settings)
|
||||||
|
:
|
||||||
|
BView(frame, name, resize, flags),
|
||||||
|
fSettings(settings)
|
||||||
|
{
|
||||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
SetLowColor(ViewColor());
|
SetLowColor(ViewColor());
|
||||||
|
|
||||||
BMessage *pmsg;
|
|
||||||
int32 val;
|
|
||||||
|
|
||||||
pmsg = new BMessage(CHANGE_IGNORE_ALPHA);
|
|
||||||
fpchkIgnoreAlpha = new BCheckBox(BRect(10, 45, 180, 62),
|
fpchkIgnoreAlpha = new BCheckBox(BRect(10, 45, 180, 62),
|
||||||
"Ignore TGA alpha channel",
|
"Ignore TGA alpha channel", "Ignore TGA alpha channel",
|
||||||
"Ignore TGA alpha channel", pmsg);
|
new BMessage(CHANGE_IGNORE_ALPHA));
|
||||||
val = (fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA)) ? 1 : 0;
|
int32 val = (fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA)) ? 1 : 0;
|
||||||
fpchkIgnoreAlpha->SetValue(val);
|
fpchkIgnoreAlpha->SetValue(val);
|
||||||
fpchkIgnoreAlpha->SetViewColor(ViewColor());
|
fpchkIgnoreAlpha->SetViewColor(ViewColor());
|
||||||
AddChild(fpchkIgnoreAlpha);
|
AddChild(fpchkIgnoreAlpha);
|
||||||
|
|
||||||
pmsg = new BMessage(CHANGE_RLE);
|
|
||||||
fpchkRLE = new BCheckBox(BRect(10, 67, 180, 84),
|
fpchkRLE = new BCheckBox(BRect(10, 67, 180, 84),
|
||||||
"Save with RLE Compression",
|
"Save with RLE Compression", "Save with RLE Compression",
|
||||||
"Save with RLE Compression", pmsg);
|
new BMessage(CHANGE_RLE));
|
||||||
val = (fSettings->SetGetBool(TGA_SETTING_RLE)) ? 1 : 0;
|
val = (fSettings->SetGetBool(TGA_SETTING_RLE)) ? 1 : 0;
|
||||||
fpchkRLE->SetValue(val);
|
fpchkRLE->SetValue(val);
|
||||||
fpchkRLE->SetViewColor(ViewColor());
|
fpchkRLE->SetViewColor(ViewColor());
|
||||||
AddChild(fpchkRLE);
|
AddChild(fpchkRLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// Destructor
|
|
||||||
//
|
|
||||||
// Releases the translator settings
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
TGAView::~TGAView()
|
TGAView::~TGAView()
|
||||||
{
|
{
|
||||||
fSettings->Release();
|
fSettings->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// AllAttached
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
//
|
|
||||||
// Parameters:
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
void
|
void
|
||||||
TGAView::AllAttached()
|
TGAView::AllAttached()
|
||||||
{
|
{
|
||||||
BMessenger msgr(this);
|
fpchkIgnoreAlpha->SetTarget(this);
|
||||||
fpchkIgnoreAlpha->SetTarget(msgr);
|
fpchkRLE->SetTarget(this);
|
||||||
fpchkRLE->SetTarget(msgr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// MessageReceived
|
|
||||||
//
|
|
||||||
// Handles state changes of the RLE setting checkbox
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
//
|
|
||||||
// Parameters: message the actual BMessage that was received
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
void
|
void
|
||||||
TGAView::MessageReceived(BMessage *message)
|
TGAView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
bool bnewval;
|
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case CHANGE_IGNORE_ALPHA:
|
case CHANGE_IGNORE_ALPHA:
|
||||||
if (fpchkIgnoreAlpha->Value())
|
{
|
||||||
bnewval = true;
|
bool ignoreAlpha = fpchkIgnoreAlpha->Value() == B_CONTROL_ON;
|
||||||
else
|
fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA, &ignoreAlpha);
|
||||||
bnewval = false;
|
|
||||||
fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA, &bnewval);
|
|
||||||
fSettings->SaveSettings();
|
fSettings->SaveSettings();
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
case CHANGE_RLE:
|
case CHANGE_RLE:
|
||||||
if (fpchkRLE->Value())
|
{
|
||||||
bnewval = true;
|
bool saveWithRLE = fpchkRLE->Value() == B_CONTROL_ON;
|
||||||
else
|
fSettings->SetGetBool(TGA_SETTING_RLE, &saveWithRLE);
|
||||||
bnewval = false;
|
|
||||||
fSettings->SetGetBool(TGA_SETTING_RLE, &bnewval);
|
|
||||||
fSettings->SaveSettings();
|
fSettings->SaveSettings();
|
||||||
break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
@@ -158,19 +101,7 @@ TGAView::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// Draw
|
|
||||||
//
|
|
||||||
// Draws information about the TGATranslator to this view.
|
|
||||||
//
|
|
||||||
// Preconditions:
|
|
||||||
//
|
|
||||||
// Parameters: area, not used
|
|
||||||
//
|
|
||||||
// Postconditions:
|
|
||||||
//
|
|
||||||
// Returns:
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
void
|
void
|
||||||
TGAView::Draw(BRect area)
|
TGAView::Draw(BRect area)
|
||||||
{
|
{
|
||||||
@@ -181,8 +112,7 @@ TGAView::Draw(BRect area)
|
|||||||
xbold = fh.descent + 1;
|
xbold = fh.descent + 1;
|
||||||
ybold = fh.ascent + fh.descent * 2 + fh.leading;
|
ybold = fh.ascent + fh.descent * 2 + fh.leading;
|
||||||
|
|
||||||
char title[] = "TGA Image Translator";
|
DrawString("TGA Image Translator", BPoint(xbold, ybold));
|
||||||
DrawString(title, BPoint(xbold, ybold));
|
|
||||||
|
|
||||||
SetFont(be_plain_font);
|
SetFont(be_plain_font);
|
||||||
font_height plainh;
|
font_height plainh;
|
||||||
@@ -197,9 +127,7 @@ TGAView::Draw(BRect area)
|
|||||||
static_cast<int>(B_TRANSLATION_REVISION_VERSION(TGA_TRANSLATOR_VERSION)),
|
static_cast<int>(B_TRANSLATION_REVISION_VERSION(TGA_TRANSLATOR_VERSION)),
|
||||||
__DATE__);
|
__DATE__);
|
||||||
DrawString(detail, BPoint(xbold, yplain + ybold));
|
DrawString(detail, BPoint(xbold, yplain + ybold));
|
||||||
/* char copyright[] = "© 2002 Haiku Project";
|
|
||||||
DrawString(copyright, BPoint(xbold, yplain * 2 + ybold));
|
DrawString("Written by the Haiku Translation Kit Team",
|
||||||
*/
|
BPoint(xbold, yplain * 7 + ybold));
|
||||||
char writtenby[] = "Written by the Haiku Translation Kit Team";
|
|
||||||
DrawString(writtenby, BPoint(xbold, yplain * 7 + ybold));
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user