* automatic whitespace cleanup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27425 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
* This file may be used under the terms of the Be Sample Code License.
|
* This file may be used under the terms of the Be Sample Code License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Magnify.h"
|
#include "Magnify.h"
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
@@ -91,13 +90,13 @@ const int32 kBorderSize = 10;
|
|||||||
static float
|
static float
|
||||||
FontHeight(BView* target, bool full)
|
FontHeight(BView* target, bool full)
|
||||||
{
|
{
|
||||||
font_height finfo;
|
font_height finfo;
|
||||||
target->GetFontHeight(&finfo);
|
target->GetFontHeight(&finfo);
|
||||||
float h = ceil(finfo.ascent) + ceil(finfo.descent);
|
float h = ceil(finfo.ascent) + ceil(finfo.descent);
|
||||||
|
|
||||||
if (full)
|
if (full)
|
||||||
h += ceil(finfo.leading);
|
h += ceil(finfo.leading);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +166,7 @@ BuildInfoMenu(BMenu *menu)
|
|||||||
menuItem = new BMenuItem("Freeze/Unfreeze image", new BMessage(msg_freeze),'F');
|
menuItem = new BMenuItem("Freeze/Unfreeze image", new BMessage(msg_freeze),'F');
|
||||||
menu->AddItem(menuItem);
|
menu->AddItem(menuItem);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
menuItem = new BMenuItem("Make Square", new BMessage(msg_make_square),'/');
|
menuItem = new BMenuItem("Make Square", new BMessage(msg_make_square),'/');
|
||||||
menu->AddItem(menuItem);
|
menu->AddItem(menuItem);
|
||||||
menuItem = new BMenuItem("Decrease Window Size", new BMessage(msg_shrink),'-');
|
menuItem = new BMenuItem("Decrease Window Size", new BMessage(msg_shrink),'-');
|
||||||
@@ -177,7 +176,7 @@ BuildInfoMenu(BMenu *menu)
|
|||||||
menuItem = new BMenuItem("Decrease Pixel Size", new BMessage(msg_shrink_pixel),',');
|
menuItem = new BMenuItem("Decrease Pixel Size", new BMessage(msg_shrink_pixel),',');
|
||||||
menu->AddItem(menuItem);
|
menu->AddItem(menuItem);
|
||||||
menuItem = new BMenuItem("Increase Pixel Size", new BMessage(msg_grow_pixel),'.');
|
menuItem = new BMenuItem("Increase Pixel Size", new BMessage(msg_grow_pixel),'.');
|
||||||
menu->AddItem(menuItem);
|
menu->AddItem(menuItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -244,7 +243,7 @@ TWindow::TWindow(int32 pixelCount)
|
|||||||
if (InfoIsShowing())
|
if (InfoIsShowing())
|
||||||
fbRect.OffsetBy(10, fInfoHeight);
|
fbRect.OffsetBy(10, fInfoHeight);
|
||||||
fFatBits = new TMagnify(fbRect, this);
|
fFatBits = new TMagnify(fbRect, this);
|
||||||
fInfo->AddChild(fFatBits);
|
fInfo->AddChild(fFatBits);
|
||||||
|
|
||||||
fFatBits->SetSelection(fShowInfo);
|
fFatBits->SetSelection(fShowInfo);
|
||||||
fInfo->SetMagView(fFatBits);
|
fInfo->SetMagView(fFatBits);
|
||||||
@@ -276,26 +275,26 @@ void
|
|||||||
TWindow::MessageReceived(BMessage* m)
|
TWindow::MessageReceived(BMessage* m)
|
||||||
{
|
{
|
||||||
bool active = fFatBits->Active();
|
bool active = fFatBits->Active();
|
||||||
|
|
||||||
switch (m->what) {
|
switch (m->what) {
|
||||||
case B_ABOUT_REQUESTED:
|
case B_ABOUT_REQUESTED:
|
||||||
be_app->MessageReceived(m);
|
be_app->MessageReceived(m);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case msg_help:
|
case msg_help:
|
||||||
ShowHelp();
|
ShowHelp();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case msg_show_info:
|
case msg_show_info:
|
||||||
if (active)
|
if (active)
|
||||||
ShowInfo(!fShowInfo);
|
ShowInfo(!fShowInfo);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case msg_toggle_grid:
|
case msg_toggle_grid:
|
||||||
if (active)
|
if (active)
|
||||||
SetGrid(!fShowGrid);
|
SetGrid(!fShowGrid);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case msg_grow:
|
case msg_grow:
|
||||||
if (active)
|
if (active)
|
||||||
ResizeWindow(true);
|
ResizeWindow(true);
|
||||||
@@ -312,7 +311,7 @@ TWindow::MessageReceived(BMessage* m)
|
|||||||
ResizeWindow(big, big);
|
ResizeWindow(big, big);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case msg_shrink_pixel:
|
case msg_shrink_pixel:
|
||||||
if (active)
|
if (active)
|
||||||
SetPixelSize(false);
|
SetPixelSize(false);
|
||||||
@@ -321,7 +320,7 @@ TWindow::MessageReceived(BMessage* m)
|
|||||||
if (active)
|
if (active)
|
||||||
SetPixelSize(true);
|
SetPixelSize(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case msg_add_cross_hair:
|
case msg_add_cross_hair:
|
||||||
if (active && fShowInfo)
|
if (active && fShowInfo)
|
||||||
AddCrossHair();
|
AddCrossHair();
|
||||||
@@ -343,7 +342,7 @@ TWindow::MessageReceived(BMessage* m)
|
|||||||
case msg_save:
|
case msg_save:
|
||||||
// freeze the image here, unfreeze after dump or cancel
|
// freeze the image here, unfreeze after dump or cancel
|
||||||
fFatBits->StartSave();
|
fFatBits->StartSave();
|
||||||
|
|
||||||
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(NULL, this),
|
fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(NULL, this),
|
||||||
0, 0, false, new BMessage(msg_dump));
|
0, 0, false, new BMessage(msg_dump));
|
||||||
fSavePanel->SetSaveText("Bitmaps.h");
|
fSavePanel->SetSaveText("Bitmaps.h");
|
||||||
@@ -352,12 +351,12 @@ TWindow::MessageReceived(BMessage* m)
|
|||||||
case msg_dump:
|
case msg_dump:
|
||||||
{
|
{
|
||||||
delete fSavePanel;
|
delete fSavePanel;
|
||||||
|
|
||||||
entry_ref dirRef;
|
entry_ref dirRef;
|
||||||
char* name;
|
char* name;
|
||||||
m->FindRef("directory", &dirRef);
|
m->FindRef("directory", &dirRef);
|
||||||
m->FindString((const char*)"name",(const char**) &name);
|
m->FindString((const char*)"name",(const char**) &name);
|
||||||
|
|
||||||
fFatBits->SaveImage(&dirRef, name);
|
fFatBits->SaveImage(&dirRef, name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -365,14 +364,14 @@ TWindow::MessageReceived(BMessage* m)
|
|||||||
// image is frozen before the FilePanel is shown
|
// image is frozen before the FilePanel is shown
|
||||||
fFatBits->EndSave();
|
fFatBits->EndSave();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case msg_copy_image:
|
case msg_copy_image:
|
||||||
fFatBits->CopyImage();
|
fFatBits->CopyImage();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(m);
|
BWindow::MessageReceived(m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -459,7 +458,7 @@ ALMOST_DONE: // clean up and try to position the window
|
|||||||
if (haveLoc && BScreen(B_MAIN_SCREEN_ID).Frame().Contains(loc)) {
|
if (haveLoc && BScreen(B_MAIN_SCREEN_ID).Frame().Contains(loc)) {
|
||||||
MoveTo(loc);
|
MoveTo(loc);
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -501,7 +500,7 @@ TWindow::SetPrefs()
|
|||||||
CrossHairsShowing(&ch1, &ch2);
|
CrossHairsShowing(&ch1, &ch2);
|
||||||
write(ref, &ch1, sizeof(bool));
|
write(ref, &ch1, sizeof(bool));
|
||||||
write(ref, &ch2, sizeof(bool));
|
write(ref, &ch2, sizeof(bool));
|
||||||
|
|
||||||
write(ref, &fHPixelCount, sizeof(int32));
|
write(ref, &fHPixelCount, sizeof(int32));
|
||||||
write(ref, &fVPixelCount, sizeof(int32));
|
write(ref, &fVPixelCount, sizeof(int32));
|
||||||
write(ref, &fPixelSize, sizeof(int32));
|
write(ref, &fPixelSize, sizeof(int32));
|
||||||
@@ -516,12 +515,12 @@ void
|
|||||||
TWindow::FrameResized(float w, float h)
|
TWindow::FrameResized(float w, float h)
|
||||||
{
|
{
|
||||||
CalcViewablePixels();
|
CalcViewablePixels();
|
||||||
|
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
GetPreferredSize(&width, &height);
|
GetPreferredSize(&width, &height);
|
||||||
ResizeTo(width, height);
|
ResizeTo(width, height);
|
||||||
|
|
||||||
fFatBits->InitBuffers(fHPixelCount, fVPixelCount, fPixelSize, ShowGrid());
|
fFatBits->InitBuffers(fHPixelCount, fVPixelCount, fPixelSize, ShowGrid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,14 +554,14 @@ TWindow::CalcViewablePixels()
|
|||||||
{
|
{
|
||||||
float w = Bounds().Width();
|
float w = Bounds().Width();
|
||||||
float h = Bounds().Height();
|
float h = Bounds().Height();
|
||||||
|
|
||||||
if (InfoIsShowing()) {
|
if (InfoIsShowing()) {
|
||||||
w -= 20; // remove the gutter
|
w -= 20; // remove the gutter
|
||||||
h = h-fInfoHeight-10; // remove info and gutter
|
h = h-fInfoHeight-10; // remove info and gutter
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ch1, ch2;
|
bool ch1, ch2;
|
||||||
fFatBits->CrossHairsShowing(&ch1, &ch2);
|
fFatBits->CrossHairsShowing(&ch1, &ch2);
|
||||||
if (ch1)
|
if (ch1)
|
||||||
h -= fFontHeight;
|
h -= fFontHeight;
|
||||||
if (ch2)
|
if (ch2)
|
||||||
@@ -584,16 +583,16 @@ TWindow::GetPreferredSize(float* width, float* height)
|
|||||||
*width = fHPixelCount * fPixelSize; // calc window width
|
*width = fHPixelCount * fPixelSize; // calc window width
|
||||||
*height = fVPixelCount * fPixelSize; // calc window height
|
*height = fVPixelCount * fPixelSize; // calc window height
|
||||||
if (InfoIsShowing()) {
|
if (InfoIsShowing()) {
|
||||||
*width += 20;
|
*width += 20;
|
||||||
*height += fInfoHeight + 10;
|
*height += fInfoHeight + 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ch1, ch2;
|
bool ch1, ch2;
|
||||||
fFatBits->CrossHairsShowing(&ch1, &ch2);
|
fFatBits->CrossHairsShowing(&ch1, &ch2);
|
||||||
if (ch1)
|
if (ch1)
|
||||||
*height += fFontHeight;
|
*height += fFontHeight;
|
||||||
if (ch2)
|
if (ch2)
|
||||||
*height += fFontHeight + 5;
|
*height += fFontHeight + 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -602,10 +601,10 @@ TWindow::ResizeWindow(int32 hPixelCount, int32 vPixelCount)
|
|||||||
{
|
{
|
||||||
fHPixelCount = hPixelCount;
|
fHPixelCount = hPixelCount;
|
||||||
fVPixelCount = vPixelCount;
|
fVPixelCount = vPixelCount;
|
||||||
|
|
||||||
float width, height;
|
float width, height;
|
||||||
GetPreferredSize(&width, &height);
|
GetPreferredSize(&width, &height);
|
||||||
|
|
||||||
ResizeTo(width, height);
|
ResizeTo(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -615,7 +614,7 @@ TWindow::ResizeWindow(bool direction)
|
|||||||
{
|
{
|
||||||
int32 x = fHPixelCount;
|
int32 x = fHPixelCount;
|
||||||
int32 y = fVPixelCount;
|
int32 y = fVPixelCount;
|
||||||
|
|
||||||
if (direction) {
|
if (direction) {
|
||||||
x += 4;
|
x += 4;
|
||||||
y += 4;
|
y += 4;
|
||||||
@@ -630,7 +629,7 @@ TWindow::ResizeWindow(bool direction)
|
|||||||
if (y < 4)
|
if (y < 4)
|
||||||
y = 4;
|
y = 4;
|
||||||
|
|
||||||
ResizeWindow(x, y);
|
ResizeWindow(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -639,7 +638,7 @@ TWindow::SetGrid(bool s)
|
|||||||
{
|
{
|
||||||
if (s == fShowGrid)
|
if (s == fShowGrid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fShowGrid = s;
|
fShowGrid = s;
|
||||||
fFatBits->SetUpdate(true);
|
fFatBits->SetUpdate(true);
|
||||||
}
|
}
|
||||||
@@ -657,7 +656,7 @@ TWindow::ShowInfo(bool i)
|
|||||||
{
|
{
|
||||||
if (i == fShowInfo)
|
if (i == fShowInfo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fShowInfo = i;
|
fShowInfo = i;
|
||||||
|
|
||||||
if (fShowInfo)
|
if (fShowInfo)
|
||||||
@@ -692,7 +691,7 @@ TWindow::AddCrossHair()
|
|||||||
fFatBits->AddCrossHair();
|
fFatBits->AddCrossHair();
|
||||||
|
|
||||||
// crosshair info needs to be added
|
// crosshair info needs to be added
|
||||||
// window resizes accordingly
|
// window resizes accordingly
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
GetPreferredSize(&width, &height);
|
GetPreferredSize(&width, &height);
|
||||||
@@ -704,9 +703,9 @@ void
|
|||||||
TWindow::RemoveCrossHair()
|
TWindow::RemoveCrossHair()
|
||||||
{
|
{
|
||||||
fFatBits->RemoveCrossHair();
|
fFatBits->RemoveCrossHair();
|
||||||
|
|
||||||
// crosshair info needs to be removed
|
// crosshair info needs to be removed
|
||||||
// window resizes accordingly
|
// window resizes accordingly
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
GetPreferredSize(&width, &height);
|
GetPreferredSize(&width, &height);
|
||||||
@@ -734,7 +733,7 @@ TWindow::SetPixelSize(int32 s)
|
|||||||
{
|
{
|
||||||
if (s == fPixelSize)
|
if (s == fPixelSize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fPixelSize = s;
|
fPixelSize = s;
|
||||||
// resize window
|
// resize window
|
||||||
// tell info that size has changed
|
// tell info that size has changed
|
||||||
@@ -762,7 +761,7 @@ TWindow::SetPixelSize(bool d)
|
|||||||
float h = Bounds().Height();
|
float h = Bounds().Height();
|
||||||
CalcViewablePixels();
|
CalcViewablePixels();
|
||||||
ResizeWindow(fHPixelCount, fVPixelCount);
|
ResizeWindow(fHPixelCount, fVPixelCount);
|
||||||
|
|
||||||
// the window might not actually change in size
|
// the window might not actually change in size
|
||||||
// in that case force the buffers to the new dimension
|
// in that case force the buffers to the new dimension
|
||||||
if (w == Bounds().Width() && h == Bounds().Height())
|
if (w == Bounds().Width() && h == Bounds().Height())
|
||||||
@@ -811,7 +810,7 @@ TWindow::ShowHelp()
|
|||||||
text->Insert("Info:\n");
|
text->Insert("Info:\n");
|
||||||
text->Insert(" hide/show info - hides/shows all these new features\n");
|
text->Insert(" hide/show info - hides/shows all these new features\n");
|
||||||
text->Insert(" note: when showing, a red square will appear which signifies\n");
|
text->Insert(" note: when showing, a red square will appear which signifies\n");
|
||||||
text->Insert(" which pixel's rgb values will be displayed\n");
|
text->Insert(" which pixel's rgb values will be displayed\n");
|
||||||
text->Insert(" add/remove crosshairs - 2 crosshairs can be added (or removed)\n");
|
text->Insert(" add/remove crosshairs - 2 crosshairs can be added (or removed)\n");
|
||||||
text->Insert(" to aid in the alignment and placement of objects.\n");
|
text->Insert(" to aid in the alignment and placement of objects.\n");
|
||||||
text->Insert(" The crosshairs are represented by blue squares and blue lines.\n");
|
text->Insert(" The crosshairs are represented by blue squares and blue lines.\n");
|
||||||
@@ -836,7 +835,7 @@ TWindow::ShowHelp()
|
|||||||
text->Insert(" option-arrow key - moves the mouse location 1 pixel at a time\n");
|
text->Insert(" option-arrow key - moves the mouse location 1 pixel at a time\n");
|
||||||
text->Insert(" x marks the selection - the current selection has an 'x' in it\n");
|
text->Insert(" x marks the selection - the current selection has an 'x' in it\n");
|
||||||
|
|
||||||
CenterWindowOnScreen(w);
|
CenterWindowOnScreen(w);
|
||||||
w->Show();
|
w->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,12 +856,12 @@ TInfoView::TInfoView(BRect frame)
|
|||||||
B_NO_BORDER)
|
B_NO_BORDER)
|
||||||
{
|
{
|
||||||
SetFont(be_plain_font);
|
SetFont(be_plain_font);
|
||||||
fFontHeight = FontHeight(this, true);
|
fFontHeight = FontHeight(this, true);
|
||||||
fMagView = NULL;
|
fMagView = NULL;
|
||||||
|
|
||||||
fSelectionColor = kBlack;
|
fSelectionColor = kBlack;
|
||||||
fCH1Loc.x = fCH1Loc.y = fCH2Loc.x = fCH2Loc.y = 0;
|
fCH1Loc.x = fCH1Loc.y = fCH2Loc.x = fCH2Loc.y = 0;
|
||||||
|
|
||||||
fInfoStr[0] = 0;
|
fInfoStr[0] = 0;
|
||||||
fRGBStr[0] = 0;
|
fRGBStr[0] = 0;
|
||||||
fCH1Str[0] = 0;
|
fCH1Str[0] = 0;
|
||||||
@@ -881,9 +880,9 @@ TInfoView::AttachedToWindow()
|
|||||||
BBox::AttachedToWindow();
|
BBox::AttachedToWindow();
|
||||||
|
|
||||||
dynamic_cast<TWindow*>(Window())->PixelCount(&fHPixelCount, &fVPixelCount);
|
dynamic_cast<TWindow*>(Window())->PixelCount(&fHPixelCount, &fVPixelCount);
|
||||||
fPixelSize = dynamic_cast<TWindow*>(Window())->PixelSize();
|
fPixelSize = dynamic_cast<TWindow*>(Window())->PixelSize();
|
||||||
|
|
||||||
AddMenu();
|
AddMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -927,14 +926,14 @@ TInfoView::Draw(BRect updateRect)
|
|||||||
SetHighColor(0,0,0,255);
|
SetHighColor(0,0,0,255);
|
||||||
strcpy(fRGBStr,str);
|
strcpy(fRGBStr,str);
|
||||||
DrawString(fRGBStr);
|
DrawString(fRGBStr);
|
||||||
|
|
||||||
bool ch1Showing, ch2Showing;
|
bool ch1Showing, ch2Showing;
|
||||||
dynamic_cast<TWindow*>(Window())->CrossHairsShowing(&ch1Showing, &ch2Showing);
|
dynamic_cast<TWindow*>(Window())->CrossHairsShowing(&ch1Showing, &ch2Showing);
|
||||||
|
|
||||||
if (fMagView) {
|
if (fMagView) {
|
||||||
BPoint pt1(fMagView->CrossHair1Loc());
|
BPoint pt1(fMagView->CrossHair1Loc());
|
||||||
BPoint pt2(fMagView->CrossHair2Loc());
|
BPoint pt2(fMagView->CrossHair2Loc());
|
||||||
|
|
||||||
float h = Bounds().Height();
|
float h = Bounds().Height();
|
||||||
if (ch2Showing) {
|
if (ch2Showing) {
|
||||||
MovePenTo(10, h-12);
|
MovePenTo(10, h-12);
|
||||||
@@ -947,7 +946,7 @@ TInfoView::Draw(BRect updateRect)
|
|||||||
strcpy(fCH2Str,str);
|
strcpy(fCH2Str,str);
|
||||||
DrawString(fCH2Str);
|
DrawString(fCH2Str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch1Showing && ch2Showing) {
|
if (ch1Showing && ch2Showing) {
|
||||||
MovePenTo(10, h-10-fFontHeight-2);
|
MovePenTo(10, h-10-fFontHeight-2);
|
||||||
sprintf(str, "1) x: %li y: %li x: %i", (int32)pt1.x, (int32)pt1.y,
|
sprintf(str, "1) x: %li y: %li x: %i", (int32)pt1.x, (int32)pt1.y,
|
||||||
@@ -969,7 +968,7 @@ TInfoView::Draw(BRect updateRect)
|
|||||||
DrawString(fCH1Str);
|
DrawString(fCH1Str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PopState();
|
PopState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1016,7 +1015,7 @@ TMenu::~TMenu()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TMenu::AttachedToWindow()
|
TMenu::AttachedToWindow()
|
||||||
{
|
{
|
||||||
bool state = true;
|
bool state = true;
|
||||||
@@ -1251,7 +1250,7 @@ TMagnify::MouseDown(BPoint where)
|
|||||||
BPopUpMenu *menu = new BPopUpMenu("Info");
|
BPopUpMenu *menu = new BPopUpMenu("Info");
|
||||||
menu->SetFont(be_plain_font);
|
menu->SetFont(be_plain_font);
|
||||||
BuildInfoMenu(menu);
|
BuildInfoMenu(menu);
|
||||||
|
|
||||||
BMenuItem *selected = menu->Go(ConvertToScreen(where));
|
BMenuItem *selected = menu->Go(ConvertToScreen(where));
|
||||||
if (selected)
|
if (selected)
|
||||||
Window()->PostMessage(selected->Message()->what);
|
Window()->PostMessage(selected->Message()->what);
|
||||||
@@ -1261,13 +1260,13 @@ TMagnify::MouseDown(BPoint where)
|
|||||||
|
|
||||||
// add a mousedown looper here
|
// add a mousedown looper here
|
||||||
|
|
||||||
int32 pixelSize = PixelSize();
|
int32 pixelSize = PixelSize();
|
||||||
float x = where.x / pixelSize;
|
float x = where.x / pixelSize;
|
||||||
float y = where.y / pixelSize;
|
float y = where.y / pixelSize;
|
||||||
|
|
||||||
MoveSelectionTo(x, y);
|
MoveSelectionTo(x, y);
|
||||||
|
|
||||||
// draw the frozen image
|
// draw the frozen image
|
||||||
// update the info region
|
// update the info region
|
||||||
|
|
||||||
fNeedToUpdate = true;
|
fNeedToUpdate = true;
|
||||||
@@ -1290,7 +1289,7 @@ TMagnify::SetSelection(bool state)
|
|||||||
{
|
{
|
||||||
if (fShowSelection == state)
|
if (fShowSelection == state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fShowSelection = state;
|
fShowSelection = state;
|
||||||
fSelection = 0;
|
fSelection = 0;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
@@ -1659,10 +1658,10 @@ TMagnify::SaveImage(entry_ref* ref, char* name, bool selectionOnly)
|
|||||||
BFile file;
|
BFile file;
|
||||||
BDirectory parentDir(ref);
|
BDirectory parentDir(ref);
|
||||||
parentDir.CreateFile(name, &file);
|
parentDir.CreateFile(name, &file);
|
||||||
|
|
||||||
// write off the bitmaps bits to the file
|
// write off the bitmaps bits to the file
|
||||||
SaveBits(&file, fImageView->Bitmap(), "Data");
|
SaveBits(&file, fImageView->Bitmap(), "Data");
|
||||||
|
|
||||||
// unfreeze the image, image was frozen before invoke of FilePanel
|
// unfreeze the image, image was frozen before invoke of FilePanel
|
||||||
EndSave();
|
EndSave();
|
||||||
}
|
}
|
||||||
@@ -1672,7 +1671,7 @@ void
|
|||||||
TMagnify::SaveBits(BFile* file, const BBitmap *bitmap, char* name) const
|
TMagnify::SaveBits(BFile* file, const BBitmap *bitmap, char* name) const
|
||||||
{
|
{
|
||||||
int32 bytesPerPixel;
|
int32 bytesPerPixel;
|
||||||
const char *kColorSpaceName;
|
const char *kColorSpaceName;
|
||||||
|
|
||||||
switch (bitmap->ColorSpace()) {
|
switch (bitmap->ColorSpace()) {
|
||||||
case B_GRAY8:
|
case B_GRAY8:
|
||||||
@@ -1773,7 +1772,7 @@ TOSMagnify::TOSMagnify(BRect r, TMagnify* parent, color_space space)
|
|||||||
fBytesPerPixel = 1;
|
fBytesPerPixel = 1;
|
||||||
break;
|
break;
|
||||||
case B_RGB15:
|
case B_RGB15:
|
||||||
case B_RGBA15:
|
case B_RGBA15:
|
||||||
case B_RGB15_BIG:
|
case B_RGB15_BIG:
|
||||||
case B_RGBA15_BIG:
|
case B_RGBA15_BIG:
|
||||||
case B_RGB16:
|
case B_RGB16:
|
||||||
@@ -1880,7 +1879,7 @@ TOSMagnify::CreateImage(BPoint mouseLoc, bool force)
|
|||||||
|
|
||||||
DrawBitmap(fBitmap, srcRect, destRect);
|
DrawBitmap(fBitmap, srcRect, destRect);
|
||||||
|
|
||||||
DrawGrid(width, height, destRect, pixelSize);
|
DrawGrid(width, height, destRect, pixelSize);
|
||||||
DrawSelection();
|
DrawSelection();
|
||||||
|
|
||||||
Sync();
|
Sync();
|
||||||
@@ -1931,7 +1930,7 @@ TOSMagnify::DrawGrid(int32 width, int32 height, BRect destRect, int32 pixelSize)
|
|||||||
// horizontal lines
|
// horizontal lines
|
||||||
for (int32 i = pixelSize; i < (height * pixelSize); i += pixelSize)
|
for (int32 i = pixelSize; i < (height * pixelSize); i += pixelSize)
|
||||||
AddLine(BPoint(0, i), BPoint(destRect.right, i), kGridGray);
|
AddLine(BPoint(0, i), BPoint(destRect.right, i), kGridGray);
|
||||||
|
|
||||||
// vertical lines
|
// vertical lines
|
||||||
for (int32 i = pixelSize; i < (width * pixelSize); i += pixelSize)
|
for (int32 i = pixelSize; i < (width * pixelSize); i += pixelSize)
|
||||||
AddLine(BPoint(i, 0), BPoint(i, destRect.bottom), kGridGray);
|
AddLine(BPoint(i, 0), BPoint(i, destRect.bottom), kGridGray);
|
||||||
@@ -1968,7 +1967,7 @@ TOSMagnify::DrawSelection()
|
|||||||
if (selection == 0) {
|
if (selection == 0) {
|
||||||
StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize));
|
StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize));
|
||||||
StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y));
|
StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ch1Showing, ch2Showing;
|
bool ch1Showing, ch2Showing;
|
||||||
fParent->CrossHairsShowing(&ch1Showing, &ch2Showing);
|
fParent->CrossHairsShowing(&ch1Showing, &ch2Showing);
|
||||||
@@ -1992,7 +1991,7 @@ TOSMagnify::DrawSelection()
|
|||||||
if (selection == 1) {
|
if (selection == 1) {
|
||||||
StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize));
|
StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize));
|
||||||
StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y));
|
StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ch2Showing) {
|
if (ch2Showing) {
|
||||||
SetHighColor(kBlueColor);
|
SetHighColor(kBlueColor);
|
||||||
@@ -2014,7 +2013,7 @@ TOSMagnify::DrawSelection()
|
|||||||
if (selection == 2) {
|
if (selection == 2) {
|
||||||
StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize));
|
StrokeLine(BPoint(x,y), BPoint(x+squareSize,y+squareSize));
|
||||||
StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y));
|
StrokeLine(BPoint(x,y+squareSize), BPoint(x+squareSize,y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PopState();
|
PopState();
|
||||||
@@ -2023,7 +2022,7 @@ TOSMagnify::DrawSelection()
|
|||||||
|
|
||||||
rgb_color
|
rgb_color
|
||||||
TOSMagnify::ColorAtSelection()
|
TOSMagnify::ColorAtSelection()
|
||||||
{
|
{
|
||||||
float x, y;
|
float x, y;
|
||||||
fParent->SelectionLoc(&x, &y);
|
fParent->SelectionLoc(&x, &y);
|
||||||
BRect srcRect(x, y, x, y);
|
BRect srcRect(x, y, x, y);
|
||||||
@@ -2033,7 +2032,7 @@ TOSMagnify::ColorAtSelection()
|
|||||||
fPixelView->Sync();
|
fPixelView->Sync();
|
||||||
fPixel->Unlock();
|
fPixel->Unlock();
|
||||||
|
|
||||||
uint32 pixel = *((uint32*)fPixel->Bits());
|
uint32 pixel = *((uint32*)fPixel->Bits());
|
||||||
rgb_color c;
|
rgb_color c;
|
||||||
c.alpha = pixel >> 24;
|
c.alpha = pixel >> 24;
|
||||||
c.red = (pixel >> 16) & 0xFF;
|
c.red = (pixel >> 16) & 0xFF;
|
||||||
@@ -2073,6 +2072,6 @@ main(long argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
TApp app(pixelCount);
|
TApp app(pixelCount);
|
||||||
app.Run();
|
app.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user