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