[haiku-commits] haiku: hrev50615 - in src: apps/magnify apps/poorman kits/tracker apps/login kits/interface

  • From: waddlesplash@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 22 Oct 2016 21:22:58 +0200 (CEST)

hrev50615 adds 3 changesets to branch 'master'
old head: 71452e98334eaac603bf542d159e24788a46bebb
new head: 3798bf90cb8e5e55b3b5ec15f22dbc0dd0735fd0
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=3798bf90cb8e+%5E71452e98334e

----------------------------------------------------------------------------

79d6f0870e70: PoorMan: Fix 'resizing mode or flags swapped', trim trailing 
space.

49a2d53d357c: Magnify: Write an actual image for "save image", not a C++ data 
header.
  
  I've no idea why this was what "save image" did, but apparently it's
  done so since this code was imported into the trunk in the very first
  commit. Now it saves PNGs, which is what users expect.
  
  Fixes #5011.

3798bf90cb8e: Use the kDesktopWindowLook/kDesktopWindowFeel constants from 
WindowPrivate.h...
  
  ... instead of redefining them, or including a private Tracker header to
  get them.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

11 files changed, 133 insertions(+), 225 deletions(-)
src/apps/login/DesktopWindow.cpp     |  11 +-
src/apps/login/Jamfile               |   2 +-
src/apps/magnify/Jamfile             |  10 +-
src/apps/magnify/Magnify.cpp         | 116 +++----------------
src/apps/magnify/Magnify.h           |   4 +-
src/apps/poorman/PoorManWindow.cpp   | 192 +++++++++++++++----------------
src/kits/interface/ControlLook.cpp   |   8 +-
src/kits/tracker/ContainerWindow.cpp |   3 +-
src/kits/tracker/ContainerWindow.h   |   4 -
src/kits/tracker/DeskWindow.cpp      |   5 +-
src/kits/tracker/SelectionWindow.cpp |   3 +-

############################################################################

Commit:      79d6f0870e70cb72a2bbd7910e05cb531335e9b7
URL:         http://cgit.haiku-os.org/haiku/commit/?id=79d6f0870e70
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Oct 22 06:57:04 2016 UTC

PoorMan: Fix 'resizing mode or flags swapped', trim trailing space.

----------------------------------------------------------------------------

diff --git a/src/apps/poorman/PoorManWindow.cpp 
b/src/apps/poorman/PoorManWindow.cpp
index 3565b90..1d15415 100644
--- a/src/apps/poorman/PoorManWindow.cpp
+++ b/src/apps/poorman/PoorManWindow.cpp
@@ -57,32 +57,32 @@ PoorManWindow::PoorManWindow(BRect frame)
        fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY);
        fIndexFileName.SetTo("index.html");
        fDirListFlag = false;
-       
+
        fLogConsoleFlag = true;
        fLogFileFlag = false;
        fLogPath.SetTo("");
-       
+
        fMaxConnections = (int16)32;
-       
+
        fIsZoomed = true;
        fLastWidth = 318.0f;
        fLastHeight = 320.0f;
        this->fFrame = frame;
        fSetwindowFrame.Set(112.0f, 60.0f, 492.0f, 340.0f);
-       
+
        // PoorMan Window
-       SetSizeLimits(318, 1600, 53, 1200); 
+       SetSizeLimits(318, 1600, 53, 1200);
        // limit the size of the size of the window
-       
+
        // -----------------------------------------------------------------
