* Applied patch by Diver that lets Mail properly render vector icons for the

attachments, and adds a few missing translated strings. Thanks!
* Some cleanups by myself.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40495 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2011-02-14 20:58:14 +00:00
parent 34d56c1bf5
commit f97b68a1e0
4 changed files with 95 additions and 114 deletions
+6 -12
View File
@@ -870,29 +870,22 @@ TTextView::TTextView(BRect frame, BRect text, bool incoming,
fCursor(false), fCursor(false),
fFirstSpellMark(NULL) fFirstSpellMark(NULL)
{ {
BFont menuFont = *be_plain_font;
menuFont.SetSize(10);
fStopSem = create_sem(1, "reader_sem"); fStopSem = create_sem(1, "reader_sem");
SetStylable(true); SetStylable(true);
fEnclosures = new BList(); fEnclosures = new BList();
// // Enclosure pop up menu
// Enclosure pop up menu
//
fEnclosureMenu = new BPopUpMenu("Enclosure", false, false); fEnclosureMenu = new BPopUpMenu("Enclosure", false, false);
fEnclosureMenu->SetFont(&menuFont); fEnclosureMenu->SetFont(be_plain_font);
fEnclosureMenu->AddItem(new BMenuItem( fEnclosureMenu->AddItem(new BMenuItem(
B_TRANSLATE("Save attachment" B_UTF8_ELLIPSIS), new BMessage(M_SAVE))); B_TRANSLATE("Save attachment" B_UTF8_ELLIPSIS), new BMessage(M_SAVE)));
fEnclosureMenu->AddItem(new BMenuItem(B_TRANSLATE("Open attachment"), fEnclosureMenu->AddItem(new BMenuItem(B_TRANSLATE("Open attachment"),
new BMessage(M_OPEN))); new BMessage(M_OPEN)));
// // Hyperlink pop up menu
// Hyperlink pop up menu
//
fLinkMenu = new BPopUpMenu("Link", false, false); fLinkMenu = new BPopUpMenu("Link", false, false);
fLinkMenu->SetFont(&menuFont); fLinkMenu->SetFont(be_plain_font);
fLinkMenu->AddItem(new BMenuItem(B_TRANSLATE("Open this link"), fLinkMenu->AddItem(new BMenuItem(B_TRANSLATE("Open this link"),
new BMessage(M_OPEN))); new BMessage(M_OPEN)));
fLinkMenu->AddItem(new BMenuItem(B_TRANSLATE("Copy link location"), fLinkMenu->AddItem(new BMenuItem(B_TRANSLATE("Copy link location"),
@@ -1543,7 +1536,8 @@ TTextView::MouseDown(BPoint where)
delete string; delete string;
} }
} else { } else {
(menuItem = new BMenuItem("No matches", NULL))->SetEnabled(false); menuItem = new BMenuItem(B_TRANSLATE("No matches"), NULL);
menuItem->SetEnabled(false);
menu.AddItem(menuItem); menu.AddItem(menuItem);
} }
+42 -43
View File
@@ -123,11 +123,35 @@ GetTrackerIcon(BMimeType &type, BBitmap *icon, icon_size iconSize)
} }
static void
recursive_attachment_search(TEnclosuresView* us, BMailContainer* mail,
BMailComponent *body)
{
if (mail == NULL)
return;
for (int32 i = 0; i < mail->CountComponents(); i++) {
BMailComponent *component = mail->GetComponent(i);
if (component == body)
continue;
if (component->ComponentType() == B_MAIL_MULTIPART_CONTAINER) {
recursive_attachment_search(us,
dynamic_cast<BMIMEMultipartMailContainer *>(component), body);
}
us->fList->AddItem(new TListItem(component));
}
}
// #pragma mark - // #pragma mark -
TEnclosuresView::TEnclosuresView(BRect rect, BRect wind_rect) TEnclosuresView::TEnclosuresView(BRect rect, BRect windowRect)
: BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW), :
BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT,
B_WILL_DRAW),
fFocus(false) fFocus(false)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -142,7 +166,7 @@ TEnclosuresView::TEnclosuresView(BRect rect, BRect wind_rect)
r.left = ENCLOSE_TEXT_H + font.StringWidth( r.left = ENCLOSE_TEXT_H + font.StringWidth(
B_TRANSLATE("Attachments: ")) + 5; B_TRANSLATE("Attachments: ")) + 5;
r.top = ENCLOSE_FIELD_V; r.top = ENCLOSE_FIELD_V;
r.right = wind_rect.right - wind_rect.left - B_V_SCROLL_BAR_WIDTH - 9; r.right = windowRect.right - windowRect.left - B_V_SCROLL_BAR_WIDTH - 9;
r.bottom = Frame().Height() - 8; r.bottom = Frame().Height() - 8;
fList = new TListView(r, this); fList = new TListView(r, this);
fList->SetInvocationMessage(new BMessage(LIST_INVOKED)); fList->SetInvocationMessage(new BMessage(LIST_INVOKED));
@@ -348,22 +372,6 @@ TEnclosuresView::Focus(bool focus)
} }
static void recursive_attachment_search(TEnclosuresView *us,BMailContainer *mail,BMailComponent *body) {
if (mail == NULL)
return;
for (int32 i = 0; i < mail->CountComponents(); i++)
{
BMailComponent *component = mail->GetComponent(i);
if (component == body)
continue;
if (component->ComponentType() == B_MAIL_MULTIPART_CONTAINER)
recursive_attachment_search(us,dynamic_cast<BMIMEMultipartMailContainer *>(component),body);
us->fList->AddItem(new TListItem(component));
}
}
void void
TEnclosuresView::AddEnclosuresFromMail(BEmailMessage *mail) TEnclosuresView::AddEnclosuresFromMail(BEmailMessage *mail)
{ {
@@ -381,12 +389,13 @@ TEnclosuresView::AddEnclosuresFromMail(BEmailMessage *mail)
} }
//====================================================================
// #pragma mark - // #pragma mark -
TListView::TListView(BRect rect, TEnclosuresView *view) TListView::TListView(BRect rect, TEnclosuresView *view)
: BListView(rect, "", B_MULTIPLE_SELECTION_LIST, B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT), :
BListView(rect, "", B_MULTIPLE_SELECTION_LIST,
B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT),
fParent(view) fParent(view)
{ {
} }
@@ -415,15 +424,11 @@ void
TListView::MouseDown(BPoint point) TListView::MouseDown(BPoint point)
{ {
int32 buttons; int32 buttons;
Looper()->CurrentMessage()->FindInt32("buttons",&buttons); Looper()->CurrentMessage()->FindInt32("buttons", &buttons);
if (buttons & B_SECONDARY_MOUSE_BUTTON)
{
BFont font = *be_plain_font;
font.SetSize(10);
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
BPopUpMenu menu("enclosure", false, false); BPopUpMenu menu("enclosure", false, false);
menu.SetFont(&font); menu.SetFont(be_plain_font);
menu.AddItem(new BMenuItem(B_TRANSLATE("Open attachment"), menu.AddItem(new BMenuItem(B_TRANSLATE("Open attachment"),
new BMessage(LIST_INVOKED))); new BMessage(LIST_INVOKED)));
menu.AddItem(new BMenuItem(B_TRANSLATE("Remove attachment"), menu.AddItem(new BMenuItem(B_TRANSLATE("Remove attachment"),
@@ -431,24 +436,19 @@ TListView::MouseDown(BPoint point)
BPoint menuStart = ConvertToScreen(point); BPoint menuStart = ConvertToScreen(point);
BMenuItem *item; BMenuItem* item = menu.Go(menuStart);
if ((item = menu.Go(menuStart)) != NULL) if (item != NULL) {
{ if (item->Command() == LIST_INVOKED) {
if (item->Command() == LIST_INVOKED)
{
BMessage msg(LIST_INVOKED); BMessage msg(LIST_INVOKED);
msg.AddPointer("source",this); msg.AddPointer("source",this);
msg.AddInt32("index",IndexOf(point)); msg.AddInt32("index",IndexOf(point));
Window()->PostMessage(&msg,fParent); Window()->PostMessage(&msg,fParent);
} } else {
else
{
Select(IndexOf(point)); Select(IndexOf(point));
Window()->PostMessage(item->Command(),fParent); Window()->PostMessage(item->Command(),fParent);
} }
} }
} } else
else
BListView::MouseDown(point); BListView::MouseDown(point);
} }
@@ -463,7 +463,6 @@ TListView::KeyDown(const char *bytes, int32 numBytes)
} }
//====================================================================
// #pragma mark - // #pragma mark -
@@ -529,10 +528,10 @@ TListItem::DrawItem(BView *owner, BRect r, bool /* complete */)
BRect iconRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1); BRect iconRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1);
BBitmap bitmap(iconRect, B_COLOR_8_BIT); BBitmap bitmap(iconRect, B_RGBA32);
if (GetTrackerIcon(type, &bitmap, B_MINI_ICON) == B_NO_ERROR) { if (GetTrackerIcon(type, &bitmap, B_MINI_ICON) == B_NO_ERROR) {
BRect rect(r.left + 4, r.top + 1, r.left + 4 + 15, r.top + 1 + 15); BRect rect(r.left + 4, r.top + 1, r.left + 4 + 15, r.top + 1 + 15);
owner->SetDrawingMode(B_OP_OVER); owner->SetDrawingMode(B_OP_ALPHA);
owner->DrawBitmap(&bitmap, iconRect, rect); owner->DrawBitmap(&bitmap, iconRect, rect);
owner->SetDrawingMode(B_OP_COPY); owner->SetDrawingMode(B_OP_COPY);
} else { } else {
@@ -552,10 +551,10 @@ TListItem::DrawItem(BView *owner, BRect r, bool /* complete */)
BNodeInfo info(&file); BNodeInfo info(&file);
BRect sr(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1); BRect sr(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1);
BBitmap bitmap(sr, B_COLOR_8_BIT); BBitmap bitmap(sr, B_RGBA32);
if (info.GetTrackerIcon(&bitmap, B_MINI_ICON) == B_NO_ERROR) { if (info.GetTrackerIcon(&bitmap, B_MINI_ICON) == B_NO_ERROR) {
BRect dr(r.left + 4, r.top + 1, r.left + 4 + 15, r.top + 1 + 15); BRect dr(r.left + 4, r.top + 1, r.left + 4 + 15, r.top + 1 + 15);
owner->SetDrawingMode(B_OP_OVER); owner->SetDrawingMode(B_OP_ALPHA);
owner->DrawBitmap(&bitmap, sr, dr); owner->DrawBitmap(&bitmap, sr, dr);
owner->SetDrawingMode(B_OP_COPY); owner->SetDrawingMode(B_OP_COPY);
} }
+45 -57
View File
@@ -31,16 +31,10 @@ of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders. names are registered trademarks or trademarks of their respective holders.
All rights reserved. All rights reserved.
*/ */
//--------------------------------------------------------------------
//
// Enclosures.h
//
//--------------------------------------------------------------------
#ifndef _ENCLOSURES_H #ifndef _ENCLOSURES_H
#define _ENCLOSURES_H #define _ENCLOSURES_H
#include <Box.h> #include <Box.h>
#include <File.h> #include <File.h>
#include <ListView.h> #include <ListView.h>
@@ -54,77 +48,71 @@ All rights reserved.
#include <MailMessage.h> #include <MailMessage.h>
#define ENCLOSURES_HEIGHT 65
#define ENCLOSE_TEXT "Attachments:" #define ENCLOSURES_HEIGHT 65
#define ENCLOSE_TEXT_H 7
#define ENCLOSE_TEXT_V 3 #define ENCLOSE_TEXT B_TRANSLATE_WITH_CONTEXT("Attachments:", "Mail")
#define ENCLOSE_FIELD_V 3 #define ENCLOSE_TEXT_H 7
#define ENCLOSE_TEXT_V 3
#define ENCLOSE_FIELD_V 3
class TListView; class TListView;
class TMailWindow; class TMailWindow;
class TScrollView; class TScrollView;
//==================================================================== class TEnclosuresView : public BView {
public:
TEnclosuresView(BRect rect, BRect windowRect);
virtual ~TEnclosuresView();
class TEnclosuresView : public BView virtual void Draw(BRect updateRect);
{ virtual void MessageReceived(BMessage* message);
public: void Focus(bool focus);
TEnclosuresView(BRect, BRect); void AddEnclosuresFromMail(BEmailMessage* mail);
~TEnclosuresView();
virtual void Draw(BRect); TListView* fList;
virtual void MessageReceived(BMessage*);
void Focus(bool);
void AddEnclosuresFromMail(BEmailMessage *mail);
TListView *fList; private:
bool fFocus;
private: float fOffset;
bool fFocus; TMailWindow* fWindow;
float fOffset;
TMailWindow *fWindow;
}; };
//==================================================================== class TListView : public BListView {
public:
TListView(BRect rect, TEnclosuresView* view);
class TListView : public BListView virtual void AttachedToWindow();
{ virtual void MakeFocus(bool focus);
public: virtual void MouseDown(BPoint point);
TListView(BRect, TEnclosuresView *); virtual void KeyDown(const char* bytes,int32 numBytes);
virtual void AttachedToWindow(); private:
virtual void MakeFocus(bool); TEnclosuresView* fParent;
virtual void MouseDown(BPoint point);
virtual void KeyDown(const char *bytes,int32 numBytes);
private:
TEnclosuresView *fParent;
}; };
//==================================================================== class TListItem : public BListItem {
public:
TListItem(entry_ref* ref);
TListItem(BMailComponent* component);
class TListItem : public BListItem virtual void DrawItem(BView* owner, BRect rect,
{ bool complete);
public: virtual void Update(BView* owner, const BFont* font);
TListItem(entry_ref *);
TListItem(BMailComponent *);
virtual void DrawItem(BView *, BRect, bool); BMailComponent* Component() { return fComponent; };
virtual void Update(BView *, const BFont *); entry_ref* Ref() { return &fRef; }
node_ref* NodeRef() { return &fNodeRef; }
BMailComponent *Component() { return fComponent; }; private:
entry_ref *Ref() { return &fRef; } BMailComponent* fComponent;
node_ref *NodeRef() { return &fNodeRef; } entry_ref fRef;
node_ref fNodeRef;
private:
BMailComponent *fComponent;
entry_ref fRef;
node_ref fNodeRef;
}; };
#endif // #ifndef _ENCLOSURES_H
#endif // _ENCLOSURES_H
+2 -2
View File
@@ -77,7 +77,7 @@ using namespace BPrivate;
using std::map; using std::map;
const char* kDateLabel = "Date:"; const char* kDateLabel = B_TRANSLATE("Date:");
const uint32 kMsgFrom = 'hFrm'; const uint32 kMsgFrom = 'hFrm';
const uint32 kMsgEncoding = 'encd'; const uint32 kMsgEncoding = 'encd';
const uint32 kMsgAddressChosen = 'acsn'; const uint32 kMsgAddressChosen = 'acsn';
@@ -234,7 +234,7 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
fEncodingMenu->AddSeparatorItem(); fEncodingMenu->AddSeparatorItem();
msg = new BMessage(kMsgEncoding); msg = new BMessage(kMsgEncoding);
msg->AddInt32("charset", B_MAIL_NULL_CONVERSION); msg->AddInt32("charset", B_MAIL_NULL_CONVERSION);
fEncodingMenu->AddItem(item = new BMenuItem("Automatic", msg)); fEncodingMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Automatic"), msg));
if (!markedCharSet) if (!markedCharSet)
item->SetMarked(true); item->SetMarked(true);
} }