* Style cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42258 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2011-06-19 22:03:49 +00:00
parent 4a135b33b7
commit ab383924fc
2 changed files with 66 additions and 50 deletions

View File

@ -1,9 +1,11 @@
/*
* Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved.
*/
#ifndef ZOIDBERG_GARGOYLE_MAIL_UTIL_H #ifndef ZOIDBERG_GARGOYLE_MAIL_UTIL_H
#define ZOIDBERG_GARGOYLE_MAIL_UTIL_H #define ZOIDBERG_GARGOYLE_MAIL_UTIL_H
/* mail util - header parsing
**
** Copyright 2001-2003 Dr. Zoidberg Enterprises. All rights reserved. //! Header parsing utilities
*/
#include <stdio.h> #include <stdio.h>
@ -13,7 +15,7 @@
#include <E-mail.h> #include <E-mail.h>
#define R5_COMPATIBLE 1 // TODO: this should only be preserved for gcc2 compatibility
class BString; class BString;
@ -95,6 +97,8 @@ void extract_address_name(BString &address);
// Given a header field (usually the From: e-mail address) with gobbledygook in // Given a header field (usually the From: e-mail address) with gobbledygook in
// it, find the longest human-readable phrase (usually the person's name). // it, find the longest human-readable phrase (usually the person's name).
void get_address_list(BList &list, const char *string, void (*cleanupFunc)(BString &) = NULL); void get_address_list(BList &list, const char *string,
void (*cleanupFunc)(BString &) = NULL);
#endif /* ZOIDBERG_GARGOYLE_MAIL_UTIL_H */ #endif /* ZOIDBERG_GARGOYLE_MAIL_UTIL_H */

View File