-       // Three Labels 
-       
+       // Three Labels
+
        // Status String
        fStatusView = new BStringView("Status View", B_TRANSLATE("Status: 
Stopped"));
-       
+
        // Directory String
        fDirView = new BStringView("Dir View", B_TRANSLATE("Directory: 
(none)"));
-       
+
        // Hits String
        fHitsView = new BStringView("Hit View", B_TRANSLATE("Hits: 0"));
 
@@ -95,10 +95,10 @@ PoorManWindow::PoorManWindow(BRect frame)
        fLoggingView->MakeSelectable(true);
        fLoggingView->SetViewColor(WHITE);
        fLoggingView->SetStylable(true);
-               
+
        // create the scroll view
        fScrollView = new BScrollView("Scroll View", fLoggingView,
-                                       B_WILL_DRAW | B_FRAME_EVENTS | 
B_FOLLOW_ALL_SIDES, 
+                                       B_WILL_DRAW | B_FRAME_EVENTS,
                                        // Make sure articles on border do not 
occur when resizing
                                        false, true);
        fLoggingView->MakeFocus(true);
@@ -107,35 +107,35 @@ PoorManWindow::PoorManWindow(BRect frame)
        // -----------------------------------------------------------------
        // menu bar
        fFileMenuBar = new BMenuBar("File Menu Bar");
-       
+
        // menus
        fFileMenu = BuildFileMenu();
        if (fFileMenu)
                fFileMenuBar->AddItem(fFileMenu);
-                       
+
        fEditMenu = BuildEditMenu();
        if (fEditMenu)
                fFileMenuBar->AddItem(fEditMenu);
-               
+
        fControlsMenu = BuildControlsMenu();
        if (fControlsMenu)
                fFileMenuBar->AddItem(fControlsMenu);
-       
+
        // File Panels
        BWindow* change_title;
-       
+
        fSaveConsoleFilePanel = new BFilePanel(B_SAVE_PANEL, new 
BMessenger(this),
                                                NULL, B_FILE_NODE, false,
                                                new 
BMessage(MSG_FILE_PANEL_SAVE_CONSOLE));
        change_title = fSaveConsoleFilePanel->Window();
        change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE);
-       
+
        fSaveConsoleSelectionFilePanel = new BFilePanel(B_SAVE_PANEL,
                                                new BMessenger(this), NULL, 
B_FILE_NODE, false,
                                                new 
BMessage(MSG_FILE_PANEL_SAVE_CONSOLE_SELECTION));
        change_title = fSaveConsoleSelectionFilePanel->Window();
        change_title->SetTitle(STR_FILEPANEL_SAVE_CONSOLE_SELECTION);
-       
+
        BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
                .SetInsets(0)
                .Add(fFileMenuBar)
@@ -151,7 +151,7 @@ PoorManWindow::PoorManWindow(BRect frame)
                                .AddGlue()
                                .End()
                        .Add(fScrollView);
-       
+
        pthread_rwlock_init(&fLogFileLock, NULL);
 }
 
@@ -182,7 +182,7 @@ PoorManWindow::MessageReceived(BMessage* message)
                        printf("FilePanel: Save console selection\n");
                        SaveConsole(message, true);
                        break;
-               case MSG_FILE_PANEL_SELECT_WEB_DIR:             
+               case MSG_FILE_PANEL_SELECT_WEB_DIR:
                        fPrefWindow->MessageReceived(message);
                        break;
                case MSG_MENU_EDIT_PREF:
@@ -212,7 +212,7 @@ PoorManWindow::MessageReceived(BMessage* message)
                case MSG_LOG: {
                        if (!fLogConsoleFlag && !fLogFileFlag)
                                break;
-       
+
                        time_t time;
                        in_addr_t address;
                        rgb_color color;
@@ -220,7 +220,7 @@ PoorManWindow::MessageReceived(BMessage* message)
                        ssize_t size;
                        const char* msg;
                        BString line;
-               
+
                        if (message->FindString("cstring", &msg) != B_OK)
                                break;
                        if (message->FindData("time_t", B_TIME_TYPE, &pointer, 
&size) != B_OK)
@@ -237,7 +237,7 @@ PoorManWindow::MessageReceived(BMessage* message)
                                color = BLACK;
                        else
                                color = *static_cast<const rgb_color*>(pointer);
-               
+
                        if (time != -1) {
                                BString timeString;
                                if (BDateTimeFormat().Format(timeString, time, 
DATE_FORMAT,
@@ -245,7 +245,7 @@ PoorManWindow::MessageReceived(BMessage* message)
                                        line << '[' << timeString << "]: ";
                                }
                        }
-               
+
                        if (address != INADDR_NONE) {
                                char addr[INET_ADDRSTRLEN];
                                struct in_addr sin_addr;
@@ -255,35 +255,35 @@ PoorManWindow::MessageReceived(BMessage* message)
                                        line << '(' << addr << ") ";
                                }
                        }
-               
+
                        line << msg;
-               
+
                        text_run run;
                        text_run_array runs;
-               
+
                        run.offset = 0;
                        run.color = color;
-               
+
                        runs.count = 1;
                        runs.runs[0] = run;
-               
+
                        if (Lock()) {
                                if (fLogConsoleFlag) {
                                        
fLoggingView->Insert(fLoggingView->TextLength(),
                                                line.String(), line.Length(), 
&runs);
                                        
fLoggingView->ScrollToOffset(fLoggingView->TextLength());
                                }
-               
+
                                if (fLogFileFlag) {
                                        if 
(pthread_rwlock_rdlock(&fLogFileLock) == 0) {
                                                fLogFile->Write(line.String(), 
line.Length());
                                                
pthread_rwlock_unlock(&fLogFileLock);
                                        }
                                }
-                       
+
                                Unlock();
                        }
-               
+
                        break;
                }
                default:
@@ -301,7 +301,7 @@ PoorManWindow::FrameMoved(BPoint origin)
 }
 
 
-void 
+void
 PoorManWindow::FrameResized(float width, float height)
 {
        if (fIsZoomed) {
@@ -318,29 +318,29 @@ PoorManWindow::QuitRequested()
                time_t now = time(NULL);
                BString timeString;
                BDateTimeFormat().Format(timeString, now, DATE_FORMAT, 
TIME_FORMAT);
-               
+
                BString line;
-               line << "[" << timeString << "]: " << B_TRANSLATE("Shutting 
down.") 
+               line << "[" << timeString << "]: " << B_TRANSLATE("Shutting 
down.")
                        << "\n";
-               
+
                if (fLogConsoleFlag) {
                        fLoggingView->Insert(fLoggingView->TextLength(),
                                line, line.Length());
                        
fLoggingView->ScrollToOffset(fLoggingView->TextLength());
                }
-               
+
                if (fLogFileFlag) {
                        if (pthread_rwlock_rdlock(&fLogFileLock) == 0) {
                                fLogFile->Write(line, line.Length());
                                pthread_rwlock_unlock(&fLogFileLock);
                        }
                }
-               
+
                fServer->Stop();
                fStatus = false;
                UpdateStatusLabelAndMenuItem();
        }
-       
+
        SaveSettings();
        be_app_messenger.SendMessage(B_QUIT_REQUESTED);
        return true;
@@ -354,7 +354,7 @@ PoorManWindow::Zoom(BPoint origin, float width, float 
height)
                // Change to the Minimal size
                fIsZoomed = false;
                ResizeTo(318, 53);
-       } else {        
+       } else {
                // Change to the Zoomed size
                fIsZoomed = true;
                ResizeTo(fLastWidth, fLastHeight);
@@ -373,65 +373,65 @@ PoorManWindow::SetHits(uint32 num)
 // Private: Methods ------------------------------------------
 
 
-BMenu* 
+BMenu*
 PoorManWindow::BuildFileMenu() const
 {
        BMenu* ptrFileMenu = new BMenu(STR_MNU_FILE);
 
        ptrFileMenu->AddItem(new BMenuItem(STR_MNU_FILE_SAVE_AS,
                new BMessage(MSG_MENU_FILE_SAVE_AS), CMD_FILE_SAVE_AS));
-               
+
        ptrFileMenu->AddItem(new BMenuItem(STR_MNU_FILE_SAVE_SELECTION,
                new BMessage(MSG_MENU_FILE_SAVE_SELECTION)));
-               
+
        ptrFileMenu->AddSeparatorItem();
 
        ptrFileMenu->AddItem(new BMenuItem(STR_MNU_FILE_QUIT,
                new BMessage(B_QUIT_REQUESTED), CMD_FILE_QUIT));
-               
+
        return ptrFileMenu;
 }
 
 
-BMenu* 
+BMenu*
 PoorManWindow::BuildEditMenu() const
 {
        BMenu* ptrEditMenu = new BMenu(STR_MNU_EDIT);
-       
+
        BMenuItem* CopyMenuItem = new BMenuItem(STR_MNU_EDIT_COPY,
                new BMessage(B_COPY), CMD_EDIT_COPY);
 
        ptrEditMenu->AddItem(CopyMenuItem);
        CopyMenuItem->SetTarget(fLoggingView, NULL);
-       
+
        ptrEditMenu->AddSeparatorItem();
 
        BMenuItem* SelectAllMenuItem = new BMenuItem(STR_MNU_EDIT_SELECT_ALL,
        new BMessage(B_SELECT_ALL), CMD_EDIT_SELECT_ALL);
-       
+
        ptrEditMenu->AddItem(SelectAllMenuItem);
        SelectAllMenuItem->SetTarget(fLoggingView, NULL);
-       
+
        ptrEditMenu->AddSeparatorItem();
-       
+
        BMenuItem* PrefMenuItem = new BMenuItem(STR_MNU_EDIT_PREF,
                new BMessage(MSG_MENU_EDIT_PREF));
        ptrEditMenu->AddItem(PrefMenuItem);
-       
+
        return ptrEditMenu;
 }
 
 
-BMenu* 
+BMenu*
 PoorManWindow::BuildControlsMenu() const
 {
        BMenu* ptrControlMenu = new BMenu(STR_MNU_CTRL);
-       
+
        BMenuItem* RunServerMenuItem = new BMenuItem(STR_MNU_CTRL_RUN_SERVER,
                new BMessage(MSG_MENU_CTRL_RUN));
        RunServerMenuItem->SetMarked(false);
        ptrControlMenu->AddItem(RunServerMenuItem);
-       
+
        BMenuItem* ClearHitCounterMenuItem = new 
BMenuItem(STR_MNU_CTRL_CLEAR_HIT_COUNTER,
                new BMessage(MSG_MENU_CTRL_CLEAR_HIT));
        ptrControlMenu->AddItem(ClearHitCounterMenuItem);
@@ -445,17 +445,17 @@ PoorManWindow::BuildControlsMenu() const
        BMenuItem* ClearLogFileMenuItem = new 
BMenuItem(STR_MNU_CTRL_CLEAR_LOG_FILE,
                new BMessage(MSG_MENU_CTRL_CLEAR_LOG));
        ptrControlMenu->AddItem(ClearLogFileMenuItem);
-       
+
        return ptrControlMenu;
 }
 
 
-void 
+void
 PoorManWindow::SetDirLabel(const char* name)
 {
        BString dirPath(B_TRANSLATE("Directory: "));
        dirPath.Append(name);
-       
+
        if (Lock()) {
                fDirView->SetText(dirPath.String());
                Unlock();
@@ -463,7 +463,7 @@ PoorManWindow::SetDirLabel(const char* name)
 }
 
 
-void 
+void
 PoorManWindow::UpdateStatusLabelAndMenuItem()
 {
        if (Lock()) {
@@ -477,19 +477,19 @@ PoorManWindow::UpdateStatusLabelAndMenuItem()
 }
 
 
-void 
+void
 PoorManWindow::UpdateHitsLabel()
 {
        if (Lock()) {
                sprintf(fHitsLabel, B_TRANSLATE("Hits: %lu"), GetHits());
                fHitsView->SetText(fHitsLabel);
-               
+
                Unlock();
        }
 }
 
 
-status_t 
+status_t
 PoorManWindow::SaveConsole(BMessage* message, bool selection)
 {
        entry_ref       ref;
@@ -498,25 +498,25 @@ PoorManWindow::SaveConsole(BMessage* message, bool 
selection)
        BEntry          entry;
        status_t        err = B_OK;
        FILE*           f;
-       
+
        err = message->FindRef("directory", &ref);
        if (err != B_OK)
                return err;
-       
+
        err = message->FindString("name", &name);
        if (err != B_OK)
                return err;
-       
+
        err = entry.SetTo(&ref);
        if (err != B_OK)
                return err;
-       
+
        entry.GetPath(&path);
        path.Append(name);
-       
+
        if (!(f = fopen(path.Path(), "w")))
                return B_ERROR;
-       
+
        if (!selection) {
                // write the data to the file
                err = fwrite(fLoggingView->Text(), 1, 
fLoggingView->TextLength(), f);
@@ -575,11 +575,11 @@ PoorManWindow::DefaultSettings()
                                break;
                        }
                        BAlert* dirCreatedAlert =
-                               new BAlert(B_TRANSLATE("Dir Created"), 
STR_DIR_CREATED, 
+                               new BAlert(B_TRANSLATE("Dir Created"), 
STR_DIR_CREATED,
                                        B_TRANSLATE("OK"));
                        dirCreatedAlert->SetFlags(dirCreatedAlert->Flags() | 
B_CLOSE_ON_ESCAPE);
                        dirCreatedAlert->Go();
-                       SetWebDir(STR_DEFAULT_WEB_DIRECTORY);   
+                       SetWebDir(STR_DEFAULT_WEB_DIRECTORY);
                        be_app->PostMessage(kStartServer);
                        break;
        }
@@ -592,21 +592,21 @@ PoorManWindow::ReadSettings()
        BPath p;
        BFile f;
        BMessage m;
-       
+
        if (find_directory(B_USER_SETTINGS_DIRECTORY, &p) != B_OK)
                return B_ERROR;
        p.Append(STR_SETTINGS_FILE_NAME);
-       
+
        f.SetTo(p.Path(), B_READ_ONLY);
        if (f.InitCheck() != B_OK)
                return B_ERROR;
-       
+
        if (m.Unflatten(&f) != B_OK)
                return B_ERROR;
-       
+
        if (MSG_PREF_FILE != m.what)
                return B_ERROR;
-       
+
        //site tab
        if (m.FindString("fWebDirectory", &fWebDirectory) != B_OK)
                fWebDirectory.SetTo(STR_DEFAULT_WEB_DIRECTORY);
@@ -614,7 +614,7 @@ PoorManWindow::ReadSettings()
                fIndexFileName.SetTo("index.html");
        if (m.FindBool("fDirListFlag", &fDirListFlag) != B_OK)
                fDirListFlag = false;
-       
+
        //logging tab
        if (m.FindBool("fLogConsoleFlag", &fLogConsoleFlag) != B_OK)
                fLogConsoleFlag = true;
@@ -622,11 +622,11 @@ PoorManWindow::ReadSettings()
                fLogFileFlag = false;
        if (m.FindString("fLogPath", &fLogPath) != B_OK)
                fLogPath.SetTo("");
-       
+
        //advance tab
        if (m.FindInt16("fMaxConnections", &fMaxConnections) != B_OK)
                fMaxConnections = (int16)32;
-       
+
        //windows' position and size
        if (m.FindRect("frame", &fFrame) != B_OK)
                fFrame.Set(82.0f, 30.0f, 400.0f, 350.0f);
@@ -638,10 +638,10 @@ PoorManWindow::ReadSettings()
                fLastWidth = 318.0f;
        if (m.FindFloat("fLastHeight", &fLastHeight) != B_OK)
                fLastHeight = 320.0f;
-       
+
        fIsZoomed?ResizeTo(fLastWidth, fLastHeight):ResizeTo(318, 53);
        MoveTo(fFrame.left, fFrame.top);
-       
+
        fLogFile = new BFile(fLogPath.String(), B_CREATE_FILE | B_WRITE_ONLY
                | B_OPEN_AT_END);
        if (fLogFile->InitCheck() != B_OK) {
@@ -649,9 +649,9 @@ PoorManWindow::ReadSettings()
                //log it to console, "log to file unavailable."
                return B_OK;
        }
-       
+
        SetDirLabel(fWebDirectory.String());
-       
+
        return B_OK;
 }
 
@@ -662,35 +662,35 @@ PoorManWindow::SaveSettings()
        BPath p;
        BFile f;
        BMessage m(MSG_PREF_FILE);
-               
+
        //site tab
        m.AddString("fWebDirectory", fWebDirectory);
        m.AddString("fIndexFileName", fIndexFileName);
        m.AddBool("fDirListFlag", fDirListFlag);
-       
+
        //logging tab
        m.AddBool("fLogConsoleFlag", fLogConsoleFlag);
        m.AddBool("fLogFileFlag", fLogFileFlag);
        m.AddString("fLogPath", fLogPath);
-       
+
        //advance tab
        m.AddInt16("fMaxConnections", fMaxConnections);
-       
+
        //windows' position and size
        m.AddRect("frame", fFrame);
        m.AddRect("fSetwindowFrame", fSetwindowFrame);
        m.AddBool("fIsZoomed", fIsZoomed);
        m.AddFloat("fLastWidth", fLastWidth);
        m.AddFloat("fLastHeight", fLastHeight);
-               
+
        if (find_directory(B_USER_SETTINGS_DIRECTORY, &p) != B_OK)
                return B_ERROR;
        p.Append(STR_SETTINGS_FILE_NAME);
-       
+
        f.SetTo(p.Path(), B_WRITE_ONLY | B_ERASE_FILE | B_CREATE_FILE);
        if (f.InitCheck() != B_OK)
                return B_ERROR;
-       
+
        if (m.Flatten(&f) != B_OK)
                return B_ERROR;
 
@@ -704,7 +704,7 @@ PoorManWindow::StartServer()
        if (fServer == NULL)
                fServer = new PoorManServer(fWebDirectory.String(), 
fMaxConnections,
                        fDirListFlag, fIndexFileName.String());
-       
+
        poorman_log(B_TRANSLATE("Starting up... "));
        if (fServer->Run() != B_OK) {
                return B_ERROR;
@@ -713,7 +713,7 @@ PoorManWindow::StartServer()
        fStatus = true;
        UpdateStatusLabelAndMenuItem();
        poorman_log(B_TRANSLATE("done.\n"), false, INADDR_NONE, GREEN);
-       
+
        return B_OK;
 }
 
@@ -723,7 +723,7 @@ PoorManWindow::StopServer()
 {
        if (fServer == NULL)
                return B_ERROR;
-       
+
        poorman_log(B_TRANSLATE("Shutting down.\n"));
        fServer->Stop();
        fStatus = false;
@@ -737,14 +737,14 @@ PoorManWindow::SetLogPath(const char* str)
 {
        if (!strcmp(fLogPath, str))
                return;
-       
+
        BFile* temp = new BFile(str, B_CREATE_FILE | B_WRITE_ONLY | 
B_OPEN_AT_END);
-       
+
        if (temp->InitCheck() != B_OK) {
                delete temp;
                return;
        }
-       
+
        if (pthread_rwlock_wrlock(&fLogFileLock) == 0) {
                delete fLogFile;
                fLogFile = temp;
@@ -753,6 +753,6 @@ PoorManWindow::SetLogPath(const char* str)
                delete temp;
                return;
        }
-       
+
        fLogPath.SetTo(str);
 }

############################################################################

Commit:      49a2d53d357c3ed6274799b5a3fcf0c0bbfa1766
URL:         http://cgit.haiku-os.org/haiku/commit/?id=49a2d53d357c
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Oct 22 07:23:21 2016 UTC

Ticket:      https://dev.haiku-os.org/ticket/5011

Magnify: Write an actual image for "save image", not a C++ data header.

I've no idea why this was what "save image" did, but apparently it's
done so since this code was imported into the trunk in the very first
commit. Now it saves PNGs, which is what users expect.

Fixes #5011.

----------------------------------------------------------------------------

diff --git a/src/apps/magnify/Jamfile b/src/apps/magnify/Jamfile
index 19aef1e..202c8fe 100644
--- a/src/apps/magnify/Jamfile
+++ b/src/apps/magnify/Jamfile
@@ -6,15 +6,15 @@ AddSubDirSupportedPlatforms libbe_test ;
 
 UsePrivateHeaders shared ;
 
-Application Magnify : 
-       Magnify.cpp 
-       : be game localestub [ TargetLibsupc++ ] tracker
+Application Magnify :
+       Magnify.cpp
+       : be game localestub [ TargetLibsupc++ ] tracker translation
        : Magnify.rdef
 ;
 
-DoCatalogs Magnify : 
+DoCatalogs Magnify :
        x-vnd.Haiku-Magnify
-       : 
+       :
        Magnify.cpp
 ;
 
diff --git a/src/apps/magnify/Magnify.cpp b/src/apps/magnify/Magnify.cpp
index f5bab51..784072e 100644
--- a/src/apps/magnify/Magnify.cpp
+++ b/src/apps/magnify/Magnify.cpp
@@ -12,6 +12,7 @@
 
 #include <Alert.h>
 #include <Bitmap.h>
+#include <BitmapStream.h>
 #include <Catalog.h>
 #include <Clipboard.h>
 #include <Debug.h>
@@ -22,11 +23,14 @@
 #include <MenuItem.h>
 #include <MenuField.h>
 #include <MessageFormat.h>
+#include <NodeInfo.h>
 #include <Path.h>
 #include <PopUpMenu.h>
 #include <Screen.h>
 #include <ScrollView.h>
 #include <TextView.h>
+#include <TranslationUtils.h>
+#include <TranslatorRoster.h>
 #include <WindowScreen.h>
 
 #include <stdio.h>
@@ -321,7 +325,7 @@ TWindow::MessageReceived(BMessage* m)
                        BMessage message(msg_dump);
                        fSavePanel = new BFilePanel(B_SAVE_PANEL, &messenger, 
0, 0, false,
                                &message);
-                       fSavePanel->SetSaveText("Bitmaps.h");
+                       fSavePanel->SetSaveText("Bitmaps.png");
                        fSavePanel->Show();
                }       break;
                case msg_dump:
@@ -1640,117 +1644,27 @@ TMagnify::EndSave()
 
 
 void
-TMagnify::SaveImage(entry_ref* ref, char* name, bool selectionOnly)
+TMagnify::SaveImage(entry_ref* ref, char* name)
 {
        // create a new file
        BFile file;
        BDirectory parentDir(ref);
        parentDir.CreateFile(name, &file);
 
-       // write off the bitmaps bits to the file
-       SaveBits(&file, fImageView->Bitmap(), "Data");
+       // Write the screenshot bitmap to the file
+       BBitmapStream stream(fImageView->Bitmap());
+       BTranslatorRoster* roster = BTranslatorRoster::Default();
+       roster->Translate(&stream, NULL, NULL, &file, B_PNG_FORMAT,
+               B_TRANSLATOR_BITMAP);
+
+       BBitmap* bitmap;
+       stream.DetachBitmap(&bitmap);
+               // The stream takes over ownership of the bitmap
 
        // unfreeze the image, image was frozen before invoke of FilePanel
        EndSave();
 }
 
-
-void
-TMagnify::SaveBits(BFile* file, const BBitmap *bitmap, const char* name) const
-{
-       int32 bytesPerPixel;
-       const char *kColorSpaceName;
-
-       switch (bitmap->ColorSpace()) {
-               case B_GRAY8:
-                       bytesPerPixel = 1;
-                       kColorSpaceName = "B_GRAY8";
-                       break;
-
-               case B_CMAP8:
-                       bytesPerPixel = 1;
-                       kColorSpaceName = "B_CMAP8";
-                       break;
-
-               case B_RGB15:
-               case B_RGBA15:
-               case B_RGB15_BIG:
-               case B_RGBA15_BIG:
-                       bytesPerPixel = 2;
-                       kColorSpaceName = "B_RGB15";
-                       break;
-
-               case B_RGB16:
-               case B_RGB16_BIG:
-                       bytesPerPixel = 2;
-                       kColorSpaceName = "B_RGB16";
-                       break;
-
-               case B_RGB32:
-               case B_RGBA32:
-               case B_RGBA32_BIG:
-               case B_BIG_RGB_32_BIT:
-                       bytesPerPixel = 3;
-                       kColorSpaceName = "B_RGB32";
-                       break;
-
-               default:
-                       printf("dump: usupported ColorSpace\n");
-                       return;
-       }
-
-       char str[1024];
-       // stream out the width, height and ColorSpace
-       sprintf(str, "const int32 k%sWidth = %" B_PRIi32 ";\n", name,
-               (int32)bitmap->Bounds().Width()+1);
-       file->Write(str, strlen(str));
-       sprintf(str, "const int32 k%sHeight = %" B_PRIi32 ";\n", name,
-               (int32)bitmap->Bounds().Height()+1);
-       file->Write(str, strlen(str));
-       sprintf(str, "const color_space k%sColorSpace = %s;\n\n", name,
-               kColorSpaceName);
-       file->Write(str, strlen(str));
-
-       // stream out the constant name for this array
-       sprintf(str, "const unsigned char k%sBits [] = {", name);
-       file->Write(str, strlen(str));
-
-       const unsigned char *bits = (const unsigned char *)bitmap->Bits();
-       const int32 kMaxColumnWidth = 16;
-       int32 bytesPerRow = bitmap->BytesPerRow();
-       int32 columnWidth = (bytesPerRow < kMaxColumnWidth) ? bytesPerRow : 
kMaxColumnWidth;
-
-       for (int32 remaining = bitmap->BitsLength(); remaining; ) {
-               sprintf(str, "\n\t");
-               file->Write(str, strlen(str));
-
-               //      stream out each row, based on the number of bytes 
required per row
-               //      padding is in the bitmap and will be streamed as 0xff
-               for (int32 column = 0; column < columnWidth; column++) {
-                       // stream out individual pixel components
-                       for (int32 count = 0; count < bytesPerPixel; count++) {
-                               --remaining;
-                               sprintf(str, "0x%02x", *bits++);
-                               file->Write(str, strlen(str));
-
-                               if (remaining) {
-                                       sprintf(str, ",");
-                                       file->Write(str, strlen(str));
-                               } else
-                                       break;
-                       }
-
-                       //      make sure we don't walk off the end of the bits 
array
-                       if (!remaining)
-                               break;
-               }
-       }
-
-       sprintf(str, "\n};\n\n");
-       file->Write(str, strlen(str));
-}
-
-
 //     #pragma mark -
 
 
diff --git a/src/apps/magnify/Magnify.h b/src/apps/magnify/Magnify.h
index ae19a71..c75b4d1 100644
--- a/src/apps/magnify/Magnify.h
+++ b/src/apps/magnify/Magnify.h
@@ -113,9 +113,7 @@ class TMagnify : public BView {
                bool                    ShowGrid();
 
                void                    StartSave();
-               void                    SaveImage(entry_ref* ref, char* name, 
bool selectionOnly=false);
-               void                    SaveBits(BFile* file, const BBitmap 
*bitmap,
-                                                       const char* name) const;
+               void                    SaveImage(entry_ref* ref, char* name);
                void                    EndSave();
 
        private:

############################################################################

Revision:    hrev50615
Commit:      3798bf90cb8e5e55b3b5ec15f22dbc0dd0735fd0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3798bf90cb8e
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Sat Oct 22 08:24:49 2016 UTC

Use the kDesktopWindowLook/kDesktopWindowFeel constants from WindowPrivate.h...

... instead of redefining them, or including a private Tracker header to
get them.

----------------------------------------------------------------------------

diff --git a/src/apps/login/DesktopWindow.cpp b/src/apps/login/DesktopWindow.cpp
index f28bd6c..374f838 100644
--- a/src/apps/login/DesktopWindow.cpp
+++ b/src/apps/login/DesktopWindow.cpp
@@ -14,6 +14,7 @@
 #include <Path.h>
 #include <Screen.h>
 #include <View.h>
+#include <WindowPrivate.h>
 
 #include "LoginApp.h"
 #include "DesktopWindow.h"
@@ -21,15 +22,11 @@
 #undef B_TRANSLATION_CONTEXT
 #define B_TRANSLATION_CONTEXT "Desktop Window"
 
-const window_feel kPrivateDesktopWindowFeel = window_feel(1024);
-const window_look kPrivateDesktopWindowLook = window_look(4);
-       // this is a mirror of an app server private values
-
 
 DesktopWindow::DesktopWindow(BRect frame, bool editMode)
-       : BWindow(frame, B_TRANSLATE("Desktop"), 
-               kPrivateDesktopWindowLook, 
-               kPrivateDesktopWindowFeel, 
+       : BWindow(frame, B_TRANSLATE("Desktop"),
+               kDesktopWindowLook,
+               kDesktopWindowFeel,
                B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE
                 | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE
                 | B_ASYNCHRONOUS_CONTROLS,
diff --git a/src/apps/login/Jamfile b/src/apps/login/Jamfile
index c3d0743..0290dcc 100644
--- a/src/apps/login/Jamfile
+++ b/src/apps/login/Jamfile
@@ -2,7 +2,7 @@ SubDir HAIKU_TOP src apps login ;
 
 SetSubDirSupportedPlatformsBeOSCompatible ;
 
-UsePrivateHeaders app ;
+UsePrivateHeaders app interface ;
 #UsePrivateHeaders shared ;
 #UsePrivateHeaders tracker ;
 #SubDirHdrs $(HAIKU_TOP) src kits tracker ;
diff --git a/src/kits/interface/ControlLook.cpp 
b/src/kits/interface/ControlLook.cpp
index 642d300..bc6f798 100644
--- a/src/kits/interface/ControlLook.cpp
+++ b/src/kits/interface/ControlLook.cpp
@@ -13,6 +13,7 @@
 
 #include <algorithm>
 
+#include <Bitmap.h>
 #include <Control.h>
 #include <GradientLinear.h>
 #include <LayoutUtils.h>
@@ -21,8 +22,7 @@
 #include <String.h>
 #include <View.h>
 #include <Window.h>
-
-#include "ContainerWindow.h"
+#include <WindowPrivate.h>
 
 
 namespace BPrivate {
@@ -1790,8 +1790,8 @@ BControlLook::DrawLabel(BView* view, const char* label, 
const rgb_color& base,
 
        BWindow* window = view->Window();
        bool isDesktop = window
-               && window->Feel() == kPrivateDesktopWindowFeel
-               && window->Look() == kPrivateDesktopWindowLook
+               && window->Feel() == kDesktopWindowFeel
+               && window->Look() == kDesktopWindowLook
                && view->Parent()
                && view->Parent()->Parent() == NULL
                && (flags & B_IGNORE_OUTLINE) == 0;
diff --git a/src/kits/tracker/ContainerWindow.cpp 
b/src/kits/tracker/ContainerWindow.cpp
index b838be1..c6f33d6 100644
--- a/src/kits/tracker/ContainerWindow.cpp
+++ b/src/kits/tracker/ContainerWindow.cpp
@@ -58,6 +58,7 @@ All rights reserved.
 #include <UnicodeChar.h>
 #include <Volume.h>
 #include <VolumeRoster.h>
+#include <WindowPrivate.h>
 
 #include <fs_attr.h>
 #include <image.h>
@@ -585,7 +586,7 @@ BContainerWindow::~BContainerWindow()
 BRect
 BContainerWindow::InitialWindowRect(window_feel feel)
 {
-       if (feel != kPrivateDesktopWindowFeel)
+       if (feel != kDesktopWindowFeel)
                return sNewWindRect;
 
        // do not offset desktop window
diff --git a/src/kits/tracker/ContainerWindow.h 
b/src/kits/tracker/ContainerWindow.h
index 58b8d20..39fd9a2 100644
--- a/src/kits/tracker/ContainerWindow.h
+++ b/src/kits/tracker/ContainerWindow.h
@@ -70,10 +70,6 @@ class SelectionWindow;
 
 extern const char* kAddOnsMenuName;
 
-const window_feel kPrivateDesktopWindowFeel = window_feel(1024);
-const window_look kPrivateDesktopWindowLook = window_look(4);
-       // this is a mirror of an app server private values
-
 
 enum {
        // flags that describe opening of the window
diff --git a/src/kits/tracker/DeskWindow.cpp b/src/kits/tracker/DeskWindow.cpp
index 808211c..9e35730 100644
--- a/src/kits/tracker/DeskWindow.cpp
+++ b/src/kits/tracker/DeskWindow.cpp
@@ -50,6 +50,7 @@ All rights reserved.
 #include <String.h>
 #include <StringList.h>
 #include <Volume.h>
+#include <WindowPrivate.h>
 
 #include <fcntl.h>
 #include <unistd.h>
@@ -186,8 +187,8 @@ LoadAddOnDir(BDirectory directory, BDeskWindow* window,
 
 BDeskWindow::BDeskWindow(LockingList<BWindow>* windowList)
        :
-       BContainerWindow(windowList, 0, kPrivateDesktopWindowLook,
-               kPrivateDesktopWindowFeel, B_NOT_MOVABLE | 
B_WILL_ACCEPT_FIRST_CLICK
+       BContainerWindow(windowList, 0, kDesktopWindowLook,
+               kDesktopWindowFeel, B_NOT_MOVABLE | B_WILL_ACCEPT_FIRST_CLICK
                        | B_NOT_ZOOMABLE | B_NOT_CLOSABLE | B_NOT_MINIMIZABLE
                        | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, 
B_ALL_WORKSPACES,
                        false, true),
diff --git a/src/kits/tracker/SelectionWindow.cpp 
b/src/kits/tracker/SelectionWindow.cpp
index 8d3a987..c87463e 100644
--- a/src/kits/tracker/SelectionWindow.cpp
+++ b/src/kits/tracker/SelectionWindow.cpp
@@ -39,6 +39,7 @@ All rights reserved.
 #include <Locale.h>
 #include <MenuItem.h>
 #include <MessageFilter.h>
+#include <WindowPrivate.h>
 
 #include "AutoLock.h"
 #include "ContainerWindow.h"
@@ -65,7 +66,7 @@ SelectionWindow::SelectionWindow(BContainerWindow* window)
                        | B_NOT_ANCHORED_ON_ACTIVATE),
        fParentWindow(window)
 {
-       if (window->Feel() & kPrivateDesktopWindowFeel) {
+       if (window->Feel() & kDesktopWindowFeel) {
                // The window will not show up if we have
                // B_FLOATING_SUBSET_WINDOW_FEEL and use it with the desktop 
window
                // since it's never in front.


Other related posts:

  • » [haiku-commits] haiku: hrev50615 - in src: apps/magnify apps/poorman kits/tracker apps/login kits/interface - waddlesplash