diff --git a/Makefile b/Makefile index 0094145..73ac2aa 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,8 @@ SRCS = \ src/Budget.cpp \ src/BudgetReport.cpp \ src/BudgetWindow.cpp \ + src/CalendarButton.cpp\ + src/CalendarMenuWindow.cpp \ src/CashFlowReport.cpp \ src/Category.cpp \ src/CategoryBox.cpp \ @@ -118,7 +120,7 @@ RSRCS = \ # - if your library does not follow the standard library naming scheme, # you need to specify the path to the library and it's name. # (e.g. for mylib.a, specify "mylib.a" or "path/mylib.a") -LIBS = be tracker localestub translation sqlite3 columnlistview $(STDCPPLIBS) +LIBS = be tracker shared localestub translation sqlite3 columnlistview $(STDCPPLIBS) # Specify additional paths to directories following the standard libXXX.so # or libXXX.a naming scheme. You can specify full paths or paths relative @@ -130,7 +132,9 @@ LIBPATHS = # Additional paths to look for system headers. These use the form # "#include
". Directories that contain the files in SRCS are # NOT auto-included here. -SYSTEM_INCLUDE_PATHS = $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/interface) +SYSTEM_INCLUDE_PATHS = \ + $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/interface) \ + $(shell findpaths -e B_FIND_PATH_HEADERS_DIRECTORY private/shared) # Additional paths paths to look for local headers. These use the form # #include "header". Directories that contain the files in SRCS are diff --git a/src/CalendarButton.cpp b/src/CalendarButton.cpp new file mode 100644 index 0000000..2b38555 --- /dev/null +++ b/src/CalendarButton.cpp @@ -0,0 +1,87 @@ +#include "CalendarButton.h" +#include "CalendarMenuWindow.h" +#include "Database.h" + +#include + +enum { + M_SHOW_CALENDER, + M_SET_DATE +}; + + +CalendarButton::CalendarButton(DateBox* datebox) + : BButton("calenderbutton", "📅", new BMessage(M_SHOW_CALENDER)), + fDateBox(datebox) +{ + float height; + fDateBox->GetPreferredSize(NULL, &height); + BSize size(height + 2, height); + SetExplicitSize(size); +} + + +void +CalendarButton::AttachedToWindow(void) +{ + SetTarget(this); +} + + +void +CalendarButton::MessageReceived(BMessage* msg) +{ + switch (msg->what) { + case M_SHOW_CALENDER: + { + ShowPopUpCalendar(); + break; + } + case M_SET_DATE: + { + int32 day, month, year; + BString date; + msg->FindInt32("day", &day); + msg->FindInt32("month", &month); + msg->FindInt32("year", &year); + date << day << "." << month << "." << year; + fDateBox->SetText(date); + fDateBox->Validate(); + break; + } + default: + { + BButton::MessageReceived(msg); + } + } +} + + + +void +CalendarButton::ShowPopUpCalendar() +{ + if (fCalendarWindow.IsValid()) { + BMessage activate(B_SET_PROPERTY); + activate.AddSpecifier("Active"); + activate.AddBool("data", true); + + if (fCalendarWindow.SendMessage(&activate) == B_OK) + return; + } + + BDate date = fDateBox->GetDate(); + BMessage* invocationMessage = new BMessage(M_SET_DATE); + BPoint where = Bounds().LeftTop(); + ConvertToScreen(&where); + + CalendarMenuWindow* window = new CalendarMenuWindow(this, where); + window->SetDate(date); + window->SetInvocationMessage(invocationMessage); + window->SetDate(date); + fCalendarWindow = BMessenger(window); + window->Show(); + + window->MoveBy(Bounds().Width() / 2, window->Bounds().Height() * -1.5); + window->MoveOnScreen(B_MOVE_IF_PARTIALLY_OFFSCREEN); +} diff --git a/src/CalendarButton.h b/src/CalendarButton.h new file mode 100644 index 0000000..4b9711b --- /dev/null +++ b/src/CalendarButton.h @@ -0,0 +1,26 @@ +#ifndef CALENDARBUTTON_H +#define CALENDARBUTTON_H + + +#include +#include + +#include "DateBox.h" + + +class CalendarButton : public BButton { +public: + CalendarButton(DateBox* box); + + void AttachedToWindow(void); + virtual void MessageReceived(BMessage* message); + +private: + void ShowPopUpCalendar(); + + DateBox* fDateBox; + BMessenger fCalendarWindow; + +}; + +#endif // CALENDARBUTTON_H diff --git a/src/CalendarMenuWindow.cpp b/src/CalendarMenuWindow.cpp new file mode 100644 index 0000000..dd98871 --- /dev/null +++ b/src/CalendarMenuWindow.cpp @@ -0,0 +1,253 @@ +/* + * Copyight 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com + * Copyright 2008 Karsten Heimrich, host.haiku@gmx.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ + + +#include "CalendarMenuWindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +using BPrivate::BCalendarView; + + +// #pragma mark - FlatButton + + +class FlatButton : public BButton +{ +public: + FlatButton(const BString& label, uint32 what) + : + BButton(label.String(), new BMessage(what)) + { + } + virtual ~FlatButton() {} + + virtual void Draw(BRect updateRect); +}; + + +void +FlatButton::Draw(BRect updateRect) +{ + updateRect = Bounds(); + rgb_color highColor = HighColor(); + + SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + FillRect(updateRect); + + font_height fh; + GetFontHeight(&fh); + + const char* label = Label(); + const float stringWidth = StringWidth(label); + const float x = (updateRect.right - stringWidth) / 2.0f; + const float labelY = updateRect.top + + ((updateRect.Height() - fh.ascent - fh.descent) / 2.0f) + fh.ascent + + 1.0f; + + SetHighColor(highColor); + DrawString(label, BPoint(x, labelY)); + + if (IsFocus()) { + SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); + StrokeRect(updateRect); + } +} + + +// #pragma mark - CalendarMenuWindow + + +CalendarMenuWindow::CalendarMenuWindow(BHandler* handler, BPoint where) + : + BWindow(BRect(0.0, 0.0, 100.0, 130.0), "", B_BORDERED_WINDOW, + B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE + | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE), + fYearLabel(NULL), + fMonthLabel(NULL), + fHandler(handler), + fInvocationMessage(NULL), + fCalendarView(NULL), + fSuppressFirstClose(true) +{ + SetFeel(B_FLOATING_ALL_WINDOW_FEEL); + + RemoveShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY); + AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); + + fYearLabel = new BStringView("year", ""); + fMonthLabel = new BStringView("month", ""); + + fCalendarView = new BCalendarView(Bounds(), "calendar", B_FOLLOW_ALL); + fCalendarView->SetInvocationMessage(new BMessage(kInvokationMessage)); + + BGroupLayout* layout = new BGroupLayout(B_HORIZONTAL); + SetLayout(layout); + + float width, height; + fMonthLabel->GetPreferredSize(&width, &height); + + BGridLayout* gridLayout = BGridLayoutBuilder(5.0) + .Add(_SetupButton("-", kMonthDownMessage, height), 0, 0) + .Add(fMonthLabel, 1, 0) + .Add(_SetupButton("+", kMonthUpMessage, height), 2, 0) + .Add(BSpaceLayoutItem::CreateGlue(), 3, 0) + .Add(_SetupButton("-", kYearDownMessage, height), 4, 0) + .Add(fYearLabel, 5, 0) + .Add(_SetupButton("+", kYearUpMessage, height), 6, 0) + .SetInsets(5.0, 0.0, 5.0, 0.0); + gridLayout->SetMinColumnWidth(1, be_plain_font->StringWidth("September")); + + BGroupView* groupView = new BGroupView(B_VERTICAL, 10.0); + BView* view = BGroupLayoutBuilder(B_VERTICAL, 5.0) + .Add(gridLayout->View()) + .Add(fCalendarView) + .SetInsets(5.0, 5.0, 5.0, 5.0) + .TopView(); + groupView->AddChild(view); + AddChild(groupView); + + MoveTo(where); +} + + +CalendarMenuWindow::~CalendarMenuWindow() +{ + SetInvocationMessage(NULL); +} + + +void +CalendarMenuWindow::Show() +{ + fCalendarView->MakeFocus(true); + BWindow::Show(); +} + + +void +CalendarMenuWindow::WindowActivated(bool active) +{ + if (active) + return; + + if (mouse_mode() != B_FOCUS_FOLLOWS_MOUSE) { + if (!active) + PostMessage(B_QUIT_REQUESTED); + } else { + if (fSuppressFirstClose && !active) { + fSuppressFirstClose = false; + return; + } + + if (!fSuppressFirstClose && !active) + PostMessage(B_QUIT_REQUESTED); + } +} + + +void +CalendarMenuWindow::MessageReceived(BMessage* message) +{ + switch (message->what) { + case kInvokationMessage: + { + int32 day, month, year; + message->FindInt32("day", &day); + message->FindInt32("month", &month); + message->FindInt32("year", &year); + BDate date = BDate(year, month, day); + _UpdateDate(date); + + BMessenger msgr(fHandler); + fInvocationMessage->AddInt32("day", day); + fInvocationMessage->AddInt32("month", month); + fInvocationMessage->AddInt32("year", year); + msgr.SendMessage(fInvocationMessage); + + PostMessage(B_QUIT_REQUESTED); + break; + } + + case kMonthDownMessage: + case kMonthUpMessage: + { + BDate date = fCalendarView->Date(); + date.AddMonths(kMonthDownMessage == message->what ? -1 : 1); + _UpdateDate(date); + break; + } + + case kYearDownMessage: + case kYearUpMessage: + { + BDate date = fCalendarView->Date(); + date.AddYears(kYearDownMessage == message->what ? -1 : 1); + _UpdateDate(date); + break; + } + + default: + BWindow::MessageReceived(message); + break; + } +} + + +void +CalendarMenuWindow::SetInvocationMessage(BMessage* message) +{ + delete fInvocationMessage; + fInvocationMessage = message; +} + + +void +CalendarMenuWindow::SetDate(const BDate& date) +{ + _UpdateDate(date); +} + + +void +CalendarMenuWindow::_UpdateDate(const BDate& date) +{ + if (!date.IsValid()) + return; + + fCalendarView->SetDate(date); + + BString yearString; + BString monthString; + + yearString << date.Year(); + fYearLabel->SetText(yearString); + + BDateFormat().GetMonthName(date.Month(), monthString); + fMonthLabel->SetText(monthString); +} + + +BButton* +CalendarMenuWindow::_SetupButton(const char* label, uint32 what, float height) +{ + FlatButton* button = new FlatButton(label, what); + button->SetExplicitMinSize(BSize(height, height)); + + return button; +} diff --git a/src/CalendarMenuWindow.h b/src/CalendarMenuWindow.h new file mode 100644 index 0000000..247119e --- /dev/null +++ b/src/CalendarMenuWindow.h @@ -0,0 +1,57 @@ +/* + * Copyight 2017 Akshay Agarwal, agarwal.akshay.akshay8@gmail.com + * Copyright 2008 Karsten Heimrich, host.haiku@gmx.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _CALENDAR_MENU_WINDOW_H_ +#define _CALENDAR_MENU_WINDOW_H_ + + +#include +#include + + +class BMessage; +class BStringView; + +namespace BPrivate { +class BCalendarView; +} + +using BPrivate::BCalendarView; + + +class CalendarMenuWindow : public BWindow +{ +public: + CalendarMenuWindow(BHandler* handler, BPoint where); + virtual ~CalendarMenuWindow(); + + virtual void Show(); + virtual void WindowActivated(bool active); + virtual void MessageReceived(BMessage* message); + void SetDate(const BDate& date); + void SetInvocationMessage(BMessage* message); + +private: + void _UpdateDate(const BDate& date); + BButton* _SetupButton(const char* label, uint32 what, float height); + +private: + static const int kInvokationMessage = 1000; + static const int kMonthDownMessage = 1001; + static const int kMonthUpMessage = 1002; + static const int kYearDownMessage = 1003; + static const int kYearUpMessage = 1004; + + + BStringView* fYearLabel; + BStringView* fMonthLabel; + BCalendarView* fCalendarView; + BHandler* fHandler; + BMessage* fInvocationMessage; + bool fSuppressFirstClose; +}; + + +#endif /* _CALENDAR_MENU_WINDOW_H_ */ diff --git a/src/CheckView.cpp b/src/CheckView.cpp index b9e1bfd..49a5482 100644 --- a/src/CheckView.cpp +++ b/src/CheckView.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -7,6 +8,7 @@ #include #include "Account.h" +#include "CalendarButton.h" #include "CategoryBox.h" #include "CheckNumBox.h" #include "CheckView.h" @@ -38,6 +40,8 @@ CheckView::CheckView(const char* name, int32 flags) dateLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fDate = new DateBox("dateentry", "", NULL, new BMessage(M_DATE_CHANGED)); + CalendarButton* calendarButton = new CalendarButton(fDate); + BStringView* typeLabel = new BStringView("typelabel", B_TRANSLATE_CONTEXT("Type", "CommonTerms")); typeLabel->SetExplicitSize(BSize(StringWidth("ShortType"), B_SIZE_UNSET)); @@ -81,22 +85,22 @@ CheckView::CheckView(const char* name, int32 flags) BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(0) .AddGrid(1.0f, 0.0f) - // .SetColumnWeight(1, 0.5f) .SetColumnWeight(2, 2.0f) .SetColumnWeight(3, 1.0f) .Add(dateLabel, 0, 0) .Add(fDate, 0, 1) - .Add(typeLabel, 1, 0) - .Add(fType, 1, 1) - .Add(payeeLabel, 2, 0) - .Add(fPayee, 2, 1) - .Add(amountLabel, 3, 0) - .Add(fAmount, 3, 1) - .Add(categoryLabel, 0, 2) - .Add(fCategory, 0, 3) - .Add(memoLabel, 1, 2, 3) - .Add(fMemo, 1, 3, 3) - .Add(fEnter, 4, 1, 1, 3) + .Add(calendarButton, 1, 1) + .Add(typeLabel, 2, 0) + .Add(fType, 2, 1) + .Add(payeeLabel, 3, 0) + .Add(fPayee, 3, 1) + .Add(amountLabel, 4, 0) + .Add(fAmount, 4, 1) + .Add(categoryLabel, 0, 2, 2, 1) + .Add(fCategory, 0, 3, 2, 1) + .Add(memoLabel, 2, 2, 3) + .Add(fMemo, 2, 3, 3) + .Add(fEnter, 5, 1, 1, 3) .End() .End(); } @@ -363,7 +367,6 @@ CheckView::DoNextField(void) } } - void CheckView::SetFieldsEnabled(bool enabled) { diff --git a/src/ReconcileWindow.cpp b/src/ReconcileWindow.cpp index 0e7e0e3..6194bf9 100644 --- a/src/ReconcileWindow.cpp +++ b/src/ReconcileWindow.cpp @@ -4,6 +4,7 @@ #include #include +#include "CalendarButton.h" #include "CBLocale.h" #include "CurrencyBox.h" #include "DAlert.h" @@ -60,53 +61,51 @@ ReconcileWindow::ReconcileWindow(const BRect frame, Account* account) } fAccount = account; - AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('Q', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); - BView* back = new BView("backview", B_WILL_DRAW); - back->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); - BLayoutBuilder::Group<>(this, B_VERTICAL, 0).SetInsets(0).Add(back).End(); - - fDateLabel = new BStringView("datelabel", B_TRANSLATE_CONTEXT("Date", "CommonTerms")); + BStringView* dateLabel = new BStringView("datelabel", B_TRANSLATE_CONTEXT("Date", "CommonTerms")); BString datestr; gDefaultLocale.DateToString(fCurrentDate, datestr); fDate = new DateBox("dateentry", NULL, datestr.String(), NULL); fDate->GetFilter()->SetMessenger(new BMessenger(this)); - fOpeningLabel = new BStringView("startinglabel", B_TRANSLATE("Starting balance")); + CalendarButton* calendarButton = new CalendarButton(fDate); + + BStringView* openingLabel = new BStringView("startinglabel", B_TRANSLATE("Starting balance")); + openingLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fOpening = new CurrencyBox("starting", NULL, NULL, new BMessage(M_SET_BALANCES)); fOpening->GetFilter()->SetMessenger(new BMessenger(this)); - fClosingLabel = new BStringView("closinglabel", B_TRANSLATE("Ending balance")); + BStringView* closingLabel = new BStringView("closinglabel", B_TRANSLATE("Ending balance")); + closingLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fClosing = new CurrencyBox("closing", NULL, NULL, new BMessage(M_SET_BALANCES)); fClosing->GetFilter()->SetMessenger(new BMessenger(this)); - fChargesLabel = new BStringView("chargeslabel", B_TRANSLATE("Bank charges")); + BStringView* chargesLabel = new BStringView("chargeslabel", B_TRANSLATE("Bank charges")); fCharges = new CurrencyBox("charges", NULL, NULL, NULL); fCharges->GetFilter()->SetMessenger(new BMessenger(this)); + fCharges->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); - fInterestLabel = new BStringView("interestlabel", B_TRANSLATE("Interest earned")); + BStringView* interestLabel = new BStringView("interestlabel", B_TRANSLATE("Interest earned")); fInterest = new CurrencyBox("interest", NULL, NULL, NULL); fInterest->GetFilter()->SetMessenger(new BMessenger(this)); + fInterest->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); fDepositList = new BListView("depositlist", B_SINGLE_SELECTION_LIST); fDepositList->SetFlags(fDepositList->Flags() | B_FULL_UPDATE_ON_RESIZE); fDepositList->SetInvocationMessage(new BMessage(M_TOGGLE_DEPOSIT)); fDepScroll = new BScrollView("fDepScroll", fDepositList, 0, false, true); - fDepScroll->SetViewColor(back->ViewColor()); fCheckList = new BListView("checklist", B_SINGLE_SELECTION_LIST); fCheckList->SetFlags(fDepositList->Flags() | B_FULL_UPDATE_ON_RESIZE); fCheckList->SetInvocationMessage(new BMessage(M_TOGGLE_CHECK)); fCheckScroll = new BScrollView("fCheckScroll", fCheckList, 0, false, true); - fCheckScroll->SetViewColor(back->ViewColor()); fChargeList = new BListView("chargelist", B_SINGLE_SELECTION_LIST); fChargeList->SetFlags(fDepositList->Flags() | B_FULL_UPDATE_ON_RESIZE); fChargeList->SetInvocationMessage(new BMessage(M_TOGGLE_CHARGE)); fChargeScroll = new BScrollView("fChargeScroll", fChargeList, 0, false, true); - fChargeScroll->SetViewColor(back->ViewColor()); BString label; @@ -147,43 +146,47 @@ ReconcileWindow::ReconcileWindow(const BRect frame, Account* account) fDate->MakeFocus(true); - BLayoutBuilder::Group<>(back, B_VERTICAL) - .SetInsets(10) +// clang-format off + BLayoutBuilder::Group<>(this, B_VERTICAL) + .SetInsets(B_USE_DEFAULT_SPACING) .AddGrid(1.0f, 1.0f) - .Add(fDateLabel, 0, 0) - .Add(fDate, 0, 1, 2) - .Add(fOpeningLabel, 2, 0) - .Add(fOpening, 2, 1, 2) - .Add(fClosingLabel, 4, 0) - .Add(fClosing, 4, 1, 2) - .End() + .Add(dateLabel, 0, 0, 2, 1) + .Add(fDate, 0, 1) + .Add(calendarButton, 1, 1) + .Add(openingLabel, 2, 0) + .Add(fOpening, 2, 1) + .Add(closingLabel, 3, 0) + .Add(fClosing, 3, 1) + .End() .AddGrid(1.0f, 1.0f) - .Add(fChargesLabel, 2, 0) - .Add(fCharges, 2, 1, 2) - .Add(fInterestLabel, 4, 0) - .Add(fInterest, 4, 1, 2) - .End() + .Add(chargesLabel, 2, 0) + .Add(fCharges, 2, 1, 2) + .Add(interestLabel, 4, 0) + .Add(fInterest, 4, 1, 2) + .End() .AddGrid(1.0f, 2.0f) - .Add(fDepScroll, 0, 0) - .Add(fDepLabel, 0, 1) - .Add(fCheckScroll, 2, 0) - .Add(fCheckLabel, 2, 1) - .Add(fChargeScroll, 4, 0) - .Add(fChargeLabel, 4, 1) - .End() - .AddGrid(1.0f, 1.0f) - .Add(fTotalLabel, 0, 0) - .End() - .AddGrid(1.0f, 1.0f) - .Add(fAutoReconcile, 0, 1) - .Add(fHelpButton, 1, 1) - .AddGlue(2, 1, 2) - .Add(fReset, 4, 1) - .AddGlue(5, 1) - .Add(fCancel, 6, 1) - .Add(fReconcile, 7, 1) - .End() + .Add(fDepScroll, 0, 0) + .Add(fDepLabel, 0, 1) + .Add(fCheckScroll, 2, 0) + .Add(fCheckLabel, 2, 1) + .Add(fChargeScroll, 4, 0) + .Add(fChargeLabel, 4, 1) + .End() + .AddGroup(B_HORIZONTAL) + .Add(fTotalLabel) + .AddGlue() + .End() + .AddGroup(B_HORIZONTAL) + .Add(fAutoReconcile) + .Add(fHelpButton) + .AddGlue() + .Add(fReset) + .AddGlue() + .Add(fCancel) + .Add(fReconcile) + .End() .End(); +// clang-format on } ReconcileWindow::~ReconcileWindow(void) @@ -194,45 +197,6 @@ ReconcileWindow::~ReconcileWindow(void) prefsLock.Unlock(); } -void -ReconcileWindow::FrameResized(float w, float h) -{ - // We implement our own resizing routines because all the controls need to be resized in a - // proportional manner of the window being resized, such as the 3 listviews each taking up just - // a little less than 1/3 of the window's width - /* - fDate->ResizeTo(w * fDateMultiplier, fDate->Frame().Height()); - fOpening->ResizeTo(w * fOpeningMultiplier, fOpening->Frame().Height()); - fOpening->MoveTo(fDate->Frame().right + 10,fOpening->Frame().top); - fClosing->MoveTo(fOpening->Frame().right + 10,fClosing->Frame().top); - fClosing->ResizeTo(w - 10 - fClosing->Frame().left, fClosing->Frame().Height()); - - - fCharges->ResizeTo((w/2)-15,fCharges->Frame().Height()); - fInterest->MoveTo(fCharges->Frame().right + 10,fInterest->Frame().top); - fInterest->ResizeTo(w - 10 - fInterest->Frame().left,fInterest->Frame().Height()); - - float listwidth = (Bounds().Width() - 40)/3; - float height = fDepScroll->Frame().Height(); - - fDepScroll->ResizeTo(listwidth, height); - fCheckScroll->ResizeTo(listwidth, height); - fChargeScroll->ResizeTo(listwidth, height); - - float top = fCheckList->Parent()->Frame().top; - fCheckScroll->MoveTo(fDepScroll->Frame().right + 10,top); - fChargeScroll->MoveTo(fCheckScroll->Frame().right + 10,top); - - fDepLabel->MoveTo(fDepScroll->Frame().left, fDepScroll->Frame().bottom+5); - fCheckLabel->MoveTo(fCheckScroll->Frame().left, fCheckScroll->Frame().bottom+5); - fChargeLabel->MoveTo(fChargeScroll->Frame().left, fChargeScroll->Frame().bottom+5); - - fDepLabel->ResizeTo(fDepScroll->Frame().Width(),fDepLabel->Frame().Height()); - fCheckLabel->ResizeTo(fCheckScroll->Frame().Width(),fCheckLabel->Frame().Height()); - fChargeLabel->ResizeTo(fChargeScroll->Frame().Width(),fChargeLabel->Frame().Height()); - */ -} - void ReconcileWindow::MessageReceived(BMessage* msg) { diff --git a/src/ReconcileWindow.h b/src/ReconcileWindow.h index f96948f..699426e 100644 --- a/src/ReconcileWindow.h +++ b/src/ReconcileWindow.h @@ -9,6 +9,7 @@ #include #include #include + #include "Account.h" #include "HelpButton.h" #include "Notifier.h" @@ -24,7 +25,6 @@ class ReconcileWindow : public BWindow, public Observer { ReconcileWindow(const BRect frame, Account* account); ~ReconcileWindow(void); void MessageReceived(BMessage* msg); - void FrameResized(float w, float h); void HandleNotify(const uint64& value, const BMessage* msg); bool QuitRequested(void); @@ -47,8 +47,7 @@ class ReconcileWindow : public BWindow, public Observer { // fTotal is the sum of all of the deposits, checks, and charges // The way to tell if we are done is if fDifference + fTotal == 0 Fixed fDepositTotal, fCheckTotal, fChargeTotal, fDifference, fTotal; - BStringView *fDepLabel, *fCheckLabel, *fChargeLabel, *fTotalLabel, *fDateLabel, *fOpeningLabel, - *fClosingLabel, *fChargesLabel, *fInterestLabel; + BStringView *fDepLabel, *fCheckLabel, *fChargeLabel, *fTotalLabel, *fDateLabel, *fChargesLabel; BScrollView *fDepScroll, *fCheckScroll, *fChargeScroll; HelpButton* fHelpButton; diff --git a/src/ReportWindow.cpp b/src/ReportWindow.cpp index 8d50884..e095f5b 100644 --- a/src/ReportWindow.cpp +++ b/src/ReportWindow.cpp @@ -8,6 +8,7 @@ #include #include +#include "CalendarButton.h" #include "ColumnTypes.h" #include "Database.h" #include "DateBox.h" @@ -63,7 +64,7 @@ ReportWindow::ReportWindow(BRect frame) BGroupLayout* subtotalLayout = new BGroupLayout(B_VERTICAL, 0); BGroupLayout* categoriesLayout = new BGroupLayout(B_VERTICAL, 0); BGroupLayout* reportsLayout = new BGroupLayout(B_VERTICAL, 0); - BGridLayout* datesLayout = new BGridLayout(B_USE_DEFAULT_SPACING, 1.0f); + BGridLayout* datesLayout = new BGridLayout(1.0f, 1.0f); BGroupLayout* listLayout = new BGroupLayout(B_VERTICAL, 1.0f); @@ -161,13 +162,14 @@ ReportWindow::ReportWindow(BRect frame) fStartDateBox = new DateBox( "startdate", temp.String(), datestring.String(), new BMessage(M_START_DATE_CHANGED)); fStartDateBox->SetDate(GetCurrentYear()); - // fStartDateBox->SetExplicitSize(BSize(be_plain_font->StringWidth("Starting date: 29.09.5038") - // + 164, B_SIZE_UNSET)); - // fStartDateBox->SetEscapeCancel(true); + datesLayout->AddItem(fStartDateBox->CreateLabelLayoutItem(), 0, 0); datesLayout->AddItem(fStartDateBox->CreateTextViewLayoutItem(), 1, 0); fStartDateBox->GetFilter()->SetMessenger(new BMessenger(this)); + CalendarButton* calendarStartButton = new CalendarButton(fStartDateBox); + datesLayout->AddView(calendarStartButton, 2, 0); + gDefaultLocale.DateToString(GetCurrentDate(), datestring); temp = B_TRANSLATE("Ending date:"); @@ -178,6 +180,9 @@ ReportWindow::ReportWindow(BRect frame) datesLayout->AddItem(fEndDateBox->CreateTextViewLayoutItem(), 1, 1); fEndDateBox->GetFilter()->SetMessenger(new BMessenger(this)); + CalendarButton* calendarEndButton = new CalendarButton(fEndDateBox); + datesLayout->AddView(calendarEndButton, 2, 1); + // TODO: Implement graph support // BBitmap *up, *down; // BRect brect(0, 0, 16, 16); diff --git a/src/ScheduleAddWindow.cpp b/src/ScheduleAddWindow.cpp index f8751f1..afd9779 100644 --- a/src/ScheduleAddWindow.cpp +++ b/src/ScheduleAddWindow.cpp @@ -12,6 +12,7 @@ #include #include +#include "CalendarButton.h" #include "CBLocale.h" #include "Database.h" #include "DateBox.h" @@ -110,6 +111,8 @@ ScheduleAddWindow::ScheduleAddWindow(const BRect& frame, const TransactionData& gDefaultLocale.DateToString(data.Date(), temp); fStartDate->SetText(temp.String()); + CalendarButton* calendarButton = new CalendarButton(fStartDate); + fRepeatAlways = new BRadioButton("inftimes", B_TRANSLATE("Indefinitely"), new BMessage(M_REPEAT_ALWAYS)); fRepeatAlways->SetValue(B_CONTROL_ON); @@ -135,52 +138,53 @@ ScheduleAddWindow::ScheduleAddWindow(const BRect& frame, const TransactionData& BButton* cancelButton = new BButton("cancelbutton", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); - // clang-format off +// clang-format off BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .SetInsets(B_USE_WINDOW_SPACING) .AddGrid(1.0f, 0.0f) - .Add(typeLabel, 0, 0) - .Add(type->CreateTextViewLayoutItem(), 0, 1) - .Add(payeeLabel, 1, 0) - .Add(payee->CreateTextViewLayoutItem(), 1, 1) - .Add(amountLabel, 2, 0) - .Add(amount->CreateTextViewLayoutItem(), 2, 1) - .End() + .Add(typeLabel, 0, 0) + .Add(type->CreateTextViewLayoutItem(), 0, 1) + .Add(payeeLabel, 1, 0) + .Add(payee->CreateTextViewLayoutItem(), 1, 1) + .Add(amountLabel, 2, 0) + .Add(amount->CreateTextViewLayoutItem(), 2, 1) + .End() .AddGrid(1.0f, 0.0f) - .Add(categoryLabel, 0, 0) - .Add(category->CreateTextViewLayoutItem(), 0, 1) - .Add(memoLabel, 1, 0) - .Add(memo->CreateTextViewLayoutItem(), 1, 1) - .End() + .Add(categoryLabel, 0, 0) + .Add(category->CreateTextViewLayoutItem(), 0, 1) + .Add(memoLabel, 1, 0) + .Add(memo->CreateTextViewLayoutItem(), 1, 1) + .End() .AddStrut(B_USE_DEFAULT_SPACING) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .AddStrut(B_USE_DEFAULT_SPACING) .AddGrid(1.0f, B_USE_DEFAULT_SPACING) - .SetColumnWeight(1, 2.0f) - .Add(intervalfield->CreateLabelLayoutItem(), 0, 0) - .Add(intervalfield->CreateMenuBarLayoutItem(), 1, 0, 3) - .Add(fStartDate->CreateLabelLayoutItem(), 0, 1) - .Add(fStartDate->CreateTextViewLayoutItem(), 1, 1, 3) - .Add(repeatLabel, 0, 2) - .Add(dummy, 0, 3) - .AddGroup(B_VERTICAL, 1.0f, 1, 2, 1, 2) - .Add(fRepeatAlways) - .AddGroup(B_HORIZONTAL, 0) - .Add(fRepeatLimited) - .Add(fRepeatCount) - .Add(timesLabel) - .End() - .End() - .AddGlue(4, 0, 4) - .End() + .SetColumnWeight(1, 2.0f) + .Add(intervalfield->CreateLabelLayoutItem(), 0, 0) + .Add(intervalfield->CreateMenuBarLayoutItem(), 1, 0, 2) + .Add(fStartDate->CreateLabelLayoutItem(), 0, 1) + .Add(fStartDate->CreateTextViewLayoutItem(), 1, 1) + .Add(calendarButton, 2, 1) + .Add(repeatLabel, 0, 2) + .Add(dummy, 0, 3) + .AddGroup(B_VERTICAL, 1.0f, 1, 2, 1, 2) + .Add(fRepeatAlways) + .AddGroup(B_HORIZONTAL, 0) + .Add(fRepeatLimited) + .Add(fRepeatCount) + .Add(timesLabel) + .End() + .End() + .AddGlue(4, 0, 4) + .End() .AddStrut(B_USE_BIG_SPACING) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) - .AddGlue() - .Add(cancelButton) - .Add(okButton) - .End() + .AddGlue() + .Add(cancelButton) + .Add(okButton) + .End() .End(); - // clang-format on +// clang-format on CenterIn(Frame()); } diff --git a/src/SplitView.cpp b/src/SplitView.cpp index 0e16aaa..d929c88 100644 --- a/src/SplitView.cpp +++ b/src/SplitView.cpp @@ -9,6 +9,7 @@ #include #include "Account.h" +#include "CalendarButton.h" #include "CategoryBox.h" #include "CheckNumBox.h" #include "CheckView.h" @@ -48,6 +49,8 @@ SplitView::SplitView(const char* name, const TransactionData& trans, const int32 gDefaultLocale.DateToString(fTransaction.Date(), tempstr); fDate->SetText(tempstr.String()); + CalendarButton* calendarButton = new CalendarButton(fDate); + // Type BStringView* typeLabel = new BStringView("typelabel", B_TRANSLATE_CONTEXT("Type", "CommonTerms")); @@ -164,7 +167,7 @@ SplitView::SplitView(const char* name, const TransactionData& trans, const int32 fStartExpanded = true; } - // clang-format off +// clang-format off BLayoutBuilder::Group<>(fSplitContainer, B_VERTICAL, 0) .SetInsets(0) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) @@ -197,16 +200,17 @@ SplitView::SplitView(const char* name, const TransactionData& trans, const int32 .SetColumnWeight(3, 1.0f) .Add(dateLabel, 0, 0) .Add(fDate, 0, 1) - .Add(typeLabel, 1, 0) - .Add(fType, 1, 1) - .Add(payeeLabel, 2, 0) - .Add(fPayee, 2, 1) - .Add(amountLabel, 3, 0) - .Add(fAmount, 3, 1) - .Add(categoryLabel, 0, 2) - .Add(fCategory, 0, 3) - .Add(memoLabel, 1, 2, 3) - .Add(fMemo, 1, 3, 3) + .Add(calendarButton, 1, 1) + .Add(typeLabel, 2, 0) + .Add(fType, 2, 1) + .Add(payeeLabel, 3, 0) + .Add(fPayee, 3, 1) + .Add(amountLabel, 4, 0) + .Add(fAmount, 4, 1) + .Add(categoryLabel, 0, 2, 2, 1) + .Add(fCategory, 0, 3, 2, 1) + .Add(memoLabel, 2, 2, 3) + .Add(fMemo, 2, 3, 3) .End() .AddGroup(B_HORIZONTAL) .Add(fSplit) diff --git a/src/SplitView.h b/src/SplitView.h index 48d82cf..b1a3947 100644 --- a/src/SplitView.h +++ b/src/SplitView.h @@ -24,7 +24,9 @@ enum { M_SPLIT_MEMO_CHANGED, M_EDIT_KEY, M_NEXT_SPLIT, - M_PREVIOUS_SPLIT + M_PREVIOUS_SPLIT, + M_SHOW_CALENDER, + M_SET_DATE }; class SplitViewFilter; @@ -67,7 +69,6 @@ class SplitView : public BView, public Observer { Fixed CalculateTotal(void); Category* MakeCategory(void); - // BTextControl *fType,*fPayee,*fAmount,*fCategory,*fMemo; DateBox* fDate; CheckNumBox* fType; PayeeBox* fPayee; @@ -77,6 +78,7 @@ class SplitView : public BView, public Observer { SplitViewFilter* fKeyFilter; BMessenger* fMessenger; BButton *fEnter, *fTransfer; + BCheckBox* fSplit; BView* fSplitContainer; diff --git a/src/TransferWindow.cpp b/src/TransferWindow.cpp index 8582cf4..be4db22 100644 --- a/src/TransferWindow.cpp +++ b/src/TransferWindow.cpp @@ -1,10 +1,13 @@ #include "TransferWindow.h" + #include +#include #include #include #include #include +#include "CalendarButton.h" #include "CBLocale.h" #include "CurrencyBox.h" #include "DAlert.h" @@ -21,6 +24,8 @@ #define M_DEST_SELECTED 'dssl' #define M_DATE_CHANGED 'dtch' #define M_AMOUNT_CHANGED 'amch' +#define M_SHOW_CALENDER 'shca' +#define M_SET_DATE 'stdt' TransferWindow::TransferWindow(BHandler* target) @@ -74,6 +79,8 @@ TransferWindow::InitObject(Account* src, Account* dest, const Fixed& amount) fDate->GetFilter()->SetMessenger(new BMessenger(this)); // fDate->SetEscapeCancel(true); + CalendarButton* calendarButton = new CalendarButton(fDate); + if (src && dest) { BString datestr; gDefaultLocale.DateToString(fDate->GetDate(), datestr); @@ -119,7 +126,7 @@ TransferWindow::InitObject(Account* src, Account* dest, const Fixed& amount) } else fDestList->MakeFocus(true); - // clang-format off +// clang-format off BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_HALF_ITEM_SPACING) .SetInsets(B_USE_WINDOW_SPACING) .AddGroup(B_HORIZONTAL) @@ -132,13 +139,15 @@ TransferWindow::InitObject(Account* src, Account* dest, const Fixed& amount) .Add(scrolldest) .End() .End() - .AddGrid(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) + .AddGrid(0.0, B_USE_SMALL_SPACING) .Add(fDate->CreateLabelLayoutItem(), 0, 0) .Add(fDate->CreateTextViewLayoutItem(), 1, 0) - .Add(fAmount->CreateLabelLayoutItem(), 2, 0) - .Add(fAmount->CreateTextViewLayoutItem(), 3, 0) + .Add(calendarButton, 2, 0) + .Add(BSpaceLayoutItem::CreateHorizontalStrut(B_USE_DEFAULT_SPACING), 3, 0) + .Add(fAmount->CreateLabelLayoutItem(), 4, 0) + .Add(fAmount->CreateTextViewLayoutItem(), 5, 0) .Add(fMemo->CreateLabelLayoutItem(), 0, 1) - .Add(fMemo->CreateTextViewLayoutItem(), 1, 1, 3, 1) + .Add(fMemo->CreateTextViewLayoutItem(), 1, 1, 5, 1) .End() .AddStrut(B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL) diff --git a/src/TransferWindow.h b/src/TransferWindow.h index fe2238d..83ff882 100644 --- a/src/TransferWindow.h +++ b/src/TransferWindow.h @@ -37,6 +37,7 @@ class TransferWindow : public BWindow { CurrencyBox* fAmount; BButton *fCancel, *fOK; + BStringView *fFromLabel, *fToLabel; BListView *fSourceList, *fDestList;