* Got rid of the _SHOW_CALENDAR_MENU_ITEM, and _SHOW_CALENDAR_MENU_WINDOW
defines - it's always in, and I don't think it makes any sense to make this an option (since it just uses a system widget). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33699 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -35,23 +35,17 @@ All rights reserved.
|
|||||||
|
|
||||||
#include "TimeView.h"
|
#include "TimeView.h"
|
||||||
|
|
||||||
#ifdef _SHOW_CALENDAR_MENU_ITEM
|
#include <string.h>
|
||||||
# include "CalendarMenuItem.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _SHOW_CALENDAR_MENU_WINDOW
|
|
||||||
# include "CalendarMenuWindow.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <Window.h>
|
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include "CalendarMenuWindow.h"
|
||||||
|
|
||||||
|
|
||||||
const char* kShortDateFormat = "%m/%d/%y";
|
const char* kShortDateFormat = "%m/%d/%y";
|
||||||
@@ -237,7 +231,7 @@ TTimeView::MessageReceived(BMessage* message)
|
|||||||
case 'time':
|
case 'time':
|
||||||
Window()->PostMessage(message, Parent());
|
Window()->PostMessage(message, Parent());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kLongClick:
|
case kLongClick:
|
||||||
{
|
{
|
||||||
StopLongClickNotifier();
|
StopLongClickNotifier();
|
||||||
@@ -246,7 +240,7 @@ TTimeView::MessageReceived(BMessage* message)
|
|||||||
ShowCalendar(where);
|
ShowCalendar(where);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kShowCalendar:
|
case kShowCalendar:
|
||||||
{
|
{
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
@@ -255,7 +249,7 @@ TTimeView::MessageReceived(BMessage* message)
|
|||||||
ShowCalendar(center);
|
ShowCalendar(center);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
}
|
}
|
||||||
@@ -265,30 +259,15 @@ TTimeView::MessageReceived(BMessage* message)
|
|||||||
void
|
void
|
||||||
TTimeView::ShowCalendar(BPoint where)
|
TTimeView::ShowCalendar(BPoint where)
|
||||||
{
|
{
|
||||||
//TODO: do nothing if the calendar is already shown
|
if (fCalendarWindow.IsValid()) {
|
||||||
|
// If the calendar is already shown, just activate it
|
||||||
|
BMessage activate(B_SET_PROPERTY);
|
||||||
|
activate.AddSpecifier("Active");
|
||||||
|
activate.AddBool("data", true);
|
||||||
|
|
||||||
#ifdef _SHOW_CALENDAR_MENU_ITEM
|
if (fCalendarWindow.SendMessage(&activate) == B_OK)
|
||||||
|
return;
|
||||||
BPopUpMenu* menu = new BPopUpMenu("", false, false);
|
}
|
||||||
menu->SetFont(be_plain_font);
|
|
||||||
|
|
||||||
menu->AddItem(new CalendarMenuItem());
|
|
||||||
menu->ResizeToPreferred();
|
|
||||||
|
|
||||||
BPoint point = where;
|
|
||||||
BScreen screen;
|
|
||||||
where.y = Bounds().bottom + 4;
|
|
||||||
|
|
||||||
// make sure the menu is visible and doesn't hide the date
|
|
||||||
ConvertToScreen(&where);
|
|
||||||
if (where.y + menu->Bounds().Height() > screen.Frame().bottom)
|
|
||||||
where.y -= menu->Bounds().Height() + 2 * Bounds().Height();
|
|
||||||
|
|
||||||
ConvertToScreen(&point);
|
|
||||||
menu->Go(where, true, true, BRect(point.x - 4, point.y - 4,
|
|
||||||
point.x + 4, point.y + 4), true);
|
|
||||||
|
|
||||||
#elif _SHOW_CALENDAR_MENU_WINDOW
|
|
||||||
|
|
||||||
where.y = Bounds().bottom + 4.0;
|
where.y = Bounds().bottom + 4.0;
|
||||||
ConvertToScreen(&where);
|
ConvertToScreen(&where);
|
||||||
@@ -297,8 +276,9 @@ TTimeView::ShowCalendar(BPoint where)
|
|||||||
where.y -= (Bounds().Height() + 4.0);
|
where.y -= (Bounds().Height() + 4.0);
|
||||||
|
|
||||||
CalendarMenuWindow* window = new CalendarMenuWindow(where, fEuroDate);
|
CalendarMenuWindow* window = new CalendarMenuWindow(where, fEuroDate);
|
||||||
window->Show();
|
fCalendarWindow = BMessenger(window);
|
||||||
#endif
|
|
||||||
|
window->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -306,16 +286,16 @@ void
|
|||||||
TTimeView::StartLongClickNotifier(BPoint where)
|
TTimeView::StartLongClickNotifier(BPoint where)
|
||||||
{
|
{
|
||||||
StopLongClickNotifier();
|
StopLongClickNotifier();
|
||||||
|
|
||||||
BMessage longClickMessage(kLongClick);
|
BMessage longClickMessage(kLongClick);
|
||||||
longClickMessage.AddPoint("where", where);
|
longClickMessage.AddPoint("where", where);
|
||||||
|
|
||||||
bigtime_t longClickThreshold;
|
bigtime_t longClickThreshold;
|
||||||
get_click_speed(&longClickThreshold);
|
get_click_speed(&longClickThreshold);
|
||||||
// use the doubleClickSpeed as a threshold
|
// use the doubleClickSpeed as a threshold
|
||||||
|
|
||||||
fLongClickMessageRunner = new BMessageRunner(BMessenger(this),
|
fLongClickMessageRunner = new BMessageRunner(BMessenger(this),
|
||||||
&longClickMessage, longClickThreshold, 1);
|
&longClickMessage, longClickThreshold, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -323,7 +303,7 @@ void
|
|||||||
TTimeView::StopLongClickNotifier()
|
TTimeView::StopLongClickNotifier()
|
||||||
{
|
{
|
||||||
delete fLongClickMessageRunner;
|
delete fLongClickMessageRunner;
|
||||||
fLongClickMessageRunner = NULL;
|
fLongClickMessageRunner = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -406,7 +386,7 @@ TTimeView::MouseDown(BPoint point)
|
|||||||
if (buttons == B_SECONDARY_MOUSE_BUTTON) {
|
if (buttons == B_SECONDARY_MOUSE_BUTTON) {
|
||||||
ShowClockOptions(ConvertToScreen(point));
|
ShowClockOptions(ConvertToScreen(point));
|
||||||
return;
|
return;
|
||||||
} else if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
} else if (buttons == B_PRIMARY_MOUSE_BUTTON) {
|
||||||
StartLongClickNotifier(point);
|
StartLongClickNotifier(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,12 +565,10 @@ TTimeView::ShowClockOptions(BPoint point)
|
|||||||
item = new BMenuItem("Hide Time", new BMessage('time'));
|
item = new BMenuItem("Hide Time", new BMessage('time'));
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
|
|
||||||
#if defined(_SHOW_CALENDAR_MENU_ITEM) || defined(_SHOW_CALENDAR_MENU_WINDOW)
|
|
||||||
item = new BMenuItem("Show Calendar" B_UTF8_ELLIPSIS,
|
item = new BMenuItem("Show Calendar" B_UTF8_ELLIPSIS,
|
||||||
new BMessage(kShowCalendar));
|
new BMessage(kShowCalendar));
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
#endif
|
|
||||||
|
|
||||||
menu->SetTargetForItems(this);
|
menu->SetTargetForItems(this);
|
||||||
// Changed to accept screen coord system point;
|
// Changed to accept screen coord system point;
|
||||||
// not constrained to this view now
|
// not constrained to this view now
|
||||||
|
|||||||
@@ -34,9 +34,12 @@ All rights reserved.
|
|||||||
#ifndef TIME_VIEW_H
|
#ifndef TIME_VIEW_H
|
||||||
#define TIME_VIEW_H
|
#define TIME_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
|
#include <Messenger.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
const uint32 kShowSeconds = 'ShSc';
|
const uint32 kShowSeconds = 'ShSc';
|
||||||
const uint32 kMilTime = 'MilT';
|
const uint32 kMilTime = 'MilT';
|
||||||
const uint32 kFullDate = 'FDat';
|
const uint32 kFullDate = 'FDat';
|
||||||
@@ -128,8 +131,9 @@ class TTimeView : public BView {
|
|||||||
bool fOrientation; // vertical = true
|
bool fOrientation; // vertical = true
|
||||||
BPoint fTimeLocation;
|
BPoint fTimeLocation;
|
||||||
BPoint fDateLocation;
|
BPoint fDateLocation;
|
||||||
|
|
||||||
BMessageRunner* fLongClickMessageRunner;
|
BMessenger fCalendarWindow;
|
||||||
|
BMessageRunner* fLongClickMessageRunner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user