diff --git a/source/MainWindow.cpp b/source/MainWindow.cpp index f90b3c5..16a468a 100644 --- a/source/MainWindow.cpp +++ b/source/MainWindow.cpp @@ -37,7 +37,7 @@ enum MainWindow::MainWindow() : BWindow(BRect(100, 100, 740, 190), B_TRANSLATE_SYSTEM_NAME("Tipster"), - B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE + B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) { BuildLayout(); @@ -63,8 +63,7 @@ MainWindow::BuildLayout() new BMessage(PREVIOUS_TIP))); fTipMenu->AddItem(new BMenuItem(B_TRANSLATE("Next tip"), new BMessage(NEXT_TIP))); - - + fTipMenu->AddItem(fDelaySubMenu); fMenuBar->AddItem(fTipsterMenu); @@ -75,8 +74,8 @@ MainWindow::BuildLayout() BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .Add(fMenuBar) .Add(fTipsterView) - .AddGlue(); - +// .AddGlue() + .End(); // After the creation of Tipster because we need the delay // time saved in the settings @@ -84,6 +83,7 @@ MainWindow::BuildLayout() AddDelaySubMenuItem(60000000, B_TRANSLATE("1 minute")); AddDelaySubMenuItem(120000000, B_TRANSLATE("2 minutes")); AddDelaySubMenuItem(300000000, B_TRANSLATE("5 minutes")); + AddDelaySubMenuItem(0, B_TRANSLATE("Off")); fDelaySubMenu->SetRadioMode(true); } @@ -108,14 +108,12 @@ MainWindow::QuitRequested() } -#undef B_TRANSLATION_CONTEXT -#define B_TRANSLATION_CONTEXT "About" - void MainWindow::MessageReceived(BMessage* message) { - switch(message->what) + switch (message->what) { + case SHOW_ABOUT: { BAboutWindow* about = new AboutTipster(); @@ -136,8 +134,8 @@ MainWindow::MessageReceived(BMessage* message) { int64 delay = 60000000; message->FindInt64("delay", &delay); - fTipsterView->SetDelay(delay); +// printf("delay: %d \n", delay); break; } case MSG_QUIT: @@ -147,6 +145,7 @@ MainWindow::MessageReceived(BMessage* message) } default: BWindow::MessageReceived(message); + message->PrintToStream(); break; } } diff --git a/source/Tipster.cpp b/source/Tipster.cpp index d730090..709e331 100644 --- a/source/Tipster.cpp +++ b/source/Tipster.cpp @@ -7,6 +7,7 @@ #include "Shuffle.h" #include +#include #include #include #include @@ -44,7 +45,6 @@ enum const float kDraggerSize = 7.0f; - Tipster::Tipster() : BGroupView("Tipster") @@ -62,15 +62,21 @@ Tipster::Tipster() fTipsterTextView = new TipsterText(); fIcon = new BButton("iconview", "", new BMessage(OPEN_URL)); + fIcon -> SetToolTip( B_TRANSLATE("Open the Tipster homepage") ); BDragger* dragger = new BDragger(this); BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0) - .SetInsets(-2, -2, 0, -2) - .Add(fIcon) + .SetInsets(1, 1, 1, 1) + .AddGroup(B_VERTICAL,0) + .Add(fIcon) + .AddGlue() + .End() + .AddStrut(be_control_look->DefaultItemSpacing()) .AddGroup(B_VERTICAL,0) .Add(fTipsterTextView) + .AddGroup(B_HORIZONTAL, 0) .AddGlue() .Add(dragger) @@ -198,7 +204,6 @@ Tipster::QuitRequested() return true; } - void Tipster::AttachedToWindow() { @@ -280,9 +285,13 @@ Tipster::_LoadSettings() void Tipster::_ResetTimer() { - BMessage message(UPDATE_TIP); - delete fRunner; - fRunner = new BMessageRunner(this, message, fDelay); + if (fDelay > 0) { + // if delay is set to Off (0), don't send a runner message + + BMessage message(UPDATE_TIP); + delete fRunner; + fRunner = new BMessageRunner(this, message, fDelay); + } } @@ -372,7 +381,6 @@ Tipster::MouseDown(BPoint point) } } - void Tipster::UpdateIcon(BString artwork, BString url) { @@ -489,9 +497,11 @@ Tipster::GetTipsFile() for (int32 i = 0; (language = message.GetString("language", i, NULL)) != NULL; i++) { - if (getLocalTipsFile(ref, language)) + printf("lang: %s \n", language); + if (getLocalTipsFile(ref, language)) // return ref; - else if (getLocalTipsFile(ref, BString(language, + else + if (getLocalTipsFile(ref, BString(language, BString(language).FindFirst("_")))) return ref; } diff --git a/source/Tipster.h b/source/Tipster.h index 6fb9e63..a8ca773 100644 --- a/source/Tipster.h +++ b/source/Tipster.h @@ -58,7 +58,7 @@ class Tipster : public BGroupView int32 fTipIndex; std::vector fRandomSeq1; std::vector fRandomSeq2; - + BString* fPreviousTip; BString* fCurrentTip; diff --git a/source/TipsterText.cpp b/source/TipsterText.cpp index a0749d5..a6b4e1f 100644 --- a/source/TipsterText.cpp +++ b/source/TipsterText.cpp @@ -11,7 +11,9 @@ enum { - UPDATE_TIP = 'uptp' + UPDATE_TIP = 'uptp', + NEXT_TIP = 'nxtp', + PREVIOUS_TIP = 'pvtp' }; @@ -42,12 +44,12 @@ TipsterText::Instantiate(BMessage *data) { if (!validate_instantiation(data, "TipsterText")) { printf("Could not complete instantiation...\n"); - + return NULL; } - + printf("Instantiation validated...\n"); - + return new TipsterText(data); } @@ -56,7 +58,7 @@ void TipsterText::AttachedToWindow() { fMessenger = new BMessenger(this->Parent()); - + SetViewColor(Parent()->ViewColor()); BTextView::AttachedToWindow(); @@ -71,8 +73,10 @@ TipsterText::MouseDown(BPoint point) GetMouse(&temp, &buttons); if (Bounds().Contains(temp)) { - BMessage message(UPDATE_TIP); - - fMessenger->SendMessage(&message); + if (buttons == 1) //left mouse button + fMessenger->SendMessage(NEXT_TIP); + if (buttons == 2) //right mouse button + fMessenger->SendMessage(PREVIOUS_TIP); + } }