* 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

View File

@ -870,29 +870,22 @@ TTextView::TTextView(BRect frame, BRect text, bool incoming,
fCursor(false),
fFirstSpellMark(NULL)
{
BFont menuFont = *be_plain_font;
menuFont.SetSize(10);
fStopSem = create_sem(1, "reader_sem");
SetStylable(true);
fEnclosures = new BList();
//
// Enclosure pop up menu
//
// Enclosure pop up menu
fEnclosureMenu = new BPopUpMenu("Enclosure", false, false);
fEnclosureMenu->SetFont(&menuFont);
fEnclosureMenu->SetFont(be_plain_font);
fEnclosureMenu->AddItem(new BMenuItem(
B_TRANSLATE("Save attachment" B_UTF8_ELLIPSIS), new BMessage(M_SAVE)));
fEnclosureMenu->AddItem(new BMenuItem(B_TRANSLATE("Open attachment"),
new BMessage(M_OPEN)));
//
// Hyperlink pop up menu
//
// Hyperlink pop up menu
fLinkMenu = new BPopUpMenu("Link", false, false);
fLinkMenu->SetFont(&menuFont);
fLinkMenu->SetFont(be_plain_font);
fLinkMenu->AddItem(new BMenuItem(B_TRANSLATE("Open this link"),
new BMessage(M_OPEN)));
fLinkMenu->AddItem(new BMenuItem(B_TRANSLATE("Copy link location"),
@ -1543,7 +1536,8 @@ TTextView::MouseDown(BPoint where)
delete string;
}
} else {
(menuItem = new BMenuItem("No matches", NULL))->SetEnabled(false);
menuItem = new BMenuItem(B_TRANSLATE("No matches"), NULL);
menuItem->SetEnabled(false);
menu.AddItem(menuItem);
}

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 -
TEnclosuresView::TEnclosuresView(BRect rect, BRect wind_rect)
: BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW),
TEnclosuresView::TEnclosuresView(BRect rect, BRect windowRect)
:
BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT,
B_WILL_DRAW),
fFocus(false)
{
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(
B_TRANSLATE("Attachments: ")) + 5;
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;
fList = new TListView(r, this);
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
TEnclosuresView::AddEnclosuresFromMail(BEmailMessage *mail)
{
@ -381,12 +389,13 @@ TEnclosuresView::AddEnclosuresFromMail(BEmailMessage *mail)
}
//====================================================================
// #pragma mark -
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)
{
}
@ -415,15 +424,11 @@ void
TListView::MouseDown(BPoint point)
{
int32 buttons;
Looper()->CurrentMessage()->FindInt32("buttons",&buttons);
if (buttons & B_SECONDARY_MOUSE_BUTTON)
{
BFont font = *be_plain_font;
font.SetSize(10);
Looper()->CurrentMessage()->FindInt32("buttons", &buttons);
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
BPopUpMenu menu("enclosure", false, false);
menu.SetFont(&font);
menu.SetFont(be_plain_font);
menu.AddItem(new BMenuItem(B_TRANSLATE("Open attachment"),
new BMessage(LIST_INVOKED)));
menu.AddItem(new BMenuItem(B_TRANSLATE("Remove attachment"),
@ -431,24 +436,19 @@ TListView::MouseDown(BPoint point)
BPoint menuStart = ConvertToScreen(point);
BMenuItem *item;
if ((item = menu.Go(menuStart)) != NULL)
{
if (item->Command() == LIST_INVOKED)
{
BMenuItem* item = menu.Go(menuStart);
if (item != NULL) {
if (item->Command() == LIST_INVOKED) {
BMessage msg(LIST_INVOKED);
msg.AddPointer("source",this);
msg.AddInt32("index",IndexOf(point));
Window()->PostMessage(&msg,fParent);
}
else
{
} else {
Select(IndexOf(point));
Window()->PostMessage(item->Command(),fParent);
}
}
}
else
} else
BListView::MouseDown(point);
}
@ -463,7 +463,6 @@ TListView::KeyDown(const char *bytes, int32 numBytes)
}
//====================================================================
// #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);
BBitmap bitmap(iconRect, B_COLOR_8_BIT);
BBitmap bitmap(iconRect, B_RGBA32);
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);
owner->SetDrawingMode(B_OP_OVER);
owner->SetDrawingMode(B_OP_ALPHA);
owner->DrawBitmap(&bitmap, iconRect, rect);
owner->SetDrawingMode(B_OP_COPY);
} else {
@ -552,10 +551,10 @@ TListItem::DrawItem(BView *owner, BRect r, bool /* complete */)
BNodeInfo info(&file);
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) {
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->SetDrawingMode(B_OP_COPY);
}

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.
All rights reserved.
*/
//--------------------------------------------------------------------
//
// Enclosures.h
//
//--------------------------------------------------------------------
#ifndef _ENCLOSURES_H
#define _ENCLOSURES_H
#include <Box.h>
#include <File.h>
#include <ListView.h>
@ -54,77 +48,71 @@ All rights reserved.
#include <MailMessage.h>
#define ENCLOSURES_HEIGHT 65
#define ENCLOSE_TEXT "Attachments:"
#define ENCLOSE_TEXT_H 7
#define ENCLOSE_TEXT_V 3
#define ENCLOSE_FIELD_V 3
#define ENCLOSURES_HEIGHT 65
#define ENCLOSE_TEXT B_TRANSLATE_WITH_CONTEXT("Attachments:", "Mail")
#define ENCLOSE_TEXT_H 7
#define ENCLOSE_TEXT_V 3
#define ENCLOSE_FIELD_V 3
class TListView;
class TMailWindow;
class TScrollView;
//====================================================================
class TEnclosuresView : public BView {
public:
TEnclosuresView(BRect rect, BRect windowRect);
virtual ~TEnclosuresView();
class TEnclosuresView : public BView
{
public:
TEnclosuresView(BRect, BRect);
~TEnclosuresView();
virtual void Draw(BRect updateRect);
virtual void MessageReceived(BMessage* message);
void Focus(bool focus);
void AddEnclosuresFromMail(BEmailMessage* mail);
virtual void Draw(BRect);
virtual void MessageReceived(BMessage*);
void Focus(bool);
void AddEnclosuresFromMail(BEmailMessage *mail);
TListView* fList;
TListView *fList;
private:
bool fFocus;
float fOffset;
TMailWindow *fWindow;
private:
bool fFocus;
float fOffset;
TMailWindow* fWindow;
};
//====================================================================
class TListView : public BListView {
public:
TListView(BRect rect, TEnclosuresView* view);
class TListView : public BListView
{
public:
TListView(BRect, TEnclosuresView *);
virtual void AttachedToWindow();
virtual void MakeFocus(bool focus);
virtual void MouseDown(BPoint point);
virtual void KeyDown(const char* bytes,int32 numBytes);
virtual void AttachedToWindow();
virtual void MakeFocus(bool);
virtual void MouseDown(BPoint point);
virtual void KeyDown(const char *bytes,int32 numBytes);
private:
TEnclosuresView *fParent;
private:
TEnclosuresView* fParent;
};
//====================================================================
class TListItem : public BListItem {
public:
TListItem(entry_ref* ref);
TListItem(BMailComponent* component);
class TListItem : public BListItem
{
public:
TListItem(entry_ref *);
TListItem(BMailComponent *);
virtual void DrawItem(BView* owner, BRect rect,
bool complete);
virtual void Update(BView* owner, const BFont* font);
virtual void DrawItem(BView *, BRect, bool);
virtual void Update(BView *, const BFont *);
BMailComponent* Component() { return fComponent; };
entry_ref* Ref() { return &fRef; }
node_ref* NodeRef() { return &fNodeRef; }
BMailComponent *Component() { return fComponent; };
entry_ref *Ref() { return &fRef; }
node_ref *NodeRef() { return &fNodeRef; }
private:
BMailComponent *fComponent;
entry_ref fRef;
node_ref fNodeRef;
private:
BMailComponent* fComponent;
entry_ref fRef;
node_ref fNodeRef;
};
#endif // #ifndef _ENCLOSURES_H
#endif // _ENCLOSURES_H

View File

@ -77,7 +77,7 @@ using namespace BPrivate;
using std::map;
const char* kDateLabel = "Date:";
const char* kDateLabel = B_TRANSLATE("Date:");
const uint32 kMsgFrom = 'hFrm';
const uint32 kMsgEncoding = 'encd';
const uint32 kMsgAddressChosen = 'acsn';
@ -234,7 +234,7 @@ THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
fEncodingMenu->AddSeparatorItem();
msg = new BMessage(kMsgEncoding);
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)
item->SetMarked(true);
}