[haiku-gsoc] Few Questions on message passing and calendar view.

  • From: Akshay Agarwal <agarwal.akshay.akshay8@xxxxxxxxx>
  • To: haiku-gsoc@xxxxxxxxxxxxx
  • Date: Wed, 14 Jun 2017 13:09:28 +0530

Hi,

I have a few questions:

1. How can the I set the day names header in the calendar view based
on the locale? In the time preferences, the calendar view seems to
display the day names based on locale but I'm not able to achieve the
same in my code.

https://pasteboard.co/i9cyHQCyl.png
https://github.com/haiku/haiku/blob/master/src/kits/shared/CalendarView.cpp#L799-L803

Also the day header in time preferences doesn't change with live
changes in locale preferences. Moreover the calendar view uses
BDate::ShortDayName() for the day header names which probably doesn't
incorporate locale based day names.

2. In order to update date in the calendar app with live changes in
system date I'm making the MainView in the calendar app accept pulse
messages(using B_PULSE_NEEDED) and every time the Pulse() method is
called I'm checking the system date and sending the state change
message using SendNotices()
to all the other subscribers(currently there is only one-
sidepanelview that contains the date header and calendar views) and
calling the method to update the date header in the sidepanel view
class on receiving the message. Is this approach right or is there any
better way?
https://github.com/AkshayAgarwal007/Calendar/commit/5dc31f9d7d8a6ab066244816e00b4b1e97c1ee64

3. How can I change the date headers with live changes in locale
preferences. From what I could understand is that there is a be_roster
global object which emits a state change message(B_LOCALE_CHANGED) on
changes in locale preferences. I subscribed the MainWindow in my app
to the same using be_roster->StarWatching(this,B_LOCALE_CHANGED) but
it's not receiving the
message. What is the correct way to do this?


4. Say there is a class MainView that inherits BView, attached to a
BWindow(there is an object fMainView created in the Window class). Now
the window receives a message(say a message generated on one of the
button presses) and in the MessageReceived hook I want to call some
functionality of MainView.

How do I do this? by directly calling, fMainView->functionname(),
or fMainView->MessageReceived()(and call the required method there) or
send the message using a BMessenger::SendMessage(). All of it works,
but what is the difference and in which case one is used.

Is it that in BMessenger::SendMessage(), it will go through the
window's looper and check for handlers and ultimately end up in
MainView's MessageReceived hook. But in fMainView->MessageReceived()
the MessageReceived is directly called and it will wait until the
message in processed?

Is the way I'm passing the kSetStartOfWeekMessage
from the preference window to the sidpanel view the correct way?
https://github.com/AkshayAgarwal007/Calendar/blob/dev/src/MainWindow.cpp#L109-L114

5. In the calendar view when I change the selected day,
the current day doesn't remain highlighted. Also if a day which is not
in the current month is selected, for e.g like this
https://pasteboard.co/ilDde4HP0.png. Then I cannot bring the focus
back to the current day programmatically i.e the
CalendarView::SetDate() doesn't work. How to achieve this?


-Akshay

Other related posts:

  • » [haiku-gsoc] Few Questions on message passing and calendar view. - Akshay Agarwal