| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../include/pdfwindow/PDFWindow.h" | 7 #include "../../include/pdfwindow/PDFWindow.h" |
| 8 #include "../../include/pdfwindow/PWL_Wnd.h" | 8 #include "../../include/pdfwindow/PWL_Wnd.h" |
| 9 #include "../../include/pdfwindow/PWL_Button.h" | 9 #include "../../include/pdfwindow/PWL_Button.h" |
| 10 #include "../../include/pdfwindow/PWL_EditCtrl.h" | 10 #include "../../include/pdfwindow/PWL_EditCtrl.h" |
| 11 #include "../../include/pdfwindow/PWL_Edit.h" | 11 #include "../../include/pdfwindow/PWL_Edit.h" |
| 12 #include "../../include/pdfwindow/PWL_ListCtrl.h" | 12 #include "../../include/pdfwindow/PWL_ListCtrl.h" |
| 13 #include "../../include/pdfwindow/PWL_ScrollBar.h" | 13 #include "../../include/pdfwindow/PWL_ScrollBar.h" |
| 14 #include "../../include/pdfwindow/PWL_Note.h" | 14 #include "../../include/pdfwindow/PWL_Note.h" |
| 15 #include "../../include/pdfwindow/PWL_Label.h" | 15 #include "../../include/pdfwindow/PWL_Label.h" |
| 16 #include "../../include/pdfwindow/PWL_Edit.h" | 16 #include "../../include/pdfwindow/PWL_Edit.h" |
| 17 #include "../../include/pdfwindow/PWL_ScrollBar.h" | 17 #include "../../include/pdfwindow/PWL_ScrollBar.h" |
| 18 #include "../../include/pdfwindow/PWL_Utils.h" | 18 #include "../../include/pdfwindow/PWL_Utils.h" |
| 19 #include "../../include/pdfwindow/PWL_Caret.h" | 19 #include "../../include/pdfwindow/PWL_Caret.h" |
| 20 | 20 |
| 21 #define POPUP_ITEM_HEAD_BOTTOM 3.0f | 21 #define POPUP_ITEM_HEAD_BOTTOM 3.0f |
| 22 #define POPUP_ITEM_BOTTOMWIDTH 1.0f | 22 #define POPUP_ITEM_BOTTOMWIDTH 1.0f |
| 23 #define POPUP_ITEM_SIDEMARGIN 3.0f | 23 #define POPUP_ITEM_SIDEMARGIN 3.0f |
| 24 #define POPUP_ITEM_SPACE 4.0f | 24 #define POPUP_ITEM_SPACE 4.0f |
| 25 #define POPUP_ITEM_TEXT_INDENT 2.0f | 25 #define POPUP_ITEM_TEXT_INDENT 2.0f |
| 26 #define POPUP_ITEM_BORDERCOLOR CPWL_Color(COLOR
TYPE_RGB, 80/255.0f, 80/255.0f, 80/255.0f) | 26 #define POPUP_ITEM_BORDERCOLOR \ |
| 27 | 27 CPWL_Color(COLORTYPE_RGB, 80 / 255.0f, 80 / 255.0f, 80 / 255.0f) |
| 28 #define IsFloatZero(f) ((f) < 0.0001 &&
(f) > -0.0001) | 28 |
| 29 #define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloat
Zero((fa) - (fb))) | 29 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
| 30 #define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloat
Zero((fa) - (fb))) | 30 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
| 31 #define IsFloatEqual(fa,fb) IsFloatZero((fa)
-(fb)) | 31 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
| 32 | 32 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
| 33 | 33 |
| 34 /* ------------------------------- CPWL_Note_Options ---------------------------
---- */ | 34 /* ------------------------------- CPWL_Note_Options |
| 35 | 35 * ------------------------------- */ |
| 36 CPWL_Note_Options::CPWL_Note_Options() : m_pText(NULL) | 36 |
| 37 { | 37 CPWL_Note_Options::CPWL_Note_Options() : m_pText(NULL) { |
| 38 } | 38 } |
| 39 | 39 |
| 40 CPWL_Note_Options::~CPWL_Note_Options() | 40 CPWL_Note_Options::~CPWL_Note_Options() { |
| 41 { | 41 } |
| 42 } | 42 |
| 43 | 43 void CPWL_Note_Options::SetTextColor(const CPWL_Color& color) { |
| 44 void CPWL_Note_Options::SetTextColor(const CPWL_Color & color) | 44 CPWL_Wnd::SetTextColor(color); |
| 45 { | 45 |
| 46 CPWL_Wnd::SetTextColor(color); | 46 if (m_pText) |
| 47 | 47 m_pText->SetTextColor(color); |
| 48 if (m_pText) | 48 } |
| 49 m_pText->SetTextColor(color); | 49 |
| 50 } | 50 void CPWL_Note_Options::RePosChildWnd() { |
| 51 | 51 if (this->IsValid()) { |
| 52 void CPWL_Note_Options::RePosChildWnd() | 52 ASSERT(m_pText != NULL); |
| 53 { | 53 |
| 54 if (this->IsValid()) | 54 CPDF_Rect rcClient = GetClientRect(); |
| 55 { | 55 |
| 56 ASSERT(m_pText != NULL); | 56 if (rcClient.Width() > 15.0f) { |
| 57 | 57 rcClient.right -= 15.0f; |
| 58 CPDF_Rect rcClient = GetClientRect(); | 58 m_pText->Move(rcClient, TRUE, FALSE); |
| 59 | 59 m_pText->SetVisible(TRUE); |
| 60 if (rcClient.Width() > 15.0f) | 60 } else { |
| 61 { | 61 m_pText->Move(CPDF_Rect(0, 0, 0, 0), TRUE, FALSE); |
| 62 rcClient.right -= 15.0f; | 62 m_pText->SetVisible(FALSE); |
| 63 m_pText->Move(rcClient, TRUE, FALSE); | 63 } |
| 64 m_pText->SetVisible(TRUE); | 64 } |
| 65 } | 65 } |
| 66 else | 66 |
| 67 { | 67 void CPWL_Note_Options::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
| 68 m_pText->Move(CPDF_Rect(0,0,0,0), TRUE, FALSE); | 68 m_pText = new CPWL_Label; |
| 69 m_pText->SetVisible(FALSE); | 69 PWL_CREATEPARAM tcp = cp; |
| 70 } | 70 tcp.pParentWnd = this; |
| 71 } | 71 tcp.dwFlags = PWS_CHILD | PWS_VISIBLE; |
| 72 } | 72 m_pText->Create(tcp); |
| 73 | 73 } |
| 74 void CPWL_Note_Options::CreateChildWnd(const PWL_CREATEPARAM & cp) | 74 |
| 75 { | 75 void CPWL_Note_Options::SetText(const CFX_WideString& sText) { |
| 76 m_pText = new CPWL_Label; | 76 m_pText->SetText(sText); |
| 77 PWL_CREATEPARAM tcp = cp; | 77 } |
| 78 tcp.pParentWnd = this; | 78 |
| 79 tcp.dwFlags = PWS_CHILD | PWS_VISIBLE; | 79 void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 80 m_pText->Create(tcp); | 80 CPDF_Matrix* pUser2Device) { |
| 81 } | 81 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); |
| 82 | 82 |
| 83 void CPWL_Note_Options::SetText(const CFX_WideString& sText) | 83 CPDF_Rect rcClient = GetClientRect(); |
| 84 { | 84 rcClient.left = rcClient.right - 15.0f; |
| 85 m_pText->SetText(sText); | 85 |
| 86 } | 86 CPDF_Point ptCenter = CPDF_Point((rcClient.left + rcClient.right) * 0.5f, |
| 87 | 87 (rcClient.top + rcClient.bottom) * 0.5f); |
| 88 void CPWL_Note_Options::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matri
x* pUser2Device) | 88 |
| 89 { | 89 CPDF_Point pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f); |
| 90 CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); | 90 CPDF_Point pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f); |
| 91 | 91 CPDF_Point pt3(ptCenter.x, ptCenter.y - 3.0f * 0.5f); |
| 92 CPDF_Rect rcClient = GetClientRect(); | 92 |
| 93 rcClient.left = rcClient.right - 15.0f; | 93 CFX_PathData path; |
| 94 | 94 |
| 95 CPDF_Point ptCenter = CPDF_Point((rcClient.left + rcClient.right) * 0.5f
, (rcClient.top + rcClient.bottom) * 0.5f); | 95 path.SetPointCount(4); |
| 96 | 96 path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); |
| 97 CPDF_Point pt1(ptCenter.x - 2.0f, ptCenter.y + 2.0f * 0.5f); | 97 path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); |
| 98 CPDF_Point pt2(ptCenter.x + 2.0f, ptCenter.y + 2.0f * 0.5f); | 98 path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); |
| 99 CPDF_Point pt3(ptCenter.x, ptCenter.y - 3.0f * 0.5f); | 99 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); |
| 100 | 100 |
| 101 CFX_PathData path; | 101 pDevice->DrawPath( |
| 102 | 102 &path, |
| 103 path.SetPointCount(4); | 103 pUser2Device, |
| 104 path.SetPoint(0, pt1.x, pt1.y, FXPT_MOVETO); | 104 NULL, |
| 105 path.SetPoint(1, pt2.x, pt2.y, FXPT_LINETO); | 105 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 106 path.SetPoint(2, pt3.x, pt3.y, FXPT_LINETO); | 106 0, |
| 107 path.SetPoint(3, pt1.x, pt1.y, FXPT_LINETO); | 107 FXFILL_ALTERNATE); |
| 108 | 108 } |
| 109 pDevice->DrawPath(&path, pUser2Device, NULL, | 109 |
| 110 CPWL_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()),
| 110 CPDF_Rect CPWL_Note_Options::GetContentRect() const { |
| 111 0, FXFILL_ALTERNATE); | 111 ASSERT(m_pText != NULL); |
| 112 } | 112 |
| 113 | 113 CPDF_Rect rcText = m_pText->GetContentRect(); |
| 114 CPDF_Rect CPWL_Note_Options::GetContentRect() const | 114 rcText.right += 15.0f; |
| 115 { | 115 return rcText; |
| 116 ASSERT(m_pText != NULL); | 116 } |
| 117 | 117 |
| 118 CPDF_Rect rcText = m_pText->GetContentRect(); | 118 /* ------------------------------- CPWL_Note_Edit ------------------------------ |
| 119 rcText.right += 15.0f; | 119 */ |
| 120 return rcText; | 120 |
| 121 } | 121 CPWL_Note_Edit::CPWL_Note_Edit() |
| 122 | 122 : m_bEnableNotify(TRUE), |
| 123 /* ------------------------------- CPWL_Note_Edit ------------------------------
*/ | 123 m_fOldItemHeight(0.0f), |
| 124 | 124 m_bSizeChanged(FALSE), |
| 125 CPWL_Note_Edit::CPWL_Note_Edit() : m_bEnableNotify(TRUE), | 125 m_fOldMin(0.0f), |
| 126 m_fOldItemHeight(0.0f), | 126 m_fOldMax(0.0f) { |
| 127 m_bSizeChanged(FALSE), | 127 } |
| 128 m_fOldMin(0.0f), | 128 |
| 129 m_fOldMax(0.0f) | 129 CPWL_Note_Edit::~CPWL_Note_Edit() { |
| 130 { | 130 } |
| 131 } | 131 |
| 132 | 132 void CPWL_Note_Edit::RePosChildWnd() { |
| 133 CPWL_Note_Edit::~CPWL_Note_Edit() | 133 m_bEnableNotify = FALSE; |
| 134 { | 134 CPWL_Edit::RePosChildWnd(); |
| 135 } | 135 m_bEnableNotify = TRUE; |
| 136 | 136 |
| 137 void CPWL_Note_Edit::RePosChildWnd() | 137 m_fOldItemHeight = this->GetContentRect().Height(); |
| 138 { | 138 } |
| 139 m_bEnableNotify = FALSE; | 139 |
| 140 CPWL_Edit::RePosChildWnd(); | 140 void CPWL_Note_Edit::SetText(FX_LPCWSTR csText) { |
| 141 m_bEnableNotify = TRUE; | 141 m_bEnableNotify = FALSE; |
| 142 | 142 CPWL_Edit::SetText(csText); |
| 143 m_fOldItemHeight = this->GetContentRect().Height(); | 143 m_bEnableNotify = TRUE; |
| 144 } | 144 m_fOldItemHeight = this->GetContentRect().Height(); |
| 145 | 145 } |
| 146 void CPWL_Note_Edit::SetText(FX_LPCWSTR csText) | 146 |
| 147 { | 147 void CPWL_Note_Edit::OnSetFocus() { |
| 148 m_bEnableNotify = FALSE; | 148 m_bEnableNotify = FALSE; |
| 149 CPWL_Edit::SetText(csText); | 149 CPWL_Edit::OnSetFocus(); |
| 150 m_bEnableNotify = TRUE; | 150 m_bEnableNotify = TRUE; |
| 151 m_fOldItemHeight = this->GetContentRect().Height(); | 151 |
| 152 } | 152 this->EnableSpellCheck(TRUE); |
| 153 | 153 } |
| 154 void CPWL_Note_Edit::OnSetFocus() | 154 |
| 155 { | 155 void CPWL_Note_Edit::OnKillFocus() { |
| 156 m_bEnableNotify = FALSE; | 156 this->EnableSpellCheck(FALSE); |
| 157 CPWL_Edit::OnSetFocus(); | 157 |
| 158 m_bEnableNotify = TRUE; | 158 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 159 | 159 if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) { |
| 160 this->EnableSpellCheck(TRUE); | 160 ASSERT(pGrand->GetClassName() == "CPWL_NoteItem"); |
| 161 } | 161 |
| 162 | 162 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand; |
| 163 void CPWL_Note_Edit::OnKillFocus() | 163 |
| 164 { | 164 pNoteItem->OnContentsValidate(); |
| 165 this->EnableSpellCheck(FALSE); | 165 } |
| 166 | 166 } |
| 167 if (CPWL_Wnd* pParent = this->GetParentWindow()) | 167 |
| 168 { | 168 CPWL_Edit::OnKillFocus(); |
| 169 if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) | 169 } |
| 170 { | 170 |
| 171 ASSERT(pGrand->GetClassName() == "CPWL_NoteItem"); | 171 void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd, |
| 172 | 172 FX_DWORD msg, |
| 173 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pGrand; | 173 FX_INTPTR wParam, |
| 174 | 174 FX_INTPTR lParam) { |
| 175 pNoteItem->OnContentsValidate(); | 175 if (m_bEnableNotify) { |
| 176 } | 176 if (wParam == SBT_VSCROLL) { |
| 177 } | 177 switch (msg) { |
| 178 | 178 case PNM_SETSCROLLINFO: |
| 179 CPWL_Edit::OnKillFocus(); | 179 if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)lParam) { |
| 180 } | 180 if (!IsFloatEqual(pInfo->fContentMax, m_fOldMax) || |
| 181 | 181 !IsFloatEqual(pInfo->fContentMin, m_fOldMin)) { |
| 182 void CPWL_Note_Edit::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX
_INTPTR lParam) | 182 m_bSizeChanged = TRUE; |
| 183 { | 183 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 184 if (m_bEnableNotify) | 184 pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); |
| 185 { | 185 } |
| 186 if (wParam == SBT_VSCROLL) | 186 |
| 187 { | 187 m_fOldMax = pInfo->fContentMax; |
| 188 switch (msg) | 188 m_fOldMin = pInfo->fContentMin; |
| 189 { | 189 return; |
| 190 case PNM_SETSCROLLINFO: | 190 } |
| 191 if (PWL_SCROLL_INFO* pInfo = (PWL_SCROLL_INFO*)l
Param) | 191 } |
| 192 { | 192 } |
| 193 if (!IsFloatEqual(pInfo->fContentMax, m_
fOldMax) || | 193 } |
| 194 !IsFloatEqual(pInfo->fContentMin
, m_fOldMin)) | 194 } |
| 195 { | 195 |
| 196 m_bSizeChanged = TRUE;
| 196 CPWL_Edit::OnNotify(pWnd, msg, wParam, lParam); |
| 197 if (CPWL_Wnd * pParent = this->G
etParentWindow()) | 197 |
| 198 { | 198 if (m_bEnableNotify) { |
| 199 pParent->OnNotify(this,
PNM_NOTEEDITCHANGED, 0, 0); | 199 switch (msg) { |
| 200 } | 200 case PNM_SETCARETINFO: |
| 201 | 201 if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) { |
| 202 m_fOldMax = pInfo->fContentMax; | 202 PWL_CARET_INFO newInfo = *pInfo; |
| 203 m_fOldMin = pInfo->fContentMin; | 203 newInfo.bVisible = TRUE; |
| 204 return; | 204 newInfo.ptHead = this->ChildToParent(pInfo->ptHead); |
| 205 } | 205 newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot); |
| 206 } | 206 |
| 207 } | 207 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 208 } | 208 pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&newInfo, 0); |
| 209 } | 209 } |
| 210 | 210 } |
| 211 CPWL_Edit::OnNotify(pWnd, msg, wParam, lParam); | 211 break; |
| 212 | 212 } |
| 213 if (m_bEnableNotify) | 213 } |
| 214 { | 214 } |
| 215 switch (msg) | 215 |
| 216 { | 216 FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth) { |
| 217 case PNM_SETCARETINFO: | 217 if (fLimitWidth > 0) { |
| 218 if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam) | 218 if (!m_bSizeChanged) |
| 219 { | 219 return m_fOldItemHeight; |
| 220 PWL_CARET_INFO newInfo = *pInfo; | 220 |
| 221 newInfo.bVisible = TRUE; | 221 m_bSizeChanged = FALSE; |
| 222 newInfo.ptHead = this->ChildToParent(pInfo->ptHe
ad); | 222 |
| 223 newInfo.ptFoot = this->ChildToParent(pInfo->ptFo
ot); | 223 this->EnableNotify(FALSE); |
| 224 | 224 this->EnableRefresh(FALSE); |
| 225 if (CPWL_Wnd * pParent = this->GetParentWindow()
) | 225 m_pEdit->EnableNotify(FALSE); |
| 226 { | 226 |
| 227 pParent->OnNotify(this, PNM_SETCARETINFO
, (FX_INTPTR)&newInfo, 0); | 227 // CPDF_Rect rcOld = this->GetWindowRect(); |
| 228 } | 228 |
| 229 } | 229 this->Move(CPDF_Rect(0, 0, fLimitWidth, 0), TRUE, FALSE); |
| 230 break; | 230 FX_FLOAT fRet = this->GetContentRect().Height(); |
| 231 } | 231 |
| 232 } | 232 // this->Move(rcOld, TRUE, FALSE); |
| 233 } | 233 |
| 234 | 234 m_pEdit->EnableNotify(TRUE); |
| 235 FX_FLOAT CPWL_Note_Edit::GetItemHeight(FX_FLOAT fLimitWidth) | 235 this->EnableNotify(TRUE); |
| 236 { | 236 this->EnableRefresh(TRUE); |
| 237 if (fLimitWidth > 0) | 237 |
| 238 { | 238 return fRet; |
| 239 if (!m_bSizeChanged) | 239 } |
| 240 return m_fOldItemHeight; | 240 |
| 241 | 241 return 0; |
| 242 m_bSizeChanged = FALSE; | 242 } |
| 243 | 243 |
| 244 this->EnableNotify(FALSE); | 244 FX_FLOAT CPWL_Note_Edit::GetItemLeftMargin() { |
| 245 this->EnableRefresh(FALSE); | 245 return POPUP_ITEM_TEXT_INDENT; |
| 246 m_pEdit->EnableNotify(FALSE); | 246 } |
| 247 | 247 |
| 248 //CPDF_Rect rcOld = this->GetWindowRect(); | 248 FX_FLOAT CPWL_Note_Edit::GetItemRightMargin() { |
| 249 | 249 return POPUP_ITEM_TEXT_INDENT; |
| 250 this->Move(CPDF_Rect(0,0,fLimitWidth,0), TRUE, FALSE); | 250 } |
| 251 FX_FLOAT fRet = this->GetContentRect().Height(); | 251 |
| 252 | 252 /* -------------------------------- CPWL_Note_LBBox |
| 253 //this->Move(rcOld, TRUE, FALSE); | 253 * --------------------------------*/ |
| 254 | 254 |
| 255 m_pEdit->EnableNotify(TRUE); | 255 CPWL_Note_LBBox::CPWL_Note_LBBox() { |
| 256 this->EnableNotify(TRUE); | 256 } |
| 257 this->EnableRefresh(TRUE); | 257 |
| 258 | 258 CPWL_Note_LBBox::~CPWL_Note_LBBox() { |
| 259 return fRet; | 259 } |
| 260 } | 260 |
| 261 | 261 void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 262 return 0; | 262 CPDF_Matrix* pUser2Device) { |
| 263 } | 263 CPDF_Rect rcClient = this->GetClientRect(); |
| 264 | 264 |
| 265 FX_FLOAT CPWL_Note_Edit::GetItemLeftMargin() | 265 CFX_GraphStateData gsd; |
| 266 { | 266 gsd.m_LineWidth = 1.0f; |
| 267 return POPUP_ITEM_TEXT_INDENT; | 267 |
| 268 } | 268 CFX_PathData pathCross; |
| 269 | 269 |
| 270 FX_FLOAT CPWL_Note_Edit::GetItemRightMargin() | 270 pathCross.SetPointCount(4); |
| 271 { | 271 pathCross.SetPoint(0, rcClient.left, rcClient.top, FXPT_MOVETO); |
| 272 return POPUP_ITEM_TEXT_INDENT; | 272 pathCross.SetPoint(1, rcClient.right, rcClient.bottom, FXPT_LINETO); |
| 273 } | 273 pathCross.SetPoint(2, |
| 274 | 274 rcClient.left, |
| 275 /* -------------------------------- CPWL_Note_LBBox ----------------------------
----*/ | 275 rcClient.bottom + rcClient.Height() * 0.5f, |
| 276 | 276 FXPT_MOVETO); |
| 277 CPWL_Note_LBBox::CPWL_Note_LBBox() | 277 pathCross.SetPoint( |
| 278 { | 278 3, rcClient.left + rcClient.Width() * 0.5f, rcClient.bottom, FXPT_LINETO); |
| 279 } | 279 |
| 280 | 280 pDevice->DrawPath( |
| 281 CPWL_Note_LBBox::~CPWL_Note_LBBox() | 281 &pathCross, |
| 282 { | 282 pUser2Device, |
| 283 } | 283 &gsd, |
| 284 | 284 0, |
| 285 void CPWL_Note_LBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix*
pUser2Device) | 285 CPWL_Utils::PWLColorToFXColor(GetTextColor(), this->GetTransparency()), |
| 286 { | 286 FXFILL_ALTERNATE); |
| 287 CPDF_Rect rcClient = this->GetClientRect(); | 287 } |
| 288 | 288 |
| 289 CFX_GraphStateData gsd; | 289 /* -------------------------------- CPWL_Note_RBBox |
| 290 gsd.m_LineWidth = 1.0f; | 290 * --------------------------------*/ |
| 291 | 291 |
| 292 CFX_PathData pathCross; | 292 CPWL_Note_RBBox::CPWL_Note_RBBox() { |
| 293 | 293 } |
| 294 pathCross.SetPointCount(4); | 294 |
| 295 pathCross.SetPoint(0, rcClient.left, rcClient.top, FXPT_MOVETO); | 295 CPWL_Note_RBBox::~CPWL_Note_RBBox() { |
| 296 pathCross.SetPoint(1, rcClient.right, rcClient.bottom, FXPT_LINETO); | 296 } |
| 297 pathCross.SetPoint(2, rcClient.left, rcClient.bottom + rcClient.Height()
* 0.5f, FXPT_MOVETO); | 297 |
| 298 pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f, rcClient.
bottom, FXPT_LINETO); | 298 void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 299 | 299 CPDF_Matrix* pUser2Device) { |
| 300 pDevice->DrawPath(&pathCross, pUser2Device, &gsd, | 300 CPDF_Rect rcClient = this->GetClientRect(); |
| 301 0, CPWL_Utils::PWLColorToFXColor(GetTextColor(),this->GetTranspa
rency()), FXFILL_ALTERNATE); | 301 |
| 302 } | 302 CFX_GraphStateData gsd; |
| 303 | 303 gsd.m_LineWidth = 1.0f; |
| 304 /* -------------------------------- CPWL_Note_RBBox ----------------------------
----*/ | 304 |
| 305 | 305 CFX_PathData pathCross; |
| 306 CPWL_Note_RBBox::CPWL_Note_RBBox() | 306 |
| 307 { | 307 pathCross.SetPointCount(4); |
| 308 } | 308 pathCross.SetPoint(0, rcClient.right, rcClient.top, FXPT_MOVETO); |
| 309 | 309 pathCross.SetPoint(1, rcClient.left, rcClient.bottom, FXPT_LINETO); |
| 310 CPWL_Note_RBBox::~CPWL_Note_RBBox() | 310 pathCross.SetPoint(2, |
| 311 { | 311 rcClient.right, |
| 312 } | 312 rcClient.bottom + rcClient.Height() * 0.5f, |
| 313 | 313 FXPT_MOVETO); |
| 314 void CPWL_Note_RBBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix*
pUser2Device) | 314 pathCross.SetPoint( |
| 315 { | 315 3, rcClient.left + rcClient.Width() * 0.5f, rcClient.bottom, FXPT_LINETO); |
| 316 CPDF_Rect rcClient = this->GetClientRect(); | 316 |
| 317 | 317 pDevice->DrawPath( |
| 318 CFX_GraphStateData gsd; | 318 &pathCross, |
| 319 gsd.m_LineWidth = 1.0f; | 319 pUser2Device, |
| 320 | 320 &gsd, |
| 321 CFX_PathData pathCross; | 321 0, |
| 322 | 322 CPWL_Utils::PWLColorToFXColor(GetTextColor(), this->GetTransparency()), |
| 323 pathCross.SetPointCount(4); | 323 FXFILL_ALTERNATE); |
| 324 pathCross.SetPoint(0, rcClient.right, rcClient.top, FXPT_MOVETO); | 324 } |
| 325 pathCross.SetPoint(1, rcClient.left, rcClient.bottom, FXPT_LINETO); | 325 |
| 326 pathCross.SetPoint(2, rcClient.right, rcClient.bottom + rcClient.Height(
) * 0.5f, FXPT_MOVETO); | 326 /* --------------------------------- CPWL_Note_Icon |
| 327 pathCross.SetPoint(3, rcClient.left + rcClient.Width() * 0.5f, rcClient.
bottom, FXPT_LINETO); | 327 * ---------------------------------- */ |
| 328 | 328 |
| 329 pDevice->DrawPath(&pathCross, pUser2Device, &gsd, | 329 CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0) { |
| 330 0, CPWL_Utils::PWLColorToFXColor(GetTextColor(),this->GetTranspa
rency()), FXFILL_ALTERNATE); | 330 } |
| 331 } | 331 |
| 332 | 332 CPWL_Note_Icon::~CPWL_Note_Icon() { |
| 333 /* --------------------------------- CPWL_Note_Icon ----------------------------
------ */ | 333 } |
| 334 | 334 |
| 335 CPWL_Note_Icon::CPWL_Note_Icon() : m_nType(0) | 335 void CPWL_Note_Icon::SetIconType(FX_INT32 nType) { |
| 336 { | 336 m_nType = nType; |
| 337 } | 337 } |
| 338 | 338 |
| 339 CPWL_Note_Icon::~CPWL_Note_Icon() | 339 void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 340 { | 340 CPDF_Matrix* pUser2Device) { |
| 341 } | 341 CPWL_Utils::DrawIconAppStream(pDevice, |
| 342 | 342 pUser2Device, |
| 343 void CPWL_Note_Icon::SetIconType(FX_INT32 nType) | 343 m_nType, |
| 344 { | 344 GetClientRect(), |
| 345 m_nType = nType; | 345 this->GetBackgroundColor(), |
| 346 } | 346 PWL_DEFAULT_BLACKCOLOR, |
| 347 | 347 this->GetTransparency()); |
| 348 void CPWL_Note_Icon::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix*
pUser2Device) | 348 } |
| 349 { | 349 |
| 350 CPWL_Utils::DrawIconAppStream(pDevice, pUser2Device, m_nType, GetClientR
ect(), | 350 /* --------------------------------- CPWL_Note_CloseBox |
| 351 this->GetBackgroundColor(), PWL_DEFAULT_BLACKCOLOR, this->GetTra
nsparency()); | 351 * ---------------------------------- */ |
| 352 } | 352 |
| 353 | 353 CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE) { |
| 354 /* --------------------------------- CPWL_Note_CloseBox ------------------------
---------- */ | 354 } |
| 355 | 355 |
| 356 CPWL_Note_CloseBox::CPWL_Note_CloseBox() : m_bMouseDown(FALSE) | 356 CPWL_Note_CloseBox::~CPWL_Note_CloseBox() { |
| 357 { | 357 } |
| 358 } | 358 |
| 359 | 359 void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice, |
| 360 CPWL_Note_CloseBox::~CPWL_Note_CloseBox() | 360 CPDF_Matrix* pUser2Device) { |
| 361 { | 361 CPWL_Button::DrawThisAppearance(pDevice, pUser2Device); |
| 362 } | 362 |
| 363 | 363 CPDF_Rect rcClient = this->GetClientRect(); |
| 364 void CPWL_Note_CloseBox::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matr
ix* pUser2Device) | 364 rcClient = CPWL_Utils::DeflateRect(rcClient, 2.0f); |
| 365 { | 365 |
| 366 CPWL_Button::DrawThisAppearance(pDevice, pUser2Device); | 366 CFX_GraphStateData gsd; |
| 367 | 367 gsd.m_LineWidth = 1.0f; |
| 368 CPDF_Rect rcClient = this->GetClientRect(); | 368 |
| 369 rcClient = CPWL_Utils::DeflateRect(rcClient, 2.0f); | 369 CFX_PathData pathCross; |
| 370 | 370 |
| 371 CFX_GraphStateData gsd; | 371 if (m_bMouseDown) { |
| 372 gsd.m_LineWidth = 1.0f; | 372 rcClient.left += 0.5f; |
| 373 | 373 rcClient.right += 0.5f; |
| 374 CFX_PathData pathCross; | 374 rcClient.top -= 0.5f; |
| 375 | 375 rcClient.bottom -= 0.5f; |
| 376 if (m_bMouseDown) | 376 } |
| 377 { | 377 |
| 378 rcClient.left += 0.5f; | 378 pathCross.SetPointCount(4); |
| 379 rcClient.right += 0.5f; | 379 pathCross.SetPoint(0, rcClient.left, rcClient.bottom, FXPT_MOVETO); |
| 380 rcClient.top -= 0.5f; | 380 pathCross.SetPoint(1, rcClient.right, rcClient.top, FXPT_LINETO); |
| 381 rcClient.bottom -= 0.5f; | 381 pathCross.SetPoint(2, rcClient.left, rcClient.top, FXPT_MOVETO); |
| 382 } | 382 pathCross.SetPoint(3, rcClient.right, rcClient.bottom, FXPT_LINETO); |
| 383 | 383 |
| 384 pathCross.SetPointCount(4); | 384 pDevice->DrawPath( |
| 385 pathCross.SetPoint(0, rcClient.left, rcClient.bottom, FXPT_MOVETO); | 385 &pathCross, |
| 386 pathCross.SetPoint(1, rcClient.right, rcClient.top, FXPT_LINETO); | 386 pUser2Device, |
| 387 pathCross.SetPoint(2, rcClient.left, rcClient.top, FXPT_MOVETO); | 387 &gsd, |
| 388 pathCross.SetPoint(3, rcClient.right, rcClient.bottom, FXPT_LINETO); | 388 0, |
| 389 | 389 CPWL_Utils::PWLColorToFXColor(GetTextColor(), this->GetTransparency()), |
| 390 pDevice->DrawPath(&pathCross, pUser2Device, &gsd, | 390 FXFILL_ALTERNATE); |
| 391 0, CPWL_Utils::PWLColorToFXColor(GetTextColor(),this->GetTranspa
rency()), FXFILL_ALTERNATE); | 391 } |
| 392 } | 392 |
| 393 | 393 FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CPDF_Point& point, |
| 394 FX_BOOL CPWL_Note_CloseBox::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFl
ag) | 394 FX_DWORD nFlag) { |
| 395 { | 395 SetBorderStyle(PBS_INSET); |
| 396 SetBorderStyle(PBS_INSET); | 396 InvalidateRect(NULL); |
| 397 InvalidateRect(NULL); | 397 |
| 398 | 398 m_bMouseDown = TRUE; |
| 399 m_bMouseDown = TRUE; | 399 |
| 400 | 400 return CPWL_Button::OnLButtonDown(point, nFlag); |
| 401 return CPWL_Button::OnLButtonDown(point,nFlag); | 401 } |
| 402 } | 402 |
| 403 | 403 FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CPDF_Point& point, |
| 404 FX_BOOL CPWL_Note_CloseBox::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag
) | 404 FX_DWORD nFlag) { |
| 405 { | 405 m_bMouseDown = FALSE; |
| 406 m_bMouseDown = FALSE; | 406 |
| 407 | 407 SetBorderStyle(PBS_BEVELED); |
| 408 SetBorderStyle(PBS_BEVELED); | 408 InvalidateRect(NULL); |
| 409 InvalidateRect(NULL); | 409 |
| 410 | 410 return CPWL_Button::OnLButtonUp(point, nFlag); |
| 411 return CPWL_Button::OnLButtonUp(point,nFlag); | 411 } |
| 412 } | 412 |
| 413 | 413 /* ------------------------------ CPWL_Note_Contents |
| 414 /* ------------------------------ CPWL_Note_Contents ---------------------------
---- */ | 414 * ------------------------------- */ |
| 415 | 415 |
| 416 CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL) | 416 CPWL_Note_Contents::CPWL_Note_Contents() : m_pEdit(NULL) { |
| 417 { | 417 } |
| 418 } | 418 |
| 419 | 419 CPWL_Note_Contents::~CPWL_Note_Contents() { |
| 420 CPWL_Note_Contents::~CPWL_Note_Contents() | 420 } |
| 421 { | 421 |
| 422 } | 422 CFX_ByteString CPWL_Note_Contents::GetClassName() const { |
| 423 | 423 return "CPWL_Note_Contents"; |
| 424 CFX_ByteString CPWL_Note_Contents::GetClassName() const | 424 } |
| 425 { | 425 |
| 426 return "CPWL_Note_Contents"; | 426 void CPWL_Note_Contents::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
| 427 } | 427 m_pEdit = new CPWL_Note_Edit; |
| 428 | 428 PWL_CREATEPARAM ecp = cp; |
| 429 void CPWL_Note_Contents::CreateChildWnd(const PWL_CREATEPARAM & cp) | 429 ecp.pParentWnd = this; |
| 430 { | 430 ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_MULTILINE | PES_AUTORETURN | |
| 431 m_pEdit = new CPWL_Note_Edit; | 431 PES_TEXTOVERFLOW | PES_UNDO | PES_SPELLCHECK; |
| 432 PWL_CREATEPARAM ecp = cp; | 432 |
| 433 ecp.pParentWnd = this; | 433 m_pEdit->EnableNotify(FALSE); |
| 434 ecp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_MULTILINE | PES_AUTORETURN |
PES_TEXTOVERFLOW | PES_UNDO | PES_SPELLCHECK; | 434 m_pEdit->Create(ecp); |
| 435 | 435 m_pEdit->EnableNotify(TRUE); |
| 436 m_pEdit->EnableNotify(FALSE); | 436 } |
| 437 m_pEdit->Create(ecp); | 437 |
| 438 m_pEdit->EnableNotify(TRUE); | 438 void CPWL_Note_Contents::SetText(const CFX_WideString& sText) { |
| 439 } | 439 if (m_pEdit) { |
| 440 | 440 m_pEdit->EnableNotify(FALSE); |
| 441 void CPWL_Note_Contents::SetText(const CFX_WideString& sText) | 441 m_pEdit->SetText(sText); |
| 442 { | 442 m_pEdit->EnableNotify(TRUE); |
| 443 if (m_pEdit) | 443 OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0); |
| 444 { | 444 } |
| 445 m_pEdit->EnableNotify(FALSE); | 445 } |
| 446 m_pEdit->SetText(sText); | 446 |
| 447 m_pEdit->EnableNotify(TRUE); | 447 CFX_WideString CPWL_Note_Contents::GetText() const { |
| 448 OnNotify(m_pEdit, PNM_NOTEEDITCHANGED, 0, 0); | 448 if (m_pEdit) |
| 449 } | 449 return m_pEdit->GetText(); |
| 450 } | 450 |
| 451 | 451 return L""; |
| 452 CFX_WideString CPWL_Note_Contents::GetText() const | 452 } |
| 453 { | 453 |
| 454 if (m_pEdit) | 454 CPWL_NoteItem* CPWL_Note_Contents::CreateSubItem() { |
| 455 return m_pEdit->GetText(); | 455 CPWL_NoteItem* pNoteItem = new CPWL_NoteItem; |
| 456 | 456 PWL_CREATEPARAM icp = this->GetCreationParam(); |
| 457 return L""; | 457 icp.pParentWnd = this; |
| 458 } | 458 icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND; |
| 459 | 459 pNoteItem->Create(icp); |
| 460 CPWL_NoteItem* CPWL_Note_Contents::CreateSubItem() | 460 |
| 461 { | 461 pNoteItem->OnCreateNoteItem(); |
| 462 CPWL_NoteItem* pNoteItem = new CPWL_NoteItem; | 462 |
| 463 PWL_CREATEPARAM icp = this->GetCreationParam(); | 463 pNoteItem->ResetSubjectName(m_aChildren.GetSize() - 1); |
| 464 icp.pParentWnd = this; | 464 |
| 465 icp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND; | 465 FX_SYSTEMTIME st; |
| 466 pNoteItem->Create(icp); | 466 if (IFX_SystemHandler* pSH = this->GetSystemHandler()) |
| 467 | 467 st = pSH->GetLocalTime(); |
| 468 pNoteItem->OnCreateNoteItem(); | 468 pNoteItem->SetDateTime(st); |
| 469 | 469 |
| 470 pNoteItem->ResetSubjectName(m_aChildren.GetSize() - 1); | 470 pNoteItem->SetContents(L""); |
| 471 | 471 |
| 472 FX_SYSTEMTIME st; | 472 this->OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0); |
| 473 if (IFX_SystemHandler* pSH = this->GetSystemHandler()) | 473 |
| 474 st = pSH->GetLocalTime(); | 474 return pNoteItem; |
| 475 pNoteItem->SetDateTime(st); | 475 } |
| 476 | 476 |
| 477 pNoteItem->SetContents(L""); | 477 FX_INT32 CPWL_Note_Contents::CountSubItems() const { |
| 478 | 478 return m_aChildren.GetSize() - 1; |
| 479 this->OnNotify(pNoteItem, PNM_NOTEEDITCHANGED, 0, 0); | 479 } |
| 480 | 480 |
| 481 return pNoteItem; | 481 IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(FX_INT32 index) const { |
| 482 } | 482 FX_INT32 nIndex = index + 1; |
| 483 | 483 |
| 484 FX_INT32 CPWL_Note_Contents::CountSubItems() const | 484 if (nIndex > 0 && nIndex < m_aChildren.GetSize()) |
| 485 { | 485 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nIndex)) { |
| 486 return m_aChildren.GetSize() - 1; | 486 ASSERT(pChild->GetClassName() == "CPWL_NoteItem"); |
| 487 } | 487 CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild; |
| 488 | 488 return pItem; |
| 489 IPWL_NoteItem* CPWL_Note_Contents::GetSubItems(FX_INT32 index) const | 489 } |
| 490 { | 490 return NULL; |
| 491 FX_INT32 nIndex = index + 1; | 491 } |
| 492 | 492 |
| 493 if (nIndex > 0 && nIndex < m_aChildren.GetSize()) | 493 void CPWL_Note_Contents::DeleteSubItem(IPWL_NoteItem* pNoteItem) { |
| 494 if (CPWL_Wnd* pChild = m_aChildren.GetAt(nIndex)) | 494 FX_INT32 nIndex = this->GetItemIndex((CPWL_NoteItem*)pNoteItem); |
| 495 { | 495 |
| 496 ASSERT(pChild->GetClassName() == "CPWL_NoteItem"); | 496 if (nIndex > 0) { |
| 497 CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild; | 497 if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem) { |
| 498 return pItem; | 498 pPWLNoteItem->KillFocus(); |
| 499 } | 499 pPWLNoteItem->Destroy(); |
| 500 return NULL; | 500 delete pPWLNoteItem; |
| 501 } | 501 } |
| 502 | 502 |
| 503 void CPWL_Note_Contents::DeleteSubItem(IPWL_NoteItem* pNoteItem) | 503 for (FX_INT32 i = nIndex, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 504 { | 504 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 505 FX_INT32 nIndex = this->GetItemIndex((CPWL_NoteItem*)pNoteItem); | 505 ASSERT(pChild->GetClassName() == "CPWL_NoteItem"); |
| 506 | 506 CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild; |
| 507 if (nIndex > 0) | 507 pItem->ResetSubjectName(i); |
| 508 { | 508 } |
| 509 if (CPWL_NoteItem* pPWLNoteItem = (CPWL_NoteItem*)pNoteItem) | 509 } |
| 510 { | 510 |
| 511 pPWLNoteItem->KillFocus(); | 511 this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); |
| 512 pPWLNoteItem->Destroy(); | 512 } |
| 513 delete pPWLNoteItem; | 513 } |
| 514 } | 514 |
| 515 | 515 IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CPDF_Point& point) { |
| 516 for (FX_INT32 i=nIndex,sz=m_aChildren.GetSize(); i<sz; i++) | 516 CPDF_Point pt = this->ParentToChild(point); |
| 517 { | 517 |
| 518 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 518 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 519 { | 519 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 520 ASSERT(pChild->GetClassName() == "CPWL_NoteItem"
); | 520 if (pChild->GetClassName() == "CPWL_NoteItem") { |
| 521 CPWL_NoteItem* pItem = (CPWL_NoteItem*)pChild; | 521 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; |
| 522 pItem->ResetSubjectName(i); | 522 if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteItem(pt)) |
| 523 } | 523 return pRet; |
| 524 } | 524 } |
| 525 | 525 } |
| 526 this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); | 526 } |
| 527 } | 527 return NULL; |
| 528 } | 528 } |
| 529 | 529 |
| 530 IPWL_NoteItem* CPWL_Note_Contents::GetHitNoteItem(const CPDF_Point& point) | 530 void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd, |
| 531 { | 531 FX_DWORD msg, |
| 532 CPDF_Point pt = this->ParentToChild(point); | 532 FX_INTPTR wParam, |
| 533 | 533 FX_INTPTR lParam) { |
| 534 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 534 switch (msg) { |
| 535 { | 535 case PNM_NOTEEDITCHANGED: { |
| 536 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 536 FX_INT32 nIndex = this->GetItemIndex(pWnd); |
| 537 { | 537 if (nIndex < 0) |
| 538 if (pChild->GetClassName() == "CPWL_NoteItem") | 538 nIndex = 0; |
| 539 { | 539 |
| 540 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChil
d; | 540 m_pEdit->EnableNotify(FALSE); |
| 541 if (IPWL_NoteItem* pRet = pNoteItem->GetHitNoteI
tem(pt)) | 541 this->ResetContent(nIndex); |
| 542 return pRet; | 542 m_pEdit->EnableNotify(TRUE); |
| 543 } | 543 |
| 544 } | 544 for (FX_INT32 i = nIndex + 1, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 545 } | 545 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) |
| 546 return NULL; | 546 pChild->OnNotify(this, PNM_NOTERESET, 0, 0); |
| 547 } | 547 } |
| 548 | 548 |
| 549 void CPWL_Note_Contents::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam
, FX_INTPTR lParam) | 549 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 550 { | 550 pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); |
| 551 switch (msg) | 551 } |
| 552 { | 552 } |
| 553 case PNM_NOTEEDITCHANGED: | 553 return; |
| 554 { | 554 case PNM_SCROLLWINDOW: |
| 555 FX_INT32 nIndex = this->GetItemIndex(pWnd); | 555 this->SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam)); |
| 556 if (nIndex < 0) nIndex = 0; | 556 this->ResetFace(); |
| 557 | 557 InvalidateRect(NULL); |
| 558 m_pEdit->EnableNotify(FALSE); | 558 return; |
| 559 this->ResetContent(nIndex); | 559 case PNM_SETCARETINFO: |
| 560 m_pEdit->EnableNotify(TRUE); | 560 if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) { |
| 561 | 561 PWL_CARET_INFO newInfo = *pInfo; |
| 562 for (FX_INT32 i=nIndex+1, sz=m_aChildren.GetSize(); i<sz
; i++) | 562 newInfo.bVisible = TRUE; |
| 563 { | 563 newInfo.ptHead = this->ChildToParent(pInfo->ptHead); |
| 564 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 564 newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot); |
| 565 pChild->OnNotify(this, PNM_NOTERESET, 0,
0); | 565 |
| 566 } | 566 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 567 | 567 pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&newInfo, 0); |
| 568 if (CPWL_Wnd * pParent = this->GetParentWindow()) | 568 } |
| 569 { | 569 } |
| 570 pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0,
0); | 570 return; |
| 571 } | 571 case PNM_NOTERESET: { |
| 572 } | 572 m_pEdit->EnableNotify(FALSE); |
| 573 return; | 573 this->ResetContent(0); |
| 574 case PNM_SCROLLWINDOW: | 574 m_pEdit->EnableNotify(TRUE); |
| 575 this->SetScrollPos(CPDF_Point(0.0f, *(FX_FLOAT*)lParam)); | 575 |
| 576 this->ResetFace(); | 576 for (FX_INT32 i = 1, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 577 InvalidateRect(NULL); | 577 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) |
| 578 return; | 578 pChild->OnNotify(this, PNM_NOTERESET, 0, 0); |
| 579 case PNM_SETCARETINFO: | 579 } |
| 580 if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam) | 580 |
| 581 { | 581 m_pEdit->EnableNotify(FALSE); |
| 582 PWL_CARET_INFO newInfo = *pInfo; | 582 this->ResetContent(0); |
| 583 newInfo.bVisible = TRUE; | 583 m_pEdit->EnableNotify(TRUE); |
| 584 newInfo.ptHead = this->ChildToParent(pInfo->ptHead); | 584 } |
| 585 newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot); | 585 return; |
| 586 | 586 } |
| 587 if (CPWL_Wnd * pParent = this->GetParentWindow()) | 587 |
| 588 { | 588 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
| 589 pParent->OnNotify(this, PNM_SETCARETINFO, (FX_IN
TPTR)&newInfo, 0); | 589 } |
| 590 } | 590 |
| 591 } | 591 FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CPDF_Point& point, |
| 592 return; | 592 FX_DWORD nFlag) { |
| 593 case PNM_NOTERESET: | 593 if (CPWL_Wnd::OnLButtonDown(point, nFlag)) |
| 594 { | 594 return TRUE; |
| 595 m_pEdit->EnableNotify(FALSE); | 595 |
| 596 this->ResetContent(0); | 596 if (!m_pEdit->IsFocused()) { |
| 597 m_pEdit->EnableNotify(TRUE); | 597 m_pEdit->SetFocus(); |
| 598 | 598 } |
| 599 for (FX_INT32 i=1, sz=m_aChildren.GetSize(); i<sz; i++) | 599 |
| 600 { | 600 return TRUE; |
| 601 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 601 } |
| 602 pChild->OnNotify(this, PNM_NOTERESET, 0,
0); | 602 |
| 603 } | 603 void CPWL_Note_Contents::SetEditFocus(FX_BOOL bLast) { |
| 604 | 604 if (!m_pEdit->IsFocused()) { |
| 605 m_pEdit->EnableNotify(FALSE); | 605 m_pEdit->SetFocus(); |
| 606 this->ResetContent(0); | 606 m_pEdit->SetCaret(bLast ? m_pEdit->GetTotalWords() : 0); |
| 607 m_pEdit->EnableNotify(TRUE); | 607 } |
| 608 } | 608 } |
| 609 return; | 609 |
| 610 } | 610 CPWL_Edit* CPWL_Note_Contents::GetEdit() const { |
| 611 | 611 return m_pEdit; |
| 612 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); | 612 } |
| 613 } | 613 |
| 614 | 614 void CPWL_Note_Contents::EnableModify(FX_BOOL bEnabled) { |
| 615 FX_BOOL CPWL_Note_Contents::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFl
ag) | 615 if (!bEnabled) |
| 616 { | 616 m_pEdit->AddFlag(PWS_READONLY); |
| 617 if (CPWL_Wnd::OnLButtonDown(point,nFlag)) return TRUE; | 617 else |
| 618 | 618 m_pEdit->RemoveFlag(PWS_READONLY); |
| 619 if (!m_pEdit->IsFocused()) | 619 |
| 620 { | 620 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 621 m_pEdit->SetFocus(); | 621 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 622 } | 622 if (pChild->GetClassName() == "CPWL_NoteItem") { |
| 623 | 623 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; |
| 624 return TRUE; | 624 pNoteItem->EnableModify(bEnabled); |
| 625 } | 625 } |
| 626 | 626 } |
| 627 void CPWL_Note_Contents::SetEditFocus(FX_BOOL bLast) | 627 } |
| 628 { | 628 } |
| 629 if (!m_pEdit->IsFocused()) | 629 |
| 630 { | 630 void CPWL_Note_Contents::EnableRead(FX_BOOL bEnabled) { |
| 631 m_pEdit->SetFocus(); | 631 if (!bEnabled) |
| 632 m_pEdit->SetCaret(bLast ? m_pEdit->GetTotalWords() : 0); | 632 m_pEdit->AddFlag(PES_NOREAD); |
| 633 } | 633 else |
| 634 } | 634 m_pEdit->RemoveFlag(PES_NOREAD); |
| 635 | 635 |
| 636 CPWL_Edit* CPWL_Note_Contents::GetEdit() const | 636 for (FX_INT32 i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { |
| 637 { | 637 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { |
| 638 return m_pEdit; | 638 if (pChild->GetClassName() == "CPWL_NoteItem") { |
| 639 } | 639 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChild; |
| 640 | 640 pNoteItem->EnableRead(bEnabled); |
| 641 void CPWL_Note_Contents::EnableModify(FX_BOOL bEnabled) | 641 } |
| 642 { | 642 } |
| 643 if (!bEnabled) | 643 } |
| 644 m_pEdit->AddFlag(PWS_READONLY); | 644 } |
| 645 else | 645 |
| 646 m_pEdit->RemoveFlag(PWS_READONLY); | 646 /* ---------------------------------- CPWL_NoteItem |
| 647 | 647 * ---------------------------------- */ |
| 648 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 648 |
| 649 { | 649 CPWL_NoteItem::CPWL_NoteItem() |
| 650 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 650 : m_pSubject(NULL), |
| 651 { | 651 m_pDateTime(NULL), |
| 652 if (pChild->GetClassName() == "CPWL_NoteItem") | 652 m_pContents(NULL), |
| 653 { | 653 m_pPrivateData(NULL), |
| 654 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChil
d; | 654 m_sAuthor(L""), |
| 655 pNoteItem->EnableModify(bEnabled); | 655 m_fOldItemHeight(0.0f), |
| 656 } | 656 m_bSizeChanged(FALSE), |
| 657 } | 657 m_bAllowModify(TRUE) { |
| 658 } | 658 } |
| 659 } | 659 |
| 660 | 660 CPWL_NoteItem::~CPWL_NoteItem() { |
| 661 void CPWL_Note_Contents::EnableRead(FX_BOOL bEnabled) | 661 } |
| 662 { | 662 |
| 663 if (!bEnabled) | 663 CFX_ByteString CPWL_NoteItem::GetClassName() const { |
| 664 m_pEdit->AddFlag(PES_NOREAD); | 664 return "CPWL_NoteItem"; |
| 665 else | 665 } |
| 666 m_pEdit->RemoveFlag(PES_NOREAD); | 666 |
| 667 | 667 void CPWL_NoteItem::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
| 668 for (FX_INT32 i=0,sz=m_aChildren.GetSize(); i<sz; i++) | 668 CPWL_Color sTextColor; |
| 669 { | 669 |
| 670 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) | 670 if (CPWL_Utils::IsBlackOrWhite(this->GetBackgroundColor())) |
| 671 { | 671 sTextColor = PWL_DEFAULT_WHITECOLOR; |
| 672 if (pChild->GetClassName() == "CPWL_NoteItem") | 672 else |
| 673 { | 673 sTextColor = PWL_DEFAULT_BLACKCOLOR; |
| 674 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pChil
d; | 674 |
| 675 pNoteItem->EnableRead(bEnabled); | 675 m_pSubject = new CPWL_Label; |
| 676 } | 676 PWL_CREATEPARAM scp = cp; |
| 677 } | 677 scp.pParentWnd = this; |
| 678 } | 678 scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP; |
| 679 } | 679 scp.sTextColor = sTextColor; |
| 680 | 680 m_pSubject->Create(scp); |
| 681 /* ---------------------------------- CPWL_NoteItem ----------------------------
------ */ | 681 |
| 682 | 682 m_pDateTime = new CPWL_Label; |
| 683 CPWL_NoteItem::CPWL_NoteItem() : | 683 PWL_CREATEPARAM dcp = cp; |
| 684 m_pSubject(NULL), | 684 dcp.pParentWnd = this; |
| 685 m_pDateTime(NULL), | 685 dcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_RIGHT | PES_TOP; |
| 686 m_pContents(NULL), | 686 dcp.sTextColor = sTextColor; |
| 687 m_pPrivateData(NULL), | 687 m_pDateTime->Create(dcp); |
| 688 m_sAuthor(L""), | 688 |
| 689 m_fOldItemHeight(0.0f), | 689 m_pContents = new CPWL_Note_Contents; |
| 690 m_bSizeChanged(FALSE), | 690 PWL_CREATEPARAM ccp = cp; |
| 691 m_bAllowModify(TRUE) | 691 ccp.pParentWnd = this; |
| 692 { | 692 // ccp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; |
| 693 } | 693 ccp.sBackgroundColor = |
| 694 | 694 CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f); |
| 695 CPWL_NoteItem::~CPWL_NoteItem() | 695 ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BACKGROUND; |
| 696 { | 696 m_pContents->Create(ccp); |
| 697 } | 697 m_pContents->SetItemSpace(POPUP_ITEM_SPACE); |
| 698 | 698 m_pContents->SetTopSpace(POPUP_ITEM_SPACE); |
| 699 CFX_ByteString CPWL_NoteItem::GetClassName() const | 699 m_pContents->SetBottomSpace(POPUP_ITEM_SPACE); |
| 700 { | 700 } |
| 701 return "CPWL_NoteItem"; | 701 |
| 702 } | 702 void CPWL_NoteItem::RePosChildWnd() { |
| 703 | 703 if (this->IsValid()) { |
| 704 void CPWL_NoteItem::CreateChildWnd(const PWL_CREATEPARAM & cp) | 704 ASSERT(m_pSubject != NULL); |
| 705 { | 705 ASSERT(m_pDateTime != NULL); |
| 706 CPWL_Color sTextColor; | 706 ASSERT(m_pContents != NULL); |
| 707 | 707 |
| 708 if (CPWL_Utils::IsBlackOrWhite(this->GetBackgroundColor())) | 708 CPDF_Rect rcClient = GetClientRect(); |
| 709 sTextColor = PWL_DEFAULT_WHITECOLOR; | 709 |
| 710 else | 710 CPDF_Rect rcSubject = rcClient; |
| 711 sTextColor = PWL_DEFAULT_BLACKCOLOR; | 711 rcSubject.left += POPUP_ITEM_TEXT_INDENT; |
| 712 | 712 rcSubject.top = rcClient.top; |
| 713 m_pSubject = new CPWL_Label; | 713 rcSubject.right = |
| 714 PWL_CREATEPARAM scp = cp; | 714 PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f, |
| 715 scp.pParentWnd = this; | 715 rcClient.right); |
| 716 scp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP; | 716 rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height(); |
| 717 scp.sTextColor = sTextColor; | 717 rcSubject.Normalize(); |
| 718 m_pSubject->Create(scp); | 718 m_pSubject->Move(rcSubject, TRUE, FALSE); |
| 719 | 719 m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject)); |
| 720 m_pDateTime = new CPWL_Label; | 720 |
| 721 PWL_CREATEPARAM dcp = cp; | 721 CPDF_Rect rcDate = rcClient; |
| 722 dcp.pParentWnd = this; | 722 rcDate.right -= POPUP_ITEM_TEXT_INDENT; |
| 723 dcp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_RIGHT | PES_TOP; | 723 rcDate.left = |
| 724 dcp.sTextColor = sTextColor; | 724 PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f, |
| 725 m_pDateTime->Create(dcp); | 725 rcSubject.right); |
| 726 | 726 rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height(); |
| 727 m_pContents = new CPWL_Note_Contents; | 727 rcDate.Normalize(); |
| 728 PWL_CREATEPARAM ccp = cp; | 728 m_pDateTime->Move(rcDate, TRUE, FALSE); |
| 729 ccp.pParentWnd = this; | 729 m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate)); |
| 730 //ccp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR; | 730 |
| 731 ccp.sBackgroundColor = CPWL_Color(COLORTYPE_RGB, 240/255.0f, 240/255.0f,
240/255.0f); | 731 CPDF_Rect rcContents = rcClient; |
| 732 ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BACKGROUND; | 732 rcContents.left += 1.0f; |
| 733 m_pContents->Create(ccp); | 733 rcContents.right -= 1.0f; |
| 734 m_pContents->SetItemSpace(POPUP_ITEM_SPACE); | 734 rcContents.top = rcDate.bottom - POPUP_ITEM_HEAD_BOTTOM; |
| 735 m_pContents->SetTopSpace(POPUP_ITEM_SPACE); | 735 rcContents.bottom += POPUP_ITEM_BOTTOMWIDTH; |
| 736 m_pContents->SetBottomSpace(POPUP_ITEM_SPACE); | 736 rcContents.Normalize(); |
| 737 } | 737 m_pContents->Move(rcContents, TRUE, FALSE); |
| 738 | 738 m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents)); |
| 739 void CPWL_NoteItem::RePosChildWnd() | 739 } |
| 740 { | 740 |
| 741 if (this->IsValid()) | 741 SetClipRect(CPWL_Utils::InflateRect(GetWindowRect(), 1.0f)); |
| 742 { | 742 } |
| 743 ASSERT(m_pSubject != NULL); | 743 |
| 744 ASSERT(m_pDateTime != NULL); | 744 void CPWL_NoteItem::SetPrivateData(void* pData) { |
| 745 ASSERT(m_pContents != NULL); | 745 m_pPrivateData = pData; |
| 746 | 746 } |
| 747 CPDF_Rect rcClient = GetClientRect(); | 747 |
| 748 | 748 void CPWL_NoteItem::SetBkColor(const CPWL_Color& color) { |
| 749 CPDF_Rect rcSubject = rcClient; | 749 CPWL_Color sBK = color; |
| 750 rcSubject.left += POPUP_ITEM_TEXT_INDENT; | 750 this->SetBackgroundColor(sBK); |
| 751 rcSubject.top = rcClient.top; | 751 |
| 752 rcSubject.right = PWL_MIN(rcSubject.left + m_pSubject->GetConten
tRect().Width() + 1.0f, rcClient.right); | 752 CPWL_Color sTextColor; |
| 753 rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().
Height(); | 753 |
| 754 rcSubject.Normalize(); | 754 if (CPWL_Utils::IsBlackOrWhite(sBK)) |
| 755 m_pSubject->Move(rcSubject, TRUE, FALSE); | 755 sTextColor = PWL_DEFAULT_WHITECOLOR; |
| 756 m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubj
ect)); | 756 else |
| 757 | 757 sTextColor = PWL_DEFAULT_BLACKCOLOR; |
| 758 CPDF_Rect rcDate = rcClient; | 758 |
| 759 rcDate.right -= POPUP_ITEM_TEXT_INDENT; | 759 this->SetTextColor(sTextColor); |
| 760 rcDate.left = PWL_MAX(rcDate.right - m_pDateTime->GetContentRect
().Width() - 1.0f, rcSubject.right); | 760 if (m_pSubject) |
| 761 rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Heigh
t(); | 761 m_pSubject->SetTextColor(sTextColor); |
| 762 rcDate.Normalize(); | 762 if (m_pDateTime) |
| 763 m_pDateTime->Move(rcDate, TRUE, FALSE); | 763 m_pDateTime->SetTextColor(sTextColor); |
| 764 m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDat
e)); | 764 |
| 765 | 765 this->InvalidateRect(NULL); |
| 766 CPDF_Rect rcContents = rcClient; | 766 |
| 767 rcContents.left += 1.0f; | 767 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 768 rcContents.right -= 1.0f; | 768 pNotify->OnSetBkColor(this); |
| 769 rcContents.top = rcDate.bottom - POPUP_ITEM_HEAD_BOTTOM; | 769 } |
| 770 rcContents.bottom += POPUP_ITEM_BOTTOMWIDTH; | 770 } |
| 771 rcContents.Normalize(); | 771 |
| 772 m_pContents->Move(rcContents, TRUE, FALSE); | 772 void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) { |
| 773 m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcCon
tents)); | 773 if (m_pSubject) { |
| 774 } | 774 m_pSubject->SetText(sName); |
| 775 | 775 } |
| 776 SetClipRect(CPWL_Utils::InflateRect(GetWindowRect(),1.0f)); | 776 |
| 777 } | 777 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 778 | 778 pNotify->OnSetSubjectName(this); |
| 779 void CPWL_NoteItem::SetPrivateData(void* pData) | 779 } |
| 780 { | 780 } |
| 781 m_pPrivateData = pData; | 781 |
| 782 } | 782 void CPWL_NoteItem::SetAuthorName(const CFX_WideString& sName) { |
| 783 | 783 m_sAuthor = sName; |
| 784 void CPWL_NoteItem::SetBkColor(const CPWL_Color& color) | 784 ResetSubjectName(-1); |
| 785 { | 785 |
| 786 CPWL_Color sBK = color; | 786 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 787 this->SetBackgroundColor(sBK); | 787 pNotify->OnSetAuthorName(this); |
| 788 | 788 } |
| 789 CPWL_Color sTextColor; | 789 } |
| 790 | 790 |
| 791 if (CPWL_Utils::IsBlackOrWhite(sBK)) | 791 void CPWL_NoteItem::ResetSubjectName(FX_INT32 nItemIndex) { |
| 792 sTextColor = PWL_DEFAULT_WHITECOLOR; | 792 if (nItemIndex < 0) { |
| 793 else | 793 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 794 sTextColor = PWL_DEFAULT_BLACKCOLOR; | 794 ASSERT(pParent->GetClassName() == "CPWL_Note_Contents"); |
| 795 | 795 |
| 796 this->SetTextColor(sTextColor); | 796 CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pParent; |
| 797 if (m_pSubject) | 797 nItemIndex = pContents->GetItemIndex(this); |
| 798 m_pSubject->SetTextColor(sTextColor); | 798 } |
| 799 if (m_pDateTime) | 799 } |
| 800 m_pDateTime->SetTextColor(sTextColor); | 800 |
| 801 | 801 const CPWL_Note* pNote = GetNote(); |
| 802 this->InvalidateRect(NULL); | 802 ASSERT(pNote != NULL); |
| 803 | 803 |
| 804 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 804 CFX_WideString sSubject; |
| 805 { | 805 sSubject.Format(pNote->GetReplyString(), nItemIndex); |
| 806 pNotify->OnSetBkColor(this); | 806 |
| 807 } | 807 if (!m_sAuthor.IsEmpty()) { |
| 808 } | 808 sSubject += L" - "; |
| 809 | 809 sSubject += m_sAuthor; |
| 810 void CPWL_NoteItem::SetSubjectName(const CFX_WideString& sName) | 810 } |
| 811 { | 811 this->SetSubjectName(sSubject); |
| 812 if (m_pSubject) | 812 this->RePosChildWnd(); |
| 813 { | 813 } |
| 814 m_pSubject->SetText(sName); | 814 |
| 815 } | 815 void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) { |
| 816 | 816 m_dtNote = time; |
| 817 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 817 |
| 818 { | 818 CFX_WideString swTime; |
| 819 pNotify->OnSetSubjectName(this); | 819 swTime.Format((FX_LPCWSTR)L"%04d-%02d-%02d %02d:%02d:%02d", |
| 820 } | 820 time.wYear, |
| 821 } | 821 time.wMonth, |
| 822 | 822 time.wDay, |
| 823 void CPWL_NoteItem::SetAuthorName(const CFX_WideString& sName) | 823 time.wHour, |
| 824 { | 824 time.wMinute, |
| 825 m_sAuthor = sName; | 825 time.wSecond); |
| 826 ResetSubjectName(-1); | 826 if (m_pDateTime) { |
| 827 | 827 m_pDateTime->SetText(swTime); |
| 828 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 828 } |
| 829 { | 829 |
| 830 pNotify->OnSetAuthorName(this); | 830 this->RePosChildWnd(); |
| 831 } | 831 |
| 832 } | 832 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 833 | 833 pNotify->OnSetDateTime(this); |
| 834 void CPWL_NoteItem::ResetSubjectName(FX_INT32 nItemIndex) | 834 } |
| 835 { | 835 } |
| 836 if (nItemIndex < 0) | 836 |
| 837 { | 837 void CPWL_NoteItem::SetContents(const CFX_WideString& sContents) { |
| 838 if (CPWL_Wnd* pParent = this->GetParentWindow()) | 838 if (m_pContents) { |
| 839 { | 839 m_pContents->SetText(sContents); |
| 840 ASSERT(pParent->GetClassName() == "CPWL_Note_Contents"); | 840 } |
| 841 | 841 |
| 842 CPWL_Note_Contents* pContents = (CPWL_Note_Contents*)pPa
rent; | 842 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 843 nItemIndex = pContents->GetItemIndex(this); | 843 pNotify->OnSetContents(this); |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 | 846 |
| 847 const CPWL_Note* pNote = GetNote(); | 847 CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const { |
| 848 ASSERT(pNote != NULL); | 848 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 849 | 849 if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) { |
| 850 CFX_WideString sSubject; | 850 ASSERT(pGrand->GetClassName() == "CPWL_NoteItem"); |
| 851 sSubject.Format(pNote->GetReplyString(), nItemIndex); | 851 return (CPWL_NoteItem*)pGrand; |
| 852 | 852 } |
| 853 if (!m_sAuthor.IsEmpty()) | 853 } |
| 854 { | 854 |
| 855 | 855 return NULL; |
| 856 sSubject += L" - "; | 856 } |
| 857 sSubject += m_sAuthor; | 857 |
| 858 } | 858 IPWL_NoteItem* CPWL_NoteItem::GetParentItem() const { |
| 859 this->SetSubjectName(sSubject); | 859 return GetParentNoteItem(); |
| 860 this->RePosChildWnd(); | 860 } |
| 861 } | 861 |
| 862 | 862 CPWL_Edit* CPWL_NoteItem::GetEdit() const { |
| 863 void CPWL_NoteItem::SetDateTime(FX_SYSTEMTIME time) | 863 if (m_pContents) |
| 864 { | 864 return m_pContents->GetEdit(); |
| 865 m_dtNote = time; | 865 return NULL; |
| 866 | 866 } |
| 867 CFX_WideString swTime; | 867 |
| 868 swTime.Format((FX_LPCWSTR)L"%04d-%02d-%02d %02d:%02d:%02d", time.wYear,
time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond); | 868 void* CPWL_NoteItem::GetPrivateData() const { |
| 869 if (m_pDateTime) | 869 return m_pPrivateData; |
| 870 { | 870 } |
| 871 m_pDateTime->SetText(swTime); | 871 |
| 872 } | 872 CFX_WideString CPWL_NoteItem::GetAuthorName() const { |
| 873 | 873 return m_sAuthor; |
| 874 this->RePosChildWnd(); | 874 } |
| 875 | 875 |
| 876 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 876 CPWL_Color CPWL_NoteItem::GetBkColor() const { |
| 877 { | 877 return this->GetBackgroundColor(); |
| 878 pNotify->OnSetDateTime(this); | 878 } |
| 879 } | 879 |
| 880 } | 880 CFX_WideString CPWL_NoteItem::GetContents() const { |
| 881 | 881 if (m_pContents) |
| 882 void CPWL_NoteItem::SetContents(const CFX_WideString& sContents) | 882 return m_pContents->GetText(); |
| 883 { | 883 |
| 884 if (m_pContents) | 884 return L""; |
| 885 { | 885 } |
| 886 m_pContents->SetText(sContents); | 886 |
| 887 } | 887 FX_SYSTEMTIME CPWL_NoteItem::GetDateTime() const { |
| 888 | 888 return m_dtNote; |
| 889 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 889 } |
| 890 { | 890 |
| 891 pNotify->OnSetContents(this); | 891 CFX_WideString CPWL_NoteItem::GetSubjectName() const { |
| 892 } | 892 if (m_pSubject) |
| 893 } | 893 return m_pSubject->GetText(); |
| 894 | 894 |
| 895 CPWL_NoteItem* CPWL_NoteItem::GetParentNoteItem() const | 895 return L""; |
| 896 { | 896 } |
| 897 if (CPWL_Wnd* pParent = this->GetParentWindow()) | 897 |
| 898 { | 898 CPWL_NoteItem* CPWL_NoteItem::CreateNoteItem() { |
| 899 if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) | 899 if (m_pContents) |
| 900 { | 900 return m_pContents->CreateSubItem(); |
| 901 ASSERT(pGrand->GetClassName() == "CPWL_NoteItem"); | 901 |
| 902 return (CPWL_NoteItem*)pGrand; | 902 return NULL; |
| 903 } | 903 } |
| 904 } | 904 |
| 905 | 905 IPWL_NoteItem* CPWL_NoteItem::CreateSubItem() { |
| 906 return NULL; | 906 return CreateNoteItem(); |
| 907 } | 907 } |
| 908 | 908 |
| 909 IPWL_NoteItem* CPWL_NoteItem::GetParentItem() const | 909 FX_INT32 CPWL_NoteItem::CountSubItems() const { |
| 910 { | 910 if (m_pContents) |
| 911 return GetParentNoteItem(); | 911 return m_pContents->CountSubItems(); |
| 912 } | 912 |
| 913 | 913 return 0; |
| 914 CPWL_Edit* CPWL_NoteItem::GetEdit() const | 914 } |
| 915 { | 915 |
| 916 if (m_pContents) | 916 IPWL_NoteItem* CPWL_NoteItem::GetSubItems(FX_INT32 index) const { |
| 917 return m_pContents->GetEdit(); | 917 if (m_pContents) |
| 918 return NULL; | 918 return m_pContents->GetSubItems(index); |
| 919 } | 919 |
| 920 | 920 return NULL; |
| 921 void* CPWL_NoteItem::GetPrivateData() const | 921 } |
| 922 { | 922 |
| 923 return m_pPrivateData; | 923 void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem) { |
| 924 } | 924 this->KillFocus(); |
| 925 | 925 |
| 926 CFX_WideString CPWL_NoteItem::GetAuthorName() const | 926 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 927 { | 927 pNotify->OnItemDelete(pNoteItem); |
| 928 return m_sAuthor; | 928 } |
| 929 } | 929 |
| 930 | 930 if (m_pContents) |
| 931 CPWL_Color CPWL_NoteItem::GetBkColor() const | 931 m_pContents->DeleteSubItem(pNoteItem); |
| 932 { | 932 } |
| 933 return this->GetBackgroundColor(); | 933 |
| 934 } | 934 IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CPDF_Point& point) { |
| 935 | 935 CPDF_Point pt = this->ParentToChild(point); |
| 936 CFX_WideString CPWL_NoteItem::GetContents() const | 936 |
| 937 { | 937 if (this->WndHitTest(pt)) { |
| 938 if (m_pContents) | 938 if (m_pContents) { |
| 939 return m_pContents->GetText(); | 939 if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteItem(pt)) |
| 940 | 940 return pNoteItem; |
| 941 return L""; | 941 } |
| 942 } | 942 |
| 943 | 943 return this; |
| 944 FX_SYSTEMTIME CPWL_NoteItem::GetDateTime() const | 944 } |
| 945 { | 945 |
| 946 return m_dtNote; | 946 return NULL; |
| 947 } | 947 } |
| 948 | 948 |
| 949 CFX_WideString CPWL_NoteItem::GetSubjectName() const | 949 IPWL_NoteItem* CPWL_NoteItem::GetFocusedNoteItem() const { |
| 950 { | 950 if (const CPWL_Wnd* pWnd = this->GetFocused()) { |
| 951 if (m_pSubject) | 951 if (pWnd->GetClassName() == "CPWL_Edit") { |
| 952 return m_pSubject->GetText(); | 952 if (CPWL_Wnd* pParent = pWnd->GetParentWindow()) { |
| 953 | 953 ASSERT(pParent->GetClassName() == "CPWL_Note_Contents"); |
| 954 return L""; | 954 |
| 955 } | 955 if (CPWL_Wnd* pGrand = pParent->GetParentWindow()) { |
| 956 | 956 ASSERT(pGrand->GetClassName() == "CPWL_NoteItem"); |
| 957 CPWL_NoteItem* CPWL_NoteItem::CreateNoteItem() | 957 return (CPWL_NoteItem*)pGrand; |
| 958 { | 958 } |
| 959 if (m_pContents) | 959 } |
| 960 return m_pContents->CreateSubItem(); | 960 } |
| 961 | 961 } |
| 962 return NULL; | 962 |
| 963 } | 963 return NULL; |
| 964 | 964 } |
| 965 IPWL_NoteItem* CPWL_NoteItem::CreateSubItem() | 965 |
| 966 { | 966 FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth) { |
| 967 return CreateNoteItem(); | 967 if (fLimitWidth > 0) { |
| 968 } | 968 if (!m_bSizeChanged) |
| 969 | 969 return m_fOldItemHeight; |
| 970 FX_INT32 CPWL_NoteItem::CountSubItems() const | 970 |
| 971 { | 971 m_bSizeChanged = FALSE; |
| 972 if (m_pContents) | 972 |
| 973 return m_pContents->CountSubItems(); | 973 ASSERT(m_pSubject != NULL); |
| 974 | 974 ASSERT(m_pDateTime != NULL); |
| 975 return 0; | 975 ASSERT(m_pContents != NULL); |
| 976 } | 976 |
| 977 | 977 FX_FLOAT fRet = m_pDateTime->GetContentRect().Height(); |
| 978 IPWL_NoteItem* CPWL_NoteItem::GetSubItems(FX_INT32 index) const | 978 FX_FLOAT fBorderWidth = (FX_FLOAT) this->GetBorderWidth(); |
| 979 { | 979 if (fLimitWidth > fBorderWidth * 2) |
| 980 if (m_pContents) | 980 fRet += m_pContents->GetContentsHeight(fLimitWidth - fBorderWidth * 2); |
| 981 return m_pContents->GetSubItems(index); | 981 fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorderWidth * 2; |
| 982 | 982 |
| 983 return NULL; | 983 return m_fOldItemHeight = fRet; |
| 984 } | 984 } |
| 985 | 985 |
| 986 void CPWL_NoteItem::DeleteSubItem(IPWL_NoteItem* pNoteItem) | 986 return 0; |
| 987 { | 987 } |
| 988 this->KillFocus(); | 988 |
| 989 | 989 FX_FLOAT CPWL_NoteItem::GetItemLeftMargin() { |
| 990 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 990 return POPUP_ITEM_SIDEMARGIN; |
| 991 { | 991 } |
| 992 pNotify->OnItemDelete(pNoteItem); | 992 |
| 993 } | 993 FX_FLOAT CPWL_NoteItem::GetItemRightMargin() { |
| 994 | 994 return POPUP_ITEM_SIDEMARGIN; |
| 995 if (m_pContents) | 995 } |
| 996 m_pContents->DeleteSubItem(pNoteItem); | 996 |
| 997 } | 997 FX_BOOL CPWL_NoteItem::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) { |
| 998 | 998 if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) { |
| 999 IPWL_NoteItem* CPWL_NoteItem::GetHitNoteItem(const CPDF_Point& point) | 999 SetNoteFocus(FALSE); |
| 1000 { | 1000 } |
| 1001 CPDF_Point pt = this->ParentToChild(point); | 1001 |
| 1002 | 1002 CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 1003 if (this->WndHitTest(pt)) | 1003 |
| 1004 { | 1004 return TRUE; |
| 1005 if (m_pContents) | 1005 } |
| 1006 { | 1006 |
| 1007 if (IPWL_NoteItem* pNoteItem = m_pContents->GetHitNoteIt
em(pt)) | 1007 FX_BOOL CPWL_NoteItem::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
| 1008 return pNoteItem; | 1008 if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) { |
| 1009 } | 1009 SetNoteFocus(FALSE); |
| 1010 | 1010 PopupNoteItemMenu(point); |
| 1011 return this; | 1011 |
| 1012 } | 1012 return TRUE; |
| 1013 | 1013 } |
| 1014 return NULL; | 1014 |
| 1015 } | 1015 return CPWL_Wnd::OnRButtonUp(point, nFlag); |
| 1016 | 1016 } |
| 1017 IPWL_NoteItem* CPWL_NoteItem::GetFocusedNoteItem() const | 1017 |
| 1018 { | 1018 void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd, |
| 1019 if (const CPWL_Wnd* pWnd = this->GetFocused()) | 1019 FX_DWORD msg, |
| 1020 { | 1020 FX_INTPTR wParam, |
| 1021 if (pWnd->GetClassName() == "CPWL_Edit") | 1021 FX_INTPTR lParam) { |
| 1022 { | 1022 switch (msg) { |
| 1023 if (CPWL_Wnd* pParent = pWnd->GetParentWindow()) | 1023 case PNM_NOTEEDITCHANGED: |
| 1024 { | 1024 m_bSizeChanged = TRUE; |
| 1025 ASSERT(pParent->GetClassName() == "CPWL_Note_Con
tents"); | 1025 |
| 1026 | 1026 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 1027 if (CPWL_Wnd* pGrand = pParent->GetParentWindow(
)) | 1027 pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); |
| 1028 { | 1028 } |
| 1029 ASSERT(pGrand->GetClassName() == "CPWL_N
oteItem"); | 1029 return; |
| 1030 return (CPWL_NoteItem*)pGrand; | 1030 case PNM_SETCARETINFO: |
| 1031 } | 1031 if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) { |
| 1032 } | 1032 PWL_CARET_INFO newInfo = *pInfo; |
| 1033 } | 1033 newInfo.bVisible = TRUE; |
| 1034 } | 1034 newInfo.ptHead = this->ChildToParent(pInfo->ptHead); |
| 1035 | 1035 newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot); |
| 1036 return NULL; | 1036 |
| 1037 } | 1037 if (CPWL_Wnd* pParent = this->GetParentWindow()) { |
| 1038 | 1038 pParent->OnNotify(this, PNM_SETCARETINFO, (FX_INTPTR)&newInfo, 0); |
| 1039 FX_FLOAT CPWL_NoteItem::GetItemHeight(FX_FLOAT fLimitWidth) | 1039 } |
| 1040 { | 1040 } |
| 1041 if (fLimitWidth > 0) | 1041 return; |
| 1042 { | 1042 case PNM_NOTERESET: |
| 1043 if (!m_bSizeChanged) | 1043 m_bSizeChanged = TRUE; |
| 1044 return m_fOldItemHeight; | 1044 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); |
| 1045 | 1045 |
| 1046 m_bSizeChanged = FALSE; | 1046 return; |
| 1047 | 1047 } |
| 1048 ASSERT(m_pSubject != NULL); | 1048 |
| 1049 ASSERT(m_pDateTime != NULL); | 1049 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); |
| 1050 ASSERT(m_pContents != NULL); | 1050 } |
| 1051 | 1051 |
| 1052 FX_FLOAT fRet = m_pDateTime->GetContentRect().Height(); | 1052 void CPWL_NoteItem::PopupNoteItemMenu(const CPDF_Point& point) { |
| 1053 FX_FLOAT fBorderWidth = (FX_FLOAT)this->GetBorderWidth(); | 1053 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 1054 if (fLimitWidth > fBorderWidth * 2) | 1054 FX_INT32 x, y; |
| 1055 fRet += m_pContents->GetContentsHeight(fLimitWidth - fBo
rderWidth * 2); | 1055 PWLtoWnd(point, x, y); |
| 1056 fRet += POPUP_ITEM_HEAD_BOTTOM + POPUP_ITEM_BOTTOMWIDTH + fBorde
rWidth * 2; | 1056 if (IFX_SystemHandler* pSH = GetSystemHandler()) |
| 1057 | 1057 pSH->ClientToScreen(GetAttachedHWnd(), x, y); |
| 1058 return m_fOldItemHeight = fRet; | 1058 pNotify->OnPopupMenu(this, x, y); |
| 1059 } | 1059 } |
| 1060 | 1060 } |
| 1061 return 0; | 1061 |
| 1062 } | 1062 const CPWL_Note* CPWL_NoteItem::GetNote() const { |
| 1063 | 1063 if (const CPWL_Wnd* pRoot = this->GetRootWnd()) { |
| 1064 FX_FLOAT CPWL_NoteItem::GetItemLeftMargin() | 1064 ASSERT(pRoot->GetClassName() == "CPWL_NoteItem"); |
| 1065 { | 1065 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pRoot; |
| 1066 return POPUP_ITEM_SIDEMARGIN; | 1066 if (pNoteItem->IsTopItem()) { |
| 1067 } | 1067 return (CPWL_Note*)pNoteItem; |
| 1068 | 1068 } |
| 1069 FX_FLOAT CPWL_NoteItem::GetItemRightMargin() | 1069 } |
| 1070 { | 1070 |
| 1071 return POPUP_ITEM_SIDEMARGIN; | 1071 return NULL; |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 FX_BOOL CPWL_NoteItem::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) | 1074 IPWL_NoteNotify* CPWL_NoteItem::GetNoteNotify() const { |
| 1075 { | 1075 if (const CPWL_Note* pNote = GetNote()) |
| 1076 if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) | 1076 return pNote->GetNoteNotify(); |
| 1077 { | 1077 |
| 1078 SetNoteFocus(FALSE); | 1078 return NULL; |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 CPWL_Wnd::OnLButtonDown(point,nFlag); | 1081 void CPWL_NoteItem::OnCreateNoteItem() { |
| 1082 | 1082 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 1083 return TRUE; | 1083 pNotify->OnItemCreate(this); |
| 1084 } | 1084 } |
| 1085 | 1085 } |
| 1086 FX_BOOL CPWL_NoteItem::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag) | 1086 |
| 1087 { | 1087 void CPWL_NoteItem::OnContentsValidate() { |
| 1088 if (!m_pContents->WndHitTest(m_pContents->ParentToChild(point))) | 1088 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 1089 { | 1089 pNotify->OnSetContents(this); |
| 1090 SetNoteFocus(FALSE); | 1090 } |
| 1091 PopupNoteItemMenu(point); | 1091 } |
| 1092 | 1092 |
| 1093 return TRUE; | 1093 void CPWL_NoteItem::SetNoteFocus(FX_BOOL bLast) { |
| 1094 } | 1094 m_pContents->SetEditFocus(bLast); |
| 1095 | 1095 } |
| 1096 return CPWL_Wnd::OnRButtonUp(point,nFlag); | 1096 |
| 1097 } | 1097 void CPWL_NoteItem::EnableModify(FX_BOOL bEnabled) { |
| 1098 | 1098 m_pContents->EnableModify(bEnabled); |
| 1099 void CPWL_NoteItem::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_
INTPTR lParam) | 1099 m_bAllowModify = bEnabled; |
| 1100 { | 1100 } |
| 1101 switch (msg) | 1101 |
| 1102 { | 1102 void CPWL_NoteItem::EnableRead(FX_BOOL bEnabled) { |
| 1103 case PNM_NOTEEDITCHANGED: | 1103 m_pContents->EnableRead(bEnabled); |
| 1104 m_bSizeChanged = TRUE; | 1104 } |
| 1105 | 1105 |
| 1106 if (CPWL_Wnd* pParent = this->GetParentWindow()) | 1106 /* ---------------------------------- CPWL_Note |
| 1107 { | 1107 * ---------------------------------- */ |
| 1108 pParent->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); | 1108 |
| 1109 } | 1109 CPWL_Note::CPWL_Note(IPopup_Note* pPopupNote, |
| 1110 return; | 1110 IPWL_NoteNotify* pNoteNotify, |
| 1111 case PNM_SETCARETINFO: | 1111 IPWL_NoteHandler* pNoteHandler) |
| 1112 if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam) | 1112 : m_pAuthor(NULL), |
| 1113 { | 1113 m_pIcon(NULL), |
| 1114 PWL_CARET_INFO newInfo = *pInfo; | 1114 m_pCloseBox(NULL), |
| 1115 newInfo.bVisible = TRUE; | 1115 m_pLBBox(NULL), |
| 1116 newInfo.ptHead = this->ChildToParent(pInfo->ptHead); | 1116 m_pRBBox(NULL), |
| 1117 newInfo.ptFoot = this->ChildToParent(pInfo->ptFoot); | 1117 m_pContentsBar(NULL), |
| 1118 | 1118 m_pOptions(NULL), |
| 1119 if (CPWL_Wnd * pParent = this->GetParentWindow()) | 1119 m_pNoteNotify(pNoteNotify), |
| 1120 { | 1120 m_bResizing(FALSE), |
| 1121 pParent->OnNotify(this, PNM_SETCARETINFO, (FX_IN
TPTR)&newInfo, 0); | 1121 m_rcCaption(0, 0, 0, 0), |
| 1122 } | 1122 m_bEnalbleNotify(TRUE), |
| 1123 } | 1123 m_pPopupNote(pPopupNote) { |
| 1124 return; | 1124 } |
| 1125 case PNM_NOTERESET: | 1125 |
| 1126 m_bSizeChanged = TRUE; | 1126 CPWL_Note::~CPWL_Note() { |
| 1127 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); | 1127 } |
| 1128 | 1128 |
| 1129 return; | 1129 IPWL_NoteItem* CPWL_Note::Reply() { |
| 1130 } | 1130 return CreateNoteItem(); |
| 1131 | 1131 } |
| 1132 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); | 1132 |
| 1133 } | 1133 void CPWL_Note::EnableNotify(FX_BOOL bEnabled) { |
| 1134 | 1134 m_bEnalbleNotify = bEnabled; |
| 1135 void CPWL_NoteItem::PopupNoteItemMenu(const CPDF_Point& point) | 1135 } |
| 1136 { | 1136 |
| 1137 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 1137 void CPWL_Note::RePosChildWnd() { |
| 1138 { | 1138 RePosNoteChildren(); |
| 1139 FX_INT32 x,y; | 1139 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); |
| 1140 PWLtoWnd(point, x, y); | 1140 ResetScrollBar(); |
| 1141 if (IFX_SystemHandler* pSH = GetSystemHandler()) | 1141 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); |
| 1142 pSH->ClientToScreen(GetAttachedHWnd(), x, y); | 1142 this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); |
| 1143 pNotify->OnPopupMenu(this, x, y); | 1143 //ͬ²½ |
| 1144 } | 1144 if (const CPWL_Wnd* pWnd = this->GetFocused()) { |
| 1145 } | 1145 if (pWnd->GetClassName() == "CPWL_Edit") { |
| 1146 | 1146 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; |
| 1147 const CPWL_Note* CPWL_NoteItem::GetNote() const | 1147 pEdit->SetCaret(pEdit->GetCaret()); |
| 1148 { | 1148 } |
| 1149 if (const CPWL_Wnd* pRoot = this->GetRootWnd()) | 1149 } |
| 1150 { | 1150 // CPDF_Point ptNew = m_pContents->GetScrollPos(); |
| 1151 ASSERT(pRoot->GetClassName() == "CPWL_NoteItem"); | 1151 // m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, |
| 1152 CPWL_NoteItem* pNoteItem = (CPWL_NoteItem*)pRoot; | 1152 // (FX_INTPTR)&ptNew.y); |
| 1153 if (pNoteItem->IsTopItem()) | 1153 } |
| 1154 { | 1154 |
| 1155 return (CPWL_Note*)pNoteItem; | 1155 FX_BOOL CPWL_Note::ResetScrollBar() { |
| 1156 } | 1156 FX_BOOL bScrollChanged = FALSE; |
| 1157 } | 1157 |
| 1158 | 1158 if (ScrollBarShouldVisible()) { |
| 1159 return NULL; | 1159 if (!m_pContentsBar->IsVisible()) { |
| 1160 } | 1160 m_pContentsBar->SetVisible(TRUE); |
| 1161 | 1161 if (m_pContentsBar->IsVisible()) { |
| 1162 IPWL_NoteNotify* CPWL_NoteItem::GetNoteNotify() const | 1162 m_pContentsBar->InvalidateRect(NULL); |
| 1163 { | 1163 bScrollChanged = TRUE; |
| 1164 if (const CPWL_Note* pNote = GetNote()) | 1164 } |
| 1165 return pNote->GetNoteNotify(); | 1165 } |
| 1166 | 1166 } else { |
| 1167 return NULL; | 1167 if (m_pContentsBar->IsVisible()) { |
| 1168 } | 1168 m_pContentsBar->SetVisible(FALSE); |
| 1169 | 1169 m_pContentsBar->InvalidateRect(NULL); |
| 1170 void CPWL_NoteItem::OnCreateNoteItem() | 1170 |
| 1171 { | 1171 bScrollChanged = TRUE; |
| 1172 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 1172 } |
| 1173 { | 1173 } |
| 1174 pNotify->OnItemCreate(this); | 1174 |
| 1175 } | 1175 if (bScrollChanged) { |
| 1176 } | 1176 CPDF_Rect rcNote = this->GetClientRect(); |
| 1177 | 1177 CPDF_Rect rcContents = m_pContents->GetWindowRect(); |
| 1178 void CPWL_NoteItem::OnContentsValidate() | 1178 rcContents.right = rcNote.right - 3.0f; |
| 1179 { | 1179 if (m_pContentsBar->IsVisible()) |
| 1180 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 1180 rcContents.right -= PWL_SCROLLBAR_WIDTH; |
| 1181 { | 1181 m_pContents->Move(rcContents, TRUE, TRUE); |
| 1182 pNotify->OnSetContents(this); | 1182 m_pContents->SetScrollPos(CPDF_Point(0.0f, 0.0f)); |
| 1183 } | 1183 m_pContents->InvalidateRect(NULL); |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 void CPWL_NoteItem::SetNoteFocus(FX_BOOL bLast) | 1186 return bScrollChanged; |
| 1187 { | 1187 } |
| 1188 m_pContents->SetEditFocus(bLast); | 1188 |
| 1189 } | 1189 FX_BOOL CPWL_Note::ScrollBarShouldVisible() { |
| 1190 | 1190 CPDF_Rect rcContentsFact = m_pContents->GetScrollArea(); |
| 1191 void CPWL_NoteItem::EnableModify(FX_BOOL bEnabled) | 1191 CPDF_Rect rcContentsClient = m_pContents->GetClientRect(); |
| 1192 { | 1192 |
| 1193 m_pContents->EnableModify(bEnabled); | 1193 return rcContentsFact.Height() > rcContentsClient.Height(); |
| 1194 m_bAllowModify = bEnabled; | 1194 } |
| 1195 } | 1195 |
| 1196 | 1196 void CPWL_Note::SetOptionsText(const CFX_WideString& sText) { |
| 1197 void CPWL_NoteItem::EnableRead(FX_BOOL bEnabled) | 1197 if (m_pOptions) |
| 1198 { | 1198 m_pOptions->SetText(sText); |
| 1199 m_pContents->EnableRead(bEnabled); | 1199 |
| 1200 } | 1200 RePosNoteChildren(); |
| 1201 | 1201 } |
| 1202 /* ---------------------------------- CPWL_Note --------------------------------
-- */ | 1202 |
| 1203 | 1203 void CPWL_Note::RePosNoteChildren() { |
| 1204 CPWL_Note::CPWL_Note(IPopup_Note* pPopupNote, IPWL_NoteNotify* pNoteNotify, IPWL
_NoteHandler* pNoteHandler) : | 1204 if (m_bResizing) |
| 1205 m_pAuthor(NULL), | 1205 return; |
| 1206 m_pIcon(NULL), | 1206 |
| 1207 m_pCloseBox(NULL), | 1207 m_bResizing = TRUE; |
| 1208 m_pLBBox(NULL), | 1208 |
| 1209 m_pRBBox(NULL), | 1209 if (this->IsValid()) { |
| 1210 m_pContentsBar(NULL), | 1210 ASSERT(m_pSubject != NULL); |
| 1211 m_pOptions(NULL), | 1211 ASSERT(m_pDateTime != NULL); |
| 1212 m_pNoteNotify(pNoteNotify), | 1212 ASSERT(m_pContents != NULL); |
| 1213 m_bResizing(FALSE), | 1213 ASSERT(m_pAuthor != NULL); |
| 1214 m_rcCaption(0,0,0,0), | 1214 ASSERT(m_pCloseBox != NULL); |
| 1215 m_bEnalbleNotify(TRUE), | 1215 ASSERT(m_pIcon != NULL); |
| 1216 m_pPopupNote(pPopupNote) | 1216 ASSERT(m_pLBBox != NULL); |
| 1217 { | 1217 ASSERT(m_pRBBox != NULL); |
| 1218 } | 1218 ASSERT(m_pContentsBar != NULL); |
| 1219 | 1219 ASSERT(m_pOptions != NULL); |
| 1220 CPWL_Note::~CPWL_Note() | 1220 |
| 1221 { | 1221 CPDF_Rect rcClient = GetClientRect(); |
| 1222 } | 1222 |
| 1223 | 1223 CPDF_Rect rcIcon = rcClient; |
| 1224 IPWL_NoteItem* CPWL_Note::Reply() | 1224 rcIcon.top -= 2.0f; |
| 1225 { | 1225 rcIcon.right = rcIcon.left + 14.0f; |
| 1226 return CreateNoteItem(); | 1226 rcIcon.bottom = rcIcon.top - 14.0f; |
| 1227 } | 1227 rcIcon.Normalize(); |
| 1228 | 1228 m_pIcon->Move(rcIcon, TRUE, FALSE); |
| 1229 void CPWL_Note::EnableNotify(FX_BOOL bEnabled) | 1229 m_pIcon->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcIcon)); |
| 1230 { | 1230 |
| 1231 m_bEnalbleNotify = bEnabled; | 1231 CPDF_Rect rcCloseBox = rcClient; |
| 1232 } | 1232 rcCloseBox.right -= 1.0f; |
| 1233 | 1233 rcCloseBox.top -= 1.0f; |
| 1234 void CPWL_Note::RePosChildWnd() | 1234 rcCloseBox.left = rcCloseBox.right - 14.0f; |
| 1235 { | 1235 rcCloseBox.bottom = rcCloseBox.top - 14.0f; |
| 1236 RePosNoteChildren(); | 1236 rcCloseBox.Normalize(); |
| 1237 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); | 1237 m_pCloseBox->Move(rcCloseBox, TRUE, FALSE); |
| 1238 ResetScrollBar(); | 1238 m_pCloseBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcCloseBox)); |
| 1239 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); | 1239 |
| 1240 this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); | 1240 CPDF_Rect rcDate = rcClient; |
| 1241 //ͬ²½ | 1241 rcDate.right = rcCloseBox.left - POPUP_ITEM_TEXT_INDENT; |
| 1242 if (const CPWL_Wnd* pWnd = this->GetFocused()) | 1242 rcDate.left = |
| 1243 { | 1243 PWL_MAX(rcDate.right - m_pDateTime->GetContentRect().Width() - 1.0f, |
| 1244 if (pWnd->GetClassName() == "CPWL_Edit") | 1244 rcIcon.right + 1.0f); |
| 1245 { | 1245 rcDate.top = rcClient.top - 2.0f; |
| 1246 CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; | 1246 rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Height(); |
| 1247 pEdit->SetCaret(pEdit->GetCaret()); | 1247 rcDate.Normalize(); |
| 1248 } | 1248 m_pDateTime->Move(rcDate, TRUE, FALSE); |
| 1249 } | 1249 m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDate)); |
| 1250 //CPDF_Point ptNew = m_pContents->GetScrollPos(); | 1250 |
| 1251 //m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTP
TR)&ptNew.y); | 1251 CPDF_Rect rcSubject = rcClient; |
| 1252 } | 1252 rcSubject.top = rcClient.top - 2.0f; |
| 1253 | 1253 rcSubject.left = rcIcon.right + POPUP_ITEM_TEXT_INDENT; |
| 1254 FX_BOOL CPWL_Note::ResetScrollBar() | 1254 rcSubject.right = |
| 1255 { | 1255 PWL_MIN(rcSubject.left + m_pSubject->GetContentRect().Width() + 1.0f, |
| 1256 FX_BOOL bScrollChanged = FALSE; | 1256 rcDate.left - 1.0f); |
| 1257 | 1257 rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().Height(); |
| 1258 if (ScrollBarShouldVisible()) | 1258 rcSubject.Normalize(); |
| 1259 { | 1259 m_pSubject->Move(rcSubject, TRUE, FALSE); |
| 1260 if (!m_pContentsBar->IsVisible()) | 1260 m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubject)); |
| 1261 { | 1261 |
| 1262 m_pContentsBar->SetVisible(TRUE); | 1262 CPDF_Rect rcOptions = rcClient; |
| 1263 if (m_pContentsBar->IsVisible()) | 1263 rcOptions.left = |
| 1264 { | 1264 PWL_MAX(rcOptions.right - m_pOptions->GetContentRect().Width(), |
| 1265 m_pContentsBar->InvalidateRect(NULL); | 1265 rcIcon.right + 1.0f); |
| 1266 bScrollChanged = TRUE; | 1266 rcOptions.top = rcSubject.bottom - 4.0f; |
| 1267 } | 1267 rcOptions.bottom = rcOptions.top - m_pOptions->GetContentRect().Height(); |
| 1268 } | 1268 rcOptions.Normalize(); |
| 1269 } | 1269 m_pOptions->Move(rcOptions, TRUE, FALSE); |
| 1270 else | 1270 m_pOptions->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcOptions)); |
| 1271 { | 1271 |
| 1272 if (m_pContentsBar->IsVisible()) | 1272 CPDF_Rect rcAuthor = rcClient; |
| 1273 { | 1273 rcAuthor.top = rcSubject.bottom - 4.0f; |
| 1274 m_pContentsBar->SetVisible(FALSE); | 1274 rcAuthor.left = rcSubject.left; |
| 1275 m_pContentsBar->InvalidateRect(NULL); | 1275 rcAuthor.right = |
| 1276 | 1276 PWL_MIN(rcSubject.left + m_pAuthor->GetContentRect().Width() + 1.0f, |
| 1277 bScrollChanged = TRUE; | 1277 rcOptions.left - 1.0f); |
| 1278 } | 1278 rcAuthor.bottom = rcAuthor.top - m_pAuthor->GetContentRect().Height(); |
| 1279 } | 1279 rcAuthor.Normalize(); |
| 1280 | 1280 m_pAuthor->Move(rcAuthor, TRUE, FALSE); |
| 1281 if (bScrollChanged) | 1281 m_pAuthor->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcAuthor)); |
| 1282 { | 1282 |
| 1283 CPDF_Rect rcNote = this->GetClientRect(); | 1283 CPDF_Rect rcLBBox = rcClient; |
| 1284 CPDF_Rect rcContents = m_pContents->GetWindowRect(); | 1284 rcLBBox.top = rcLBBox.bottom + 7.0f; |
| 1285 rcContents.right = rcNote.right - 3.0f; | 1285 rcLBBox.right = rcLBBox.left + 7.0f; |
| 1286 if (m_pContentsBar->IsVisible()) | 1286 rcLBBox.Normalize(); |
| 1287 rcContents.right -= PWL_SCROLLBAR_WIDTH; | 1287 m_pLBBox->Move(rcLBBox, TRUE, FALSE); |
| 1288 m_pContents->Move(rcContents, TRUE, TRUE); | 1288 m_pLBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcLBBox)); |
| 1289 m_pContents->SetScrollPos(CPDF_Point(0.0f,0.0f)); | 1289 |
| 1290 m_pContents->InvalidateRect(NULL); | 1290 CPDF_Rect rcRBBox = rcClient; |
| 1291 } | 1291 rcRBBox.top = rcRBBox.bottom + 7.0f; |
| 1292 | 1292 rcRBBox.left = rcRBBox.right - 7.0f; |
| 1293 return bScrollChanged; | 1293 rcRBBox.Normalize(); |
| 1294 } | 1294 m_pRBBox->Move(rcRBBox, TRUE, FALSE); |
| 1295 | 1295 m_pRBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcRBBox)); |
| 1296 FX_BOOL CPWL_Note::ScrollBarShouldVisible() | 1296 |
| 1297 { | 1297 CPDF_Rect rcContents = rcClient; |
| 1298 CPDF_Rect rcContentsFact = m_pContents->GetScrollArea(); | 1298 rcContents.top = rcAuthor.bottom - POPUP_ITEM_HEAD_BOTTOM; |
| 1299 CPDF_Rect rcContentsClient = m_pContents->GetClientRect(); | 1299 rcContents.left += 3.0f; |
| 1300 | 1300 rcContents.right -= 3.0f; |
| 1301 return rcContentsFact.Height() > rcContentsClient.Height(); | 1301 if (m_pContentsBar->IsVisible()) |
| 1302 } | 1302 rcContents.right -= PWL_SCROLLBAR_WIDTH; |
| 1303 | 1303 rcContents.bottom += 14.0f; |
| 1304 void CPWL_Note::SetOptionsText(const CFX_WideString& sText) | 1304 rcContents.Normalize(); |
| 1305 { | 1305 m_pContents->Move(rcContents, FALSE, FALSE); |
| 1306 if (m_pOptions) | 1306 m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcContents)); |
| 1307 m_pOptions->SetText(sText); | 1307 |
| 1308 | 1308 CPDF_Rect rcContentsBar = rcContents; |
| 1309 RePosNoteChildren(); | 1309 rcContentsBar.right = rcClient.right - 3.0f; |
| 1310 } | 1310 rcContentsBar.left = rcContentsBar.right - PWL_SCROLLBAR_WIDTH; |
| 1311 | 1311 rcContentsBar.Normalize(); |
| 1312 void CPWL_Note::RePosNoteChildren() | 1312 m_pContentsBar->Move(rcContentsBar, TRUE, FALSE); |
| 1313 { | 1313 |
| 1314 if (m_bResizing) return; | 1314 m_rcCaption = rcClient; |
| 1315 | 1315 m_rcCaption.bottom = rcContents.top; |
| 1316 m_bResizing = TRUE; | 1316 } |
| 1317 | 1317 |
| 1318 if (this->IsValid()) | 1318 m_bResizing = FALSE; |
| 1319 { | 1319 } |
| 1320 ASSERT(m_pSubject != NULL); | 1320 |
| 1321 ASSERT(m_pDateTime != NULL); | 1321 // 0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close / |
| 1322 ASSERT(m_pContents != NULL); | 1322 // 5-options |
| 1323 ASSERT(m_pAuthor != NULL); | 1323 FX_INT32 CPWL_Note::NoteHitTest(const CPDF_Point& point) const { |
| 1324 ASSERT(m_pCloseBox != NULL); | 1324 ASSERT(m_pSubject != NULL); |
| 1325 ASSERT(m_pIcon != NULL); | 1325 ASSERT(m_pDateTime != NULL); |
| 1326 ASSERT(m_pLBBox != NULL); | 1326 ASSERT(m_pContents != NULL); |
| 1327 ASSERT(m_pRBBox != NULL); | 1327 ASSERT(m_pAuthor != NULL); |
| 1328 ASSERT(m_pContentsBar != NULL); | 1328 ASSERT(m_pIcon != NULL); |
| 1329 ASSERT(m_pOptions != NULL); | 1329 ASSERT(m_pContentsBar != NULL); |
| 1330 | 1330 |
| 1331 CPDF_Rect rcClient = GetClientRect(); | 1331 ASSERT(m_pCloseBox != NULL); |
| 1332 | 1332 ASSERT(m_pLBBox != NULL); |
| 1333 CPDF_Rect rcIcon = rcClient; | 1333 ASSERT(m_pRBBox != NULL); |
| 1334 rcIcon.top -= 2.0f; | 1334 ASSERT(m_pOptions != NULL); |
| 1335 rcIcon.right = rcIcon.left + 14.0f; | 1335 |
| 1336 rcIcon.bottom = rcIcon.top - 14.0f; | 1336 GetClientRect(); |
| 1337 rcIcon.Normalize(); | 1337 |
| 1338 m_pIcon->Move(rcIcon, TRUE, FALSE); | 1338 if (m_pSubject->WndHitTest(m_pSubject->ParentToChild(point))) |
| 1339 m_pIcon->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcIcon)); | 1339 return 1; |
| 1340 | 1340 if (m_pDateTime->WndHitTest(m_pDateTime->ParentToChild(point))) |
| 1341 CPDF_Rect rcCloseBox = rcClient; | 1341 return 1; |
| 1342 rcCloseBox.right -= 1.0f; | 1342 if (m_pAuthor->WndHitTest(m_pAuthor->ParentToChild(point))) |
| 1343 rcCloseBox.top -= 1.0f; | 1343 return 1; |
| 1344 rcCloseBox.left = rcCloseBox.right - 14.0f; | 1344 if (m_pIcon->WndHitTest(m_pIcon->ParentToChild(point))) |
| 1345 rcCloseBox.bottom = rcCloseBox.top - 14.0f; | 1345 return 1; |
| 1346 rcCloseBox.Normalize(); | 1346 |
| 1347 m_pCloseBox->Move(rcCloseBox, TRUE, FALSE); | 1347 if (m_pContents->WndHitTest(m_pContents->ParentToChild(point))) |
| 1348 m_pCloseBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcClo
seBox)); | 1348 return 0; |
| 1349 | 1349 if (m_pContentsBar->WndHitTest(m_pContentsBar->ParentToChild(point))) |
| 1350 CPDF_Rect rcDate = rcClient; | 1350 return 0; |
| 1351 rcDate.right = rcCloseBox.left - POPUP_ITEM_TEXT_INDENT; | 1351 |
| 1352 rcDate.left = PWL_MAX(rcDate.right - m_pDateTime->GetContentRect
().Width() - 1.0f, rcIcon.right + 1.0f); | 1352 if (m_pCloseBox->WndHitTest(m_pCloseBox->ParentToChild(point))) |
| 1353 rcDate.top = rcClient.top - 2.0f; | 1353 return 4; |
| 1354 rcDate.bottom = rcDate.top - m_pDateTime->GetContentRect().Heigh
t(); | 1354 if (m_pLBBox->WndHitTest(m_pLBBox->ParentToChild(point))) |
| 1355 rcDate.Normalize(); | 1355 return 2; |
| 1356 m_pDateTime->Move(rcDate, TRUE, FALSE); | 1356 if (m_pRBBox->WndHitTest(m_pRBBox->ParentToChild(point))) |
| 1357 m_pDateTime->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcDat
e)); | 1357 return 3; |
| 1358 | 1358 if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) |
| 1359 CPDF_Rect rcSubject = rcClient; | 1359 return 5; |
| 1360 rcSubject.top = rcClient.top - 2.0f; | 1360 |
| 1361 rcSubject.left = rcIcon.right + POPUP_ITEM_TEXT_INDENT; | 1361 return 1; |
| 1362 rcSubject.right = PWL_MIN(rcSubject.left + m_pSubject->GetConten
tRect().Width() + 1.0f, rcDate.left - 1.0f); | 1362 } |
| 1363 rcSubject.bottom = rcSubject.top - m_pSubject->GetContentRect().
Height(); | 1363 |
| 1364 rcSubject.Normalize(); | 1364 void CPWL_Note::CreateChildWnd(const PWL_CREATEPARAM& cp) { |
| 1365 m_pSubject->Move(rcSubject, TRUE, FALSE); | 1365 CPWL_NoteItem::CreateChildWnd(cp); |
| 1366 m_pSubject->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcSubj
ect)); | 1366 |
| 1367 | 1367 CPWL_Color sTextColor; |
| 1368 CPDF_Rect rcOptions = rcClient; | 1368 |
| 1369 rcOptions.left = PWL_MAX(rcOptions.right - m_pOptions->GetConten
tRect().Width(), rcIcon.right + 1.0f); | 1369 if (CPWL_Utils::IsBlackOrWhite(this->GetBackgroundColor())) |
| 1370 rcOptions.top = rcSubject.bottom - 4.0f; | 1370 sTextColor = PWL_DEFAULT_WHITECOLOR; |
| 1371 rcOptions.bottom = rcOptions.top - m_pOptions->GetContentRect().
Height(); | 1371 else |
| 1372 rcOptions.Normalize(); | 1372 sTextColor = PWL_DEFAULT_BLACKCOLOR; |
| 1373 m_pOptions->Move(rcOptions, TRUE, FALSE); | 1373 |
| 1374 m_pOptions->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcOpti
ons)); | 1374 m_pAuthor = new CPWL_Label; |
| 1375 | 1375 PWL_CREATEPARAM acp = cp; |
| 1376 CPDF_Rect rcAuthor = rcClient; | 1376 acp.pParentWnd = this; |
| 1377 rcAuthor.top = rcSubject.bottom - 4.0f; | 1377 acp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP; |
| 1378 rcAuthor.left = rcSubject.left; | 1378 acp.sTextColor = sTextColor; |
| 1379 rcAuthor.right = PWL_MIN(rcSubject.left + m_pAuthor->GetContentR
ect().Width() + 1.0f, rcOptions.left - 1.0f); | 1379 m_pAuthor->Create(acp); |
| 1380 rcAuthor.bottom = rcAuthor.top - m_pAuthor->GetContentRect().Hei
ght(); | 1380 |
| 1381 rcAuthor.Normalize(); | 1381 m_pCloseBox = new CPWL_Note_CloseBox; |
| 1382 m_pAuthor->Move(rcAuthor, TRUE, FALSE); | 1382 PWL_CREATEPARAM ccp = cp; |
| 1383 m_pAuthor->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcAutho
r)); | 1383 ccp.pParentWnd = this; |
| 1384 | 1384 ccp.dwBorderWidth = 2; |
| 1385 CPDF_Rect rcLBBox = rcClient; | 1385 ccp.nBorderStyle = PBS_BEVELED; |
| 1386 rcLBBox.top = rcLBBox.bottom + 7.0f; | 1386 ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER; |
| 1387 rcLBBox.right = rcLBBox.left + 7.0f; | 1387 ccp.sTextColor = sTextColor; |
| 1388 rcLBBox.Normalize(); | 1388 m_pCloseBox->Create(ccp); |
| 1389 m_pLBBox->Move(rcLBBox, TRUE, FALSE); | 1389 |
| 1390 m_pLBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcLBBox)
); | 1390 m_pIcon = new CPWL_Note_Icon; |
| 1391 | 1391 PWL_CREATEPARAM icp = cp; |
| 1392 CPDF_Rect rcRBBox = rcClient; | 1392 icp.pParentWnd = this; |
| 1393 rcRBBox.top = rcRBBox.bottom + 7.0f; | 1393 icp.dwFlags = PWS_VISIBLE | PWS_CHILD; |
| 1394 rcRBBox.left = rcRBBox.right - 7.0f; | 1394 m_pIcon->Create(icp); |
| 1395 rcRBBox.Normalize(); | 1395 |
| 1396 m_pRBBox->Move(rcRBBox, TRUE, FALSE); | 1396 m_pOptions = new CPWL_Note_Options; |
| 1397 m_pRBBox->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcRBBox)
); | 1397 PWL_CREATEPARAM ocp = cp; |
| 1398 | 1398 ocp.pParentWnd = this; |
| 1399 CPDF_Rect rcContents = rcClient; | 1399 ocp.dwFlags = PWS_CHILD | PWS_VISIBLE; |
| 1400 rcContents.top = rcAuthor.bottom - POPUP_ITEM_HEAD_BOTTOM; | 1400 ocp.sTextColor = sTextColor; |
| 1401 rcContents.left += 3.0f; | 1401 m_pOptions->Create(ocp); |
| 1402 rcContents.right -= 3.0f; | 1402 |
| 1403 if (m_pContentsBar->IsVisible()) | 1403 m_pLBBox = new CPWL_Note_LBBox; |
| 1404 rcContents.right -= PWL_SCROLLBAR_WIDTH; | 1404 PWL_CREATEPARAM lcp = cp; |
| 1405 rcContents.bottom += 14.0f; | 1405 lcp.pParentWnd = this; |
| 1406 rcContents.Normalize(); | 1406 lcp.dwFlags = PWS_VISIBLE | PWS_CHILD; |
| 1407 m_pContents->Move(rcContents, FALSE, FALSE); | 1407 lcp.eCursorType = FXCT_NESW; |
| 1408 m_pContents->SetVisible(CPWL_Utils::ContainsRect(rcClient, rcCon
tents)); | 1408 lcp.sTextColor = sTextColor; |
| 1409 | 1409 m_pLBBox->Create(lcp); |
| 1410 CPDF_Rect rcContentsBar = rcContents; | 1410 |
| 1411 rcContentsBar.right = rcClient.right - 3.0f; | 1411 m_pRBBox = new CPWL_Note_RBBox; |
| 1412 rcContentsBar.left = rcContentsBar.right - PWL_SCROLLBAR_WIDTH; | 1412 PWL_CREATEPARAM rcp = cp; |
| 1413 rcContentsBar.Normalize(); | 1413 rcp.pParentWnd = this; |
| 1414 m_pContentsBar->Move(rcContentsBar, TRUE, FALSE); | 1414 rcp.dwFlags = PWS_VISIBLE | PWS_CHILD; |
| 1415 | 1415 rcp.eCursorType = FXCT_NWSE; |
| 1416 m_rcCaption = rcClient; | 1416 rcp.sTextColor = sTextColor; |
| 1417 m_rcCaption.bottom = rcContents.top; | 1417 m_pRBBox->Create(rcp); |
| 1418 } | 1418 |
| 1419 | 1419 m_pContentsBar = new CPWL_ScrollBar(SBT_VSCROLL); |
| 1420 m_bResizing = FALSE; | 1420 PWL_CREATEPARAM scp = cp; |
| 1421 } | 1421 scp.pParentWnd = this; |
| 1422 | 1422 scp.sBackgroundColor = |
| 1423 //0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close /
5-options | 1423 CPWL_Color(COLORTYPE_RGB, 240 / 255.0f, 240 / 255.0f, 240 / 255.0f); |
| 1424 FX_INT32 CPWL_Note::NoteHitTest(const CPDF_Point& point) const | 1424 scp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND; |
| 1425 { | 1425 m_pContentsBar->Create(scp); |
| 1426 ASSERT(m_pSubject != NULL); | 1426 m_pContentsBar->SetNotifyForever(TRUE); |
| 1427 ASSERT(m_pDateTime != NULL); | 1427 } |
| 1428 ASSERT(m_pContents != NULL); | 1428 |
| 1429 ASSERT(m_pAuthor != NULL); | 1429 void CPWL_Note::SetSubjectName(const CFX_WideString& sName) { |
| 1430 ASSERT(m_pIcon != NULL); | 1430 CPWL_NoteItem::SetSubjectName(sName); |
| 1431 ASSERT(m_pContentsBar != NULL); | 1431 RePosChildWnd(); |
| 1432 | 1432 } |
| 1433 ASSERT(m_pCloseBox != NULL); | 1433 |
| 1434 ASSERT(m_pLBBox != NULL); | 1434 void CPWL_Note::SetAuthorName(const CFX_WideString& sName) { |
| 1435 ASSERT(m_pRBBox != NULL); | 1435 if (m_pAuthor) { |
| 1436 ASSERT(m_pOptions != NULL); | 1436 m_pAuthor->SetText(sName); |
| 1437 | 1437 RePosChildWnd(); |
| 1438 GetClientRect(); | 1438 } |
| 1439 | 1439 |
| 1440 if (m_pSubject->WndHitTest(m_pSubject->ParentToChild(point))) return 1; | 1440 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) { |
| 1441 if (m_pDateTime->WndHitTest(m_pDateTime->ParentToChild(point))) return 1
; | 1441 pNotify->OnSetAuthorName(this); |
| 1442 if (m_pAuthor->WndHitTest(m_pAuthor->ParentToChild(point))) return 1; | 1442 } |
| 1443 if (m_pIcon->WndHitTest(m_pIcon->ParentToChild(point))) return 1; | 1443 } |
| 1444 | 1444 |
| 1445 if (m_pContents->WndHitTest(m_pContents->ParentToChild(point))) return 0
; | 1445 CFX_WideString CPWL_Note::GetAuthorName() const { |
| 1446 if (m_pContentsBar->WndHitTest(m_pContentsBar->ParentToChild(point))) re
turn 0; | 1446 if (m_pAuthor) |
| 1447 | 1447 return m_pAuthor->GetText(); |
| 1448 if (m_pCloseBox->WndHitTest(m_pCloseBox->ParentToChild(point))) return 4
; | 1448 |
| 1449 if (m_pLBBox->WndHitTest(m_pLBBox->ParentToChild(point))) return 2; | 1449 return L""; |
| 1450 if (m_pRBBox->WndHitTest(m_pRBBox->ParentToChild(point))) return 3; | 1450 } |
| 1451 if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) return 5; | 1451 |
| 1452 | 1452 FX_BOOL CPWL_Note::OnMouseWheel(short zDelta, |
| 1453 return 1; | 1453 const CPDF_Point& point, |
| 1454 } | 1454 FX_DWORD nFlag) { |
| 1455 | 1455 CPDF_Point ptScroll = m_pContents->GetScrollPos(); |
| 1456 void CPWL_Note::CreateChildWnd(const PWL_CREATEPARAM & cp) | 1456 CPDF_Rect rcScroll = m_pContents->GetScrollArea(); |
| 1457 { | 1457 CPDF_Rect rcContents = m_pContents->GetClientRect(); |
| 1458 CPWL_NoteItem::CreateChildWnd(cp); | 1458 |
| 1459 | 1459 if (rcScroll.top - rcScroll.bottom > rcContents.Height()) { |
| 1460 CPWL_Color sTextColor; | 1460 CPDF_Point ptNew = ptScroll; |
| 1461 | 1461 |
| 1462 if (CPWL_Utils::IsBlackOrWhite(this->GetBackgroundColor())) | 1462 if (zDelta > 0) |
| 1463 sTextColor = PWL_DEFAULT_WHITECOLOR; | 1463 ptNew.y += 30; |
| 1464 else | 1464 else |
| 1465 sTextColor = PWL_DEFAULT_BLACKCOLOR; | 1465 ptNew.y -= 30; |
| 1466 | 1466 |
| 1467 m_pAuthor = new CPWL_Label; | 1467 if (ptNew.y > rcScroll.top) |
| 1468 PWL_CREATEPARAM acp = cp; | 1468 ptNew.y = rcScroll.top; |
| 1469 acp.pParentWnd = this; | 1469 if (ptNew.y < rcScroll.bottom + rcContents.Height()) |
| 1470 acp.dwFlags = PWS_VISIBLE | PWS_CHILD | PES_LEFT | PES_TOP; | 1470 ptNew.y = rcScroll.bottom + rcContents.Height(); |
| 1471 acp.sTextColor = sTextColor; | 1471 if (ptNew.y < rcScroll.bottom) |
| 1472 m_pAuthor->Create(acp); | 1472 ptNew.y = rcScroll.bottom; |
| 1473 | 1473 |
| 1474 m_pCloseBox = new CPWL_Note_CloseBox; | 1474 if (ptNew.y != ptScroll.y) { |
| 1475 PWL_CREATEPARAM ccp = cp; | 1475 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); |
| 1476 ccp.pParentWnd = this; | 1476 m_pContents->OnNotify( |
| 1477 ccp.dwBorderWidth = 2; | 1477 this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&ptNew.y); |
| 1478 ccp.nBorderStyle = PBS_BEVELED; | 1478 m_pContentsBar->OnNotify( |
| 1479 ccp.dwFlags = PWS_VISIBLE | PWS_CHILD | PWS_BORDER; | 1479 this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y); |
| 1480 ccp.sTextColor = sTextColor; | 1480 |
| 1481 m_pCloseBox->Create(ccp); | 1481 return TRUE; |
| 1482 | 1482 } |
| 1483 m_pIcon = new CPWL_Note_Icon; | 1483 } |
| 1484 PWL_CREATEPARAM icp = cp; | 1484 |
| 1485 icp.pParentWnd = this; | 1485 return FALSE; |
| 1486 icp.dwFlags = PWS_VISIBLE | PWS_CHILD; | 1486 } |
| 1487 m_pIcon->Create(icp); | 1487 |
| 1488 | 1488 void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, |
| 1489 m_pOptions = new CPWL_Note_Options; | 1489 FX_DWORD msg, |
| 1490 PWL_CREATEPARAM ocp = cp; | 1490 FX_INTPTR wParam, |
| 1491 ocp.pParentWnd = this; | 1491 FX_INTPTR lParam) { |
| 1492 ocp.dwFlags = PWS_CHILD | PWS_VISIBLE; | 1492 switch (msg) { |
| 1493 ocp.sTextColor = sTextColor; | 1493 case PNM_NOTEEDITCHANGED: { |
| 1494 m_pOptions->Create(ocp); | 1494 CPDF_Rect rcScroll = m_pContents->GetScrollArea(); |
| 1495 | 1495 |
| 1496 m_pLBBox = new CPWL_Note_LBBox; | 1496 PWL_SCROLL_INFO sInfo; |
| 1497 PWL_CREATEPARAM lcp = cp; | 1497 sInfo.fContentMin = rcScroll.bottom; |
| 1498 lcp.pParentWnd = this; | 1498 sInfo.fContentMax = rcScroll.top; |
| 1499 lcp.dwFlags = PWS_VISIBLE | PWS_CHILD; | 1499 sInfo.fPlateWidth = m_pContents->GetClientRect().Height(); |
| 1500 lcp.eCursorType = FXCT_NESW; | 1500 sInfo.fSmallStep = 13.0f; |
| 1501 lcp.sTextColor = sTextColor; | 1501 sInfo.fBigStep = sInfo.fPlateWidth; |
| 1502 m_pLBBox->Create(lcp); | 1502 |
| 1503 | 1503 if (FXSYS_memcmp(&m_OldScrollInfo, &sInfo, sizeof(PWL_SCROLL_INFO)) != |
| 1504 m_pRBBox = new CPWL_Note_RBBox; | 1504 0) { |
| 1505 PWL_CREATEPARAM rcp = cp; | 1505 FX_BOOL bScrollChanged = FALSE; |
| 1506 rcp.pParentWnd = this; | 1506 |
| 1507 rcp.dwFlags = PWS_VISIBLE | PWS_CHILD; | 1507 if (lParam < 3) //·ÀÖ¹ËÀÑ»· mantis:15759 |
| 1508 rcp.eCursorType = FXCT_NWSE; | 1508 { |
| 1509 rcp.sTextColor = sTextColor; | 1509 bScrollChanged = ResetScrollBar(); |
| 1510 m_pRBBox->Create(rcp); | 1510 if (bScrollChanged) { |
| 1511 | 1511 lParam++; |
| 1512 m_pContentsBar = new CPWL_ScrollBar(SBT_VSCROLL); | 1512 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); |
| 1513 PWL_CREATEPARAM scp = cp; | 1513 this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam); |
| 1514 scp.pParentWnd = this; | 1514 } |
| 1515 scp.sBackgroundColor = CPWL_Color(COLORTYPE_RGB, 240/255.0f, 240/255.0f,
240/255.0f); | 1515 } |
| 1516 scp.dwFlags = PWS_CHILD | PWS_VISIBLE | PWS_BACKGROUND; | 1516 |
| 1517 m_pContentsBar->Create(scp); | 1517 if (!bScrollChanged) { |
| 1518 m_pContentsBar->SetNotifyForever(TRUE); | 1518 if (m_pContentsBar->IsVisible()) { |
| 1519 } | 1519 m_pContentsBar->OnNotify( |
| 1520 | 1520 pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTPTR)&sInfo); |
| 1521 void CPWL_Note::SetSubjectName(const CFX_WideString& sName) | 1521 m_OldScrollInfo = sInfo; |
| 1522 { | 1522 |
| 1523 CPWL_NoteItem::SetSubjectName(sName); | 1523 CPDF_Point ptScroll = m_pContents->GetScrollPos(); |
| 1524 RePosChildWnd(); | 1524 CPDF_Point ptOld = ptScroll; |
| 1525 } | 1525 |
| 1526 | 1526 if (ptScroll.y > sInfo.fContentMax) |
| 1527 void CPWL_Note::SetAuthorName(const CFX_WideString& sName) | 1527 ptScroll.y = sInfo.fContentMax; |
| 1528 { | 1528 if (ptScroll.y < sInfo.fContentMin + sInfo.fPlateWidth) |
| 1529 if (m_pAuthor) | 1529 ptScroll.y = sInfo.fContentMin + sInfo.fPlateWidth; |
| 1530 { | 1530 if (ptScroll.y < sInfo.fContentMin) |
| 1531 m_pAuthor->SetText(sName); | 1531 ptScroll.y = sInfo.fContentMin; |
| 1532 RePosChildWnd(); | 1532 |
| 1533 } | 1533 if (ptOld.y != ptScroll.y) { |
| 1534 | 1534 m_pContentsBar->OnNotify( |
| 1535 if (IPWL_NoteNotify* pNotify = GetNoteNotify()) | 1535 this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); |
| 1536 { | 1536 m_pContentsBar->InvalidateRect(NULL); |
| 1537 pNotify->OnSetAuthorName(this); | 1537 m_pContents->OnNotify( |
| 1538 } | 1538 this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); |
| 1539 } | 1539 } |
| 1540 | 1540 } |
| 1541 CFX_WideString CPWL_Note::GetAuthorName() const | 1541 } |
| 1542 { | 1542 } |
| 1543 if (m_pAuthor) | 1543 } |
| 1544 return m_pAuthor->GetText(); | 1544 |
| 1545 | 1545 m_pContents->InvalidateRect(NULL); |
| 1546 return L""; | 1546 |
| 1547 } | 1547 return; |
| 1548 | 1548 case PNM_SCROLLWINDOW: |
| 1549 FX_BOOL CPWL_Note::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD
nFlag) | 1549 if (m_pContents) |
| 1550 { | 1550 m_pContents->OnNotify(pWnd, msg, wParam, lParam); |
| 1551 CPDF_Point ptScroll = m_pContents->GetScrollPos(); | 1551 return; |
| 1552 CPDF_Rect rcScroll = m_pContents->GetScrollArea(); | 1552 case PNM_SETSCROLLPOS: |
| 1553 CPDF_Rect rcContents = m_pContents->GetClientRect(); | 1553 if (m_pContentsBar) |
| 1554 | 1554 m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLPOS, wParam, lParam); |
| 1555 if (rcScroll.top - rcScroll.bottom > rcContents.Height()) | 1555 return; |
| 1556 { | 1556 } |
| 1557 CPDF_Point ptNew = ptScroll; | 1557 |
| 1558 | 1558 if (msg == PNM_SETCARETINFO && IsValid()) { |
| 1559 if (zDelta > 0) | 1559 if (PWL_CARET_INFO* pInfo = (PWL_CARET_INFO*)wParam) { |
| 1560 ptNew.y += 30; | 1560 if (m_pContents) { |
| 1561 else | 1561 CPDF_Rect rcClient = m_pContents->GetClientRect(); |
| 1562 ptNew.y -= 30; | 1562 if (pInfo->ptHead.y > rcClient.top) { |
| 1563 | 1563 CPDF_Point pt = m_pContents->OutToIn(pInfo->ptHead); |
| 1564 if (ptNew.y > rcScroll.top) | 1564 m_pContents->OnNotify( |
| 1565 ptNew.y = rcScroll.top; | 1565 this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y); |
| 1566 if (ptNew.y < rcScroll.bottom + rcContents.Height()) | 1566 |
| 1567 ptNew.y = rcScroll.bottom + rcContents.Height(); | 1567 CPDF_Point ptScroll = m_pContents->GetScrollPos(); |
| 1568 if (ptNew.y < rcScroll.bottom) | 1568 m_pContentsBar->OnNotify( |
| 1569 ptNew.y = rcScroll.bottom; | 1569 this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); |
| 1570 | 1570 |
| 1571 if (ptNew.y != ptScroll.y) | 1571 return; |
| 1572 { | 1572 } |
| 1573 m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); | 1573 |
| 1574 m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROL
L, (FX_INTPTR)&ptNew.y); | 1574 if (pInfo->ptFoot.y < rcClient.bottom) { |
| 1575 m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSC
ROLL, (FX_INTPTR)&ptNew.y); | 1575 CPDF_Point pt = m_pContents->OutToIn(pInfo->ptFoot); |
| 1576 | 1576 pt.y += rcClient.Height(); |
| 1577 return TRUE; | 1577 m_pContents->OnNotify( |
| 1578 } | 1578 this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y); |
| 1579 } | 1579 |
| 1580 | 1580 CPDF_Point ptScroll = m_pContents->GetScrollPos(); |
| 1581 return FALSE; | 1581 m_pContentsBar->OnNotify( |
| 1582 } | 1582 this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); |
| 1583 | 1583 |
| 1584 void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTP
TR lParam) | 1584 return; |
| 1585 { | 1585 } |
| 1586 switch (msg) | 1586 } |
| 1587 { | 1587 } |
| 1588 case PNM_NOTEEDITCHANGED: | 1588 } |
| 1589 { | 1589 |
| 1590 CPDF_Rect rcScroll = m_pContents->GetScrollArea(); | 1590 CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam); |
| 1591 | 1591 } |
| 1592 | 1592 |
| 1593 PWL_SCROLL_INFO sInfo; | 1593 void CPWL_Note::SetBkColor(const CPWL_Color& color) { |
| 1594 sInfo.fContentMin = rcScroll.bottom; | 1594 CPWL_NoteItem::SetBkColor(color); |
| 1595 sInfo.fContentMax = rcScroll.top; | 1595 |
| 1596 sInfo.fPlateWidth = m_pContents->GetClientRect().Height(
); | 1596 CPWL_Color sBK = color; |
| 1597 sInfo.fSmallStep = 13.0f; | 1597 CPWL_Color sTextColor; |
| 1598 sInfo.fBigStep = sInfo.fPlateWidth; | 1598 if (CPWL_Utils::IsBlackOrWhite(sBK)) |
| 1599 | 1599 sTextColor = PWL_DEFAULT_WHITECOLOR; |
| 1600 if (FXSYS_memcmp(&m_OldScrollInfo, &sInfo, sizeof(PWL_SC
ROLL_INFO)) != 0) | 1600 else |
| 1601 { | 1601 sTextColor = PWL_DEFAULT_BLACKCOLOR; |
| 1602 FX_BOOL bScrollChanged = FALSE; | 1602 |
| 1603 | 1603 if (m_pCloseBox) |
| 1604 if (lParam < 3) //·ÀÖ¹ËÀÑ»· mantis:15759 | 1604 m_pCloseBox->SetTextColor(sTextColor); |
| 1605 { | 1605 if (m_pAuthor) |
| 1606 bScrollChanged = ResetScrollBar(); | 1606 m_pAuthor->SetTextColor(sTextColor); |
| 1607 if (bScrollChanged) | 1607 if (m_pOptions) |
| 1608 { | 1608 m_pOptions->SetTextColor(sTextColor); |
| 1609 lParam++; | 1609 if (m_pLBBox) |
| 1610 m_pContents->OnNotify(this, PNM_
NOTERESET, 0, 0); | 1610 m_pLBBox->SetTextColor(sTextColor); |
| 1611 this->OnNotify(this, PNM_NOTEEDI
TCHANGED, 0, lParam); | 1611 if (m_pRBBox) |
| 1612 } | 1612 m_pRBBox->SetTextColor(sTextColor); |
| 1613 } | 1613 } |
| 1614 | 1614 |
| 1615 if (!bScrollChanged) | 1615 FX_BOOL CPWL_Note::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) { |
| 1616 { | 1616 if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) { |
| 1617 if (m_pContentsBar->IsVisible()) | 1617 if (IPWL_NoteNotify* pNotify = this->GetNoteNotify()) { |
| 1618 { | 1618 FX_INT32 x, y; |
| 1619 m_pContentsBar->OnNotify(pWnd, P
NM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTPTR)&sInfo); | 1619 PWLtoWnd(point, x, y); |
| 1620 m_OldScrollInfo = sInfo; | 1620 if (IFX_SystemHandler* pSH = GetSystemHandler()) |
| 1621 | 1621 pSH->ClientToScreen(GetAttachedHWnd(), x, y); |
| 1622 CPDF_Point ptScroll = m_pContent
s->GetScrollPos(); | 1622 this->KillFocus(); |
| 1623 CPDF_Point ptOld = ptScroll; | 1623 pNotify->OnPopupMenu(x, y); |
| 1624 | 1624 |
| 1625 if (ptScroll.y > sInfo.fContentM
ax) | 1625 return TRUE; |
| 1626 ptScroll.y = sInfo.fCont
entMax; | 1626 } |
| 1627 if (ptScroll.y < sInfo.fContentM
in + sInfo.fPlateWidth) | 1627 } |
| 1628 ptScroll.y = sInfo.fCont
entMin + sInfo.fPlateWidth; | 1628 |
| 1629 if (ptScroll.y < sInfo.fContentM
in) | 1629 return CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 1630 ptScroll.y = sInfo.fCont
entMin; | 1630 } |
| 1631 | 1631 |
| 1632 if (ptOld.y != ptScroll.y) | 1632 FX_BOOL CPWL_Note::OnRButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
| 1633 { | 1633 return CPWL_Wnd::OnRButtonUp(point, nFlag); |
| 1634 m_pContentsBar->OnNotify
(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); | 1634 } |
| 1635 m_pContentsBar->Invalida
teRect(NULL); | 1635 |
| 1636 m_pContents->OnNotify(th
is, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); | 1636 const CPWL_Note* CPWL_Note::GetNote() const { |
| 1637 } | 1637 return this; |
| 1638 } | 1638 } |
| 1639 } | 1639 |
| 1640 } | 1640 IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const { |
| 1641 } | 1641 if (m_bEnalbleNotify) |
| 1642 | 1642 return m_pNoteNotify; |
| 1643 m_pContents->InvalidateRect(NULL); | 1643 |
| 1644 | 1644 return NULL; |
| 1645 return; | 1645 } |
| 1646 case PNM_SCROLLWINDOW: | 1646 |
| 1647 if (m_pContents) | 1647 void CPWL_Note::SetIconType(FX_INT32 nType) { |
| 1648 m_pContents->OnNotify(pWnd, msg, wParam, lParam); | 1648 if (m_pIcon) |
| 1649 return; | 1649 m_pIcon->SetIconType(nType); |
| 1650 case PNM_SETSCROLLPOS: | 1650 } |
| 1651 if (m_pContentsBar) | 1651 |
| 1652 m_pContentsBar->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lP
aram); | 1652 void CPWL_Note::EnableModify(FX_BOOL bEnabled) { |
| 1653 return; | 1653 m_pContents->EnableModify(bEnabled); |
| 1654 } | 1654 } |
| 1655 | 1655 |
| 1656 if (msg == PNM_SETCARETINFO && IsValid()) | 1656 void CPWL_Note::EnableRead(FX_BOOL bEnabled) { |
| 1657 { | 1657 m_pContents->EnableRead(bEnabled); |
| 1658 if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam) | 1658 } |
| 1659 { | 1659 |
| 1660 if (m_pContents) | 1660 CFX_WideString CPWL_Note::GetReplyString() const { |
| 1661 { | 1661 return m_sReplyString; |
| 1662 CPDF_Rect rcClient = m_pContents->GetClientRect(
); | 1662 } |
| 1663 if (pInfo->ptHead.y > rcClient.top) | 1663 |
| 1664 { | 1664 void CPWL_Note::SetReplyString(const CFX_WideString& string) { |
| 1665 CPDF_Point pt = m_pContents->OutToIn(pIn
fo->ptHead); | 1665 m_sReplyString = string; |
| 1666 m_pContents->OnNotify(this, PNM_SCROLLWI
NDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y); | 1666 } |
| 1667 | |
| 1668 CPDF_Point ptScroll = m_pContents->GetSc
rollPos(); | |
| 1669 m_pContentsBar->OnNotify(this, PNM_SETSC
ROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); | |
| 1670 | |
| 1671 return; | |
| 1672 } | |
| 1673 | |
| 1674 if (pInfo->ptFoot.y < rcClient.bottom) | |
| 1675 { | |
| 1676 CPDF_Point pt = m_pContents->OutToIn(pIn
fo->ptFoot); | |
| 1677 pt.y += rcClient.Height(); | |
| 1678 m_pContents->OnNotify(this, PNM_SCROLLWI
NDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y); | |
| 1679 | |
| 1680 CPDF_Point ptScroll = m_pContents->GetSc
rollPos(); | |
| 1681 m_pContentsBar->OnNotify(this, PNM_SETSC
ROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); | |
| 1682 | |
| 1683 return; | |
| 1684 } | |
| 1685 } | |
| 1686 } | |
| 1687 } | |
| 1688 | |
| 1689 CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam); | |
| 1690 } | |
| 1691 | |
| 1692 void CPWL_Note::SetBkColor(const CPWL_Color& color) | |
| 1693 { | |
| 1694 CPWL_NoteItem::SetBkColor(color); | |
| 1695 | |
| 1696 CPWL_Color sBK = color; | |
| 1697 CPWL_Color sTextColor; | |
| 1698 if (CPWL_Utils::IsBlackOrWhite(sBK)) | |
| 1699 sTextColor = PWL_DEFAULT_WHITECOLOR; | |
| 1700 else | |
| 1701 sTextColor = PWL_DEFAULT_BLACKCOLOR; | |
| 1702 | |
| 1703 if (m_pCloseBox) | |
| 1704 m_pCloseBox->SetTextColor(sTextColor); | |
| 1705 if (m_pAuthor) | |
| 1706 m_pAuthor->SetTextColor(sTextColor); | |
| 1707 if (m_pOptions) | |
| 1708 m_pOptions->SetTextColor(sTextColor); | |
| 1709 if (m_pLBBox) | |
| 1710 m_pLBBox->SetTextColor(sTextColor); | |
| 1711 if (m_pRBBox) | |
| 1712 m_pRBBox->SetTextColor(sTextColor); | |
| 1713 } | |
| 1714 | |
| 1715 FX_BOOL CPWL_Note::OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag) | |
| 1716 { | |
| 1717 if (m_pOptions->WndHitTest(m_pOptions->ParentToChild(point))) | |
| 1718 { | |
| 1719 if (IPWL_NoteNotify* pNotify = this->GetNoteNotify()) | |
| 1720 { | |
| 1721 FX_INT32 x, y; | |
| 1722 PWLtoWnd(point, x, y); | |
| 1723 if (IFX_SystemHandler* pSH = GetSystemHandler()) | |
| 1724 pSH->ClientToScreen(GetAttachedHWnd(), x, y); | |
| 1725 this->KillFocus(); | |
| 1726 pNotify->OnPopupMenu(x, y); | |
| 1727 | |
| 1728 return TRUE; | |
| 1729 } | |
| 1730 } | |
| 1731 | |
| 1732 return CPWL_Wnd::OnLButtonDown(point,nFlag); | |
| 1733 } | |
| 1734 | |
| 1735 FX_BOOL CPWL_Note::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag) | |
| 1736 { | |
| 1737 return CPWL_Wnd::OnRButtonUp(point,nFlag); | |
| 1738 } | |
| 1739 | |
| 1740 const CPWL_Note* CPWL_Note::GetNote() const | |
| 1741 { | |
| 1742 return this; | |
| 1743 } | |
| 1744 | |
| 1745 IPWL_NoteNotify* CPWL_Note::GetNoteNotify() const | |
| 1746 { | |
| 1747 if (m_bEnalbleNotify) | |
| 1748 return m_pNoteNotify; | |
| 1749 | |
| 1750 return NULL; | |
| 1751 } | |
| 1752 | |
| 1753 void CPWL_Note::SetIconType(FX_INT32 nType) | |
| 1754 { | |
| 1755 if (m_pIcon) | |
| 1756 m_pIcon->SetIconType(nType); | |
| 1757 } | |
| 1758 | |
| 1759 void CPWL_Note::EnableModify(FX_BOOL bEnabled) | |
| 1760 { | |
| 1761 m_pContents->EnableModify(bEnabled); | |
| 1762 } | |
| 1763 | |
| 1764 void CPWL_Note::EnableRead(FX_BOOL bEnabled) | |
| 1765 { | |
| 1766 m_pContents->EnableRead(bEnabled); | |
| 1767 } | |
| 1768 | |
| 1769 CFX_WideString CPWL_Note::GetReplyString() const | |
| 1770 { | |
| 1771 return m_sReplyString; | |
| 1772 } | |
| 1773 | |
| 1774 void CPWL_Note::SetReplyString(const CFX_WideString& string) | |
| 1775 { | |
| 1776 m_sReplyString = string; | |
| 1777 } | |
| 1778 | |
| OLD | NEW |