hrev45170 adds 4 changesets to branch 'master' old head: c45e8003d32dfa75fb3ed160b10fe818e875ef10 new head: 20cbdcd16648f6b2a0add3374f00380249789d45 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=20cbdcd+%5Ec45e800 ---------------------------------------------------------------------------- 8a85cd4: StyledEdit::StatusView Encoding context menu implemented 29155ba: StyledEdit::StatusView: prevent duplicating context menu ad834f7: StyledEdit:EncodingMenu: autodetect on root menu entry 20cbdcd: StyledEdit::StatusView:No stretching for pos cell only [ Siarzhuk Zharski <zharik@xxxxxx> ] ---------------------------------------------------------------------------- 4 files changed, 46 insertions(+), 26 deletions(-) src/apps/stylededit/StatusView.cpp | 36 ++++++++++++++++++---------- src/apps/stylededit/StatusView.h | 1 + src/apps/stylededit/StyledEditWindow.cpp | 32 +++++++++++++++---------- src/apps/stylededit/StyledEditWindow.h | 3 ++- ############################################################################ Commit: 8a85cd4ce8e1d53e676e7abbd4fa016001f4489c URL: http://cgit.haiku-os.org/haiku/commit/?id=8a85cd4 Author: Siarzhuk Zharski <zharik@xxxxxx> Date: Wed Jan 16 13:51:41 2013 UTC StyledEdit::StatusView Encoding context menu implemented ---------------------------------------------------------------------------- diff --git a/src/apps/stylededit/StatusView.cpp b/src/apps/stylededit/StatusView.cpp index edd3d98..4d65f7c 100644 --- a/src/apps/stylededit/StatusView.cpp +++ b/src/apps/stylededit/StatusView.cpp @@ -26,6 +26,7 @@ #include <Window.h> #include "Constants.h" +#include "StyledEditWindow.h" const float kHorzSpacing = 5.f; @@ -158,17 +159,19 @@ StatusView::MouseDown(BPoint where) if (!fReadOnly) return; - float left = fCellWidth[kPositionCell] + fCellWidth[kEncodingCell]; - if (where.x < left) + if (where.x < fCellWidth[kPositionCell]) return; + BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); + float left = fCellWidth[kPositionCell] + fCellWidth[kEncodingCell]; + if (where.x < left) + StyledEditWindow::PopulateEncodingMenu(menu, fEncoding); + else + menu->AddItem(new BMenuItem(B_TRANSLATE("Unlock file"), + new BMessage(UNLOCK_FILE))); where.x = left; where.y = Bounds().bottom; - BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); - menu->AddItem(new BMenuItem(B_TRANSLATE("Unlock file"), - new BMessage(UNLOCK_FILE))); - ConvertToScreen(&where); menu->SetTargetForItems(this); menu->Go(where, true, true, true); @@ -188,20 +191,21 @@ StatusView::SetStatus(BMessage* message) fCellText[kPositionCell].SetTo(info); } - BString encoding; - if (B_OK == message->FindString("encoding", &encoding)) { + if (B_OK == message->FindString("encoding", &fEncoding)) { // sometime corresponding Int-32 "encoding" attrib is read as string :( - if (encoding.Length() == 0 - || encoding.Compare("\xff\xff") == 0 - || encoding.Compare("UTF-8") == 0) + if (fEncoding.Length() == 0 + || fEncoding.Compare("\xff\xff") == 0 + || fEncoding.Compare("UTF-8") == 0) { fCellText[kEncodingCell] = "UTF-8"; + fEncoding.Truncate(0); } else { const BCharacterSet* charset - = BCharacterSetRoster::FindCharacterSetByName(encoding); + = BCharacterSetRoster::FindCharacterSetByName(fEncoding); fCellText[kEncodingCell] = charset != NULL ? charset->GetPrintName() : ""; } + fCellText[kEncodingCell] << " " UTF8_EXPAND_ARROW; } bool modified = false; diff --git a/src/apps/stylededit/StatusView.h b/src/apps/stylededit/StatusView.h index fcf542f..80f92b5 100644 --- a/src/apps/stylededit/StatusView.h +++ b/src/apps/stylededit/StatusView.h @@ -45,6 +45,7 @@ private: BString fCellText[kStatusCellCount]; float fCellWidth[kStatusCellCount]; bool fReadOnly; + BString fEncoding; }; #endif // STATUS_VIEW_H diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp index 9e08d4f..7732017 100644 --- a/src/apps/stylededit/StyledEditWindow.cpp +++ b/src/apps/stylededit/StyledEditWindow.cpp @@ -287,8 +287,8 @@ StyledEditWindow::MessageReceived(BMessage* message) case MSG_REPLACE_ALL: { message->FindBool("casesens", &fCaseSensitive); - message->FindString("FindText",&fStringToFind); - message->FindString("ReplaceText",&fReplaceString); + message->FindString("FindText", &fStringToFind); + message->FindString("ReplaceText", &fReplaceString); bool allWindows; message->FindBool("allwindows", &allWindows); @@ -1291,7 +1291,9 @@ StyledEditWindow::_InitWindow(uint32 encoding) fWrapItem->SetMarked(true); fWrapItem->SetShortcut('W', B_OPTION_KEY); - menu->AddItem(fEncodingItem = _MakeEncodingMenuItem()); + menu->AddItem(fEncodingItem = new BMenuItem(PopulateEncodingMenu( + new BMenu(B_TRANSLATE("Text encoding")), "UTF-8"), + new BMessage(MENU_RELOAD))); fEncodingItem->SetEnabled(false); menu->AddSeparatorItem(); @@ -1564,7 +1566,7 @@ StyledEditWindow::_UnlockFile() status_t status = dir.InitCheck(); if (status != B_OK) return status; - + status = entry.InitCheck(); if (status != B_OK) return status; @@ -1578,7 +1580,7 @@ StyledEditWindow::_UnlockFile() status = file.GetStat(&st); if (status != B_OK) return status; - + st.st_mode |= S_IWUSR; status = file.SetPermissions(st.st_mode); if (status == B_OK) @@ -1882,10 +1884,13 @@ StyledEditWindow::_ShowAlert(const BString& text, const BString& label, } -BMenuItem* -StyledEditWindow::_MakeEncodingMenuItem() +BMenu* +StyledEditWindow::PopulateEncodingMenu(BMenu* menu, const char* currentEncoding) { - BMenu* menu = new BMenu(B_TRANSLATE("Text encoding")); + menu->SetRadioMode(true); + BString encoding(currentEncoding); + if (encoding.Length() == 0) + encoding.SetTo("UTF-8"); BCharacterSetRoster roster; BCharacterSet charset; @@ -1899,7 +1904,10 @@ StyledEditWindow::_MakeEncodingMenuItem() BMessage *message = new BMessage(MENU_RELOAD); if (message != NULL) { message->AddString("encoding", charset.GetName()); - menu->AddItem(new BMenuItem(name, message)); + BMenuItem* item = new BMenuItem(name, message); + if (encoding.Compare(charset.GetName()) == 0) + item->SetMarked(true); + menu->AddItem(item); } } @@ -1908,9 +1916,7 @@ StyledEditWindow::_MakeEncodingMenuItem() message->AddString("encoding", "auto"); menu->AddItem(new BMenuItem(B_TRANSLATE("Autodetect"), message)); - menu->SetRadioMode(true); - - return new BMenuItem(menu, new BMessage(MENU_RELOAD)); + return menu; } diff --git a/src/apps/stylededit/StyledEditWindow.h b/src/apps/stylededit/StyledEditWindow.h index ae8aac3..af8dc04 100644 --- a/src/apps/stylededit/StyledEditWindow.h +++ b/src/apps/stylededit/StyledEditWindow.h @@ -49,9 +49,10 @@ public: bool caseSensitive); bool IsDocumentEntryRef(const entry_ref* ref); + static BMenu* PopulateEncodingMenu(BMenu* menu, + const char* encoding); private: void _InitWindow(uint32 encoding = 0); - BMenuItem* _MakeEncodingMenuItem(); void _LoadAttrs(); void _SaveAttrs(); status_t _LoadFile(entry_ref* ref, ############################################################################ Commit: 29155ba4de03e767c1a9c9baac71ee51660087d4 URL: http://cgit.haiku-os.org/haiku/commit/?id=29155ba Author: Siarzhuk Zharski <zharik@xxxxxx> Date: Wed Jan 16 13:58:12 2013 UTC StyledEdit::StatusView: prevent duplicating context menu ---------------------------------------------------------------------------- diff --git a/src/apps/stylededit/StatusView.cpp b/src/apps/stylededit/StatusView.cpp index 4d65f7c..30bf0f9 100644 --- a/src/apps/stylededit/StatusView.cpp +++ b/src/apps/stylededit/StatusView.cpp @@ -162,6 +162,12 @@ StatusView::MouseDown(BPoint where) if (where.x < fCellWidth[kPositionCell]) return; + int32 clicks = 0; + BMessage* message = Window()->CurrentMessage(); + if (message != NULL + && message->FindInt32("clicks", &clicks) == B_OK && clicks > 1) + return; + BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false); float left = fCellWidth[kPositionCell] + fCellWidth[kEncodingCell]; if (where.x < left) ############################################################################ Commit: ad834f7320d508dc5991adcef2f10e3fd37fca9d URL: http://cgit.haiku-os.org/haiku/commit/?id=ad834f7 Author: Siarzhuk Zharski <zharik@xxxxxx> Date: Fri Jan 18 15:09:01 2013 UTC StyledEdit:EncodingMenu: autodetect on root menu entry ---------------------------------------------------------------------------- diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp index 7732017..03b79a3 100644 --- a/src/apps/stylededit/StyledEditWindow.cpp +++ b/src/apps/stylededit/StyledEditWindow.cpp @@ -1291,9 +1291,11 @@ StyledEditWindow::_InitWindow(uint32 encoding) fWrapItem->SetMarked(true); fWrapItem->SetShortcut('W', B_OPTION_KEY); + BMessage *message = new BMessage(MENU_RELOAD); + message->AddString("encoding", "auto"); menu->AddItem(fEncodingItem = new BMenuItem(PopulateEncodingMenu( new BMenu(B_TRANSLATE("Text encoding")), "UTF-8"), - new BMessage(MENU_RELOAD))); + message)); fEncodingItem->SetEnabled(false); menu->AddSeparatorItem(); ############################################################################ Revision: hrev45170 Commit: 20cbdcd16648f6b2a0add3374f00380249789d45 URL: http://cgit.haiku-os.org/haiku/commit/?id=20cbdcd Author: Siarzhuk Zharski <zharik@xxxxxx> Date: Wed Jan 16 16:38:45 2013 UTC StyledEdit::StatusView:No stretching for pos cell only ---------------------------------------------------------------------------- diff --git a/src/apps/stylededit/StatusView.cpp b/src/apps/stylededit/StatusView.cpp index 30bf0f9..a6bdfcc 100644 --- a/src/apps/stylededit/StatusView.cpp +++ b/src/apps/stylededit/StatusView.cpp @@ -243,7 +243,7 @@ StatusView::_ValidatePreferredSize() float width = ceilf(StringWidth(fCellText[i])); if (width > 0) width += kHorzSpacing * 2; - if (width > fCellWidth[i]) + if (width > fCellWidth[i] || i != kPositionCell) fCellWidth[i] = width; fPreferredSize.width += fCellWidth[i]; }