syncsettings.cpp
来自「funambol window mobile客户端源代码」· C++ 代码 · 共 1,160 行 · 第 1/3 页
CPP
1,160 行
switch(DRA::GetDisplayMode())
{
case DRA::Landscape:
resId = IDD_UI_SYNC_WIDE;
showScroll = TRUE;
break;
case DRA::Portrait:
resId = IDD_UI_SYNC; break;
showScroll = FALSE;
break;
case DRA::Square:
resId = IDD_UI_SYNC_SQUARE; break;
showScroll = TRUE;
break;
default:
resId = IDD_UI_SYNC; break;
showScroll = FALSE;
break;
};
DRA::RelayoutDialog( AfxGetInstanceHandle(), this->m_hWnd, MAKEINTRESOURCE(resId));
#else
switch(DRA::GetDisplayMode())
{
case DRA::Landscape:
if(s1.GetLength()>13){
paddingVal = 140;
}else{
paddingVal = 100;
}
break;
case DRA::Portrait:
if(s1.GetLength()>13){
paddingVal = 130;
}else{
paddingVal = 90;
}
break;
default:
paddingVal = 6;
break;
};
#endif
LoadStringResources();
}
#endif
void CSyncSettings::OnClickedSyncButtonMail(){
source = "mail";
showAdvanced();
}
void CSyncSettings::OnClickedSyncButtonBriefcase(){
source = "briefcase";
showAdvanced();
}
void CSyncSettings::OnClickedSyncButtonPimOptions(){
source = "pim";
showAdvanced();
}
#if defined(WIN32_PLATFORM_PSPC)
void CSyncSettings::OnBnClickedSyncNotes(){
// if(checkNotes.GetCheck() == BST_UNCHECKED)
// butNotes.EnableWindow(FALSE);
// else
// butNotes.EnableWindow(TRUE);
if(checkNotes.GetCheck() == BST_CHECKED) {
source=TEXT("note");
}
bool flag = true;
if (checkContacts.GetCheck() == BST_UNCHECKED &&
checkCalendar.GetCheck() == BST_UNCHECKED &&
checkTasks.GetCheck() == BST_UNCHECKED ) {
flag = false;
}
if (showBriefcaseSource) {
// if (!getRegConfig()->getIsPortal()){
if(checkBriefcase.GetCheck() == BST_CHECKED){
flag = true;
}
}
if (showNoteSource) {
#if defined(WIN32_PLATFORM_PSPC)
if(checkNotes.GetCheck() == BST_CHECKED){
flag = true;
}
#endif
}
butPimOptions.EnableWindow(flag);
}
void CSyncSettings::OnClickedSyncButtonNotes(){
source = "note";
showAdvanced();
}
#endif
void CSyncSettings::LoadStringResources(){
CString s1;
// load strings
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_EMAIL); SetDlgItemText(IDC_SYNC_MAIL, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CONTACTS); SetDlgItemText(IDC_SYNC_CONTACTS, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_CALENDAR); SetDlgItemText(IDC_SYNC_CALENDAR,s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_TASKS); SetDlgItemText(IDC_SYNC_TASKS, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_BRIEFCASE); SetDlgItemText(IDC_SYNC_BRIEFCASE, s1);
#if defined(WIN32_PLATFORM_PSPC)
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_NOTES);
SetDlgItemText(IDC_SYNC_NOTES, s1);
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SYNC_SETTINGS);
SetDlgItemText(IDC_HEADER_STATIC, s1);
GetDlgItem(IDC_HEADER_STATIC)->SetFont(&fontBold);
#endif
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SYNC_ITEMS); SetDlgItemText(IDC_SYNC_STATIC_ITEMS, s1);
// Read sync method from config
SetDlgItemText(IDC_SYNC_METHOD_LABEL, getActiveSyncMethod());
s1.LoadString(getLocalizationUtils()->getLocaleResource(), IDS_SYNC_METHOD_ABB);
CRect advancedRect;
CRect syncMethodRect;
GetDlgItem(IDC_SYNC_LINK_ADVANCED)->GetWindowRect(&advancedRect);
GetDlgItem(IDC_PIM_GROUPBOX)->GetWindowRect(&syncMethodRect);
linkAdvanced.SetWindowPos(&CWnd::wndTop, 3,syncMethodRect.bottom - 20,
paddingVal, advancedRect.Height(),SWP_NOZORDER);
s1 = getActiveSyncMethod();
int dimSyncMethod = s1.GetLength();
GetDlgItem(IDC_SYNC_METHOD_LABEL)->SetWindowPos(&CWnd::wndTop,
(paddingVal)+4, syncMethodRect.bottom - 20,
dimSyncMethod*8,advancedRect.Height(),SWP_NOZORDER);
}
#if defined(WIN32_PLATFORM_PSPC)
void CSyncSettings::OnBnSetfocusSyncNotes(){
if(checkNotes.GetCheck() == BST_CHECKED) {
source=TEXT("note");
}
}
#endif
// user clicked 'Sync Method' link
void CSyncSettings::OnBnClickedSyncLinkAdvanced(){
CSyncMethod wndSyncAdvanced;
INT_PTR result = wndSyncAdvanced.DoModal();
// Reload resources, this is necessary to correctly
// display the Sync method used.
LoadStringResources();
}
// capture pressing of 'Advanced' link
BOOL CSyncSettings::PreTranslateMessage(MSG* pMsg){
bool bProcessed =false;
if(pMsg->message == WM_KEYDOWN){
if(pMsg->wParam == VK_RETURN){
if(processKeyEvents(pMsg->wParam)){
bProcessed = true;
}
};
// left/right/down arrow keys
if( (pMsg->wParam == VK_LEFT) || (pMsg->wParam == VK_RIGHT) ||
(pMsg->wParam == VK_DOWN) || (pMsg->wParam == VK_UP)){
if(processKeyEvents(pMsg->wParam)){
bProcessed = true;
}
};
};
if(bProcessed){
return TRUE;
}
else{
return CDialog::PreTranslateMessage(pMsg);
}
}
void CSyncSettings::OnBnSetfocusSyncLinkAdvanced(){
}
bool CSyncSettings::processKeyEvents(WPARAM key){
bool bProcessed = false;
HWND wndFocus = GetFocus()->GetSafeHwnd();
if(key == VK_RETURN){
if(wndFocus == butMail.GetSafeHwnd()){
OnClickedSyncButtonMail();
return true;
};
if(wndFocus == butPimOptions.GetSafeHwnd()){
OnClickedSyncButtonPimOptions();
return true;
}
if(wndFocus == linkAdvanced.GetSafeHwnd()){
OnBnClickedSyncLinkAdvanced();
return true;
};
}
if( (key == VK_LEFT) || (key == VK_RIGHT) ){
if(wndFocus == checkMail.GetSafeHwnd()){
butMail.SetFocus();
return true;
}
if ( wndFocus == checkContacts.GetSafeHwnd() ||
wndFocus == checkCalendar.GetSafeHwnd() ||
wndFocus == checkTasks.GetSafeHwnd() ){
butPimOptions.SetFocus();
return true;
}
#if defined(WIN32_PLATFORM_PSPC)
if(wndFocus == checkNotes.GetSafeHwnd()){
return true;
};
#endif
if(wndFocus == checkBriefcase.GetSafeHwnd()){
return true;
}
if(wndFocus == butMail.GetSafeHwnd()){
checkMail.SetFocus();
return true;
}
if (wndFocus == butPimOptions.GetSafeHwnd()){
checkContacts.SetFocus();
return true;
}
}
if(key == VK_DOWN){
if(checkBriefcase.IsWindowEnabled()){
if(wndFocus == checkBriefcase.GetSafeHwnd()){
linkAdvanced.SetFocus();
return true;
}
}
else{
// for portal last source is Tasks
if(wndFocus == checkTasks.GetSafeHwnd()){
linkAdvanced.SetFocus();
return true;
}
}
}
if(key == VK_UP){
if(wndFocus == linkAdvanced.GetSafeHwnd()){
if(checkBriefcase.IsWindowEnabled()){
checkBriefcase.SetFocus();
}
else{
checkTasks.SetFocus();
}
return true;
}
}
return false;
}
//
// These are called from menu
//
void CSyncSettings::OnEmailOptionsClicked() {
OnClickedSyncButtonMail();
}
void CSyncSettings::OnPIMOptionsClicked() {
OnClickedSyncButtonPimOptions();
}
void CSyncSettings::OnSyncMethodClicked() {
OnBnClickedSyncLinkAdvanced();
}
/**
* Repaint objects. Draw 2 lines as separators between email and PIM,
* and between PIM and SyncMode.
*/
void CSyncSettings::OnPaint() {
// Call default handler to redraw items if needed
Default();
// CDC::LineTo() uses x,y coordinates related to the display window area,
// we need the offset between the window rect and the client rect.
CRect clientRect, windowrect;
GetClientRect(&clientRect);
GetWindowRect(&windowrect);
int offset = windowrect.top - clientRect.top;
//
// Set the SyncMode link & label...
//
int border = 2;
int linkLength = (int)(clientRect.Width() * 0.45); // too much?
int labelLength = clientRect.Width() - linkLength; // all the remaining
CRect syncModeRect, grboxRect;
linkAdvanced.GetWindowRect(&syncModeRect);
GetDlgItem(IDC_PIM_GROUPBOX)->GetWindowRect(&grboxRect);
int linkTop = grboxRect.bottom - offset + 5; // +5 = some space under the separator line
linkAdvanced.SetWindowPos(&CWnd::wndTop,
border, // some space from border
linkTop,
linkLength-border,
syncModeRect.Height(),
SWP_NOZORDER);
GetDlgItem(IDC_SYNC_METHOD_LABEL)->SetWindowPos(&CWnd::wndTop,
linkLength,
linkTop+2, // +2 because the other one is underlined, so it's higher
labelLength,
syncModeRect.Height(),
SWP_NOZORDER);
linkAdvanced.GetWindowRect(&syncModeRect);
//
// 1st horizontal line: black line above the SyncMode.
// Starts left aligned with "SyncMode" and ends at 95% of the screen width
// Top aligned with the groupbox (hidden)
//
CPoint start, end;
start.x = syncModeRect.left +2; start.y = grboxRect.bottom - offset;
end.x = (int)(clientRect.Width() * 0.95); end.y = grboxRect.bottom - offset;
CClientDC dc(this);
drawLine(&dc, start, end);
//
// 2nd horizontal line: gray dashed line [5% - 95%] between checkMail and checkContacts
//
CRect mailCheckboxRect, contactsCheckboxRect, mailOptionsRect;
checkMail.GetWindowRect(&mailCheckboxRect);
checkContacts.GetWindowRect(&contactsCheckboxRect);
butMail.GetWindowRect(&mailOptionsRect);
// Get the middle Y position between checkMail and checkContacts
int posY = mailCheckboxRect.bottom + (contactsCheckboxRect.top - mailCheckboxRect.bottom)/2;
start.x = (int)(clientRect.Width() * 0.05); start.y = posY - offset;
end.x = (int)(clientRect.Width() * 0.95); end.y = posY - offset;
COLORREF grey = RGB(180,180,180);
drawLine(&dc, start, end, grey, 1, PS_DASH);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?