diff --git a/src/apps/bemail/Mail.cpp b/src/apps/bemail/Mail.cpp index 4848cb1f39..09dd992dfb 100644 --- a/src/apps/bemail/Mail.cpp +++ b/src/apps/bemail/Mail.cpp @@ -138,7 +138,7 @@ bool header_flag = false; static bool sWrapMode = true; bool attachAttributes_mode = true; bool gColoredQuotes = true; -bool show_buttonbar = true; +static uint8 sShowButtonBar = true; char *gReplyPreamble; char *signature; int32 level = L_BEGINNER; @@ -428,26 +428,24 @@ TMailApp::MessageReceived(BMessage *msg) &gColoredQuotes, &gDefaultChain, &gUseAccountFrom, &gReplyPreamble, &signature, &gMailCharacterSet, &gWarnAboutUnencodableCharacters, - &gStartWithSpellCheckOn, &show_buttonbar); + &gStartWithSpellCheckOn, &sShowButtonBar); fPrefsWindow->Show(); - fPrevBBPref = show_buttonbar; + fPreviousShowButtonBar = sShowButtonBar; } break; case PREFS_CHANGED: { // Do we need to update the state of the button bars? - if (fPrevBBPref != show_buttonbar) - { + if (fPreviousShowButtonBar != sShowButtonBar) { // Notify all BeMail windows TMailWindow *window; - for (int32 i = 0; (window=(TMailWindow *)fWindowList.ItemAt(i)) != NULL; i++) - { + for (int32 i = 0; (window=(TMailWindow *)fWindowList.ItemAt(i)) != NULL; i++) { window->Lock(); window->UpdateViews(); window->Unlock(); } - fPrevBBPref = show_buttonbar; + fPreviousShowButtonBar = sShowButtonBar; } break; } @@ -455,8 +453,7 @@ TMailApp::MessageReceived(BMessage *msg) case M_EDIT_SIGNATURE: if (fSigWindow) fSigWindow->Activate(true); - else - { + else { fSigWindow = new TSignatureWindow(signature_window); fSigWindow->Show(); } @@ -943,8 +940,8 @@ TMailApp::LoadSavePrefs(bool loadThem) FindWindow::SetFindString(findString); free(findString); } - if (prefsFile.Read(&show_buttonbar, sizeof(bool)) <= 0) - show_buttonbar = true; + if (prefsFile.Read(&sShowButtonBar, sizeof(uint8)) <= 0) + sShowButtonBar = true; if (prefsFile.Read(&gUseAccountFrom, sizeof(int32)) <= 0 || gUseAccountFrom < ACCOUNT_USE_DEFAULT || gUseAccountFrom > ACCOUNT_FROM_MAIL) @@ -1088,10 +1085,11 @@ TMailApp::LoadSavePrefs(bool loadThem) fieldName = "ShowButtonBar"; if (loadThem) { - if (settingsMsg.FindBool(fieldName, &tempBool) == B_OK) - show_buttonbar = tempBool; + int8 value; + if (settingsMsg.FindInt8(fieldName, &value) == B_OK) + sShowButtonBar = value; } else if (errorCode == B_OK) - errorCode = settingsMsg.AddBool(fieldName, show_buttonbar); + errorCode = settingsMsg.AddInt8(fieldName, sShowButtonBar); fieldName = "UseAccountFrom"; if (loadThem) { @@ -1503,13 +1501,11 @@ TMailWindow::TMailWindow(BRect rect, const char *title, const entry_ref *ref, co } menu->AddItem(subMenu); - } - else { + } else { menu->AddItem(fSendNow = new BMenuItem( MDR_DIALECT_CHOICE ("Send Message", "M) メッセージを送信"), new BMessage(M_SEND_NOW), 'M')); - if (!fResending) - { + if (!fResending) { // We want to make alt-shift-M work to send mail as well as just alt-M // Gross hack follows... hey, don't look at me like that... it works. // Create a hidden menu bar with a single "Send Now" item linked to alt-shift-M @@ -1525,8 +1521,7 @@ TMailWindow::TMailWindow(BRect rect, const char *title, const entry_ref *ref, co // // Enclosures Menu // - if (!fIncoming) - { + if (!fIncoming) { menu = new BMenu(MDR_DIALECT_CHOICE ("Enclosures","N) 添付ファイル")); menu->AddItem(fAdd = new BMenuItem(MDR_DIALECT_CHOICE ("Add","E) 追加")B_UTF8_ELLIPSIS, new BMessage(M_ADD), 'E')); menu->AddItem(fRemove = new BMenuItem(MDR_DIALECT_CHOICE ("Remove","T) 削除"), new BMessage(M_REMOVE), 'T')); @@ -1543,18 +1538,16 @@ TMailWindow::TMailWindow(BRect rect, const char *title, const entry_ref *ref, co // float bbwidth = 0, bbheight = 0; - if (show_buttonbar) - { + if (sShowButtonBar) { BuildButtonBar(); - fButtonBar->ShowLabels(show_buttonbar & 1); + fButtonBar->ShowLabels(sShowButtonBar == 1); fButtonBar->Arrange(/* True for all buttons same size, false to just fit */ MDR_DIALECT_CHOICE (true, true)); fButtonBar->GetPreferredSize(&bbwidth, &bbheight); fButtonBar->ResizeTo(Bounds().right+3, bbheight+1); fButtonBar->MoveTo(-1, height-1); fButtonBar->Show(); - } - else + } else fButtonBar = NULL; r.top = r.bottom = height + bbheight + 1; @@ -1576,8 +1569,7 @@ TMailWindow::TMailWindow(BRect rect, const char *title, const entry_ref *ref, co AddChild(fContentView); Unlock(); - if (to) - { + if (to) { Lock(); fHeaderView->fTo->SetText(to); Unlock(); @@ -1593,12 +1585,10 @@ TMailWindow::TMailWindow(BRect rect, const char *title, const entry_ref *ref, co // If auto-signature, add signature to the text here. // - if (!fIncoming && strcmp(signature, SIG_NONE) != 0) - { + if (!fIncoming && strcmp(signature, SIG_NONE) != 0) { if (strcmp(signature, SIG_RANDOM) == 0) PostMessage(M_RANDOM_SIG); - else - { + else { // // Create a query to find this signature // @@ -1616,13 +1606,11 @@ TMailWindow::TMailWindow(BRect rect, const char *title, const entry_ref *ref, co // If we find the named query, add it to the text. // BEntry entry; - if (query.GetNextEntry(&entry) == B_NO_ERROR) - { + if (query.GetNextEntry(&entry) == B_NO_ERROR) { off_t size; BFile file; file.SetTo(&entry, O_RDWR); - if (file.InitCheck() == B_NO_ERROR) - { + if (file.InitCheck() == B_NO_ERROR) { file.GetSize(&size); char *str = (char *)malloc(size); size = file.Read(str, size); @@ -1635,8 +1623,7 @@ TMailWindow::TMailWindow(BRect rect, const char *title, const entry_ref *ref, co if (fStartingText != NULL) strcpy(fStartingText, fContentView->fTextView->Text()); } - } - else { + } else { char tempString [2048]; query.GetPredicate (tempString, sizeof (tempString)); printf ("Query failed, was looking for: %s\n", tempString); @@ -1703,18 +1690,18 @@ TMailWindow::BuildButtonBar() } -void TMailWindow::UpdateViews( void ) +void +TMailWindow::UpdateViews() { float bbwidth = 0, bbheight = 0; float nextY = fMenuBar->Frame().bottom+1; // Show/Hide Button Bar - if (show_buttonbar) - { + if (sShowButtonBar) { // Create the Button Bar if needed if (!fButtonBar) BuildButtonBar(); - fButtonBar->ShowLabels(show_buttonbar & 1); + fButtonBar->ShowLabels(sShowButtonBar == 1); fButtonBar->Arrange(/* True for all buttons same size, false to just fit */ MDR_DIALECT_CHOICE (true, true)); fButtonBar->GetPreferredSize( &bbwidth, &bbheight); @@ -1725,15 +1712,13 @@ void TMailWindow::UpdateViews( void ) fButtonBar->Show(); else fButtonBar->Invalidate(); - } - else if (fButtonBar) + } else if (fButtonBar) fButtonBar->Hide(); // Arange other views to match fHeaderView->MoveTo(0, nextY); nextY = fHeaderView->Frame().bottom; - if (fEnclosuresView) - { + if (fEnclosuresView) { fEnclosuresView->MoveTo(0, nextY); nextY = fEnclosuresView->Frame().bottom+1; } diff --git a/src/apps/bemail/Mail.h b/src/apps/bemail/Mail.h index fa44e53bec..a432dfee87 100644 --- a/src/apps/bemail/Mail.h +++ b/src/apps/bemail/Mail.h @@ -205,10 +205,8 @@ class TMailApp : public BApplication { int32 fWindowCount; TPrefsWindow *fPrefsWindow; TSignatureWindow *fSigWindow; - //BMessenger fTrackerMessenger; - // Talks to tracker window that this was launched from. - bool fPrevBBPref; + uint8 fPreviousShowButtonBar; }; //-------------------------------------------------------------------- diff --git a/src/apps/bemail/Prefs.cpp b/src/apps/bemail/Prefs.cpp index 4a0fbad09f..d5191cc6fa 100644 --- a/src/apps/bemail/Prefs.cpp +++ b/src/apps/bemail/Prefs.cpp @@ -113,7 +113,7 @@ extern BPoint prefs_window; TPrefsWindow::TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *wrap, bool *attachAttributes, bool *cquotes, uint32 *account, int32 *replyTo, char **preamble, char **sig, uint32 *encoding, bool *warnUnencodable, - bool *spellCheckStartOn, bool *buttonBar) + bool *spellCheckStartOn, uint8 *buttonBar) : BWindow(rect, MDR_DIALECT_CHOICE ("BeMail Preferences","BeMailの設定"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) { BMenuField *menu; @@ -530,13 +530,10 @@ TPrefsWindow::MessageReceived(BMessage *msg) } case P_SIG: free(*fNewSignature); - if (msg->FindString("signature", &signature) == B_NO_ERROR) - { + if (msg->FindString("signature", &signature) == B_NO_ERROR) { *fNewSignature = (char *)malloc(strlen(signature) + 1); strcpy(*fNewSignature, signature); - } - else - { + } else { *fNewSignature = (char *)malloc(strlen(SIG_NONE) + 1); strcpy(*fNewSignature, SIG_NONE); } @@ -552,7 +549,7 @@ TPrefsWindow::MessageReceived(BMessage *msg) break; case P_BUTTON_BAR: msg->FindInt8("bar", (int8 *)fNewButtonBar); - be_app->PostMessage( PREFS_CHANGED ); + be_app->PostMessage(PREFS_CHANGED); break; default: @@ -585,7 +582,6 @@ TPrefsWindow::MessageReceived(BMessage *msg) BPopUpMenu * TPrefsWindow::BuildFontMenu(BFont *font) { - font_family def_family; font_style def_style; font_family f_family; @@ -594,7 +590,7 @@ TPrefsWindow::BuildFontMenu(BFont *font) BPopUpMenu *menu = new BPopUpMenu(""); font->GetFamilyAndStyle(&def_family, &def_style); - int32 family_menu_index=0; + int32 family_menu_index = 0; int family_count = count_font_families(); for (int family_loop = 0; family_loop < family_count; family_loop++) { get_font_family(family_loop, &f_family); @@ -612,9 +608,9 @@ TPrefsWindow::BuildFontMenu(BFont *font) BMenuItem *item = new BMenuItem(f_style, msg); 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->SetTarget(this); } @@ -622,10 +618,12 @@ TPrefsWindow::BuildFontMenu(BFont *font) BMenuItem *item = menu->ItemAt(family_menu_index); BMessage *msg = new BMessage(P_FONT); msg->AddString("font", f_family); - + item->SetMessage(msg); item->SetTarget(this); - if (strcmp(def_family, f_family) == 0) { item->SetMarked(true); } + if (strcmp(def_family, f_family) == 0) + item->SetMarked(true); + family_menu_index++; } return menu; @@ -635,9 +633,9 @@ TPrefsWindow::BuildFontMenu(BFont *font) BPopUpMenu * TPrefsWindow::BuildLevelMenu(int32 level) { - BMenuItem *item; - BMessage *msg; - BPopUpMenu *menu; + BMenuItem *item; + BMessage *msg; + BPopUpMenu *menu; menu = new BPopUpMenu(""); msg = new BMessage(P_LEVEL); @@ -660,23 +658,20 @@ BPopUpMenu * TPrefsWindow::BuildAccountMenu(uint32 account) { BPopUpMenu *menu = new BPopUpMenu(""); - BMenuItem *item; //menu->SetRadioMode(true); BList chains; - if (GetOutboundMailChains(&chains) < B_OK) - { - menu->AddItem(item = new BMenuItem("",NULL)); + if (GetOutboundMailChains(&chains) < B_OK) { + menu->AddItem(item = new BMenuItem("", NULL)); item->SetEnabled(false); return menu; } BMessage *msg; - for (int32 i = 0;i < chains.CountItems();i++) - { + for (int32 i = 0; i < chains.CountItems(); i++) { BMailChain *chain = (BMailChain *)chains.ItemAt(i); - item = new BMenuItem(chain->Name(),msg = new BMessage(P_ACCOUNT)); + item = new BMenuItem(chain->Name(), msg = new BMessage(P_ACCOUNT)); msg->AddInt32("id",chain->ID()); @@ -928,35 +923,36 @@ TPrefsWindow::BuildWarnUnencodableMenu(bool warnUnencodable) BPopUpMenu * TPrefsWindow::BuildSpellCheckStartOnMenu(bool spellCheckStartOn) { - return BuildBoolMenu(P_SPELL_CHECK_START_ON,"spellCheckStartOn",spellCheckStartOn); + return BuildBoolMenu(P_SPELL_CHECK_START_ON, "spellCheckStartOn", spellCheckStartOn); } BPopUpMenu * -TPrefsWindow::BuildButtonBarMenu(bool show) +TPrefsWindow::BuildButtonBarMenu(uint8 show) { BMenuItem *item; BMessage *msg; BPopUpMenu *menu; - + menu = new BPopUpMenu(""); - + msg = new BMessage(P_BUTTON_BAR); msg->AddInt8("bar", 1); menu->AddItem(item = new BMenuItem(ICON_LABEL_TEXT, msg)); if (show & 1) item->SetMarked(true); - + msg = new BMessage(P_BUTTON_BAR); msg->AddInt8("bar", 2); menu->AddItem(item = new BMenuItem(ICON_TEXT, msg)); if (show & 2) item->SetMarked(true); - + msg = new BMessage(P_BUTTON_BAR); msg->AddInt8("bar", 0); menu->AddItem(item = new BMenuItem(HIDE_TEXT, msg)); if (!show) item->SetMarked(true); + return menu; } diff --git a/src/apps/bemail/Prefs.h b/src/apps/bemail/Prefs.h index 9e8c992da7..82c36087db 100644 --- a/src/apps/bemail/Prefs.h +++ b/src/apps/bemail/Prefs.h @@ -66,17 +66,17 @@ class Button; //==================================================================== -class TPrefsWindow : public BWindow -{ +class TPrefsWindow : public BWindow { public: TPrefsWindow(BRect rect, BFont *font, int32 *level, bool *warp, bool *attachAttributes, bool *cquotes, uint32 *account, int32 *replyTo, char **preamble, char **sig, uint32 *encoding, - bool *warnUnencodable, bool *spellCheckStartOn, bool *buttonBar); + bool *warnUnencodable, bool *spellCheckStartOn, uint8 *buttonBar); ~TPrefsWindow(); - virtual void MessageReceived(BMessage*); + virtual void MessageReceived(BMessage *message); + private: BPopUpMenu *BuildFontMenu(BFont*); BPopUpMenu *BuildLevelMenu(int32); BPopUpMenu *BuildAccountMenu(uint32); @@ -90,17 +90,16 @@ class TPrefsWindow : public BWindow BPopUpMenu *BuildEncodingMenu(uint32 encoding); BPopUpMenu *BuildWarnUnencodableMenu(bool warnUnencodable); BPopUpMenu *BuildSpellCheckStartOnMenu(bool spellCheckStartOn); - BPopUpMenu *BuildButtonBarMenu(bool show); + BPopUpMenu *BuildButtonBarMenu(uint8 show); - private: BPopUpMenu *BuildBoolMenu(uint32 msg, const char *boolItem, bool isTrue); bool fWrap; bool *fNewWrap; bool fAttachAttributes; bool *fNewAttachAttributes; - bool fButtonBar; - bool *fNewButtonBar; + uint8 fButtonBar; + uint8 *fNewButtonBar; bool fColoredQuotes, *fNewColoredQuotes; uint32 fAccount; uint32 *fNewAccount;