* Renamed "mio" to mallocIO.
* Don't define status in CopyToClipboard() before it's actually used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37124 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007-2008, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2007-2010, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -470,65 +470,64 @@ SudokuView::SaveTo(BDataIO& stream, uint32 exportAs)
|
|||||||
status_t
|
status_t
|
||||||
SudokuView::CopyToClipboard()
|
SudokuView::CopyToClipboard()
|
||||||
{
|
{
|
||||||
status_t status = B_ERROR;
|
|
||||||
if (!be_clipboard->Lock())
|
if (!be_clipboard->Lock())
|
||||||
return status;
|
return B_ERROR;
|
||||||
|
|
||||||
be_clipboard->Clear();
|
be_clipboard->Clear();
|
||||||
|
|
||||||
BMessage* clip = be_clipboard->Data();
|
BMessage* clip = be_clipboard->Data();
|
||||||
if (clip == NULL) {
|
if (clip == NULL) {
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
return status;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// As BBitmap
|
// As BBitmap
|
||||||
BMallocIO mio;
|
BMallocIO mallocIO;
|
||||||
status = SaveTo(mio, kExportAsBitmap);
|
status_t status = SaveTo(mallocIO, kExportAsBitmap);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
mio.Seek(0LL, SEEK_SET);
|
mallocIO.Seek(0LL, SEEK_SET);
|
||||||
// ShowImage, ArtPaint & WonderBrush use that
|
// ShowImage, ArtPaint & WonderBrush use that
|
||||||
status = clip->AddData("image/bitmap", B_MESSAGE_TYPE,
|
status = clip->AddData("image/bitmap", B_MESSAGE_TYPE,
|
||||||
mio.Buffer(), mio.BufferLength());
|
mallocIO.Buffer(), mallocIO.BufferLength());
|
||||||
// Becasso uses that ?
|
// Becasso uses that ?
|
||||||
clip->AddData("image/x-be-bitmap", B_MESSAGE_TYPE, mio.Buffer(),
|
clip->AddData("image/x-be-bitmap", B_MESSAGE_TYPE, mallocIO.Buffer(),
|
||||||
mio.BufferLength());
|
mallocIO.BufferLength());
|
||||||
// Gobe Productive uses that...
|
// Gobe Productive uses that...
|
||||||
// QuickRes as well, with a rect field.
|
// QuickRes as well, with a rect field.
|
||||||
clip->AddData("image/x-vnd.Be-bitmap", B_MESSAGE_TYPE, mio.Buffer(),
|
clip->AddData("image/x-vnd.Be-bitmap", B_MESSAGE_TYPE,
|
||||||
mio.BufferLength());
|
mallocIO.Buffer(), mallocIO.BufferLength());
|
||||||
}
|
}
|
||||||
mio.Seek(0LL, SEEK_SET);
|
mallocIO.Seek(0LL, SEEK_SET);
|
||||||
mio.SetSize(0LL);
|
mallocIO.SetSize(0LL);
|
||||||
|
|
||||||
// As HTML
|
// As HTML
|
||||||
if (status >= B_OK)
|
if (status >= B_OK)
|
||||||
status = SaveTo(mio, kExportAsHTML);
|
status = SaveTo(mallocIO, kExportAsHTML);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
status = clip->AddData("text/html", B_MIME_TYPE, mio.Buffer(),
|
status = clip->AddData("text/html", B_MIME_TYPE, mallocIO.Buffer(),
|
||||||
mio.BufferLength());
|
mallocIO.BufferLength());
|
||||||
}
|
}
|
||||||
mio.Seek(0LL, SEEK_SET);
|
mallocIO.Seek(0LL, SEEK_SET);
|
||||||
mio.SetSize(0LL);
|
mallocIO.SetSize(0LL);
|
||||||
|
|
||||||
// As plain text
|
// As plain text
|
||||||
if (status >= B_OK)
|
if (status >= B_OK)
|
||||||
SaveTo(mio, kExportAsText);
|
SaveTo(mallocIO, kExportAsText);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
status = clip->AddData("text/plain", B_MIME_TYPE, mio.Buffer(),
|
status = clip->AddData("text/plain", B_MIME_TYPE, mallocIO.Buffer(),
|
||||||
mio.BufferLength());
|
mallocIO.BufferLength());
|
||||||
}
|
}
|
||||||
mio.Seek(0LL, SEEK_SET);
|
mallocIO.Seek(0LL, SEEK_SET);
|
||||||
mio.SetSize(0LL);
|
mallocIO.SetSize(0LL);
|
||||||
|
|
||||||
// As flattened BPicture, anyone handles that ?
|
// As flattened BPicture, anyone handles that?
|
||||||
if (status >= B_OK)
|
if (status >= B_OK)
|
||||||
status = SaveTo(mio, kExportAsPicture);
|
status = SaveTo(mallocIO, kExportAsPicture);
|
||||||
if (status >= B_OK) {
|
if (status >= B_OK) {
|
||||||
status = clip->AddData("image/x-vnd.Be-picture", B_MIME_TYPE,
|
status = clip->AddData("image/x-vnd.Be-picture", B_MIME_TYPE,
|
||||||
mio.Buffer(), mio.BufferLength());
|
mallocIO.Buffer(), mallocIO.BufferLength());
|
||||||
}
|
}
|
||||||
mio.SetSize(0LL);
|
mallocIO.SetSize(0LL);
|
||||||
|
|
||||||
be_clipboard->Commit();
|
be_clipboard->Commit();
|
||||||
be_clipboard->Unlock();
|
be_clipboard->Unlock();
|
||||||
@@ -631,7 +630,7 @@ SudokuView::FrameResized(float /*width*/, float /*height*/)
|
|||||||
fHintFont.GetHeight(&fontHeight);
|
fHintFont.GetHeight(&fontHeight);
|
||||||
fHintBaseline = ceilf(fontHeight.ascent) / 2
|
fHintBaseline = ceilf(fontHeight.ascent) / 2
|
||||||
+ (fHintHeight - ceilf(fontHeight.descent)) / 2;
|
+ (fHintHeight - ceilf(fontHeight.descent)) / 2;
|
||||||
|
|
||||||
// fix the dragger's position
|
// fix the dragger's position
|
||||||
BView *dragger = FindView("_dragger_");
|
BView *dragger = FindView("_dragger_");
|
||||||
if (dragger)
|
if (dragger)
|
||||||
@@ -1216,7 +1215,7 @@ SudokuView::Draw(BRect /*updateRect*/)
|
|||||||
SetLowColor(fBackgroundColor);
|
SetLowColor(fBackgroundColor);
|
||||||
FillRect(_Frame(x, y), B_SOLID_LOW);
|
FillRect(_Frame(x, y), B_SOLID_LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fShowKeyboardFocus && x == fKeyboardX && y == fKeyboardY)
|
if (fShowKeyboardFocus && x == fKeyboardX && y == fKeyboardY)
|
||||||
_DrawKeyboardFocus();
|
_DrawKeyboardFocus();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user