@ -1,52 +1,58 @@
/* BMailFileConfigView - a file configuration view for filters /*
** * Copyright 20011, Haiku Inc. All Rights Reserved.
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved. * Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/ */
#include <BeBuild.h>
class _EXPORT BFileControl; //! A file configuration view for filters.
class _EXPORT BMailFileConfigView;
#include <TextControl.h>
#include <Button.h>
#include <String.h>
#include <Message.h>
#include <Path.h>
#include <stdio.h>
#include <FileConfigView.h> #include <FileConfigView.h>
#include <stdio.h>
#include <Button.h>
#include <Message.h>
#include <Path.h>
#include <String.h>
#include <TextControl.h>
#include <MDRLanguage.h> #include <MDRLanguage.h>
const uint32 kMsgSelectButton = 'fsel'; const uint32 kMsgSelectButton = 'fsel';
BFileControl::BFileControl(BRect rect,const char *name,const char *label,const char *pathOfFile,uint32 flavors)
: BView(rect,name,B_FOLLOW_LEFT | B_FOLLOW_TOP,0) BFileControl::BFileControl(BRect rect, const char* name, const char* label,
const char* pathOfFile, uint32 flavors)
:
BView(rect, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0)
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// determine font height // determine font height
font_height fontHeight; font_height fontHeight;
GetFontHeight(&fontHeight); GetFontHeight(&fontHeight);
float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 13; float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent
+ fontHeight.leading) + 13;
float labelWidth = StringWidth("Select" B_UTF8_ELLIPSIS) + 20; float labelWidth = StringWidth("Select" B_UTF8_ELLIPSIS) + 20;
rect = Bounds(); rect = Bounds();
rect.right -= labelWidth; rect.right -= labelWidth;
rect.top = 4; rect.bottom = itemHeight + 2; rect.top = 4; rect.bottom = itemHeight + 2;
fText = new BTextControl(rect,"file_path",label,pathOfFile,NULL); fText = new BTextControl(rect, "file_path", label, pathOfFile, NULL);
if (label) if (label)
fText->SetDivider(fText->StringWidth(label) + 6); fText->SetDivider(fText->StringWidth(label) + 6);
AddChild(fText); AddChild(fText);
fButton = new BButton(BRect(0,0,1,1),"select_file",MDR_DIALECT_CHOICE ("Select","選択") B_UTF8_ELLIPSIS, fButton = new BButton(BRect(0, 0, 1, 1), "select_file",
MDR_DIALECT_CHOICE ("Select","選択") B_UTF8_ELLIPSIS,
new BMessage(kMsgSelectButton)); new BMessage(kMsgSelectButton));
fButton->ResizeToPreferred(); fButton->ResizeToPreferred();
fButton->MoveBy(rect.right + 6, (rect.Height() - fButton->Frame().Height()) / 2); fButton->MoveBy(rect.right + 6,
(rect.Height() - fButton->Frame().Height()) / 2);
AddChild(fButton); AddChild(fButton);
fPanel = new BFilePanel(B_OPEN_PANEL,NULL,NULL,flavors,false); fPanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, flavors, false);
ResizeToPreferred(); ResizeToPreferred();
} }
@ -58,7 +64,8 @@ BFileControl::~BFileControl()
} }
void BFileControl::AttachedToWindow() void
BFileControl::AttachedToWindow()
{ {
fButton->SetTarget(this); fButton->SetTarget(this);
@ -68,14 +75,13 @@ void BFileControl::AttachedToWindow()
} }
void BFileControl::MessageReceived(BMessage *msg) void
BFileControl::MessageReceived(BMessage *msg)
{ {
switch (msg->what) switch (msg->what) {
{
case kMsgSelectButton: case kMsgSelectButton:
{ {
fPanel->Hide(); fPanel->Hide();
//fPanel->Window()->SetTitle(title);
BPath path(fText->Text()); BPath path(fText->Text());
if (path.InitCheck() >= B_OK) if (path.InitCheck() >= B_OK)
@ -108,61 +114,67 @@ void BFileControl::MessageReceived(BMessage *msg)
} }
void BFileControl::SetText(const char *pathOfFile) void
BFileControl::SetText(const char *pathOfFile)
{ {
fText->SetText(pathOfFile); fText->SetText(pathOfFile);
} }
const char *BFileControl::Text() const const char*
BFileControl::Text() const
{ {
return fText->Text(); return fText->Text();
} }
void BFileControl::SetEnabled(bool enabled) void
BFileControl::SetEnabled(bool enabled)
{ {
fText->SetEnabled(enabled); fText->SetEnabled(enabled);
fButton->SetEnabled(enabled); fButton->SetEnabled(enabled);
} }
void BFileControl::GetPreferredSize(float *width, float *height) void
BFileControl::GetPreferredSize(float* width, float* height)
{ {
*width = fButton->Frame().right + 5; *width = fButton->Frame().right + 5;
*height = fText->Bounds().Height() + 8; *height = fText->Bounds().Height() + 8;
} }
//--------------------------------------------------------------------------
// #pragma mark - // #pragma mark -
BMailFileConfigView::BMailFileConfigView(const char *label,const char *name,bool useMeta,const char *defaultPath,uint32 flavors)
: BFileControl(BRect(5,0,255,10),name,label,defaultPath,flavors), BMailFileConfigView::BMailFileConfigView(const char* label, const char* name,
bool useMeta, const char* defaultPath, uint32 flavors)
:
BFileControl(BRect(5, 0, 255, 10), name, label, defaultPath, flavors),
fUseMeta(useMeta), fUseMeta(useMeta),
fName(name) fName(name)
{ {
} }
void BMailFileConfigView::SetTo(const BMessage *archive, BMessage *meta) void
BMailFileConfigView::SetTo(const BMessage* archive, BMessage* meta)
{ {
fMeta = meta; fMeta = meta;
BString path = (fUseMeta ? meta : archive)->FindString(fName); BString path = (fUseMeta ? meta : archive)->FindString(fName);
if (path != "") if (path != "")
SetText(path.String()); SetText(path.String());
} }
status_t BMailFileConfigView::Archive(BMessage *into, bool /*deep*/) const status_t
BMailFileConfigView::Archive(BMessage* into, bool /*deep*/) const
{ {
const char *path = Text(); const char* path = Text();
BMessage *archive = fUseMeta ? fMeta : into; BMessage* archive = fUseMeta ? fMeta : into;
if (archive->ReplaceString(fName,path) != B_OK) if (archive->ReplaceString(fName, path) != B_OK)
archive->AddString(fName,path); archive->AddString(fName, path);
return B_OK; return B_OK;
} }