Coding style cleanup, no functional change. Hopefully. :-)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29673 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-03-24 11:22:35 +00:00
parent 8ba65ba1b4
commit f7335ab6ed
2 changed files with 326 additions and 270 deletions
+163 -119
View File
@@ -106,34 +106,56 @@ extern BPoint prefs_window;
#define ATTRIBUTE_ON_TEXT MDR_DIALECT_CHOICE ("Include BeOS Attributes in Attachments", "BeOSの属性を付ける") #define ATTRIBUTE_ON_TEXT MDR_DIALECT_CHOICE ("Include BeOS Attributes in Attachments", "BeOSの属性を付ける")
#define ATTRIBUTE_OFF_TEXT MDR_DIALECT_CHOICE ("No BeOS Attributes, just Plain Data", "BeOSの属性を付けない(データのみ)") #define ATTRIBUTE_OFF_TEXT MDR_DIALECT_CHOICE ("No BeOS Attributes, just Plain Data", "BeOSの属性を付けない(データのみ)")
//==================================================================== //#pragma mark -
TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap, TPrefsWindow::TPrefsWindow(BRect rect, BFont* font, int32* level, bool* wrap,
bool* attachAttributes, bool* cquotes, uint32* account, int32* replyTo, bool* attachAttributes, bool* cquotes, uint32* account, int32* replyTo,
char** preamble, char** sig, uint32* encoding, bool* warnUnencodable, char** preamble, char** sig, uint32* encoding, bool* warnUnencodable,
bool* spellCheckStartOn, uint8* buttonBar) bool* spellCheckStartOn, uint8* buttonBar)
: BWindow(rect, MDR_DIALECT_CHOICE ("Mail Preferences","Mailの設定"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) :
BWindow(rect, MDR_DIALECT_CHOICE ("Mail Preferences", "Mailの設定"),
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE),
fNewWrap(wrap),
fWrap(*fNewWrap),
fNewAttachAttributes(attachAttributes),
fAttachAttributes(*fNewAttachAttributes),
fNewButtonBar(buttonBar),
fButtonBar(*fNewButtonBar),
fNewColoredQuotes(cquotes),
fColoredQuotes(*fNewColoredQuotes),
fNewAccount(account),
fAccount(*fNewAccount),
fNewReplyTo(replyTo),
fReplyTo(*fNewReplyTo),
fNewPreamble(preamble),
fNewSignature(sig),
fSignature((char*)malloc(strlen(*fNewSignature) + 1)),
fNewFont(font),
fFont(*fNewFont),
fNewEncoding(encoding),
fEncoding(*fNewEncoding),
fNewWarnUnencodable(warnUnencodable),
fWarnUnencodable(*fNewWarnUnencodable),
fNewSpellCheckStartOn(spellCheckStartOn),
fSpellCheckStartOn(*fNewSpellCheckStartOn)
{ {
BMenuField *menu;
fNewFont = font; fFont = *fNewFont;
fNewWrap = wrap; fWrap = *fNewWrap;
fNewAttachAttributes = attachAttributes; fAttachAttributes = *fNewAttachAttributes;
fNewColoredQuotes = cquotes; fColoredQuotes = *fNewColoredQuotes;
fNewAccount = account; fAccount = *fNewAccount;
fNewReplyTo = replyTo; fReplyTo = *fNewReplyTo;
fNewEncoding = encoding; fEncoding = *fNewEncoding;
fNewWarnUnencodable = warnUnencodable; fWarnUnencodable = *fNewWarnUnencodable;
fNewSpellCheckStartOn = spellCheckStartOn; fSpellCheckStartOn = *fNewSpellCheckStartOn;
fNewButtonBar = buttonBar; fButtonBar = *fNewButtonBar;
fNewPreamble = preamble;
fNewSignature = sig;
fSignature = (char *)malloc(strlen(*fNewSignature) + 1);
strcpy(fSignature, *fNewSignature); strcpy(fSignature, *fNewSignature);
BMenuField* menu;
BRect r = Bounds(); BRect r = Bounds();
BView *view = new BView(r, NULL, B_FOLLOW_ALL, B_FRAME_EVENTS); BView *view = new BView(r, NULL, B_FOLLOW_ALL, B_FRAME_EVENTS);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -142,14 +164,17 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *wrap,
// determine font height // determine font height
font_height fontHeight; font_height fontHeight;
view->GetFontHeight(&fontHeight); view->GetFontHeight(&fontHeight);
int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 6; int32 height = (int32)(fontHeight.ascent + fontHeight.descent
int32 labelWidth = (int32)view->StringWidth(SPELL_CHECK_START_ON_TEXT) + SEPARATOR_MARGIN; + fontHeight.leading) + 6;
int32 labelWidth = (int32)view->StringWidth(SPELL_CHECK_START_ON_TEXT)
+ SEPARATOR_MARGIN;
// group boxes // group boxes
r.Set(8,4,Bounds().right - 8,4 + 6 * (height + ITEM_SPACE)); r.Set(8,4,Bounds().right - 8,4 + 6 * (height + ITEM_SPACE));
BBox *interfaceBox = new BBox(r , NULL,B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); BBox *interfaceBox = new BBox(r , NULL,B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
interfaceBox->SetLabel(MDR_DIALECT_CHOICE ("User Interface","ユーザーインターフェース")); interfaceBox->SetLabel(MDR_DIALECT_CHOICE ("User Interface",
"ユーザーインターフェース"));
view->AddChild(interfaceBox); view->AddChild(interfaceBox);
r.top = r.bottom + 8; r.bottom = r.top + 9 * (height + ITEM_SPACE); r.top = r.bottom + 8; r.bottom = r.top + 9 * (height + ITEM_SPACE);
@@ -166,51 +191,56 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *wrap,
view->AddChild(button); view->AddChild(button);
r.OffsetBy(-(OK_BUTTON_X2 - OK_BUTTON_X1 + 10), 0); r.OffsetBy(-(OK_BUTTON_X2 - OK_BUTTON_X1 + 10), 0);
button = new BButton(r, "cancel", CANCEL_BUTTON_TEXT, new BMessage(P_CANCEL)); button = new BButton(r, "cancel", CANCEL_BUTTON_TEXT,
new BMessage(P_CANCEL));
view->AddChild(button); view->AddChild(button);
r.left = REVERT_BUTTON_X1; r.right = REVERT_BUTTON_X2; r.left = REVERT_BUTTON_X1; r.right = REVERT_BUTTON_X2;
fRevert = new BButton(r, "revert", REVERT_BUTTON_TEXT, new BMessage(P_REVERT)); fRevert = new BButton(r, "revert", REVERT_BUTTON_TEXT,
new BMessage(P_REVERT));
fRevert->SetEnabled(false); fRevert->SetEnabled(false);
view->AddChild(fRevert); view->AddChild(fRevert);
// User Interface // User Interface
r = interfaceBox->Bounds(); r = interfaceBox->Bounds();
r.left += 8; r.right -= 8; r.top = height; r.bottom = r.top + height - 3; r.left += 8;
fButtonBarMenu = BuildButtonBarMenu(*buttonBar); r.right -= 8;
menu = new BMenuField(r, "bar", BUTTONBAR_TEXT, fButtonBarMenu,B_FOLLOW_ALL, r.top = height;
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); r.bottom = r.top + height - 3;
fButtonBarMenu = _BuildButtonBarMenu(*buttonBar);
menu = new BMenuField(r, "bar", BUTTONBAR_TEXT, fButtonBarMenu,
B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
interfaceBox->AddChild(menu); interfaceBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fFontMenu = BuildFontMenu(font); fFontMenu = _BuildFontMenu(font);
menu = new BMenuField(r, "font", FONT_TEXT, fFontMenu,B_FOLLOW_ALL, menu = new BMenuField(r, "font", FONT_TEXT, fFontMenu,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
interfaceBox->AddChild(menu); interfaceBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fSizeMenu = BuildSizeMenu(font); fSizeMenu = _BuildSizeMenu(font);
menu = new BMenuField(r, "size", SIZE_TEXT, fSizeMenu,B_FOLLOW_ALL, menu = new BMenuField(r, "size", SIZE_TEXT, fSizeMenu,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
interfaceBox->AddChild(menu); interfaceBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fColoredQuotesMenu = BuildColoredQuotesMenu(fColoredQuotes); fColoredQuotesMenu = _BuildColoredQuotesMenu(fColoredQuotes);
menu = new BMenuField(r, "cquotes", QUOTES_TEXT, fColoredQuotesMenu,B_FOLLOW_ALL, menu = new BMenuField(r, "cquotes", QUOTES_TEXT, fColoredQuotesMenu,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
interfaceBox->AddChild(menu); interfaceBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fSpellCheckStartOnMenu = BuildSpellCheckStartOnMenu(fSpellCheckStartOn); fSpellCheckStartOnMenu = _BuildSpellCheckStartOnMenu(fSpellCheckStartOn);
menu = new BMenuField(r, "spellCheckStartOn", SPELL_CHECK_START_ON_TEXT, menu = new BMenuField(r, "spellCheckStartOn", SPELL_CHECK_START_ON_TEXT,
fSpellCheckStartOnMenu, B_FOLLOW_ALL, fSpellCheckStartOnMenu, B_FOLLOW_ALL,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
@@ -222,57 +252,65 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *wrap,
// Mail Accounts // Mail Accounts
r = mailBox->Bounds(); r = mailBox->Bounds();
r.left += 8; r.right -= 8; r.top = height; r.bottom = r.top + height - 3; r.left += 8;
fAccountMenu = BuildAccountMenu(fAccount); r.right -= 8;
menu = new BMenuField(r, "account", ACCOUNT_TEXT, fAccountMenu, B_FOLLOW_ALL, r.top = height;
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); r.bottom = r.top + height - 3;
fAccountMenu = _BuildAccountMenu(fAccount);
menu = new BMenuField(r, "account", ACCOUNT_TEXT, fAccountMenu,
B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
mailBox->AddChild(menu); mailBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fReplyToMenu = BuildReplyToMenu(fReplyTo); fReplyToMenu = _BuildReplyToMenu(fReplyTo);
menu = new BMenuField(r, "replyTo", REPLYTO_TEXT, fReplyToMenu, B_FOLLOW_ALL, menu = new BMenuField(r, "replyTo", REPLYTO_TEXT, fReplyToMenu,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
mailBox->AddChild(menu); mailBox->AddChild(menu);
// Mail Contents // Mail Contents
r.OffsetBy(0, height + ITEM_SPACE); r.right -= 25; r.OffsetBy(0, height + ITEM_SPACE);
fReplyPreamble = new BTextControl(r, "replytext", REPLY_PREAMBLE_TEXT, *preamble, r.right -= 25;
new BMessage(P_REPLY_PREAMBLE), B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE); fReplyPreamble = new BTextControl(r, "replytext", REPLY_PREAMBLE_TEXT,
*preamble, new BMessage(P_REPLY_PREAMBLE), B_FOLLOW_ALL,
B_WILL_DRAW | B_NAVIGABLE);
fReplyPreamble->SetDivider(labelWidth); fReplyPreamble->SetDivider(labelWidth);
fReplyPreamble->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fReplyPreamble->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
mailBox->AddChild(fReplyPreamble); mailBox->AddChild(fReplyPreamble);
BRect popRect = r; BRect popRect = r;
popRect.left = r.right + 6; r.right += 25; popRect.right = r.right; popRect.left = r.right + 6;
fReplyPreambleMenu = BuildReplyPreambleMenu(); r.right += 25;
menu = new BMenuField(popRect, "replyPreamble", B_EMPTY_STRING, fReplyPreambleMenu, popRect.right = r.right;
B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); fReplyPreambleMenu = _BuildReplyPreambleMenu();
menu = new BMenuField(popRect, "replyPreamble", B_EMPTY_STRING,
fReplyPreambleMenu, B_FOLLOW_ALL,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(0); menu->SetDivider(0);
mailBox->AddChild(menu); mailBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fSignatureMenu = BuildSignatureMenu(*sig); fSignatureMenu = _BuildSignatureMenu(*sig);
menu = new BMenuField(r, "sig", SIGNATURE_TEXT, fSignatureMenu,B_FOLLOW_ALL, menu = new BMenuField(r, "sig", SIGNATURE_TEXT, fSignatureMenu,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
mailBox->AddChild(menu); mailBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fEncodingMenu = BuildEncodingMenu(fEncoding); fEncodingMenu = _BuildEncodingMenu(fEncoding);
menu = new BMenuField(r, "enc", ENCODING_TEXT, fEncodingMenu,B_FOLLOW_ALL, menu = new BMenuField(r, "enc", ENCODING_TEXT, fEncodingMenu,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
mailBox->AddChild(menu); mailBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fWarnUnencodableMenu = BuildWarnUnencodableMenu(fWarnUnencodable); fWarnUnencodableMenu = _BuildWarnUnencodableMenu(fWarnUnencodable);
menu = new BMenuField(r, "warnUnencodable", WARN_UNENCODABLE_TEXT, menu = new BMenuField(r, "warnUnencodable", WARN_UNENCODABLE_TEXT,
fWarnUnencodableMenu, B_FOLLOW_ALL, fWarnUnencodableMenu, B_FOLLOW_ALL,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
@@ -281,7 +319,7 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *wrap,
mailBox->AddChild(menu); mailBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fWrapMenu = BuildWrapMenu(*wrap); fWrapMenu = _BuildWrapMenu(*wrap);
menu = new BMenuField(r, "wrap", WRAP_TEXT, fWrapMenu, B_FOLLOW_ALL, menu = new BMenuField(r, "wrap", WRAP_TEXT, fWrapMenu, B_FOLLOW_ALL,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
@@ -289,8 +327,9 @@ TPrefsWindow::TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *wrap,
mailBox->AddChild(menu); mailBox->AddChild(menu);
r.OffsetBy(0, height + ITEM_SPACE); r.OffsetBy(0, height + ITEM_SPACE);
fAttachAttributesMenu = BuildAttachAttributesMenu(*attachAttributes); fAttachAttributesMenu = _BuildAttachAttributesMenu(*attachAttributes);
menu = new BMenuField(r, "attachAttributes", ATTACH_ATTRIBUTES_TEXT, fAttachAttributesMenu, B_FOLLOW_ALL, menu = new BMenuField(r, "attachAttributes", ATTACH_ATTRIBUTES_TEXT,
fAttachAttributesMenu, B_FOLLOW_ALL,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
menu->SetDivider(labelWidth); menu->SetDivider(labelWidth);
menu->SetAlignment(B_ALIGN_RIGHT); menu->SetAlignment(B_ALIGN_RIGHT);
@@ -313,7 +352,6 @@ TPrefsWindow::~TPrefsWindow()
void void
TPrefsWindow::MessageReceived(BMessage* msg) TPrefsWindow::MessageReceived(BMessage* msg)
{ {
bool changed;
bool revert = true; bool revert = true;
const char* family; const char* family;
const char* signature; const char* signature;
@@ -330,10 +368,10 @@ TPrefsWindow::MessageReceived(BMessage *msg)
switch (msg->what) { switch (msg->what) {
case P_OK: case P_OK:
if (strcmp(fReplyPreamble->Text(), *fNewPreamble)) if (strcmp(fReplyPreamble->Text(), *fNewPreamble)) {
{
free(*fNewPreamble); free(*fNewPreamble);
*fNewPreamble = (char *)malloc(strlen(fReplyPreamble->Text()) + 1); *fNewPreamble
= (char *)malloc(strlen(fReplyPreamble->Text()) + 1);
strcpy(*fNewPreamble, fReplyPreamble->Text()); strcpy(*fNewPreamble, fReplyPreamble->Text());
} }
be_app->PostMessage(PREFS_CHANGED); be_app->PostMessage(PREFS_CHANGED);
@@ -349,8 +387,7 @@ TPrefsWindow::MessageReceived(BMessage *msg)
old_size = (int32)fFont.Size(); old_size = (int32)fFont.Size();
new_size = (int32)fNewFont->Size(); new_size = (int32)fNewFont->Size();
if (strcmp(old_family, new_family) || strcmp(old_style, new_style) if (strcmp(old_family, new_family) || strcmp(old_style, new_style)
|| old_size != new_size) || old_size != new_size) {
{
fNewFont->SetFamilyAndStyle(old_family, old_style); fNewFont->SetFamilyAndStyle(old_family, old_style);
if (revert) { if (revert) {
sprintf(label, "%s %s", old_family, old_style); sprintf(label, "%s %s", old_family, old_style);
@@ -386,10 +423,14 @@ TPrefsWindow::MessageReceived(BMessage *msg)
be_app->PostMessage(PREFS_CHANGED); be_app->PostMessage(PREFS_CHANGED);
if (revert) { if (revert) {
for (int i = fAccountMenu->CountItems();i-- > 0;) { for (int i = fAccountMenu->CountItems(); --i > 0;) {
if (BMenuItem *item = fAccountMenu->ItemAt(i)) BMenuItem *item = fAccountMenu->ItemAt(i);
if (item->Message()->FindInt32("id") == *(int32 *)&fAccount) BMessage* itemMessage = item->Message();
if (itemMessage != NULL
&& itemMessage->FindInt32("id") == *(int32 *)&fAccount) {
item->SetMarked(true); item->SetMarked(true);
break;
}
} }
strcpy(label,fReplyTo == ACCOUNT_USE_DEFAULT strcpy(label,fReplyTo == ACCOUNT_USE_DEFAULT
@@ -419,12 +460,12 @@ TPrefsWindow::MessageReceived(BMessage *msg)
uint32 index = 0; uint32 index = 0;
while ((item = fEncodingMenu->ItemAt(index++)) != NULL) { while ((item = fEncodingMenu->ItemAt(index++)) != NULL) {
BMessage * message = item->Message(); BMessage* itemMessage = item->Message();
if (message == NULL) if (itemMessage == NULL)
continue; continue;
int32 encoding; int32 encoding;
if (message->FindInt32("encoding", &encoding) == B_OK if (itemMessage->FindInt32("encoding", &encoding) == B_OK
&& (uint32)encoding == *fNewEncoding) { && (uint32)encoding == *fNewEncoding) {
item->SetMarked(true); item->SetMarked(true);
break; break;
@@ -530,7 +571,7 @@ TPrefsWindow::MessageReceived(BMessage *msg)
fNewFont->GetFamilyAndStyle(&new_family, &new_style); fNewFont->GetFamilyAndStyle(&new_family, &new_style);
old_size = (int32) fFont.Size(); old_size = (int32) fFont.Size();
new_size = (int32) fNewFont->Size(); new_size = (int32) fNewFont->Size();
changed = old_size != new_size bool changed = old_size != new_size
|| fWrap != *fNewWrap || fWrap != *fNewWrap
|| fAttachAttributes != *fNewAttachAttributes || fAttachAttributes != *fNewAttachAttributes
|| fColoredQuotes != *fNewColoredQuotes || fColoredQuotes != *fNewColoredQuotes
@@ -549,7 +590,7 @@ TPrefsWindow::MessageReceived(BMessage *msg)
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildFontMenu(BFont *font) TPrefsWindow::_BuildFontMenu(BFont* font)
{ {
font_family def_family; font_family def_family;
font_style def_style; font_style def_style;
@@ -572,13 +613,16 @@ TPrefsWindow::BuildFontMenu(BFont *font)
BMessage *msg = new BMessage(P_FONT); BMessage *msg = new BMessage(P_FONT);
msg->AddString("font", f_family); msg->AddString("font", f_family);
msg->AddString("style", f_style); msg->AddString("style", f_style);
/* we send this to make setting the Family easier when things change */ // we send this to make setting the Family easier when things
// change
msg->AddInt32("parent_index", family_menu_index); msg->AddInt32("parent_index", family_menu_index);
BMenuItem *item = new BMenuItem(f_style, msg); BMenuItem *item = new BMenuItem(f_style, msg);
family_menu->AddItem(item); family_menu->AddItem(item);
if ((strcmp(def_family, f_family) == 0) && (strcmp(def_style, f_style) == 0)) if ((strcmp(def_family, f_family) == 0)
&& (strcmp(def_style, f_style) == 0)) {
item->SetMarked(true); item->SetMarked(true);
}
item->SetTarget(this); item->SetTarget(this);
} }
@@ -600,7 +644,7 @@ TPrefsWindow::BuildFontMenu(BFont *font)
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildLevelMenu(int32 level) TPrefsWindow::_BuildLevelMenu(int32 level)
{ {
BMenuItem* item; BMenuItem* item;
BMessage* msg; BMessage* msg;
@@ -609,13 +653,15 @@ TPrefsWindow::BuildLevelMenu(int32 level)
menu = new BPopUpMenu(""); menu = new BPopUpMenu("");
msg = new BMessage(P_LEVEL); msg = new BMessage(P_LEVEL);
msg->AddInt32("level", L_BEGINNER); msg->AddInt32("level", L_BEGINNER);
menu->AddItem(item = new BMenuItem(MDR_DIALECT_CHOICE ("Beginner","初心者"),msg)); menu->AddItem(item = new BMenuItem(MDR_DIALECT_CHOICE ("Beginner","初心者"),
msg));
if (level == L_BEGINNER) if (level == L_BEGINNER)
item->SetMarked(true); item->SetMarked(true);
msg = new BMessage(P_LEVEL); msg = new BMessage(P_LEVEL);
msg->AddInt32("level", L_EXPERT); msg->AddInt32("level", L_EXPERT);
menu->AddItem(item = new BMenuItem(MDR_DIALECT_CHOICE ("Expert","上級者"),msg)); menu->AddItem(item = new BMenuItem(MDR_DIALECT_CHOICE ("Expert","上級者"),
msg));
if (level == L_EXPERT) if (level == L_EXPERT)
item->SetMarked(true); item->SetMarked(true);
@@ -624,7 +670,7 @@ TPrefsWindow::BuildLevelMenu(int32 level)
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildAccountMenu(uint32 account) TPrefsWindow::_BuildAccountMenu(uint32 account)
{ {
BPopUpMenu* menu = new BPopUpMenu(""); BPopUpMenu* menu = new BPopUpMenu("");
BMenuItem* item; BMenuItem* item;
@@ -655,18 +701,20 @@ TPrefsWindow::BuildAccountMenu(uint32 account)
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildReplyToMenu(int32 account) TPrefsWindow::_BuildReplyToMenu(int32 account)
{ {
BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING); BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING);
BMenuItem* item; BMenuItem* item;
BMessage* msg; BMessage* msg;
menu->AddItem(item = new BMenuItem(REPLYTO_USE_DEFAULT_TEXT, msg = new BMessage(P_REPLYTO))); menu->AddItem(item = new BMenuItem(REPLYTO_USE_DEFAULT_TEXT,
msg = new BMessage(P_REPLYTO)));
msg->AddInt32("replyTo", ACCOUNT_USE_DEFAULT); msg->AddInt32("replyTo", ACCOUNT_USE_DEFAULT);
if (account == ACCOUNT_USE_DEFAULT) if (account == ACCOUNT_USE_DEFAULT)
item->SetMarked(true); item->SetMarked(true);
menu->AddItem(item = new BMenuItem(REPLYTO_FROM_MAIL_TEXT, msg = new BMessage(P_REPLYTO))); menu->AddItem(item = new BMenuItem(REPLYTO_FROM_MAIL_TEXT,
msg = new BMessage(P_REPLYTO)));
msg->AddInt32("replyTo", ACCOUNT_FROM_MAIL); msg->AddInt32("replyTo", ACCOUNT_FROM_MAIL);
if (account == ACCOUNT_FROM_MAIL) if (account == ACCOUNT_FROM_MAIL)
item->SetMarked(true); item->SetMarked(true);
@@ -676,7 +724,7 @@ TPrefsWindow::BuildReplyToMenu(int32 account)
BMenu* BMenu*
TPrefsWindow::BuildReplyPreambleMenu() TPrefsWindow::_BuildReplyPreambleMenu()
{ {
const char *substitutes[] = { const char *substitutes[] = {
/* To do: Not yet working, leave out for 2.0.0 beta 4: /* To do: Not yet working, leave out for 2.0.0 beta 4:
@@ -693,12 +741,13 @@ TPrefsWindow::BuildReplyPreambleMenu()
BMenu *menu = new BMenu(B_EMPTY_STRING); BMenu *menu = new BMenu(B_EMPTY_STRING);
for (int32 i = 0; substitutes[i]; i++) for (int32 i = 0; substitutes[i]; i++) {
{ if (*substitutes[i] == '\0') {
if (*substitutes[i] == '\0')
menu->AddSeparatorItem(); menu->AddSeparatorItem();
else } else {
menu->AddItem(new BMenuItem(substitutes[i], new BMessage(P_REPLY_PREAMBLE))); menu->AddItem(new BMenuItem(substitutes[i],
new BMessage(P_REPLY_PREAMBLE)));
}
} }
return menu; return menu;
@@ -706,19 +755,18 @@ TPrefsWindow::BuildReplyPreambleMenu()
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildSignatureMenu(char *sig) TPrefsWindow::_BuildSignatureMenu(char* sig)
{ {
char name[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH];
BEntry entry; BEntry entry;
BFile file; BFile file;
BMenuItem* item; BMenuItem* item;
BMessage* msg; BMessage* msg;
BPopUpMenu *menu;
BQuery query; BQuery query;
BVolume vol; BVolume vol;
BVolumeRoster volume; BVolumeRoster volume;
menu = new BPopUpMenu(""); BPopUpMenu* menu = new BPopUpMenu("");
msg = new BMessage(P_SIG); msg = new BMessage(P_SIG);
msg->AddString("signature", SIG_NONE); msg->AddString("signature", SIG_NONE);
@@ -754,7 +802,7 @@ TPrefsWindow::BuildSignatureMenu(char *sig)
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildSizeMenu(BFont *font) TPrefsWindow::_BuildSizeMenu(BFont* font)
{ {
char label[16]; char label[16];
uint32 loop; uint32 loop;
@@ -779,7 +827,7 @@ TPrefsWindow::BuildSizeMenu(BFont *font)
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildBoolMenu(uint32 what,const char *boolItem,bool isTrue) TPrefsWindow::_BuildBoolMenu(uint32 what, const char* boolItem, bool isTrue)
{ {
BMenuItem* item; BMenuItem* item;
BMessage* msg; BMessage* msg;
@@ -803,14 +851,14 @@ TPrefsWindow::BuildBoolMenu(uint32 what,const char *boolItem,bool isTrue)
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildWrapMenu(bool wrap) TPrefsWindow::_BuildWrapMenu(bool wrap)
{ {
return BuildBoolMenu(P_WRAP,"wrap",wrap); return _BuildBoolMenu(P_WRAP, "wrap", wrap);
} }
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildAttachAttributesMenu(bool attachAttributes) TPrefsWindow::_BuildAttachAttributesMenu(bool attachAttributes)
{ {
BMenuItem* item; BMenuItem* item;
BMessage* msg; BMessage* msg;
@@ -834,14 +882,14 @@ TPrefsWindow::BuildAttachAttributesMenu(bool attachAttributes)
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildColoredQuotesMenu(bool quote) TPrefsWindow::_BuildColoredQuotesMenu(bool quote)
{ {
return BuildBoolMenu(P_COLORED_QUOTES,"cquotes",quote); return _BuildBoolMenu(P_COLORED_QUOTES, "cquotes", quote);
} }
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildEncodingMenu(uint32 encoding) TPrefsWindow::_BuildEncodingMenu(uint32 encoding)
{ {
BMenuItem* item; BMenuItem* item;
BMessage* msg; BMessage* msg;
@@ -854,56 +902,52 @@ TPrefsWindow::BuildEncodingMenu(uint32 encoding)
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) { while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
BString name(charset.GetPrintName()); BString name(charset.GetPrintName());
const char* mime = charset.GetMIMEName(); const char* mime = charset.GetMIMEName();
if (mime) { if (mime)
name << " (" << mime << ")"; name << " (" << mime << ")";
}
msg = new BMessage(P_ENC); msg = new BMessage(P_ENC);
uint32 convert_id; uint32 convert_id;
if ((mime == 0) || (strcasecmp(mime, "UTF-8") != 0)) { if ((mime == 0) || (strcasecmp(mime, "UTF-8") != 0))
convert_id = charset.GetConversionID(); convert_id = charset.GetConversionID();
} else { else
convert_id = B_MAIL_UTF8_CONVERSION; convert_id = B_MAIL_UTF8_CONVERSION;
}
msg->AddInt32("encoding", convert_id); msg->AddInt32("encoding", convert_id);
menu->AddItem(item = new BMenuItem(name.String(), msg)); menu->AddItem(item = new BMenuItem(name.String(), msg));
if (convert_id == encoding) { if (convert_id == encoding)
item->SetMarked(true); item->SetMarked(true);
} }
}
msg = new BMessage(P_ENC); msg = new BMessage(P_ENC);
msg->AddInt32("encoding", B_MAIL_US_ASCII_CONVERSION); msg->AddInt32("encoding", B_MAIL_US_ASCII_CONVERSION);
menu->AddItem(item = new BMenuItem("US-ASCII", msg)); menu->AddItem(item = new BMenuItem("US-ASCII", msg));
if (encoding == B_MAIL_US_ASCII_CONVERSION) { if (encoding == B_MAIL_US_ASCII_CONVERSION)
item->SetMarked(true); item->SetMarked(true);
}
return menu; return menu;
} }
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildWarnUnencodableMenu(bool warnUnencodable) TPrefsWindow::_BuildWarnUnencodableMenu(bool warnUnencodable)
{ {
return BuildBoolMenu(P_WARN_UNENCODABLE,"warnUnencodable",warnUnencodable); return _BuildBoolMenu(P_WARN_UNENCODABLE, "warnUnencodable",
warnUnencodable);
} }
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildSpellCheckStartOnMenu(bool spellCheckStartOn) TPrefsWindow::_BuildSpellCheckStartOnMenu(bool spellCheckStartOn)
{ {
return BuildBoolMenu(P_SPELL_CHECK_START_ON, "spellCheckStartOn", spellCheckStartOn); return _BuildBoolMenu(P_SPELL_CHECK_START_ON, "spellCheckStartOn",
spellCheckStartOn);
} }
BPopUpMenu* BPopUpMenu*
TPrefsWindow::BuildButtonBarMenu(uint8 show) TPrefsWindow::_BuildButtonBarMenu(uint8 show)
{ {
BMenuItem* item; BMenuItem* item;
BMessage* msg; BMessage* msg;
BPopUpMenu *menu; BPopUpMenu* menu = new BPopUpMenu("");
menu = new BPopUpMenu("");
msg = new BMessage(P_BUTTON_BAR); msg = new BMessage(P_BUTTON_BAR);
msg->AddInt8("bar", 1); msg->AddInt8("bar", 1);
+45 -33
View File
@@ -63,61 +63,73 @@ extern const EncodingItem kEncodings[];
class TPrefsWindow : public BWindow { class TPrefsWindow : public BWindow {
public: public:
TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *warp, TPrefsWindow(BRect rect, BFont* font,
bool *attachAttributes, bool *cquotes, uint32 *account, int32* level, bool* warp,
int32 *replyTo, char **preamble, char **sig, uint32 *encoding, bool* attachAttributes, bool* cquotes,
bool *warnUnencodable, bool *spellCheckStartOn, uint8 *buttonBar); uint32* account, int32* replyTo,
~TPrefsWindow(); char** preamble, char** sig,
uint32* encoding, bool* warnUnencodable,
bool* spellCheckStartOn, uint8* buttonBar);
virtual ~TPrefsWindow();
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
private: private:
BPopUpMenu *BuildFontMenu(BFont*); BPopUpMenu* _BuildFontMenu(BFont*);
BPopUpMenu *BuildLevelMenu(int32); BPopUpMenu* _BuildLevelMenu(int32);
BPopUpMenu *BuildAccountMenu(uint32); BPopUpMenu* _BuildAccountMenu(uint32);
BPopUpMenu *BuildReplyToMenu(int32); BPopUpMenu* _BuildReplyToMenu(int32);
BMenu *BuildReplyPreambleMenu(); BMenu* _BuildReplyPreambleMenu();
BPopUpMenu *BuildSignatureMenu(char*); BPopUpMenu* _BuildSignatureMenu(char*);
BPopUpMenu *BuildSizeMenu(BFont*); BPopUpMenu* _BuildSizeMenu(BFont*);
BPopUpMenu *BuildWrapMenu(bool); BPopUpMenu* _BuildWrapMenu(bool);
BPopUpMenu *BuildAttachAttributesMenu(bool); BPopUpMenu* _BuildAttachAttributesMenu(bool);
BPopUpMenu *BuildColoredQuotesMenu(bool quote); BPopUpMenu* _BuildColoredQuotesMenu(bool quote);
BPopUpMenu *BuildEncodingMenu(uint32 encoding); BPopUpMenu* _BuildEncodingMenu(uint32 encoding);
BPopUpMenu *BuildWarnUnencodableMenu(bool warnUnencodable); BPopUpMenu* _BuildWarnUnencodableMenu(
BPopUpMenu *BuildSpellCheckStartOnMenu(bool spellCheckStartOn); bool warnUnencodable);
BPopUpMenu *BuildButtonBarMenu(uint8 show); BPopUpMenu* _BuildSpellCheckStartOnMenu(
bool spellCheckStartOn);
BPopUpMenu* _BuildButtonBarMenu(uint8 show);
BPopUpMenu *BuildBoolMenu(uint32 msg, const char *boolItem, bool isTrue); BPopUpMenu* _BuildBoolMenu(uint32 msg,
const char* boolItem, bool isTrue);
bool fWrap;
bool* fNewWrap; bool* fNewWrap;
bool fAttachAttributes; bool fWrap;
bool* fNewAttachAttributes; bool* fNewAttachAttributes;
uint8 fButtonBar; bool fAttachAttributes;
uint8* fNewButtonBar; uint8* fNewButtonBar;
bool fColoredQuotes, *fNewColoredQuotes; uint8 fButtonBar;
uint32 fAccount; bool* fNewColoredQuotes;
bool fColoredQuotes;
uint32* fNewAccount; uint32* fNewAccount;
int32 fReplyTo; uint32 fAccount;
int32* fNewReplyTo; int32* fNewReplyTo;
int32 fReplyTo;
char** fNewPreamble; char** fNewPreamble;
char *fSignature;
char** fNewSignature; char** fNewSignature;
BFont fFont; char* fSignature;
BFont* fNewFont; BFont* fNewFont;
uint32 fEncoding; BFont fFont;
uint32* fNewEncoding; uint32* fNewEncoding;
bool fWarnUnencodable; uint32 fEncoding;
bool* fNewWarnUnencodable; bool* fNewWarnUnencodable;
bool fSpellCheckStartOn; bool fWarnUnencodable;
bool* fNewSpellCheckStartOn; bool* fNewSpellCheckStartOn;
bool fSpellCheckStartOn;
BButton* fRevert; BButton* fRevert;
BPopUpMenu* fFontMenu; BPopUpMenu* fFontMenu;
BPopUpMenu* fSizeMenu; BPopUpMenu* fSizeMenu;
BPopUpMenu *fWrapMenu, *fColoredQuotesMenu; BPopUpMenu* fWrapMenu;
BPopUpMenu* fColoredQuotesMenu;
BPopUpMenu* fAttachAttributesMenu; BPopUpMenu* fAttachAttributesMenu;
BPopUpMenu *fAccountMenu, *fReplyToMenu; BPopUpMenu* fAccountMenu;
BPopUpMenu* fReplyToMenu;
BMenu* fReplyPreambleMenu; BMenu* fReplyPreambleMenu;
BTextControl* fReplyPreamble; BTextControl* fReplyPreamble;
BPopUpMenu* fSignatureMenu; BPopUpMenu* fSignatureMenu;