From f803922246cf1f4ceaf58f9e1b8d6e7690867a5a Mon Sep 17 00:00:00 2001 From: cmanske Date: Sat, 30 May 1998 23:05:39 +0000 Subject: [PATCH] Composer bug fixes and features (table editing, font size, color picker, etc) --- cmd/winfe/cfe.cpp | 12 + cmd/winfe/cxdc.cpp | 194 ++++++----- cmd/winfe/dialog.cpp | 30 +- cmd/winfe/eddialog.cpp | 72 ++++ cmd/winfe/eddialog.h | 85 +++++ cmd/winfe/edframe.cpp | 83 +++-- cmd/winfe/edframe.h | 4 - cmd/winfe/editor.rc | 27 +- cmd/winfe/edprops.cpp | 186 +++++++--- cmd/winfe/edprops.h | 18 +- cmd/winfe/edtable.cpp | 4 +- cmd/winfe/edtrcdll/src/edtrcdll.rc | 35 +- cmd/winfe/edtrcdll/src/resource.h | 5 + cmd/winfe/edview.cpp | 241 ++++++++----- cmd/winfe/edview.h | 51 +-- cmd/winfe/edview2.cpp | 535 +++++++++++++---------------- cmd/winfe/fegui.cpp | 17 + cmd/winfe/mozilla.rc | 4 +- cmd/winfe/res/edcolsiz.cur | Bin 326 -> 326 bytes cmd/winfe/res/editor.rc2 | 2 - cmd/winfe/res/edrowsiz.cur | Bin 326 -> 326 bytes cmd/winfe/resource.h | 29 +- cmd/winfe/sysinfo.cpp | 6 + cmd/winfe/template.cpp | 4 +- 24 files changed, 1017 insertions(+), 627 deletions(-) diff --git a/cmd/winfe/cfe.cpp b/cmd/winfe/cfe.cpp index 33d548e82eff..8775b484de24 100644 --- a/cmd/winfe/cfe.cpp +++ b/cmd/winfe/cfe.cpp @@ -1506,3 +1506,15 @@ extern "C" void FE_RunNetcaster(MWContext *context) { extern "C" MWContext *FE_IsNetcasterRunning(void) { return theApp.m_pNetcasterWindow; } + +#ifdef SHACK +void CFE_DisplayBuiltin(MWContext *context, int iLocation, LO_BuiltinStruct *builtin_struct) +{ + return; +} + +void CFE_FreeBuiltinElement(MWContext *context, LO_BuiltinStruct *builtin_struct) +{ + return; +} +#endif //SHACK \ No newline at end of file diff --git a/cmd/winfe/cxdc.cpp b/cmd/winfe/cxdc.cpp index 96f964beab27..dc476cb896a1 100644 --- a/cmd/winfe/cxdc.cpp +++ b/cmd/winfe/cxdc.cpp @@ -1659,83 +1659,82 @@ CDCCX::DisplayTableBorder(LTRB& Rect, LO_TableStruct *pTable) } else { + if (pTable->border_style == BORDER_GROOVE || pTable->border_style == BORDER_RIDGE || + pTable->border_style == BORDER_INSET || pTable->border_style == BORDER_OUTSET) { - if (pTable->border_style == BORDER_GROOVE || pTable->border_style == BORDER_RIDGE || - pTable->border_style == BORDER_INSET || pTable->border_style == BORDER_OUTSET) { + // Compute the 3D colors to use. If the border color is the same as the background + // color then just use the light/dark colors we've already computed + if (rgbBorder == m_rgbBackgroundColor) { + rgbLight = m_rgbLightColor; + rgbDark = m_rgbDarkColor; + + } else { + Compute3DColors(rgbBorder, rgbLight, rgbDark); + } + } - // Compute the 3D colors to use. If the border color is the same as the background - // color then just use the light/dark colors we've already computed - if (rgbBorder == m_rgbBackgroundColor) { - rgbLight = m_rgbLightColor; - rgbDark = m_rgbDarkColor; - - } else { - Compute3DColors(rgbBorder, rgbLight, rgbDark); - } - } + hDC = GetContextDC(); + switch (pTable->border_style) { + case BORDER_NONE: + break; - hDC = GetContextDC(); - switch (pTable->border_style) { - case BORDER_NONE: - break; + case BORDER_DOTTED: + case BORDER_DASHED: + case BORDER_SOLID: + // hDC = GetContextDC(); + DisplaySolidBorder(hDC, r, rgbBorder, borderWidths); + // ReleaseContextDC(hDC); + break; - case BORDER_DOTTED: - case BORDER_DASHED: - case BORDER_SOLID: -// hDC = GetContextDC(); - DisplaySolidBorder(hDC, r, rgbBorder, borderWidths); -// ReleaseContextDC(hDC); - break; + case BORDER_DOUBLE: + // hDC = GetContextDC(); + DisplayDoubleBorder(hDC, r, rgbBorder, borderWidths); + // ReleaseContextDC(hDC); + break; - case BORDER_DOUBLE: -// hDC = GetContextDC(); - DisplayDoubleBorder(hDC, r, rgbBorder, borderWidths); -// ReleaseContextDC(hDC); - break; + case BORDER_GROOVE: + // This is done as a sunken outer border with a raised inner + // border. Windows group boxes have this appearance + borderWidths.left /= 2; + borderWidths.top /= 2; + borderWidths.right /= 2; + borderWidths.bottom /= 2; + Display3DBorder(Rect, rgbDark, rgbLight, borderWidths); + insetRect.left = Rect.left + borderWidths.left; + insetRect.top = Rect.top + borderWidths.top; + insetRect.right = Rect.right - borderWidths.right; + insetRect.bottom = Rect.bottom - borderWidths.bottom; + Display3DBorder(insetRect, rgbLight, rgbDark, borderWidths); + break; - case BORDER_GROOVE: - // This is done as a sunken outer border with a raised inner - // border. Windows group boxes have this appearance - borderWidths.left /= 2; - borderWidths.top /= 2; - borderWidths.right /= 2; - borderWidths.bottom /= 2; - Display3DBorder(Rect, rgbDark, rgbLight, borderWidths); - insetRect.left = Rect.left + borderWidths.left; - insetRect.top = Rect.top + borderWidths.top; - insetRect.right = Rect.right - borderWidths.right; - insetRect.bottom = Rect.bottom - borderWidths.bottom; - Display3DBorder(insetRect, rgbLight, rgbDark, borderWidths); - break; + case BORDER_RIDGE: + // This is done as a raised outer border with a sunken inner border + borderWidths.left /= 2; + borderWidths.top /= 2; + borderWidths.right /= 2; + borderWidths.bottom /= 2; + Display3DBorder(Rect, rgbLight, rgbDark, borderWidths); + insetRect.left = Rect.left + borderWidths.left; + insetRect.top = Rect.top + borderWidths.top; + insetRect.right = Rect.right - borderWidths.right; + insetRect.bottom = Rect.bottom - borderWidths.bottom; + Display3DBorder(insetRect, rgbDark, rgbLight, borderWidths); + break; - case BORDER_RIDGE: - // This is done as a raised outer border with a sunken inner border - borderWidths.left /= 2; - borderWidths.top /= 2; - borderWidths.right /= 2; - borderWidths.bottom /= 2; - Display3DBorder(Rect, rgbLight, rgbDark, borderWidths); - insetRect.left = Rect.left + borderWidths.left; - insetRect.top = Rect.top + borderWidths.top; - insetRect.right = Rect.right - borderWidths.right; - insetRect.bottom = Rect.bottom - borderWidths.bottom; - Display3DBorder(insetRect, rgbDark, rgbLight, borderWidths); - break; + case BORDER_INSET: + // This is what Windows refers to as a sunken border + Display3DBorder(Rect, rgbDark, rgbLight, borderWidths); + break; - case BORDER_INSET: - // This is what Windows refers to as a sunken border - Display3DBorder(Rect, rgbDark, rgbLight, borderWidths); - break; + case BORDER_OUTSET: + // This is what Windows refers to as a raised border + Display3DBorder(Rect, rgbLight, rgbDark, borderWidths); + break; - case BORDER_OUTSET: - // This is what Windows refers to as a raised border - Display3DBorder(Rect, rgbLight, rgbDark, borderWidths); - break; - - default: - ASSERT(FALSE); - break; - } + default: + ASSERT(FALSE); + break; + } } return 0; } @@ -1752,11 +1751,9 @@ void CDCCX::EditorDisplayZeroWidthBorder(LTRB& Rect, BOOL bSelected){ // Use dotted line if not selected, or solid if selecting HPEN pPen = ::CreatePen(bSelected ? PS_SOLID : PS_DOT, 1, rgbColor); HPEN pOldPen = (HPEN)::SelectObject(hdc, pPen); - ::MoveToEx(hdc, CASTINT(Rect.left), CASTINT(Rect.top), NULL); - ::LineTo(hdc, CASTINT(Rect.right), CASTINT(Rect.top)); - ::LineTo(hdc, CASTINT(Rect.right), CASTINT(Rect.bottom)); - ::LineTo(hdc, CASTINT(Rect.left), CASTINT(Rect.bottom)); - ::LineTo(hdc, CASTINT(Rect.left), CASTINT(Rect.top)); + + ::Rectangle(hdc, Rect.left, Rect.top, Rect.right, Rect.bottom); + ::SelectObject(hdc, pOldPen); ReleaseContextDC(hdc); VERIFY(::DeleteObject(pPen)); @@ -3069,7 +3066,6 @@ void CDCCX::DisplaySubDoc(MWContext *pContext, int iLocation, LO_SubDocStruct *p void CDCCX::DisplayCell(MWContext *pContext, int iLocation, LO_CellStruct *pCell) { LTRB Rect; -// if(ResolveElement(Rect, pCell, iLocation) == TRUE) { if(ResolveElement(Rect, pCell->x, pCell->y, pCell->x_offset, pCell->y_offset, pCell->width, pCell->height) == TRUE) { SafeSixteen(Rect); @@ -3101,9 +3097,14 @@ void CDCCX::DisplayCell(MWContext *pContext, int iLocation, LO_CellStruct *pCell // If we decide to allow nested table cells to have the // background show through then we need this code #endif /* LAYERS */ + #ifdef EDITOR if( EDT_IS_EDITOR(pContext) ) { + if( pCell->border_width == 0 || LO_IsEmptyCell(pCell) ) + { + EraseToBackground(Rect); + } int32 iExtraSpace = 0; int32 iBorder = pCell->border_width; // Cell highlightin is thicker @@ -3120,25 +3121,26 @@ void CDCCX::DisplayCell(MWContext *pContext, int iLocation, LO_CellStruct *pCell hDC = GetContextDC(); RECT r; ::SetRect(&r, CASTINT(Rect.left), CASTINT(Rect.top), CASTINT(Rect.right), CASTINT(Rect.bottom)); + if( iBorder > 0 ) + { + // If there is inter-cell spacing, + // draw selection in that region as much as possible + if( pCell->inter_cell_space > 0 && iBorder < iMaxWidth ) + { + iExtraSpace = min(iMaxWidth - iBorder, pCell->inter_cell_space / 2); + iBorder += iExtraSpace; + ::InflateRect(&r, iExtraSpace, iExtraSpace); + } + LTRB borderWidths(iBorder, iBorder, iBorder, iBorder); - // If there is inter-cell spacing and - // draw selection in that region as much as possible - if( pCell->inter_cell_space > 0 && iBorder < iMaxWidth ) - { - iExtraSpace = min(iMaxWidth - iBorder, pCell->inter_cell_space / 2); - iBorder += iExtraSpace; - ::InflateRect(&r, iExtraSpace, iExtraSpace); - } - - LTRB borderWidths(iBorder, iBorder, iBorder, iBorder); - - if( bSelectedSpecial ) - { - // Show a solid DASHED border as the special selection feedback - DisplaySpecialBorder(hDC, r, rgbBorder, iBorder, TRUE); - } else { - // Show a solid border as the selection feedback - DisplaySolidBorder(hDC, r, rgbBorder, borderWidths); + if( bSelectedSpecial ) + { + // Show a solid DASHED border as the special selection feedback + DisplaySpecialBorder(hDC, r, rgbBorder, iBorder, TRUE); + } else { + // Show a solid border as the selection feedback + DisplaySolidBorder(hDC, r, rgbBorder, borderWidths); + } } } @@ -3148,7 +3150,7 @@ void CDCCX::DisplayCell(MWContext *pContext, int iLocation, LO_CellStruct *pCell // (Navigator will not display borders of empty cells) // Don't bother testing (EDT_DISPLAY_TABLE_BORDERS) // since we don't support turning borders off now - EditorDisplayZeroWidthBorder(Rect, pCell->ele_attrmask & LO_ELE_SELECTED); + EditorDisplayZeroWidthBorder(Rect, bSelected | bSelectedSpecial ); } else if( !bSelected ) @@ -3167,13 +3169,15 @@ void CDCCX::DisplayCell(MWContext *pContext, int iLocation, LO_CellStruct *pCell LTRB CellRect = Rect; // Draw inside the border rect CellRect.Inflate(-1); + if( bSelectedSpecial ) { RECT r; ::SetRect(&r, CASTINT(CellRect.left), CASTINT(CellRect.top), CASTINT(CellRect.right), CASTINT(CellRect.bottom)); - // Show an inverted DASHED border as the special selection feedback - DisplaySpecialBorder(hDC, r, rgbBorder, iBorder, FALSE); + + // Show an inverted DASHED border as the special selection feedback + DisplaySpecialBorder(hDC, r, rgbBorder, ED_SELECTION_BORDER, FALSE); } else { DisplaySelectionFeedback(LO_ELE_SELECTED, CellRect); } diff --git a/cmd/winfe/dialog.cpp b/cmd/winfe/dialog.cpp index 91ba33d37908..16d2d88ba450 100755 --- a/cmd/winfe/dialog.cpp +++ b/cmd/winfe/dialog.cpp @@ -125,17 +125,41 @@ void CDialogURL::OnOK() #endif // this was typed in so no referrer -> OK to do an OnNormalLoad - if(!url_string.IsEmpty()) { + if(!url_string.IsEmpty()) + { + // Bug 36087: Convert relative URL strings to an absolute URL based on current location + char *pAbsoluteURL = (char *)LPCSTR(url_string); + + int iType = NET_URL_Type(pAbsoluteURL); + + CString csTemp; + if( iType == 0 ) + { + WFE_ConvertFile2Url( csTemp, pAbsoluteURL ); + pAbsoluteURL = (char*)LPCSTR(csTemp); + } + + BOOL bFreeString = FALSE; + BOOL bIsFile = NET_IsLocalFileURL(pAbsoluteURL); + + History_entry * pEntry = SHIST_GetCurrent(&m_Context->hist); + if( pEntry && pEntry->address ) { + pAbsoluteURL = NET_MakeAbsoluteURL(pEntry->address, pAbsoluteURL ); + bFreeString = TRUE; + } #ifdef EDITOR BOOL bEdit = ((CButton *)GetDlgItem(IDC_OPEN_URL_EDITOR))->GetCheck() != 0; if (bEdit || EDT_IS_EDITOR(m_Context)) { - FE_LoadUrl((char*)LPCSTR(url_string), bEdit); + FE_LoadUrl(/*pAbsoluteURL*/(char *)LPCSTR(url_string), bEdit); } else #endif // Load the URL into the same window only if called from an existing browser - ABSTRACTCX(m_Context)->NormalGetUrl(url_string); + ABSTRACTCX(m_Context)->NormalGetUrl(/*pAbsoluteURL*/ url_string); + + if( pAbsoluteURL && bFreeString ) + XP_FREE(pAbsoluteURL); } } diff --git a/cmd/winfe/eddialog.cpp b/cmd/winfe/eddialog.cpp index 08ad947ddfbc..ace134adbff6 100644 --- a/cmd/winfe/eddialog.cpp +++ b/cmd/winfe/eddialog.cpp @@ -1422,3 +1422,75 @@ void CPageTitleDlg::OnOK() *m_ppTitle = XP_STRDUP(LPCSTR(m_csTitle)); } } + +CPasteSpecialDlg::CPasteSpecialDlg(CWnd* pParent) + : CDialog(CPasteSpecialDlg::IDD, pParent), + m_iResult(0) +{ +} + +BEGIN_MESSAGE_MAP(CPasteSpecialDlg, CDialog) + //{{AFX_MSG_MAP(CPasteSpecialDlg) + ON_BN_CLICKED(IDC_PASTE_TEXT, OnPasteText) + ON_BN_CLICKED(IDC_PASTE_IMAGE, OnPasteImage) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +BOOL CPasteSpecialDlg::OnInitDialog() +{ + m_ResourceSwitcher.Reset(); + CDialog::OnInitDialog(); + return TRUE; +} + +void CPasteSpecialDlg::OnPasteImage() +{ + m_iResult = ED_PASTE_IMAGE; + CDialog::OnOK(); +} + +void CPasteSpecialDlg::OnPasteText() +{ + m_iResult = ED_PASTE_TEXT; + CDialog::OnOK(); +} + +///////////////////////////////////////////////////////////////////////////// +// CGetColumnsDlg dialog + +CGetColumnsDlg::CGetColumnsDlg(CWnd* pParent) + : CDialog(CGetColumnsDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CEditHintDlg) + m_iColumns = 1; + //}}AFX_DATA_INIT +} + +BEGIN_MESSAGE_MAP(CGetColumnsDlg, CDialog) + //{{AFX_MSG_MAP(CGetColumnsDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +BOOL CGetColumnsDlg::OnInitDialog() +{ + m_ResourceSwitcher.Reset(); + CDialog::OnInitDialog(); + return TRUE; +} + +void CGetColumnsDlg::OnOK() +{ + // TODO: Add extra validation here + + CDialog::OnOK(); +} + +void CGetColumnsDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CGetColumnsDlg) + DDX_Text(pDX, IDC_TABLE_COLUMNS, m_iColumns); + DDV_MinMaxInt(pDX, m_iColumns, 1, 100 /*MAX_TABLE_COLUMNS*/); + //}}AFX_DATA_MAP +} + diff --git a/cmd/winfe/eddialog.h b/cmd/winfe/eddialog.h index f0ff62e25aa3..41223f93b684 100644 --- a/cmd/winfe/eddialog.h +++ b/cmd/winfe/eddialog.h @@ -480,4 +480,89 @@ protected: DECLARE_MESSAGE_MAP() }; +// CPasteSpecialDlg::m_iResult values +enum { + ED_PASTE_CANCEL, + ED_PASTE_TEXT, + ED_PASTE_IMAGE +}; + +///////////////////////////////////////////////////////////////////////////// +// CPasteSpecialDlg dialog +// Called for user feedback when saving remote images +// +class CPasteSpecialDlg : public CDialog +{ +// Construction +public: + CPasteSpecialDlg(CWnd* pParent); + + // Put user's choice here + int m_iResult; + +// Dialog Data + //{{AFX_DATA(CSaveFileOverwriteDlg) + enum { IDD = IDD_PASTE_SPECIAL }; + //}}AFX_DATA + +private: + // This will change resource hInstance to Editor dll (in constructor) + CEditorResourceSwitcher m_ResourceSwitcher; + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSaveFileOverwriteDlg) + afx_msg void OnPasteText(); + afx_msg void OnPasteImage(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// +// CGetColumnsDlg dialog + +class CGetColumnsDlg : public CDialog +{ +// Construction +public: + CGetColumnsDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CGetColumnsDlg) + enum { IDD = IDD_GET_TABLE_COLUMNS }; + int m_iColumns; + //}}AFX_DATA + + int GetColumns() { return m_iColumns; } + +private: + + // This will change resource hInstance to Editor dll (in constructor) + // Be sure to call m_ResourceSwitcher.Reset() + // in InitDialog() or OnSetActive() if dialog accesses strings + // in NETSCAPE.EXE + CEditorResourceSwitcher m_ResourceSwitcher; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGetColumnsDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CGetColumnsDlg) + virtual void OnOK(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +}; + #endif // EDDIALOG_H diff --git a/cmd/winfe/edframe.cpp b/cmd/winfe/edframe.cpp index d487b655de94..9927889b24d0 100644 --- a/cmd/winfe/edframe.cpp +++ b/cmd/winfe/edframe.cpp @@ -263,7 +263,9 @@ void WFE_InitComposer() PREF_RegisterCallback("editor.author", ed_prefWatcher, (void*)3); wfe_pFont = new CFont(); - if( wfe_pFont ){ + wfe_pBoldFont = new CFont(); + + if( wfe_pFont && wfe_pBoldFont ){ if( GetSystemMetrics(SM_DBCSENABLED) ){ HFONT hFont = NULL; @@ -274,7 +276,7 @@ void WFE_InitComposer() hFont = (HFONT)GetStockObject(SYSTEM_FONT); } wfe_pFont->Attach(hFont); - + wfe_pBoldFont->Attach(hFont); } else { // Get a 1-pixel font LOGFONT logFont; @@ -293,6 +295,12 @@ void WFE_InitComposer() delete wfe_pFont; wfe_pFont = NULL; } + + logFont.lfWeight = FW_BOLD; + if( !wfe_pBoldFont->CreateFontIndirect(&logFont) ){ + delete wfe_pBoldFont; + wfe_pBoldFont = NULL; + } } } @@ -328,6 +336,16 @@ void WFE_InitComposer() wfe_crLastColorPicked = 0; } + PREF_CopyCharPref("editor.last_background_color_picked", &pCustomColor); + if( pCustomColor ) + { + EDT_ParseColorString(&LoColor, pCustomColor); + wfe_crLastBkgrndColorPicked = RGB(LoColor.red, LoColor.green, LoColor.blue); + XP_FREEIF(pCustomColor); + } else { + wfe_crLastBkgrndColorPicked = RGB(255, 255, 255); + } + // Fill color table with 0s memset((void*)wfe_CustomPalette, 0, 16*sizeof(COLORREF)); @@ -351,6 +369,9 @@ void WFE_ExitComposer() if( wfe_pFont ){ delete wfe_pFont; } + if( wfe_pBoldFont ){ + delete wfe_pBoldFont; + } XP_FREEIF(ed_pOther); XP_FREEIF(ed_pMixedFonts); XP_FREEIF(ed_pDontChange); @@ -476,6 +497,7 @@ BOOL CEditToolBarController::CreateEditBars(MWContext *pMWContext, unsigned ett) } } } + // String used to get width of FontSize combobox csTemp = "55"; cSize = CIntlWin::GetTextExtent(wincsid, pDC->GetSafeHdc(), csTemp, csTemp.GetLength()); pDC->LPtoDP(&cSize); @@ -561,7 +583,9 @@ BOOL CEditToolBarController::CreateEditBars(MWContext *pMWContext, unsigned ett) m_wndCharacterBar.RecalcLayout(); #endif } - + + int nLastID = ID_EDIT_LAST_ID; + ASSERT(nLastID < 42000); return TRUE; } @@ -663,7 +687,6 @@ CEditFrame::CEditFrame() m_pToolBarController = new CEditToolBarController( this ); m_hPal = NULL; m_pTemplateContext = NULL; - m_bImportTextFile = FALSE; } CEditFrame::~CEditFrame() @@ -1263,18 +1286,6 @@ void FE_EditorGetUrlExitRoutine(URL_Struct *pUrlStruct, int iStatus, MWContext * FE_RevertToPreviousFrame(pAddress, pMWContext); theApp.m_nChangeHomePage = iTemp; } - } else { - // Set flag that we are importing a text file so we treat it - // like a template file - // (But Message composition should do the template stuff -- - // We end up here with a MWContextMessageComposition type - // when replying to a mail message.) - if( pUrlStruct && pUrlStruct->content_type && - pMWContext->type == MWContextBrowser && - 0 == strcmpi(pUrlStruct->content_type, INTERNAL_PARSER) ) - { - pFrame->m_bImportTextFile = TRUE; - } } } @@ -1325,18 +1336,16 @@ void FE_EditorDocumentLoaded(MWContext* pMWContext) wfe_pLastFrame->PostMessage(WM_CLOSE); } - if( pFrame->m_bImportTextFile || pMWContext == pFrame->m_pTemplateContext ) + if( pMWContext == pFrame->m_pTemplateContext ) { // We loaded a URL (template or text file) // that we want to convert to a new doc - // If it is a template file, save in history - if( pMWContext == pFrame->m_pTemplateContext ) - pFrame->SaveTemplateLocation(hist_ent->address); + // Save in history + pFrame->SaveTemplateLocation(hist_ent->address); EDT_ConvertCurrentDocToNewDoc(pMWContext); pFrame->m_pTemplateContext = NULL; - pFrame->m_bImportTextFile = FALSE; } // This is really needed only for Win16 -- to set initial focus, @@ -2167,11 +2176,15 @@ void CGenericFrame::OnMenuSelectComposer(UINT nItemID, UINT nFlags, HMENU hSysMe if( bInTableMenu ) return; bInTableMenu = TRUE; + // Show "Convert table to text" when table is selected or + // caret is inside table with nothing selected + BOOL bConvertToText = EDT_IsTableSelected(pMWContext) || + (EDT_IsInsertPointInTable(pMWContext) && + !EDT_IsSelected(pMWContext) && + EDT_GetSelectedCellCount(pMWContext) == 0); - //TODO: Enable/Disable items appropriate only when inside a table - BOOL bInTable = EDT_IsInsertPointInTable(pMWContext); ::ModifyMenu(hSubMenu, ID_TABLE_TEXT_CONVERT, MF_BYCOMMAND | MF_STRING, ID_TABLE_TEXT_CONVERT, - szLoadString(bInTable ? IDS_CONVERT_TABLE_TO_TEXT : IDS_CONVERT_TEXT_TO_TABLE) ); + szLoadString(bConvertToText ? IDS_CONVERT_TABLE_TO_TEXT : IDS_CONVERT_TEXT_TO_TABLE) ); // We can return here ONLY if we don't need to look at menus after "Table" break; } @@ -2275,12 +2288,24 @@ void CGenericFrame::OnMenuSelectComposer(UINT nItemID, UINT nFlags, HMENU hSysMe if( bInSizeMenu ) return; bInSizeMenu = TRUE; - - // Delete any existing items - for( i = ::GetMenuItemCount(hSizeMenu) - 1; i >= 0; i--) + int iCount = ::GetMenuItemCount(hSizeMenu); + if( iCount == 1 ) + { + // Initial menu has 1 placeholder - modify that + // and append the rest + // First 2 menu items are relative size change + ::ModifyMenu( hSizeMenu, 0, MF_BYPOSITION | MF_STRING, ID_FORMAT_INCREASE_FONTSIZE, + szLoadString(IDS_INCREASE_FONTSIZE) ); + ::AppendMenu( hSizeMenu, MF_STRING, ID_FORMAT_DECREASE_FONTSIZE, + szLoadString(IDS_DECREASE_FONTSIZE) ); + ::AppendMenu( hSizeMenu, MF_SEPARATOR, 0, 0); + } + // Delete any existing items except for 1st three + for( i = iCount - 1; i > 2; i--) { DeleteMenu(hSizeMenu, i, MF_BYPOSITION); } + // Check if current base font is fixed width BOOL bFixedWidth = (EDT_GetFontFaceIndex(pMWContext) == 1); // Change font size strings based on current font base @@ -2293,7 +2318,9 @@ void CGenericFrame::OnMenuSelectComposer(UINT nItemID, UINT nFlags, HMENU hSysMe { // The "Advanced" absolute point size strings ::AppendMenu( hSizeMenu, MF_SEPARATOR, 0, 0); - ::AppendMenu( hSizeMenu, MF_STRING, ID_FORMAT_POINTSIZE_BASE, "8"); + // This string is "8 pts" so it must be translated + ::AppendMenu( hSizeMenu, MF_STRING, ID_FORMAT_POINTSIZE_BASE, szLoadString(IDS_8_PTS)); + // Others assume pure numbers don't have to be translated ::AppendMenu( hSizeMenu, MF_STRING, ID_FORMAT_POINTSIZE_BASE+1, "9"); ::AppendMenu( hSizeMenu, MF_STRING, ID_FORMAT_POINTSIZE_BASE+2, "10"); ::AppendMenu( hSizeMenu, MF_STRING, ID_FORMAT_POINTSIZE_BASE+3, "11"); diff --git a/cmd/winfe/edframe.h b/cmd/winfe/edframe.h index 43be1192ace2..16173d009049 100644 --- a/cmd/winfe/edframe.h +++ b/cmd/winfe/edframe.h @@ -112,10 +112,6 @@ public: // we want to convert to a new doc // Signals appropriate action in FE_EditorGetUrlExitRoutine() MWContext * m_pTemplateContext; - // Set this to trigger importing a text file just like - // we handle a template file - change it to an Untitled new doc - // to prevent overwriting original file - BOOL m_bImportTextFile; private: // Save original state of browser toolbars diff --git a/cmd/winfe/editor.rc b/cmd/winfe/editor.rc index 123236329f04..859873636f9b 100644 --- a/cmd/winfe/editor.rc +++ b/cmd/winfe/editor.rc @@ -121,7 +121,7 @@ IDB_FILE_PICT_TOOLBAR BITMAP DISCARDABLE "res\\editbar.bmp" IDR_COMPOSEFRAME ACCELERATORS DISCARDABLE BEGIN - 27, ID_FORMAT_DECREASE_FONTSIZE, ASCII, NOINVERT +// 27, ID_FORMAT_DECREASE_FONTSIZE, ASCII, NOINVERT 29, ID_FORMAT_INCREASE_FONTSIZE, ASCII, NOINVERT "1", ID_TOOLS_WEB, VIRTKEY, CONTROL, NOINVERT "1", ID_TOOLS_MAIL, VIRTKEY, SHIFT, CONTROL, @@ -176,6 +176,7 @@ BEGIN VK_APPS, ID_LOCAL_POPUP, VIRTKEY, NOINVERT VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT VK_F10, ID_LOCAL_POPUP, VIRTKEY, SHIFT, NOINVERT + VK_F1, ID_COMMAND_HELPINDEX, VIRTKEY, NOINVERT VK_F2, ID_LOCATION_FOCUS, VIRTKEY, NOINVERT VK_F3, ID_EDIT_FINDAGAIN, VIRTKEY, NOINVERT VK_F6, ID_NEXT_WINDOW, VIRTKEY, NOINVERT @@ -196,7 +197,7 @@ END IDR_EDITFRAME ACCELERATORS PRELOAD MOVEABLE PURE BEGIN - 27, ID_FORMAT_DECREASE_FONTSIZE, ASCII, NOINVERT +// 27, ID_FORMAT_DECREASE_FONTSIZE, ASCII, NOINVERT 29, ID_FORMAT_INCREASE_FONTSIZE, ASCII, NOINVERT "1", ID_TOOLS_WEB, VIRTKEY, CONTROL, NOINVERT "1", ID_TOOLS_MAIL, VIRTKEY, SHIFT, CONTROL, @@ -248,6 +249,7 @@ BEGIN "U", ID_FORMAT_CHAR_UNDERLINE, VIRTKEY, CONTROL, NOINVERT VK_APPS, ID_LOCAL_POPUP, VIRTKEY, NOINVERT VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT, NOINVERT + VK_F1, ID_COMMAND_HELPINDEX, VIRTKEY, NOINVERT VK_F10, ID_LOCAL_POPUP, VIRTKEY, SHIFT, NOINVERT VK_F2, ID_LOCATION_FOCUS, VIRTKEY, NOINVERT VK_F3, ID_EDIT_FINDAGAIN, VIRTKEY, NOINVERT @@ -849,12 +851,21 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_DEFAULT_BKGRND_COLOR "Browser preference color" - IDS_CUSTOM_COLORS_LABEL "Quick Palette:" - IDS_LAST_USED_COLOR "Last-picked color" - IDS_OTHER "Other..." - IDS_OTHER_BUTTON "&Other..." - IDS_DEFAULT_BUTTON "&Browser default" + IDS_DEFAULT_BKGRND_COLOR "Browser preference color" + IDS_CUSTOM_COLORS_LABEL "Quick Palette:" + IDS_TEXT_COLOR "Text Color" + IDS_PAGE_BACKGROUND "Page Background Color" + IDS_TABLE_BACKGROUND "Table Background Color" + IDS_CELL_BACKGROUND "Cell Background Color" + IDS_LAST_USED_COLOR "Last-picked color" + IDS_OTHER "Other..." + IDS_OTHER_BUTTON "&Other..." + IDS_DEFAULT_BUTTON "&Browser default" + IDS_INCREASE_FONTSIZE "&Increase\tCtrl+]" + IDS_DECREASE_FONTSIZE "&Decrease\tCtrl+[" + ID_FORMAT_INCREASE_FONTSIZE "Increase font size 1 unit\nIncrease font size" + ID_FORMAT_DECREASE_FONTSIZE "Decrease font size 1 unit\nDecrease font size" + IDS_8_PTS "8 pts" END #endif // English (U.S.) resources diff --git a/cmd/winfe/edprops.cpp b/cmd/winfe/edprops.cpp index 07d21264acac..7cecade4ffc1 100644 --- a/cmd/winfe/edprops.cpp +++ b/cmd/winfe/edprops.cpp @@ -55,6 +55,8 @@ static char BASED_CODE THIS_FILE[] = __FILE__; // Font shared by all comboboxes in dialogs and toolbars // Should be 1-pixel, 8pt MS Sans Serif or default GUI or font on foreign systems CFont * wfe_pFont = 0; +// BOLD version of above font +CFont * wfe_pBoldFont = 0; int wfe_iFontHeight = 15; // Full Height of the this font // Modification of wfe_iFontHeight for list boxes; @@ -79,7 +81,9 @@ int32 wfe_iFontSizeMode = ED_FONTSIZE_POINTS; // Array of colors to show in common color dialog COLORREF wfe_CustomPalette[16]; +// Colors saved in prefs - the last-picked text and background COLORREF wfe_crLastColorPicked; +COLORREF wfe_crLastBkgrndColorPicked; int wfe_iTrueTypeFontBase = 0; int wfe_iTrueTypeFontCount = 0; @@ -261,7 +265,9 @@ int wfe_FillFontSizeCombo(MWContext *pMWContext, CNSComboBox * pCombo, BOOL bFix if( wfe_iFontSizeMode == ED_FONTSIZE_ADVANCED ){ // "_" will signal combobox to draw a separator under this pCombo->AddString("_+4"); - pCombo->AddString("8"); + // This is "8 pts" so we must allow translating string + // (others assume all languages can use ascii numbers) + pCombo->AddString(szLoadString(IDS_8_PTS)); pCombo->AddString("9"); pCombo->AddString("10"); pCombo->AddString("11"); @@ -314,7 +320,7 @@ char * wfe_GetFontSizeString(MWContext * pMWContext, int iSize, BOOL bFixedWidth wsprintf(wfe_pFontSizeList[iSize-1], LPCSTR(csFormat), abs(iRelative)); } else { - // Contstruct strings for Point sizes + // Construct strings for Point sizes CDCCX *pDC = VOID2CX(pMWContext->fe.cx, CDCCX); EncodingInfo *pEncoding = theApp.m_pIntlFont->GetEncodingInfo(pMWContext); @@ -583,17 +589,21 @@ int CNSComboBox::FindSelectedOrSetText(char * pText, int iStartAt) break; } } - if( iSel == -1 ){ - // Text is not in the list - XP_FREEIF(m_pNotInListText); - m_pNotInListText = XP_STRDUP(pText); - } - SetCurSel(iSel); - // SetCurSel doesn't display text! - SetWindowText(pText); - } else { - SetWindowText(""); } + if( iSel == -1 ){ + // Text is not in the list + XP_FREEIF(m_pNotInListText); + m_pNotInListText = XP_STRDUP(pText ? pText : " "); + SetWindowText(m_pNotInListText); + } + else { + SetWindowText(pText); + } + // This must be AFTER the SetWindowText() + // so our setting it to -1 triggers display + // of m_pNotInListText in the closed combobox + SetCurSel(iSel); + return iSel; } @@ -975,13 +985,17 @@ int CColorComboBox::SetColor(COLORREF cr) #define COLOR_ROWS 7 #define COLOR_COLS 10 +// NOTE: This is same as the wfe_iFontHeight found for +// our 8-pt Sans Serif font (wfe_pFont) +// This might be a problem for some Asian fonts if they are taller? #define COLOR_SWATCH_HEIGHT 16 #define COLOR_SWATCH_WIDTH 18 #define COLOR_SWATCH_SPACING 0 -#define COLOR_SWATCH_TOP (COLOR_SWATCH_HEIGHT + 4) -#define COLOR_PICKER_HEIGHT (((COLOR_ROWS + 6)*COLOR_SWATCH_HEIGHT) + 26) -#define COLOR_PICKER_WIDTH (COLOR_COLS*COLOR_SWATCH_WIDTH + 7) -#define BUTTON_WIDTH (4*COLOR_SWATCH_WIDTH - 4) +#define MAIN_COLORS_TOP (2*COLOR_SWATCH_HEIGHT + 4) +#define LAST_COLOR_TOP (COLOR_SWATCH_HEIGHT + 4) +#define COLOR_PICKER_HEIGHT (((COLOR_ROWS + 7)*COLOR_SWATCH_HEIGHT) + 26) +#define COLOR_PICKER_WIDTH (COLOR_COLS*COLOR_SWATCH_WIDTH + 7) +#define BUTTON_WIDTH (4*COLOR_SWATCH_WIDTH - 4) // Index to the first USER custom color, which follows the Netscape colors // (first custom color, the "last-used" is actually 0 in color array) @@ -1015,6 +1029,10 @@ CColorPicker::CColorPicker(CWnd * pParent, m_bMouseDown(FALSE), m_crDragColor(0) { + // Caption choices are: "Text Color", + // or "[Page | Table | Cell] Background" + m_bBackground = (nIDCaption != IDS_TEXT_COLOR); + POINT ptOrigin; if( pCallerRect ) @@ -1039,7 +1057,6 @@ CColorPicker::CColorPicker(CWnd * pParent, m_crCurrentColor = bCust ? tmpColor : defColor; } else if( crDefColor == BACKGROUND_COLORREF ) { - // Get current page's background color // as "default" for table backgrounds CDCCX *pDC = VOID2CX(pMWContext->fe.cx, CDCCX); @@ -1116,8 +1133,14 @@ CColorPicker::CColorPicker(CWnd * pParent, if( i > 0 && i <= MAX_NS_COLORS ) // in main color grid { + // Reset to first column + if( i == 1 ) + { + iCol = 0; + } + // Set top to be used for all colors in main region - iTop = COLOR_SWATCH_TOP; + iTop = MAIN_COLORS_TOP; EDT_GetNSColor(i-1, &LoColor); m_crColors[i] = RGB(LoColor.red, LoColor.green, LoColor.blue); } @@ -1125,16 +1148,23 @@ CColorPicker::CColorPicker(CWnd * pParent, { if( i == 0 ) { - // The very first Custom color is actually the "last-used" color - m_crColors[i] = wfe_crLastColorPicked; + // The first swatch is the "last-picked" color + if( m_bBackground ) + m_crColors[i] = wfe_crLastBkgrndColorPicked; + else + m_crColors[i] = wfe_crLastColorPicked; + // "Last-picked color" at left margin, below caption area pLabel = szLoadString(IDS_LAST_USED_COLOR); - rectLabel.top = iTop + 1; + rectLabel.top = LAST_COLOR_TOP+2; rectLabel.left = COLOR_SWATCH_WIDTH + 2; rectLabel.right = COLOR_PICKER_WIDTH; rectLabel. bottom = rectLabel.top + COLOR_SWATCH_HEIGHT; if( !m_LastUsedLabel.Create(pLabel, WS_VISIBLE | WS_CHILD, rectLabel, this) ) return; + + // Set the top of the color swatch + iTop = LAST_COLOR_TOP; } else if( i == MAX_NS_COLORS+1 ) // Should = FIRST_CUSTOM_COLOR_INDEX-1 { @@ -1144,7 +1174,7 @@ CColorPicker::CColorPicker(CWnd * pParent, // Set text label next to this color swatch pLabel = szLoadString(IDS_CURRENT_COLOR); - iTop = COLOR_SWATCH_TOP + (COLOR_ROWS * COLOR_SWATCH_HEIGHT) + 2; + iTop = MAIN_COLORS_TOP + (COLOR_ROWS * COLOR_SWATCH_HEIGHT) + 2; rectLabel.top = iTop + 1; rectLabel.left = COLOR_SWATCH_WIDTH + 2; rectLabel.right = COLOR_PICKER_WIDTH - 6 - BUTTON_WIDTH; @@ -1282,13 +1312,10 @@ CColorPicker::CColorPicker(CWnd * pParent, m_HelpButton.Create(szLoadString(IDS_HELP_BUTTON), BS_PUSHBUTTON|WS_CHILD|WS_VISIBLE|WS_GROUP|WS_TABSTOP, rect, this, IDC_COLOR_HELP); - - // Set this so color doesn't change if no interaction? - m_crColor = WFE_GetCurrentFontColor(m_pMWContext); - // Set our font for all static strings used if( wfe_pFont ) { + // Set the font to our usual 8-pt font m_OtherButton.SetFont(wfe_pFont); m_HelpButton.SetFont(wfe_pFont); @@ -1314,8 +1341,49 @@ CColorPicker::CColorPicker(CWnd * pParent, // Capture mouse so we can detect clicking off the dialog SetCapture(); - // Restore active caption highlighting to parent frame - GetParentFrame()->SetActiveWindow(); + + // Snap focus to the first button + // Needed to allow Esc key to work + // after click down/up on the control that launched us + m_pColorButtons[0]->SetFocus(); + m_crColor = m_crColors[0]; + + // Initialize the array of flags for Quick Palette + for ( i = 0; i < MAX_CUSTOM_COLORS; i++ ) + m_bColorChanged[i] = FALSE; +} + +void CColorPicker::OnPaint() +{ + CPaintDC dc(this); + + // Draw the caption text + int iRight = COLOR_PICKER_WIDTH-8; + CRect cRect(2,2,iRight-1, COLOR_SWATCH_HEIGHT); + dc.SetBkMode(TRANSPARENT); + dc.SetTextColor(sysInfo.m_clrBtnText); + CFont *pOldFont = dc.SelectObject(wfe_pFont); + CString cString(szLoadString(m_nIDCaption)); + dc.DrawText(cString, cRect, DT_CENTER); + dc.SelectObject(pOldFont); + + // Draw a depressed rect around caption + +// This doesn't draw very well - it uses right-1 and bottom-1, +// and the lower-left corner doesn't look good +// WFE_DrawHighlight( dc.m_hDC, LPRECT(cRect), sysInfo.m_clrBtnShadow, sysInfo.m_clrBtnHilite ); + + CPen cPenShadow(PS_SOLID, 1, sysInfo.m_clrBtnShadow); + CPen cPenHilite(PS_SOLID, 1, sysInfo.m_clrBtnHilite); + CPen *pPenOld = (CPen*)dc.SelectObject(&cPenShadow); + int iBottom = COLOR_SWATCH_HEIGHT+ (wfe_iFontHeight > 16 ? 2: 1); + dc.MoveTo(1,iBottom); + dc.LineTo(1,1); + dc.LineTo(iRight,1); + dc.SelectObject(&cPenHilite); + dc.LineTo(iRight,iBottom); + dc.LineTo(1,iBottom); + dc.SelectObject(pPenOld); } COLORREF crReturnColor; @@ -1367,9 +1435,15 @@ void CColorPicker::PostNcDestroy() char pPref[32]; char pColorString[32]; - // Save the last-picked color - wsprintf(pColorString, "%d,%d,%d", GetRValue(wfe_crLastColorPicked), GetGValue(wfe_crLastColorPicked), GetBValue(wfe_crLastColorPicked)); - PREF_SetCharPref("editor.last_color_picked", pColorString); + // Save the last-picked color to appropriate pref + if( m_bBackground ) + { + wsprintf(pColorString, "%d,%d,%d", GetRValue(wfe_crLastBkgrndColorPicked), GetGValue(wfe_crLastBkgrndColorPicked), GetBValue(wfe_crLastBkgrndColorPicked)); + PREF_SetCharPref("editor.last_background_color_picked", pColorString); + } else { + wsprintf(pColorString, "%d,%d,%d", GetRValue(wfe_crLastColorPicked), GetGValue(wfe_crLastColorPicked), GetBValue(wfe_crLastColorPicked)); + PREF_SetCharPref("editor.last_color_picked", pColorString); + } // Save custom colors back to prefs for ( int i = 0; i < MAX_CUSTOM_COLORS; i++ ) @@ -1396,6 +1470,7 @@ BEGIN_MESSAGE_MAP(CColorPicker, CWnd) ON_WM_LBUTTONUP() ON_WM_LBUTTONDOWN() ON_WM_MOUSEMOVE() + ON_WM_PAINT() //}}AFX_MSG_MAP #ifdef XP_WIN32 ON_NOTIFY_EX( TTN_NEEDTEXT, 0, OnToolTipNotify ) @@ -1414,6 +1489,10 @@ BOOL CColorPicker::PreTranslateMessage(MSG* pMsg) { CancelAndExit(); } + else if( pMsg->wParam == VK_RETURN ) + { + SetColorAndExit(); + } else if( pMsg->wParam == VK_F1 ) { OnColorHelp(); @@ -1508,8 +1587,9 @@ void CColorPicker::OnLButtonDown(UINT nFlags, CPoint cPoint) void CColorPicker::OnLButtonUp(UINT nFlags, CPoint cPoint) { - // We get this when user "dragged" over combobox to trigger - // dialog, then move away and let mouse up. Quit just like combo-list would + // Simulate how a combobox widget works, + // quit if mouse up is off the window, except if it comes up + // over the control that launched us if( !IsMouseOverDlg(cPoint) ) { // But check if over the caller rect @@ -1520,6 +1600,9 @@ void CColorPicker::OnLButtonUp(UINT nFlags, CPoint cPoint) CancelAndExit(); return; } + // Mouse came up over the caller control, + // so default to last color used + m_crColor = m_crColors[0]; } else { // Detect mouse up on a color swatch select it // or drop copied color @@ -1551,7 +1634,11 @@ void CColorPicker::OnLButtonUp(UINT nFlags, CPoint cPoint) // because mouse was already down when picker started m_crColor = m_crColors[i]; // Always save selected color as the "last color picked" - wfe_crLastColorPicked = m_crColor; + if( m_bBackground ) + wfe_crLastBkgrndColorPicked = m_crColor; + else + wfe_crLastColorPicked = m_crColor; + SetColorAndExit(); return; } @@ -1707,10 +1794,20 @@ void CColorPicker::OnChooseColor() if( nResult == IDOK ){ m_crColor = dlg.GetColor(); // Save this color as last color picked - wfe_crLastColorPicked = m_crColor; + if( m_bBackground ) + wfe_crLastBkgrndColorPicked = m_crColor; + else + wfe_crLastColorPicked = m_crColor; + + // Set flags for colors that changed + for ( int i = 0; i < MAX_CUSTOM_COLORS; i++ ) + { + if( wfe_CustomPalette[i] != crCustomColors[i] ) + m_bColorChanged[i] = TRUE; + } // Copy custom colors back to global palette memcpy((void*)wfe_CustomPalette, (void*)crCustomColors, sizeof(crCustomColors)); - m_bColorChanged[0] = TRUE; + SetColorAndExit(); } else { CancelAndExit(); @@ -3611,13 +3708,6 @@ void CDocColorPage::OnOK() // to setbackground colors and image EDT_SetPageData(m_pMWContext, m_pPageData); - // This forces redraw of entire window - // (to correct paint bug: missing redraw areas at top of window above cursor) - HWND hView = PANECX(m_pMWContext)->GetPane(); - if( hView ){ - ::InvalidateRect(hView, NULL, TRUE); - } - // This forces redraw of entire window // (there is some missing redraw areas at top of window) ::InvalidateRect(PANECX(m_pMWContext)->GetPane(), NULL, TRUE); @@ -3717,11 +3807,13 @@ void CDocColorPage::OnSelchangeSchemeList() UseCustomColors(TRUE, FALSE); } -BOOL CDocColorPage::ChooseColor(COLORREF * pColor, CColorButton * pButton, COLORREF crDefault ) +BOOL CDocColorPage::ChooseColor(COLORREF * pColor, CColorButton * pButton, COLORREF crDefault, BOOL bBackground ) { RECT rect; pButton->GetWindowRect(&rect); - CColorPicker ColorPicker(this, m_pMWContext, m_bCustomColors ? *pColor : DEFAULT_COLORREF, crDefault, 0, &rect); + CColorPicker ColorPicker(this, m_pMWContext, m_bCustomColors ? *pColor : DEFAULT_COLORREF, crDefault, + bBackground ? IDS_PAGE_BACKGROUND : IDS_TEXT_COLOR, &rect); + COLORREF crNew = ColorPicker.GetColor(); if( crNew != CANCEL_COLORREF ){ if( crNew == DEFAULT_COLORREF){ @@ -3761,7 +3853,7 @@ void CDocColorPage::OnChooseFollowedlinkColor() void CDocColorPage::OnChooseBkgrndColor() { - if ( ChooseColor(&m_crCustomBackground, &m_BackgroundColorButton, m_crBrowserBackground) ) { + if ( ChooseColor(&m_crCustomBackground, &m_BackgroundColorButton, m_crBrowserBackground, TRUE) ) { // Change to custom colors if we were Browser mode UseCustomColors(!m_bWasCustomColors); } @@ -4792,7 +4884,7 @@ void CCharacterPage::OnChooseColor() RECT rect; GetDlgItem(IDC_CHOOSE_COLOR)->GetWindowRect(&rect); - CColorPicker ColorPicker(this, m_pMWContext, m_crColor, DEFAULT_COLORREF, 0, &rect); + CColorPicker ColorPicker(this, m_pMWContext, m_crColor, DEFAULT_COLORREF, IDS_TEXT_COLOR, &rect); COLORREF crNew = ColorPicker.GetColor(); if( crNew != CANCEL_COLORREF ){ diff --git a/cmd/winfe/edprops.h b/cmd/winfe/edprops.h index 3f5658b1046c..aff683579c1d 100644 --- a/cmd/winfe/edprops.h +++ b/cmd/winfe/edprops.h @@ -42,6 +42,7 @@ void wfe_GetLayoutViewSize(MWContext * pMWContext, int32 * pWidth, int32 * pHeig // Font shared by all comboboxes in dialogs and toolbars // Should be 1-pixel, 8pt MS Sans Serif or default GUI or font on foreing systems extern CFont * wfe_pFont; +extern CFont * wfe_pBoldFont; // Bold version of same font extern int wfe_iFontHeight; @@ -68,8 +69,8 @@ char * wfe_GetFontSizeString(MWContext * pMWContext, int iSize, BOOL bFixedWidt // Number of colors in custom palette #define MAX_CUSTOM_COLORS 10 -// Add 1 for Current, 1 for Last-Picked and 10 for custom color palette -#define MAX_COLORS (MAX_NS_COLORS+MAX_CUSTOM_COLORS+2) +// Add 1 for Current and 1 for Last-Picked and 10 for custom color palette +#define MAX_COLORS (MAX_NS_COLORS+MAX_CUSTOM_COLORS+2) extern char **wfe_ppTrueTypeFonts; // The Sorted list of fonts in combobox or menu extern int wfe_iTrueTypeFontBase; @@ -113,8 +114,9 @@ void wfe_SetLO_Color( COLORREF crColor, LO_Color *pLoColor ); // Array of colors to show in common color dialog extern COLORREF wfe_CustomPalette[16]; -// Last-Picked color in color-picker: Saved in prefs +// Last-Picked colors in color-picker: Saved in prefs extern COLORREF wfe_crLastColorPicked; +extern COLORREF wfe_crLastBkgrndColorPicked; // Define makes more sense in some circumstances // We either don't want to show color because of mixed state in selection (in lists and comboboxes) @@ -317,7 +319,7 @@ public: MWContext * pMWContext, COLORREF crCurrentColor, COLORREF crDefColor, // Actual color or DEFAULT_COLORREF or BACKGROUND_COLORREF - UINT nIDCaption = 0, // Optional string ID for dialog caption + UINT nIDCaption = IDS_TEXT_COLOR, // Defines what color we are setting RECT * pCallerRect = NULL); // If null, normal centerred dialog, // else positions like a dropdown from caller's rect @@ -331,17 +333,18 @@ public: private: RECT m_CallerRect; CWnd *m_pParent; - UINT m_nIDCaption; COLORREF m_crColors[MAX_COLORS]; CColorButton *m_pColorButtons[MAX_COLORS]; CButton m_DefaultButton; CButton m_OtherButton; CButton m_HelpButton; CStatic m_CurrentLabel; - CStatic m_LastUsedLabel; //m_DefaultLabel; + CStatic m_LastUsedLabel; CStatic m_CustomColorsLabel; CStatic m_SaveColorLabel; CStatic m_CustomColorNumber[MAX_CUSTOM_COLORS]; + BOOL m_bBackground; + UINT m_nIDCaption; BOOL m_bColorChanged[MAX_CUSTOM_COLORS]; BOOL m_bMouseDown; int m_iMouseDownColorIndex; @@ -412,6 +415,7 @@ protected: afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnPaint(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; @@ -786,7 +790,7 @@ protected: // Get a color using our CColorPicker color picker // Use string from nIDCaption for the dialog caption // Return TRUE if OK is pressed - BOOL ChooseColor(COLORREF * pColor, CColorButton * pButton, COLORREF crDefault); + BOOL ChooseColor(COLORREF * pColor, CColorButton * pButton, COLORREF crDefault, BOOL bBackground = FALSE); void UseBrowserColors(BOOL bRedraw = TRUE); void UseCustomColors(BOOL bRedraw = TRUE, BOOL bUnselectScheme = TRUE); diff --git a/cmd/winfe/edtable.cpp b/cmd/winfe/edtable.cpp index a25754e5dc23..88e3a5872265 100755 --- a/cmd/winfe/edtable.cpp +++ b/cmd/winfe/edtable.cpp @@ -751,7 +751,7 @@ void CTablePage::OnChooseColor() RECT rect; GetDlgItem(IDC_CHOOSE_COLOR)->GetWindowRect(&rect); - CColorPicker dlg(this, m_pMWContext, m_crColor, BACKGROUND_COLORREF, 0, &rect); + CColorPicker dlg(this, m_pMWContext, m_crColor, BACKGROUND_COLORREF, IDS_TABLE_BACKGROUND, &rect); COLORREF crNew = dlg.GetColor(); if( crNew != CANCEL_COLORREF ) @@ -1515,7 +1515,7 @@ void CTableCellPage::OnChooseColor() RECT rect; GetDlgItem(IDC_CHOOSE_COLOR)->GetWindowRect(&rect); - CColorPicker dlg(this, m_pMWContext, m_crColor, BACKGROUND_COLORREF, 0, &rect); + CColorPicker dlg(this, m_pMWContext, m_crColor, BACKGROUND_COLORREF, IDS_CELL_BACKGROUND, &rect); COLORREF crNew = dlg.GetColor(); if( crNew != CANCEL_COLORREF ) diff --git a/cmd/winfe/edtrcdll/src/edtrcdll.rc b/cmd/winfe/edtrcdll/src/edtrcdll.rc index e2311c6de9f5..cfed7704ee32 100644 --- a/cmd/winfe/edtrcdll/src/edtrcdll.rc +++ b/cmd/winfe/edtrcdll/src/edtrcdll.rc @@ -793,8 +793,7 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION CAPTION "Page Title" FONT 8, "MS Sans Serif" BEGIN - LTEXT "Enter a title for the current page",IDC_STATIC,8,7,224, - 8 + LTEXT "Enter a title for the current page",IDC_STATIC,8,7,224,8 EDITTEXT IDC_DOC_TITLE,8,19,224,14,ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,98,86,62,14,WS_GROUP PUSHBUTTON "Cancel",IDCANCEL,169,86,62,14 @@ -847,6 +846,30 @@ BEGIN END +IDD_PASTE_SPECIAL DIALOG DISCARDABLE 0, 0, 142, 81 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Paste Special" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "Paste &Text",IDC_PASTE_TEXT,36,40,69,14 + PUSHBUTTON "Paste &Image",IDC_PASTE_IMAGE,36,60,69,14 + LTEXT "The clipboard contains both text and image versions of the same data.\nSelect which type to paste:", + IDC_STATIC,7,7,127,29 +END + +IDD_GET_TABLE_COLUMNS DIALOG DISCARDABLE 0, 0, 153, 73 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Convert Text to Table" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Enter number of columns for new table:",IDC_STATIC,7,7, + 139,19 + EDITTEXT IDC_TABLE_COLUMNS, 50,25,25,14,ES_AUTOHSCROLL | WS_GROUP + LTEXT "columns",IDC_STATIC,81,27,65,8 + DEFPUSHBUTTON "OK",IDOK,16,52,50,14,WS_GROUP + PUSHBUTTON "Cancel",IDCANCEL,87,52,50,14 +END + ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO @@ -1014,6 +1037,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 147 END + + IDD_GET_TABLE_COLUMNS, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 146 + TOPMARGIN, 7 + BOTTOMMARGIN, 66 + END END #endif // APSTUDIO_INVOKED diff --git a/cmd/winfe/edtrcdll/src/resource.h b/cmd/winfe/edtrcdll/src/resource.h index 2a2cd2f0ce3e..8bd625778426 100644 --- a/cmd/winfe/edtrcdll/src/resource.h +++ b/cmd/winfe/edtrcdll/src/resource.h @@ -25,6 +25,7 @@ #define IDD_FECONVERTIMAGE 103 #define IDD_LOCATION_DLG 104 #define IDD_PAGE_TITLE 105 +#define IDD_PASTE_SPECIAL 112 #define IDD_TABLE_INSERT 136 #define IDC_FONTFACE_COMBO 213 #define IDC_AUTO_SAVE_MINUTES 214 @@ -176,9 +177,11 @@ #define IDD_NO_SPELL_CHECKER 1474 #define IDD_CUSTOM_DICTIONARY 1476 #define IDD_SPELLING_LANGUAGE 1500 +#define IDC_TABLE_COLUMNS 2007 #define IDD_PREF_EDITOR 2008 #define IDD_HINT_DLG 2022 #define IDC_HREF_FILE 2023 +#define IDD_GET_TABLE_COLUMNS 2023 #define IDD_PROPS_HRULE 2024 #define IDC_ANCHOR_EDIT 2026 #define IDC_HREF_UNLINK 2036 @@ -353,6 +356,8 @@ #define IDD_PAGE_TABLE_CELL 2269 #define IDD_FEJPEGOPTIONS 2270 #define IDC_APPLY 2272 +#define IDC_PASTE_TEXT 2401 +#define IDC_PASTE_IMAGE 2402 #define IDS_HREF_OTHER_ATTRIBS 42271 #define IDS_HREF_OTHER_ATTRIBS_CAPTION 42272 #define IDS_ERROR_HTML_CAPTION 42296 diff --git a/cmd/winfe/edview.cpp b/cmd/winfe/edview.cpp index 62bba6139e77..56d5c1f23258 100644 --- a/cmd/winfe/edview.cpp +++ b/cmd/winfe/edview.cpp @@ -241,16 +241,6 @@ BEGIN_MESSAGE_MAP(CNetscapeEditView, CNetscapeView) ON_UPDATE_COMMAND_UI(ID_PROPS_DOCUMENT, HaveEditContext) ON_COMMAND(ID_FORMAT_CHAR_NO_TEXT_STYLES, OnCharacterNoTextStyles) ON_COMMAND(ID_FORMAT_CHAR_NONE, OnCharacterNone) - ON_COMMAND(ID_FORMAT_CHAR_NONE, OnCharacterNoTextStyles) - ON_COMMAND(ID_FORMAT_CHAR_BOLD, OnCharacterBold) - ON_COMMAND(IDC_FONT_FIXED_WIDTH, OnCharacterFixedWidth) - ON_COMMAND(ID_FORMAT_CHAR_ITALIC, OnCharacterItalic) - ON_COMMAND(ID_FORMAT_CHAR_NOBREAKS, OnCharacterNoBreaks) - ON_COMMAND(ID_FORMAT_CHAR_UNDERLINE, OnCharacterUnderline) - ON_COMMAND(ID_FORMAT_CHAR_SUPER, OnCharacterSuper) - ON_COMMAND(ID_FORMAT_CHAR_SUB, OnCharacterSub) - ON_COMMAND(ID_FORMAT_CHAR_STRIKEOUT, OnCharacterStrikeout) - ON_COMMAND(ID_FORMAT_CHAR_BLINK, OnCharacterBlink) ON_COMMAND(ID_FORMAT_INDENT, OnFormatIndent) ON_COMMAND(ID_FORMAT_OUTDENT, OnFormatOutdent) ON_COMMAND(ID_ALIGN_POPUP, OnAlignPopup) @@ -350,14 +340,6 @@ BEGIN_MESSAGE_MAP(CNetscapeEditView, CNetscapeView) ON_UPDATE_COMMAND_UI(ID_PROPS_CHARACTER, HaveEditContext) ON_UPDATE_COMMAND_UI(ID_PROPS_DOC_COLOR, HaveEditContext) ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_NONE, OnCanInteract) - ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_BOLD, OnUpdateCharacterBold) - ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_ITALIC, OnUpdateCharacterItalic) - ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_NOBREAKS, OnUpdateCharacterNoBreaks) - ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_UNDERLINE, OnUpdateCharacterUnderline) - ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_SUPER, OnUpdateCharacterSuper) - ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_SUB, OnUpdateCharacterSub) - ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_STRIKEOUT, OnUpdateCharacterStrikeout) - ON_UPDATE_COMMAND_UI(ID_FORMAT_CHAR_BLINK, OnUpdateCharacterBlink) ON_UPDATE_COMMAND_UI(ID_FORMAT_INDENT, HaveEditContext) ON_UPDATE_COMMAND_UI(ID_FORMAT_OUTDENT, HaveEditContext) ON_UPDATE_COMMAND_UI(ID_ALIGN_POPUP, HaveEditContext) @@ -452,43 +434,6 @@ BEGIN_MESSAGE_MAP(CNetscapeEditView, CNetscapeView) #endif //WIN32 #endif //_IME_COMPOSITION ON_MESSAGE(NSBUTTONMENUOPEN, OnButtonMenuOpen) - ON_COMMAND((ID_FORMAT_FONTSIZE_BASE), OnFontSize_2) - ON_COMMAND((ID_FORMAT_FONTSIZE_BASE+1), OnFontSize_1) - ON_COMMAND((ID_FORMAT_FONTSIZE_BASE+2), OnFontSize0) - ON_COMMAND((ID_FORMAT_FONTSIZE_BASE+3), OnFontSize1) - ON_COMMAND((ID_FORMAT_FONTSIZE_BASE+4), OnFontSize2) - ON_COMMAND((ID_FORMAT_FONTSIZE_BASE+5), OnFontSize3) - ON_COMMAND((ID_FORMAT_FONTSIZE_BASE+6), OnFontSize4) - ON_COMMAND(ID_FORMAT_POINTSIZE_BASE, OnPointSize8) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+1), OnPointSize9) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+2), OnPointSize10) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+3), OnPointSize11) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+4), OnPointSize12) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+5), OnPointSize14) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+6), OnPointSize16) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+7), OnPointSize18) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+8), OnPointSize20) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+9), OnPointSize22) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+10), OnPointSize24) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+11), OnPointSize28) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+12), OnPointSize36) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+13), OnPointSize48) - ON_COMMAND((ID_FORMAT_POINTSIZE_BASE+14), OnPointSize72) - ON_UPDATE_COMMAND_UI(ID_FORMAT_POINTSIZE_BASE, HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+1), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+2), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+3), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+4), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+5), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+6), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+7), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+8), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+9), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+10), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+11), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+12), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+13), HaveEditContext) - ON_UPDATE_COMMAND_UI((ID_FORMAT_POINTSIZE_BASE+14), HaveEditContext) ON_COMMAND(ID_CHECK_SPELLING, OnCheckSpelling) ON_UPDATE_COMMAND_UI(ID_CHECK_SPELLING, OnCanInteract) ON_UPDATE_COMMAND_UI(ID_INSERT_NONBREAK_SPACE, OnCanInteract) @@ -1064,10 +1009,22 @@ BOOL CNetscapeEditView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDL OnFormatParagraph(nID); return TRUE; } + else if( nID >= ID_FORMAT_CHAR_BOLD && nID <= ID_FORMAT_CHAR_BLINK ) + { + OnCharacterStyle(nID); + return TRUE; + } + else if( nID >= ID_FORMAT_FONTSIZE_BASE && nID <= ID_FORMAT_FONTSIZE_BASE+6) + { + OnFontSize(nID); + return TRUE; + } + else if( nID >= ID_FORMAT_POINTSIZE_BASE && nID <= ID_FORMAT_POINTSIZE_BASE+14) + { + OnPointSize(nID); + return TRUE; + } break; - // TODO: Do this for these ranges as well: - //ON_COMMAND_RANGE(ID_FORMAT_FONTSIZE_BASE, ID_FORMAT_FONTSIZE_BASE+MAX_FONT_SIZE, OnFontSize) - //ON_COMMAND_RANGE(ID_FORMAT_FONTCOLOR_BASE, ID_FORMAT_FONTCOLOR_BASE+MAX_FONT_COLOR, OnFontColorMenu) case CN_UPDATE_COMMAND_UI: if (!pExtra) @@ -1109,17 +1066,23 @@ BOOL CNetscapeEditView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDL pCmdUI->Enable(CAN_INTERACT); return TRUE; } - else if( nID > ID_FORMAT_PARAGRAPH_BASE ){ + else if( nID > ID_FORMAT_PARAGRAPH_BASE && nID <= ID_FORMAT_PARAGRAPH_END ) + { TagType t = TagType(nID - ID_FORMAT_PARAGRAPH_BASE); if( t == P_BLOCKQUOTE || t == P_DIRECTORY || t == P_MENU || - t == P_DESC_LIST){ + t == P_DESC_LIST) + { UpdateListMenuItem(pCmdUI, t); return TRUE; } } - + else if( nID >= ID_FORMAT_CHAR_BOLD && nID <= ID_FORMAT_CHAR_BLINK ) + { + OnUpdateCharacterStyle(nID, pCmdUI); + return TRUE; + } break; } @@ -1130,10 +1093,9 @@ BOOL CNetscapeEditView::PreTranslateMessage(MSG * pMsg) { if( pMsg->message == WM_KEYDOWN ) { - // Process Ctrl+equals keydown -- for some bizarre reason, - // we don't get an OnKeyDown call for this message if( pMsg->wParam == VK_CONTROL ) { + // Allow pressing control to change cursor UpdateCursor(); } else if( pMsg->wParam == 187 && (GetKeyState(VK_CONTROL) & 0x8000) ) @@ -1303,7 +1265,10 @@ void CNetscapeEditView::OnChar(UINT nChar, UINT nRepCnt, UINT nflags) MWContext * pMWContext = GET_MWCONTEXT; - EDT_ClearTableAndCellSelection(pMWContext); + // Any kepress except Ctrl+[ (for decrease font size) + // should clear a table selection + if( !(nChar == 27 && bControl) ) + EDT_ClearTableAndCellSelection(pMWContext); // Ignore keys if we can't interact INTL_CharSetInfo csi = LO_GetDocumentCharacterSetInfo(pMWContext); @@ -1314,6 +1279,16 @@ void CNetscapeEditView::OnChar(UINT nChar, UINT nRepCnt, UINT nflags) // Since any key can replace a selection, // we need to test for this for any key! switch (nChar) { + case 27: + // Test for Ctrl+[ keypress (27 = ESC key code) + // We can't make an accelerator for this else + // ESC key reduces font size as well! + if(bControl) + { + OnDecreaseFontSize(); + return; + } + break; case 22: // Ctrl+V OnEditPaste(); return; @@ -2147,6 +2122,37 @@ BOOL CNetscapeEditView::DoPasteItem(COleDataObject* pDataObject, EDT_BeginBatchChanges(pMWContext); + BOOL bHaveText = pDataObject->IsDataAvailable(CF_TEXT); + BOOL bHaveUnicode = FALSE; + BOOL bHaveImage = FALSE; + +#ifdef XP_WIN32 + bHaveUnicode = pDataObject->IsDataAvailable(CF_UNICODETEXT) && + (CS_USER_DEFINED_ENCODING != INTL_GetCSIWinCSID(LO_GetDocumentCharacterSetInfo(pMWContext))); +#endif +#ifdef EDITOR +#ifdef _IMAGE_CONVERT + bHaveImage = pDataObject->IsDataAvailable(CF_DIB); + if( bHaveImage && (bHaveText || bHaveUnicode) ) + { + //TODO: POPUP DIALOG TO + CPasteSpecialDlg dlg(this); + if( IDOK == dlg.DoModal() || dlg.m_iResult > 0) + { + if( dlg.m_iResult == ED_PASTE_IMAGE ) + { + bHaveText = bHaveUnicode = FALSE; + } else if( dlg.m_iResult == ED_PASTE_TEXT ) + { + bHaveImage = FALSE; + } + } else { + goto NO_PASTE; + } + } +#endif +#endif + if( bDeleteSource ){ // This deletes current selection and sets // cursor at point where moved data will be inserted. @@ -2213,9 +2219,9 @@ BOOL CNetscapeEditView::DoPasteItem(COleDataObject* pDataObject, } #ifdef EDITOR else if(pDataObject->IsDataAvailable(m_cfImageFormat) ) { - h = pDataObject->GetGlobalData(m_cfImageFormat); - WFE_DragDropImage(h, pMWContext); - } + h = pDataObject->GetGlobalData(m_cfImageFormat); + WFE_DragDropImage(h, pMWContext); + } #endif // EDITOR #ifdef XP_WIN32 else if( pDataObject->IsDataAvailable(CF_HDROP) ){ @@ -2228,10 +2234,8 @@ BOOL CNetscapeEditView::DoPasteItem(COleDataObject* pDataObject, } // **** Test for other formats here } - else if ( pDataObject->IsDataAvailable(CF_UNICODETEXT) && - (CS_USER_DEFINED_ENCODING != INTL_GetCSIWinCSID(LO_GetDocumentCharacterSetInfo(pMWContext))) - ) { // Let's try CF_UNICODETEXT before CF_TEXT - + else if ( bHaveUnicode ) + { int datacsid = INTL_GetCSIWinCSID(LO_GetDocumentCharacterSetInfo(pMWContext)) & ~CS_AUTO; HGLOBAL hUnicodeStr = NULL; @@ -2264,7 +2268,7 @@ BOOL CNetscapeEditView::DoPasteItem(COleDataObject* pDataObject, } } #endif //XP_WIN32 - else if ( pDataObject->IsDataAvailable(CF_TEXT) ) { + else if ( bHaveText ) { if( pString ) { // *** TODO: Analyze string: // Check if its a valid local filename (use XP_STAT). If yes, pop-up menu: @@ -2280,7 +2284,7 @@ BOOL CNetscapeEditView::DoPasteItem(COleDataObject* pDataObject, } #ifdef EDITOR #ifdef _IMAGE_CONVERT - else if( pDataObject->IsDataAvailable(CF_DIB) ) { + else if( bHaveImage ) { CONVERT_IMGCONTEXT imageContext; CONVERT_IMG_INFO imageInfo; memset(&imageContext,0,sizeof(CONVERT_IMGCONTEXT)); @@ -2317,6 +2321,7 @@ BOOL CNetscapeEditView::DoPasteItem(COleDataObject* pDataObject, XP_FREE(szURL); } +NO_PASTE: if ( hString ) { GlobalUnlock(hString); } @@ -2527,21 +2532,29 @@ void CNetscapeEditView::DropFiles( HDROP hDropInfo, BOOL bGetDropPoint) ::DragFinish( hDropInfo ); } +void CNetscapeEditView::OnUpdateEditSource(CCmdUI* pCmdUI) +{ + MWContext * pMWContext = GET_MWCONTEXT; + if( pMWContext && pCmdUI->m_pMenu ) + { + History_entry * hist_entry = SHIST_GetCurrent(&(pMWContext->hist)); + if(hist_entry && hist_entry->address) + pCmdUI->Enable(CAN_INTERACT && NET_IsLocalFileURL(hist_entry->address) ); + else + pCmdUI->Enable(CAN_INTERACT); + } +} + void CNetscapeEditView::OnEditBarToggle() { GetFrame()->GetChrome()->ShowToolbar(IDS_EDIT_TOOLBAR_CAPTION, !GetFrame()->GetChrome()->GetToolbarVisible(IDS_EDIT_TOOLBAR_CAPTION)); } -void CNetscapeEditView::OnCharacterBarToggle() -{ - GetFrame()->GetChrome()->ShowToolbar(IDS_CHAR_TOOLBAR_CAPTION, - !GetFrame()->GetChrome()->GetToolbarVisible(IDS_CHAR_TOOLBAR_CAPTION)); -} - void CNetscapeEditView::OnUpdateEditBarToggle(CCmdUI* pCmdUI) { - if( pCmdUI->m_pMenu ){ + if( pCmdUI->m_pMenu ) + { pCmdUI->m_pMenu->ModifyMenu(ID_OPT_EDITBAR_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_OPT_EDITBAR_TOGGLE, szLoadString(CASTUINT(GetFrame()->GetChrome()->GetToolbarVisible(IDS_EDIT_TOOLBAR_CAPTION) ? IDS_HIDE_EDITBAR : IDS_SHOW_EDITBAR)) ); @@ -2549,13 +2562,57 @@ void CNetscapeEditView::OnUpdateEditBarToggle(CCmdUI* pCmdUI) } } +void CNetscapeEditView::OnCharacterBarToggle() +{ + CFrameGlue *pFrame = GetFrame(); + if( pFrame && pFrame->IsEditFrame() ) + { + pFrame->GetChrome()->ShowToolbar(IDS_CHAR_TOOLBAR_CAPTION, + !pFrame->GetChrome()->GetToolbarVisible(IDS_CHAR_TOOLBAR_CAPTION)); + } + else + { // In Mail Composer, we didn't embed the Character toolbar inside a CCommandToolbar + CEditToolBarController * pController = + (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); + if( pController ) + { + CComboToolBar * pToolBar = pController->GetCharacterBar(); + if( pToolBar) + { + pController->ShowToolBar( !pToolBar->IsVisible(), pToolBar ); + } + } + } +} + void CNetscapeEditView::OnUpdateCharacterBarToggle(CCmdUI* pCmdUI) { - if( pCmdUI->m_pMenu ){ - pCmdUI->m_pMenu->ModifyMenu(ID_OPT_CHARBAR_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_OPT_CHARBAR_TOGGLE, - szLoadString(CASTUINT(GetFrame()->GetChrome()->GetToolbarVisible(IDS_CHAR_TOOLBAR_CAPTION) ? - IDS_HIDE_FORMATBAR : IDS_SHOW_FORMATBAR)) ); - pCmdUI->Enable(CAN_INTERACT); + if( pCmdUI->m_pMenu ) + { + CFrameGlue *pFrame = GetFrame(); + if( pFrame && pFrame->IsEditFrame() ) + { + pCmdUI->m_pMenu->ModifyMenu(ID_OPT_CHARBAR_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_OPT_CHARBAR_TOGGLE, + szLoadString(CASTUINT(GetFrame()->GetChrome()->GetToolbarVisible(IDS_CHAR_TOOLBAR_CAPTION) ? + IDS_HIDE_FORMATBAR : IDS_SHOW_FORMATBAR)) ); + pCmdUI->Enable(CAN_INTERACT); + } + else + { // In Mail Composer, we didn't embed the Character toolbar inside a CCommandToolbar + CEditToolBarController * pController = + (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); + if( pController && pController->GetCharacterBar() ) + { + pCmdUI->m_pMenu->ModifyMenu(ID_OPT_CHARBAR_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_OPT_CHARBAR_TOGGLE, + szLoadString(CASTUINT(pController->GetCharacterBar()->IsVisible() ? + IDS_HIDE_FORMATBAR : IDS_SHOW_FORMATBAR)) ); + pCmdUI->Enable(CAN_INTERACT); + } + else + { + pCmdUI->Enable(FALSE); + } + } } } @@ -2793,6 +2850,10 @@ BOOL CNetscapeEditView::SaveDocumentAs(BOOL bKeepImagesWithDoc, #endif } else bRetVal = FALSE; // Error at end of save + + // EXPERIMENTAL: Prefs are lost to easily - save now! + PREF_SavePrefFile(); + } else bRetVal = FALSE; // Error during start of save } @@ -2878,6 +2939,9 @@ BOOL CNetscapeEditView::SaveDocument() #endif } else bRetVal = FALSE; // Error at end of save + + // EXPERIMENTAL: Prefs are lost to easily - save now! + PREF_SavePrefFile(); } else bRetVal = FALSE; // Error during start of save @@ -3072,7 +3136,7 @@ BOOL CNetscapeEditView::SaveRemote() if ( m_FileSaveStatus == ED_ERROR_NONE ) { bRetVal = TRUE; - #ifdef XP_WIN32 +#ifdef XP_WIN32 if( bSiteMgrIsActive ) { // Tell SiteManager we saved a file @@ -3084,7 +3148,7 @@ BOOL CNetscapeEditView::SaveRemote() // Add file to Win95 Shell's Documents menu SHAddToRecentDocs( SHARD_PATH, hist_entry->address ); }*/ - #endif +#endif } } @@ -3140,7 +3204,8 @@ void CNetscapeEditView::OnPublish() XP_FREE(pSrcURL); } -// USE BROWSER'S SAVE MECHANISM FOR TEXT FILES +// Use Browser's save mechanism for text files +// TODO: Change text file UI to "Import/Export" (i.e., add new menu items)? void EdtSaveToTempCallback( char *pFileURL, void *hook ) { MWContext *pMWContext = (MWContext*)hook; diff --git a/cmd/winfe/edview.h b/cmd/winfe/edview.h index 93fcd620e9c0..fa5bcfa23f3f 100644 --- a/cmd/winfe/edview.h +++ b/cmd/winfe/edview.h @@ -234,6 +234,9 @@ public: void DoProperties(int iStartPage = -1, UINT nIDFirstTab = 0); void ShowCaret() { if (m_pChild == NULL) ::ShowCaret(m_hWnd); } + // Called from OnCMD, converts nID to appropriate point size + // for SetPointSize() + void OnPointSize(UINT nID); void SetPointSize(int iPoints); #ifdef _DEBUG virtual void AssertValid() const; @@ -344,23 +347,7 @@ protected: afx_msg void OnDocColorProperties(); afx_msg void OnCharacterNoTextStyles(); afx_msg void OnCharacterNone(); - afx_msg void OnCharacterBold(); - afx_msg void OnCharacterItalic(); - afx_msg void OnCharacterNoBreaks(); - afx_msg void OnCharacterUnderline(); - afx_msg void OnCharacterSuper(); - afx_msg void OnCharacterSub(); - afx_msg void OnCharacterStrikeout(); - afx_msg void OnCharacterBlink(); afx_msg void OnCharacterFixedWidth(); - afx_msg void OnUpdateCharacterBold(CCmdUI* pCmdUI); - afx_msg void OnUpdateCharacterItalic(CCmdUI* pCmdUI); - afx_msg void OnUpdateCharacterNoBreaks(CCmdUI* pCmdUI); - afx_msg void OnUpdateCharacterUnderline(CCmdUI* pCmdUI); - afx_msg void OnUpdateCharacterSuper(CCmdUI* pCmdUI); - afx_msg void OnUpdateCharacterSub(CCmdUI* pCmdUI); - afx_msg void OnUpdateCharacterStrikeout(CCmdUI* pCmdUI); - afx_msg void OnUpdateCharacterBlink(CCmdUI* pCmdUI); afx_msg void OnFormatIndent(); afx_msg void OnFormatOutdent(); afx_msg void OnAlignPopup(); @@ -490,15 +477,21 @@ protected: afx_msg void OnUpdateCharacterBarToggle(CCmdUI* pCmdUI); afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI); afx_msg void OnSelectNextNonTextObject(); + afx_msg void OnUpdateEditSource(CCmdUI* pCmdUI); //}}AFX_MSG + // These are called CNetscapeEditView::OnCmdMsg + // to avoid too many individual message-map funtions + void OnFontSize(UINT nID); + void OnCharacterStyle(UINT nID); + void OnUpdateCharacterStyle(UINT nID, CCmdUI* pCmdUI); + // Keep these outside of AFX_MSG - they use calculated // or use a range of IDs and are not understood by App/Class wizards afx_msg void OnFormatParagraph( UINT nID ); afx_msg void OnUpdateParagraphMenu(CCmdUI* pCmdUI); afx_msg void OnUpdateParagraphControls(CCmdUI* pCmdUI); afx_msg void OnUpdateCharacterControls(CCmdUI* pCmdUI); - afx_msg void OnFontSize(UINT nID); afx_msg void OnFontColorMenu(UINT nID); //afx_msg void OnUpdateFontSize(CCmdUI* pCmdUI); afx_msg void OnUpdateInsertMenu(CCmdUI* pCmdUI); @@ -515,30 +508,6 @@ protected: afx_msg LRESULT OnReportIme(WPARAM wparam,LPARAM lparam); #endif //XP_WIN32 #endif //_IME_COMPOSITION - afx_msg void OnFontSize_2(); - afx_msg void OnFontSize_1(); - afx_msg void OnFontSize0(); - afx_msg void OnFontSize1(); - afx_msg void OnFontSize2(); - afx_msg void OnFontSize3(); - afx_msg void OnFontSize4(); - - afx_msg void OnPointSize8(); - afx_msg void OnPointSize9(); - afx_msg void OnPointSize10(); - afx_msg void OnPointSize11(); - afx_msg void OnPointSize12(); - afx_msg void OnPointSize14(); - afx_msg void OnPointSize16(); - afx_msg void OnPointSize18(); - afx_msg void OnPointSize20(); - afx_msg void OnPointSize22(); - afx_msg void OnPointSize24(); - afx_msg void OnPointSize28(); - afx_msg void OnPointSize36(); - afx_msg void OnPointSize48(); - afx_msg void OnPointSize72(); - afx_msg void OnCheckSpelling(); afx_msg void OnSpellingLanguage(); afx_msg void OnUpdateEditFindincurrent(CCmdUI* pCmdUI); diff --git a/cmd/winfe/edview2.cpp b/cmd/winfe/edview2.cpp index a95b5e1179fe..b14ae704bfe6 100644 --- a/cmd/winfe/edview2.cpp +++ b/cmd/winfe/edview2.cpp @@ -253,35 +253,6 @@ void CNetscapeEditView::OnFormatParagraph( UINT nID ) } } -void CNetscapeEditView::OnFontSize_2() -{ - OnFontSize(ID_FORMAT_FONTSIZE_BASE); -} -void CNetscapeEditView::OnFontSize_1() -{ - OnFontSize(ID_FORMAT_FONTSIZE_BASE+1); -} -void CNetscapeEditView::OnFontSize0() -{ - OnFontSize(ID_FORMAT_FONTSIZE_BASE+2); -} -void CNetscapeEditView::OnFontSize1() -{ - OnFontSize(ID_FORMAT_FONTSIZE_BASE+3); -} -void CNetscapeEditView::OnFontSize2() -{ - OnFontSize(ID_FORMAT_FONTSIZE_BASE+4); -} -void CNetscapeEditView::OnFontSize3() -{ - OnFontSize(ID_FORMAT_FONTSIZE_BASE+5); -} -void CNetscapeEditView::OnFontSize4() -{ - OnFontSize(ID_FORMAT_FONTSIZE_BASE+6); -} - void CNetscapeEditView::SetPointSize(int iPointSize) { // If Selected, we can't be sure of multible attributes, so set it @@ -294,76 +265,59 @@ void CNetscapeEditView::SetPointSize(int iPointSize) } } -void CNetscapeEditView::OnPointSize8() +void CNetscapeEditView::OnPointSize(UINT nID) { - SetPointSize(8); -} -void CNetscapeEditView::OnPointSize9() -{ - SetPointSize(9); -} -void CNetscapeEditView::OnPointSize10() -{ - SetPointSize(10); -} -void CNetscapeEditView::OnPointSize11() -{ - SetPointSize(11); -} - -void CNetscapeEditView::OnPointSize12() -{ - SetPointSize(12); -} - -void CNetscapeEditView::OnPointSize14() -{ - SetPointSize(14); -} - -void CNetscapeEditView::OnPointSize16() -{ - SetPointSize(16); -} - -void CNetscapeEditView::OnPointSize18() -{ - SetPointSize(18); -} - -void CNetscapeEditView::OnPointSize20() -{ - SetPointSize(20); -} - -void CNetscapeEditView::OnPointSize22() -{ - SetPointSize(22); -} - -void CNetscapeEditView::OnPointSize24() -{ - SetPointSize(24); -} - -void CNetscapeEditView::OnPointSize28() -{ - SetPointSize(28); -} - -void CNetscapeEditView::OnPointSize36() -{ - SetPointSize(36); -} - -void CNetscapeEditView::OnPointSize48() -{ - SetPointSize(48); -} - -void CNetscapeEditView::OnPointSize72() -{ - SetPointSize(72); + int iSize = 0; + switch( nID ) + { + case ID_FORMAT_POINTSIZE_BASE: + iSize = 8; + break; + case ID_FORMAT_POINTSIZE_BASE+1: + iSize = 9; + break; + case ID_FORMAT_POINTSIZE_BASE+2: + iSize = 10; + break; + case ID_FORMAT_POINTSIZE_BASE+3: + iSize = 11; + break; + case ID_FORMAT_POINTSIZE_BASE+4: + iSize = 12; + break; + case ID_FORMAT_POINTSIZE_BASE+5: + iSize = 14; + break; + case ID_FORMAT_POINTSIZE_BASE+6: + iSize = 16; + break; + case ID_FORMAT_POINTSIZE_BASE+7: + iSize = 8; + break; + case ID_FORMAT_POINTSIZE_BASE+8: + iSize = 20; + break; + case ID_FORMAT_POINTSIZE_BASE+9: + iSize = 22; + break; + case ID_FORMAT_POINTSIZE_BASE+10: + iSize = 24; + break; + case ID_FORMAT_POINTSIZE_BASE+11: + iSize = 28; + break; + case ID_FORMAT_POINTSIZE_BASE+12: + iSize = 36; + break; + case ID_FORMAT_POINTSIZE_BASE+13: + iSize = 48; + break; + case ID_FORMAT_POINTSIZE_BASE+14: + iSize = 72; + break; + } + if( iSize > 0 ) + SetPointSize(iSize); } void CNetscapeEditView::OnCharacterNoTextStyles() @@ -417,45 +371,6 @@ void CNetscapeEditView::OnCharacterFixedWidth() EDT_FormatCharacter(GET_MWCONTEXT, TF_FIXED); } -void CNetscapeEditView::OnCharacterBold() -{ - EDT_FormatCharacter(GET_MWCONTEXT, TF_BOLD); -} - -void CNetscapeEditView::OnCharacterItalic() -{ - EDT_FormatCharacter(GET_MWCONTEXT, TF_ITALIC); -} - -void CNetscapeEditView::OnCharacterNoBreaks() -{ - EDT_FormatCharacter(GET_MWCONTEXT, TF_NOBREAK); -} - -void CNetscapeEditView::OnCharacterUnderline() -{ - EDT_FormatCharacter(GET_MWCONTEXT, TF_UNDERLINE); -} - -void CNetscapeEditView::OnCharacterSuper() -{ - EDT_FormatCharacter(GET_MWCONTEXT, TF_SUPER); -} - -void CNetscapeEditView::OnCharacterSub() -{ - EDT_FormatCharacter(GET_MWCONTEXT, TF_SUB); -} - -void CNetscapeEditView::OnCharacterStrikeout() -{ - EDT_FormatCharacter(GET_MWCONTEXT, TF_STRIKEOUT); -} - -void CNetscapeEditView::OnCharacterBlink() -{ - EDT_FormatCharacter(GET_MWCONTEXT, TF_BLINK); -} // Local helper used to get character style state void SetCharacterCheck(MWContext * pMWContext, CCmdUI* pCmdUI, CComboToolBar* pToolbar, ED_TextFormat tf ) @@ -481,6 +396,41 @@ void SetCharacterCheck(MWContext * pMWContext, CCmdUI* pCmdUI, CComboToolBar* pT } } +void CNetscapeEditView::OnCharacterStyle(UINT nID) +{ + ED_TextFormat iStyle = -1; + switch( nID ) + { + case ID_FORMAT_CHAR_BOLD: + iStyle = TF_BOLD; + break; + case ID_FORMAT_CHAR_ITALIC: + iStyle = TF_ITALIC; + break; + case ID_FORMAT_CHAR_NOBREAKS: + iStyle = TF_NOBREAK; + break; + case ID_FORMAT_CHAR_UNDERLINE: + iStyle = TF_UNDERLINE; + break; + case ID_FORMAT_CHAR_SUPER: + iStyle = TF_SUPER; + break; + case ID_FORMAT_CHAR_SUB: + iStyle = TF_SUB; + break; + case ID_FORMAT_CHAR_STRIKEOUT: + iStyle = TF_STRIKEOUT; + break; + case ID_FORMAT_CHAR_BLINK: + iStyle = TF_BLINK; + break; + } + if( iStyle != -1 ){ + EDT_FormatCharacter(GET_MWCONTEXT, iStyle); + } +} + void SetCharacterCheck(MWContext * pMWContext, CCmdUI* pCmdUI, CNSToolbar2* pToolbar, ED_TextFormat tf ) { EDT_CharacterData * pData = EDT_GetCharacterData(pMWContext); @@ -504,91 +454,44 @@ void SetCharacterCheck(MWContext * pMWContext, CCmdUI* pCmdUI, CNSToolbar2* pToo } } -void CNetscapeEditView::OnUpdateCharacterBold(CCmdUI* pCmdUI) +void CNetscapeEditView::OnUpdateCharacterStyle(UINT nID, CCmdUI* pCmdUI) { CEditToolBarController * pController = (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); if (pController) { - SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCNSToolbar(), TF_BOLD); - pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); - } -} - - -void CNetscapeEditView::OnUpdateCharacterItalic(CCmdUI* pCmdUI) -{ - CEditToolBarController * pController = - (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { - SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCNSToolbar(), TF_ITALIC); - pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); - } -} - - -void CNetscapeEditView::OnUpdateCharacterNoBreaks(CCmdUI* pCmdUI) -{ - CEditToolBarController * pController = - (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { - SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCharacterBar(), TF_NOBREAK); - pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); - } -} - -void CNetscapeEditView::OnUpdateCharacterUnderline(CCmdUI* pCmdUI) -{ - CEditToolBarController * pController = - (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { - SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCNSToolbar(), TF_UNDERLINE); - - pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); - } -} - - -void CNetscapeEditView::OnUpdateCharacterSuper(CCmdUI* pCmdUI) -{ - CEditToolBarController * pController = - (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { - SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCharacterBar(), TF_SUPER); - pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); - } -} - - -void CNetscapeEditView::OnUpdateCharacterSub(CCmdUI* pCmdUI) -{ - CEditToolBarController * pController = - (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { - SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCharacterBar(), TF_SUB); - pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); - } -} - - -void CNetscapeEditView::OnUpdateCharacterStrikeout(CCmdUI* pCmdUI) -{ - CEditToolBarController * pController = - (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { - SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCharacterBar(), TF_STRIKEOUT); - pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); - } -} - - -void CNetscapeEditView::OnUpdateCharacterBlink(CCmdUI* pCmdUI) -{ - CEditToolBarController * pController = - (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { - SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCharacterBar(), TF_BLINK); - pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); - } + ED_TextFormat iStyle = -1; + switch( nID ) + { + case ID_FORMAT_CHAR_BOLD: + iStyle = TF_BOLD; + break; + case ID_FORMAT_CHAR_ITALIC: + iStyle = TF_ITALIC; + break; + case ID_FORMAT_CHAR_NOBREAKS: + iStyle = TF_NOBREAK; + break; + case ID_FORMAT_CHAR_UNDERLINE: + iStyle = TF_UNDERLINE; + break; + case ID_FORMAT_CHAR_SUPER: + iStyle = TF_SUPER; + break; + case ID_FORMAT_CHAR_SUB: + iStyle = TF_SUB; + break; + case ID_FORMAT_CHAR_STRIKEOUT: + iStyle = TF_STRIKEOUT; + break; + case ID_FORMAT_CHAR_BLINK: + iStyle = TF_BLINK; + break; + } + if( iStyle != -1 ){ + SetCharacterCheck(GET_MWCONTEXT, pCmdUI, pController->GetCNSToolbar(), iStyle); + pCmdUI->Enable( EDT_CanSetCharacterAttribute(GET_MWCONTEXT) ); + } + } } //////////////////////////////////////////////////////////////////////////////// @@ -627,46 +530,79 @@ static BOOL bBusy = FALSE; void CNetscapeEditView::OnGetFontColor() { // Prevent recursion - if( bBusy ){ + if( bBusy ) return; - } + bBusy = TRUE; CEditToolBarController * pController = (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { + if (pController) + { pController->GetFontColorCombo()->SendMessage(WM_LBUTTONUP, 0,0);// ShowDropDown(FALSE); // NEW: Color Combo is only for showing color in toolbar, // popup dialog to get color to set MWContext *pMWContext = GET_MWCONTEXT; CComboBox * pCombo = pController->GetFontColorCombo(); - if( !pMWContext || !pCombo ){ + if( !pMWContext || !pCombo ) return; - } // Get the combobox location so we popup new dialog just under it RECT rect = {0,0,0,0}; - if( pCombo->IsWindowVisible() ){ + if( pCombo->IsWindowVisible() ) pCombo->GetWindowRect(&rect); - } - CColorPicker dlg(GET_DLG_PARENT(this), pMWContext, m_EditState.crFontColor, DEFAULT_COLORREF, 0, &rect); + // "Hidden" feature: If Alt key is pressed, set the background color + // (Note: Shift+Ctrl+C launches color picker via keyboard, + // so we can't use Shift or Control!) + XP_Bool bBackground = (GetAsyncKeyState(VK_MENU) < 0); + + LO_Color LoColor; + COLORREF crBackground; + UINT nIDCaption = IDS_TEXT_COLOR; + if( bBackground ) + { + // Get color of current cell, table, or the page + ED_ElementType type = EDT_GetBackgroundColor(pMWContext, &LoColor); + crBackground = WFE_LO2COLORREF( &LoColor, LO_COLOR_BG ); + + // Set caption string according to type + if( type == ED_ELEMENT_TABLE ) + nIDCaption = IDS_TABLE_BACKGROUND; + else if( type == ED_ELEMENT_CELL ) + nIDCaption = IDS_CELL_BACKGROUND; + else + nIDCaption = IDS_PAGE_BACKGROUND; + } + CColorPicker dlg(GET_DLG_PARENT(this), pMWContext, + bBackground ? crBackground : m_EditState.crFontColor, + bBackground ? BACKGROUND_COLORREF : DEFAULT_COLORREF, + nIDCaption, &rect); COLORREF crNew = dlg.GetColor(); - if( crNew != CANCEL_COLORREF ){ - if ( crNew != m_EditState.crFontColor || - EDT_IsSelected(pMWContext) ) - { - if( crNew == DEFAULT_COLORREF ){ - // Set the "Default" color (actually = no color attribute written) - EDT_SetFontColor(pMWContext, NULL); - } else { - LO_Color LoColor; - WFE_SetLO_Color(crNew, &LoColor); - EDT_SetFontColor(pMWContext, &LoColor); + if( crNew != CANCEL_COLORREF ) + { + WFE_SetLO_Color(crNew, &LoColor); + if( bBackground ) + { + if( crNew != crBackground ) + { + // Set the BACKGROUND color: + // If "Default", no color attribute is written + EDT_SetBackgroundColor(pMWContext, (crNew == DEFAULT_COLORREF) ? NULL : &LoColor); + } + } + else + { + // Set the FONT color + if ( crNew != m_EditState.crFontColor || + EDT_IsSelected(pMWContext) ) + { + EDT_SetFontColor(pMWContext, (crNew == DEFAULT_COLORREF) ? NULL : &LoColor); + + // Trigger update of color in combo display + m_EditState.bFontColorMaybeChanged = TRUE; } - // Trigger update of color in combo display - m_EditState.bFontColorMaybeChanged = TRUE; } } // Return focus to the view @@ -878,10 +814,11 @@ void CNetscapeEditView::OnSelendokFontSizeCombo() char pSize[16] = ""; char *pEnd; strcpy(pSize, (char*)pController->GetFontSizeCombo()->GetItemData(iSel)); - int iSize = (int)strtol( pSize, &pEnd, 10 ); - if( *pEnd == '\0' ){ - iNewFontSize = iSize; - } + // We will trust that the strings in the combobox + // begin with a valid integer, so strings like "8 pts" + // will yield "8" and we don't check for + // "bad" string + iNewFontSize = (int)strtol( pSize, &pEnd, 10 ); } // If Selected, we can't be sure of multible attributes, so set it if ( iNewFontSize > 0 && iNewFontSize != m_EditState.iFontSize || @@ -926,39 +863,58 @@ void CNetscapeEditView::OnUpdateFontSizeComboBox(CCmdUI* pCmdUI) { MWContext *pMWContext = GET_MWCONTEXT; int iFontSize = 0; - if( pMWContext ){ + if( pMWContext ) + { EDT_CharacterData * pData = EDT_GetCharacterData(pMWContext); - if(pData){ - iFontSize = pData->iPointSize ? pData->iPointSize : pData->iSize; - int iFontIndex = EDT_GetFontFaceIndex(pMWContext); - if( iFontSize != m_EditState.iFontSize || - iFontIndex != m_EditState.iFontIndex || - iFontIndex > 1 ){ - CEditToolBarController * pController = - (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); - if (pController) { - char * pSize = NULL; - char pSizeNotInList[16]; - if( iFontSize > 0 && iFontSize <= MAX_FONT_SIZE ){ - pController->GetFontSizeCombo()->SetCurSel(iFontSize-1); - pSize = wfe_GetFontSizeString(pMWContext, iFontSize, iFontIndex == 1); - } else { - wsprintf(pSizeNotInList, "%d", iFontSize); - pSize = pSizeNotInList; - } - if(pSize){ - pController->GetFontSizeCombo()->FindSelectedOrSetText(pSize, MAX_FONT_SIZE); + if(pData) + { + if( (pData->mask & TF_FONT_SIZE) && (pData->mask & TF_FONT_POINT_SIZE) ) + { + iFontSize = pData->iPointSize ? pData->iPointSize : pData->iSize; + int iFontIndex = EDT_GetFontFaceIndex(pMWContext); + // Point sizes in lower range overlap with relative size numbers (1 through 7) + // and combobox item uses "8 pts" but we only want to display "8" + // when combobox is closed + BOOL bSmallPointSize = (pData->iPointSize > 0 && pData->iPointSize <= 8 ); + + if( iFontSize != m_EditState.iFontSize || + bSmallPointSize || + iFontIndex != m_EditState.iFontIndex || + iFontIndex > 1 ) + { + CEditToolBarController * pController = + (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); + if (pController) + { + char * pSize = NULL; + char pSizeNotInList[16]; + if( !bSmallPointSize && iFontSize > 0 && iFontSize <= MAX_FONT_SIZE ) + { + pController->GetFontSizeCombo()->SetCurSel(iFontSize-1); + pSize = wfe_GetFontSizeString(pMWContext, iFontSize, iFontIndex == 1); + } else { + wsprintf(pSizeNotInList, "%d", iFontSize); + pSize = pSizeNotInList; + } + if(pSize) + pController->GetFontSizeCombo()->FindSelectedOrSetText(pSize, MAX_FONT_SIZE); } } } + else + { + CEditToolBarController * pController = + (CEditToolBarController *)GetParentFrame()->SendMessage(WM_TOOLCONTROLLER); + if (pController) + pController->GetFontSizeCombo()->FindSelectedOrSetText(NULL); + } m_EditState.iFontSize = iFontSize; EDT_FreeCharacterData(pData); } m_EditState.bFontSizeMaybeChanged = FALSE; } - if( pCmdUI ){ + if( pCmdUI ) pCmdUI->Enable( EDT_CanSetCharacterAttribute(pMWContext) ); - } } } @@ -978,25 +934,16 @@ void CNetscapeEditView::UpdateFontSizeCombo() void CNetscapeEditView::OnIncreaseFontSize() { - int iFontSize = EDT_GetFontSize( GET_MWCONTEXT ); - // TODO: MAKE THIS WORK WITH ABSOLUTE POINT SIZE? - if ( iFontSize < MAX_FONT_SIZE ) // 7 - { - EDT_SetFontSize( GET_MWCONTEXT, iFontSize + 1 ); - m_EditState.bFontSizeMaybeChanged = TRUE; - } + EDT_IncreaseFontSize(GET_MWCONTEXT); + // Force update of size controls on toolbar + m_EditState.bFontSizeMaybeChanged = TRUE; } void CNetscapeEditView::OnDecreaseFontSize() { - int iFontSize = EDT_GetFontSize( GET_MWCONTEXT ); - - // TODO: MAKE THIS WORK WITH ABSOLUTE POINT SIZE? - if ( iFontSize > 1 ) - { - EDT_SetFontSize( GET_MWCONTEXT, iFontSize - 1 ); - m_EditState.bFontSizeMaybeChanged = TRUE; - } + EDT_DecreaseFontSize(GET_MWCONTEXT); + // Force update of size controls on toolbar + m_EditState.bFontSizeMaybeChanged = TRUE; } void CNetscapeEditView::OnUpdateIncreaseFontSize(CCmdUI* pCmdUI) @@ -1477,6 +1424,11 @@ void CNetscapeEditView::OnRButtonDown(UINT uFlags, CPoint cpPoint) if( bInTable ) { + // After using this for awhile, it seems hard to right click to + // get table properties, so lets always include both Table and Cell items + cmPopup.AppendMenu(uState, ID_PROPS_TABLE, szLoadString(IDS_POPUP_TABLE_PROPS)); + cmPopup.AppendMenu(uState, ID_PROPS_TABLE_CELL, szLoadString(IDS_POPUP_TABLE_CELL_PROPS)); +#if 0 // Default is "Table Properties" -- first table property page nID = ID_PROPS_TABLE; nIDS = IDS_POPUP_TABLE_PROPS; @@ -1496,7 +1448,7 @@ void CNetscapeEditView::OnRButtonDown(UINT uFlags, CPoint cpPoint) } cmPopup.AppendMenu(uState, nID, szLoadString(nIDS)); - +#endif ED_MergeType MergeType = EDT_GetMergeTableCellsType(pMWContext); if( MergeType != ED_MERGE_NONE ) { @@ -2836,9 +2788,13 @@ void CNetscapeEditView::OnTableTextConvert() { EDT_ConvertTableToText(pMWContext); } else { - //TODO: ADD DIALOG TO GET NUMBER OF COLUMNS - // Convert selected text into a table - EDT_ConvertTextToTable(pMWContext, 3); + // Get number of columns from user + CGetColumnsDlg dlg(this); + if( dlg.DoModal() == IDOK ) + { + // Convert selected text into a table + EDT_ConvertTextToTable(pMWContext, dlg.GetColumns()); + } } } @@ -2846,11 +2802,16 @@ void CNetscapeEditView::OnUpdateTableTextConvert(CCmdUI* pCmdUI) { // Insert point should ALWAYS be inside table if any cells are selected MWContext * pMWContext = GET_MWCONTEXT; - if( EDT_IsTableSelected(pMWContext) || EDT_IsInsertPointInTable(pMWContext) ) + if( EDT_IsTableSelected(pMWContext) || + (EDT_IsInsertPointInTable(pMWContext) && + !EDT_IsSelected(pMWContext) && + EDT_GetSelectedCellCount(pMWContext) == 0) ) { + // Note that we allow converting of entire table to text + // if caret is in a cell, but nothing is selected pCmdUI->Enable(CAN_INTERACT); } else { - pCmdUI->Enable(CAN_INTERACT && EDT_IsSelected(pMWContext) ); + pCmdUI->Enable(CAN_INTERACT && EDT_CanConvertTextToTable(pMWContext)); } } diff --git a/cmd/winfe/fegui.cpp b/cmd/winfe/fegui.cpp index 0387f8e70d9f..d6e6319478cc 100755 --- a/cmd/winfe/fegui.cpp +++ b/cmd/winfe/fegui.cpp @@ -33,6 +33,7 @@ #include "ipframe.h" #include "mnprefs.h" #include "secnav.h" +#include "edprops.h" //xpstrsw header is for resource switcher that will hold the proper instance handle for each stringloaded #include "xpstrsw.h" @@ -3901,3 +3902,19 @@ void FE_GetDocAndWindowPosition(MWContext * context, int32 *pX, int32 *pY, *pX = *pY = *pHeight = *pWidth = 0; } } + +/* Convert an HTML SIZE param value (1-7) into POINT-SIZE value */ +int16 FE_CalcFontPointSize(MWContext * pMWContext, intn iSize, XP_Bool bFixedWidth) +{ + if( pMWContext /*&& wfe_iFontSizeMode == ED_FONTSIZE_ADVANCED*/ ) + { + EncodingInfo *pEncoding = theApp.m_pIntlFont->GetEncodingInfo(pMWContext); + int iBaseSize = bFixedWidth ? pEncoding->iFixSize : pEncoding->iPropSize; + + CDCCX *pDC = VOID2CX(pMWContext->fe.cx, CDCCX); + + if( pDC && iSize >= MIN_FONT_SIZE && iSize <= MAX_FONT_SIZE ) + return (int16)(pDC->CalcFontPointSize(iSize, iBaseSize)); + } + return 0; +} diff --git a/cmd/winfe/mozilla.rc b/cmd/winfe/mozilla.rc index 45a6b464f0f0..8fb323044b79 100644 --- a/cmd/winfe/mozilla.rc +++ b/cmd/winfe/mozilla.rc @@ -1257,7 +1257,6 @@ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Ask Me" FONT 8, "MS Sans Serif" BEGIN - DEFPUSHBUTTON "OK",IDOK,73,161,50,14 LTEXT "Startup Option",IDC_STATIC_TITLE,21,4,123,9 LTEXT "How would you like to work on startup?",IDC_STATIC,21, 18,145,10 @@ -1265,7 +1264,7 @@ BEGIN BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,21,34,85,15 CONTROL "Work O&ffline",IDC_RADIO_OFFLINE,"Button", BS_AUTORADIOBUTTON,21,71,65,15 - LTEXT "Enables network connections",IDC_STATIC,33,49,120,15 + LTEXT "Enables network connections", WS_GROUP | IDC_STATIC,33,49,120,15 LTEXT "Disables network connections until you say so.", IDC_STATIC,33,86,146,19 CONTROL "Set as &default",IDC_CHECK_ASKME_DEFAULT,"Button", @@ -1273,6 +1272,7 @@ BEGIN LTEXT "Changes the ""Ask Me"" preference to the above option so you won't be asked again.", IDC_STATIC,33,129,141,20 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,10,109,177,1 + DEFPUSHBUTTON "OK",IDOK,73,161,50,14 END IDD_PP_DOWNLOAD_DISCUS DIALOG DISCARDABLE 0, 0, 206, 158 diff --git a/cmd/winfe/res/edcolsiz.cur b/cmd/winfe/res/edcolsiz.cur index 6af8b4164fc4428428959e54d6e7358bff8b298a..380513022becd575caf229cab563acb8eeed476c 100644 GIT binary patch delta 29 jcmX@cbc~6cfq{vEkwHO$fq{D>w>*$NF;Hxy6AL2%MOFlu delta 28 jcmX@cbc~6cfq{vEkwHO$fq`=(w>)FR#6a screenX && - rectLastFrame.Width() < screenX && + rectLastFrame.Width() <= screenX && wp.rcNormalPosition.left != theApp.m_iCmdLnX ) { wp.rcNormalPosition.left = 0; @@ -428,7 +428,7 @@ void wfe_InitialUpdateFrame(CFrameWnd* pFrame, } if( wp.rcNormalPosition.bottom > screenY && - rectLastFrame.Height() < screenY && + rectLastFrame.Height() <= screenY && wp.rcNormalPosition.top != theApp.m_iCmdLnY ) { wp.rcNormalPosition.top = 0;