UT_RGBColor AP_UnixFrameImpl::getColorSelBackground () const { UT_return_val_if_fail(m_dArea, UT_RGBColor(0,0,0)); // owen says that any widget should be ok, not just text widgets GdkColor clr = m_dArea->style->base[GTK_STATE_SELECTED]; return UT_RGBColor (clr.red >> 8, clr.green >> 8, clr.blue >> 8); }
void AP_Preview_Annotation::draw(const UT_Rect *clip) { UT_UNUSED(clip); m_drawString = m_sDescription; UT_RGBColor FGcolor(0,0,0); UT_RGBColor BGcolor(m_clrBackground); m_pFont = m_gc->findFont("Times New Roman", "normal", "normal", "normal", "normal", "12pt", NULL); UT_ASSERT_HARMLESS(m_pFont); if(!m_pFont) { clearScreen(); return; } m_gc->setFont(m_pFont); m_iAscent = m_gc->getFontAscent(m_pFont); m_iDescent = m_gc->getFontDescent(m_pFont); m_iHeight = m_gc->getFontHeight(m_pFont); clearScreen(); // // Calculate the draw coordinates position // UT_sint32 iTop = m_gc->tlu(1); UT_sint32 len = m_drawString.size(); UT_sint32 iLeft = m_gc->tlu(2); // // Fill the background color // GR_Painter painter(m_gc); // // Do the draw chars at last! // m_gc->setColor(FGcolor); painter.drawChars(m_drawString.ucs4_str(), 0, len, iLeft, iTop); // bad hardcoded color, but this will probably [ <-this assumption is the bad thing :) ] never be different anyway m_gc->setColor(UT_RGBColor(0,0,0)); painter.drawLine(0, 0, m_gc->tlu(getWindowWidth()), 0); painter.drawLine(m_gc->tlu(getWindowWidth()) - m_gc->tlu(1), 0, m_gc->tlu(getWindowWidth()) - m_gc->tlu(1), m_gc->tlu(getWindowHeight())); painter.drawLine(m_gc->tlu(getWindowWidth()) - m_gc->tlu(1), m_gc->tlu(getWindowHeight()) - m_gc->tlu(1), 0, m_gc->tlu(getWindowHeight()) - m_gc->tlu(1)); painter.drawLine(0, m_gc->tlu(getWindowHeight()) - m_gc->tlu(1), 0, 0); }
UT_RGBColor AP_UnixFrameImpl::getColorSelForeground () const { UT_return_val_if_fail(m_dArea, UT_RGBColor(0,0,0)); // owen says that any widget should be ok, not just text widgets gint state; // our text widget has focus if (GTK_WIDGET_HAS_FOCUS(m_dArea)) state = GTK_STATE_SELECTED; else state = GTK_STATE_ACTIVE; GdkColor clr = m_dArea->style->text[state]; return UT_RGBColor (clr.red >> 8, clr.green >> 8, clr.blue >> 8); }
/* * * Finally draw the characters in the preview. * */ void XAP_Preview_FontPreview::draw(void) { // // Get text decorations. // bool isUnder,isOver,isStrike; const std::string sDecor = getVal("text-decoration"); if(!sDecor.empty()) { isUnder = (NULL != strstr(sDecor.c_str(),"underline")); isOver = (NULL != strstr(sDecor.c_str(),"overline")); isStrike = (NULL != strstr(sDecor.c_str(),"line-through")); } else { isUnder = false; isOver = false; isStrike = false; } // // Do foreground and background colors. // UT_RGBColor FGcolor(0,0,0); const std::string sFGColor = getVal("color"); if(!sFGColor.empty()) UT_parseColor(sFGColor.c_str(),FGcolor); UT_RGBColor BGcolor(m_clrBackground); const std::string sBGColor = getVal("bgcolor"); if(!sBGColor.empty() && strcmp(sBGColor.c_str(),"transparent") != 0) UT_parseColor(sBGColor.c_str(),BGcolor); // // Get the font and bold/italic- ness // //GR_Font * pFont; std::string sFamily = getVal("font-family"); std::string sStyle = getVal("font-style"); std::string sVariant = getVal("font-variant"); std::string sStretch = getVal("font-stretch"); std::string sSize = getVal("font-size"); std::string sWeight = getVal("font-weight"); if(sFamily.empty()) sFamily = "Times New Roman"; if(sStyle.empty()) sStyle = "normal"; if(sVariant.empty()) sVariant = "normal"; if(sStretch.empty()) sStretch = "normal"; if(sSize.empty()) sSize="12pt"; if(sWeight.empty()) sWeight = "normal"; m_pFont = m_gc->findFont(sFamily.c_str(), sStyle.c_str(), sVariant.c_str(), sWeight.c_str(), sStretch.c_str(), sSize.c_str(), NULL); UT_ASSERT_HARMLESS(m_pFont); if(!m_pFont) { clearScreen(); return; } m_gc->setFont(m_pFont); m_iAscent = m_gc->getFontAscent(m_pFont); m_iDescent = m_gc->getFontDescent(m_pFont); m_iHeight = m_gc->getFontHeight(m_pFont); // // Clear the screen! // clearScreen(); // // Calculate the draw coordinates position // UT_sint32 iWinWidth = m_gc->tlu(getWindowWidth()); UT_sint32 iWinHeight = m_gc->tlu(getWindowHeight()); UT_sint32 iTop = (iWinHeight - m_iHeight)/2; UT_sint32 len = UT_UCS4_strlen(m_pszChars); UT_sint32 twidth = m_gc->measureString(m_pszChars,0,len,NULL); UT_sint32 iLeft = (iWinWidth - twidth)/2; // // Fill the background color // GR_Painter painter(m_gc); if(!sBGColor.empty()) painter.fillRect(BGcolor,iLeft,iTop,twidth,m_iHeight); // // Do the draw chars at last! // m_gc->setColor(FGcolor); painter.drawChars(m_pszChars, 0, len, iLeft, iTop); // // Do the decorations // if(isUnder) { UT_sint32 iDrop = iTop + m_iAscent + m_iDescent/3; painter.drawLine(iLeft,iDrop,iLeft+twidth,iDrop); } if(isOver) { UT_sint32 iDrop = iTop + m_gc->tlu(1) + (UT_MAX(m_gc->tlu(10),m_iAscent) - m_gc->tlu(10))/8; painter.drawLine(iLeft,iDrop,iLeft+twidth,iDrop); } if(isStrike) { UT_sint32 iDrop = iTop + m_iAscent * 2 /3; painter.drawLine(iLeft,iDrop,iLeft+twidth,iDrop); } // bad hardcoded color, but this will probably [ <-this assumption is the bad thing :) ] never be different anyway m_gc->setColor(UT_RGBColor(0,0,0)); painter.drawLine(0, 0, m_gc->tlu(getWindowWidth()), 0); painter.drawLine(m_gc->tlu(getWindowWidth()) - m_gc->tlu(1), 0, m_gc->tlu(getWindowWidth()) - m_gc->tlu(1), m_gc->tlu(getWindowHeight())); painter.drawLine(m_gc->tlu(getWindowWidth()) - m_gc->tlu(1), m_gc->tlu(getWindowHeight()) - m_gc->tlu(1), 0, m_gc->tlu(getWindowHeight()) - m_gc->tlu(1)); painter.drawLine(0, m_gc->tlu(getWindowHeight()) - m_gc->tlu(1), 0, 0); }
void AP_FormatFrame_preview::draw(void) { GR_Painter painter(m_gc); UT_sint32 iWidth = m_gc->tlu (getWindowWidth()); UT_sint32 iHeight = m_gc->tlu (getWindowHeight()); UT_Rect pageRect(m_gc->tlu(7), m_gc->tlu(7), iWidth - m_gc->tlu(14), iHeight - m_gc->tlu(14)); painter.fillRect(GR_Graphics::CLR3D_Background, 0, 0, iWidth, iHeight); painter.clearArea(pageRect.left, pageRect.top, pageRect.width, pageRect.height); UT_RGBColor tmpCol; UT_RGBColor black(0, 0, 0); m_gc->setLineWidth(m_gc->tlu(1)); int border = m_gc->tlu(20); int cornerLength = m_gc->tlu(5); // // Draw the cell background // const gchar * pszBGCol = NULL; if(m_pFormatFrame->getImage()) { GR_Image * pImg = m_pFormatFrame->getImage(); FG_Graphic * pFG = m_pFormatFrame->getGraphic(); const char * szName = pFG->getDataId(); const UT_ByteBuf * pBB = static_cast<FG_GraphicRaster *>(pFG)->getBuffer(); if(pFG->getType() == FGT_Raster) { pImg = static_cast<GR_Image *>( m_gc->createNewImage( szName, pBB, pFG->getMimeType(), pageRect.width - 2*border, pageRect.height - 2*border, GR_Image::GRT_Raster)); } else { pImg = static_cast<GR_Image *>( m_gc->createNewImage( szName, pBB, pFG->getMimeType(), pageRect.width - 2*border, pageRect.height - 2*border, GR_Image::GRT_Vector)); } UT_Rect rec(pageRect.left + border, pageRect.top + border, pageRect.width - 2*border, pageRect.height - 2*border); painter.drawImage(pImg,pageRect.left + border, pageRect.top + border); delete pImg; } else { m_pFormatFrame->getPropVector().getProp(static_cast<const gchar *>("background-color"), pszBGCol); if (pszBGCol && *pszBGCol) { UT_parseColor(pszBGCol, tmpCol); painter.fillRect(tmpCol, pageRect.left + border, pageRect.top + border, pageRect.width - 2*border, pageRect.height - 2*border); } } // // Draw the cell corners // m_gc->setColor(UT_RGBColor(127,127,127)); // top left corner painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + border, pageRect.left + border, pageRect.top + border); painter.drawLine(pageRect.left + border, pageRect.top + border - cornerLength, pageRect.left + border, pageRect.top + border); // top right corner painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + border, pageRect.left + pageRect.width - border, pageRect.top + border); painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border - cornerLength, pageRect.left + pageRect.width - border, pageRect.top + border); // bottom left corner painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + pageRect.height - border, pageRect.left + border, pageRect.top + pageRect.height - border); painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border + cornerLength, pageRect.left + border, pageRect.top + pageRect.height - border); // bottom right corner painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + pageRect.height - border, pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border); painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border + cornerLength, pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border); // // Draw the cell borders // // right border if (m_pFormatFrame->getRightToggled()) { UT_sint32 linestyle = m_pFormatFrame->borderLineStyleRight(); if (linestyle == LS_DOTTED) m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED); else if (linestyle == LS_DASHED) m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH); else m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID); m_gc->setColor(m_pFormatFrame->borderColorRight()); UT_sint32 iRightThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessRight().utf8_str()); m_gc->setLineWidth(iRightThickness); painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border, pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border); } // left border if (m_pFormatFrame->getLeftToggled()) { UT_sint32 linestyle = m_pFormatFrame->borderLineStyleLeft(); if (linestyle == LS_DOTTED) m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED); else if (linestyle == LS_DASHED) m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH); else m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID); m_gc->setColor(m_pFormatFrame->borderColorLeft()); UT_sint32 iLeftThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessLeft().utf8_str()); m_gc->setLineWidth(iLeftThickness); painter.drawLine(pageRect.left + border, pageRect.top + border, pageRect.left + border, pageRect.top + pageRect.height - border); } // top border if (m_pFormatFrame->getTopToggled()) { UT_sint32 linestyle = m_pFormatFrame->borderLineStyleTop(); if (linestyle == LS_DOTTED) m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED); else if (linestyle == LS_DASHED) m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH); else m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID); m_gc->setColor(m_pFormatFrame->borderColorTop()); UT_sint32 iTopThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessTop().utf8_str()); m_gc->setLineWidth(iTopThickness); painter.drawLine(pageRect.left + border, pageRect.top + border, pageRect.left + pageRect.width - border, pageRect.top + border); } // bottom border if (m_pFormatFrame->getBottomToggled()) { UT_sint32 linestyle = m_pFormatFrame->borderLineStyleBottom(); if (linestyle == LS_DOTTED) m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_DOTTED); else if (linestyle == LS_DASHED) m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_ON_OFF_DASH); else m_gc->setLineProperties(1, GR_Graphics::JOIN_MITER, GR_Graphics::CAP_BUTT, GR_Graphics::LINE_SOLID); m_gc->setColor(m_pFormatFrame->borderColorBottom()); UT_sint32 iBottomThickness = UT_convertToLogicalUnits(m_pFormatFrame->getBorderThicknessBottom().utf8_str()); m_gc->setLineWidth(iBottomThickness); painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border, pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border); } }
BOOL AP_Win32Dialog_FormatTable::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { WORD wNotifyCode = HIWORD(wParam); WORD wId = LOWORD(wParam); HWND hWndCtrl = (HWND)lParam; switch (wId) { case AP_RID_DIALOG_FORMATTABLE_BMP_BOTTOM: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hwndDlg, AP_RID_DIALOG_FORMATTABLE_BMP_BOTTOM)==BST_CHECKED); toggleLineType(AP_Dialog_FormatTable::toggle_bottom, bChecked); event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATTABLE_BMP_TOP: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hwndDlg, AP_RID_DIALOG_FORMATTABLE_BMP_TOP)==BST_CHECKED); toggleLineType(AP_Dialog_FormatTable::toggle_top, bChecked); event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATTABLE_BMP_RIGHT: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hwndDlg, AP_RID_DIALOG_FORMATTABLE_BMP_RIGHT)==BST_CHECKED); toggleLineType(AP_Dialog_FormatTable::toggle_right, bChecked); event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATTABLE_BMP_LEFT: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hwndDlg, AP_RID_DIALOG_FORMATTABLE_BMP_LEFT)==BST_CHECKED); toggleLineType(AP_Dialog_FormatTable::toggle_left, bChecked); event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATTABLE_BTN_BORDERCOLOR: { CHOOSECOLOR cc; static COLORREF acrCustClr[16]; /* Initialize CHOOSECOLOR */ ZeroMemory(&cc, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = m_hwndDlg; cc.lpCustColors = (LPDWORD) acrCustClr; cc.rgbResult = 0; cc.Flags = CC_FULLOPEN | CC_RGBINIT; if(ChooseColor(&cc)) { setBorderColor(UT_RGBColor(GetRValue( cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult))); m_borderButton.setColour(cc.rgbResult); /*Force redraw*/ InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATTABLE_BTN_BORDERCOLOR), NULL, FALSE); event_previewExposed(); } return 1; } case AP_RID_DIALOG_FORMATTABLE_BTN_BACKCOLOR: { CHOOSECOLOR cc; static COLORREF acrCustClr2[16]; /* Initialize CHOOSECOLOR */ ZeroMemory(&cc, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = m_hwndDlg; cc.lpCustColors = (LPDWORD) acrCustClr2; cc.rgbResult = 0; cc.Flags = CC_FULLOPEN | CC_RGBINIT; if(ChooseColor(&cc)) { setBackgroundColor(UT_RGBColor(GetRValue( cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult))); m_backgButton.setColour(cc.rgbResult); /*Force redraw*/ InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATTABLE_BTN_BACKCOLOR), NULL, FALSE); event_previewExposed(); } return 1; } case AP_RID_DIALOG_FORMATTABLE_COMBO_THICKNESS: { if (wNotifyCode == CBN_SELCHANGE) { int nSelected; HWND hCombo = GetDlgItem(hWnd, AP_RID_DIALOG_FORMATTABLE_COMBO_THICKNESS); nSelected = SendMessage(hCombo, CB_GETCURSEL, 0, 0); if (nSelected != CB_ERR) { char szThickness[1024]; UT_UTF8String sThicknessTable; SendMessage(hCombo, CB_GETLBTEXT, nSelected, (LPARAM)szThickness); sThicknessTable = szThickness; setBorderThickness(sThicknessTable); /*Force redraw*/ InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATTABLE_BTN_BACKCOLOR), NULL, FALSE); event_previewExposed(); } } return 1; } case AP_RID_DIALOG_FORMATTABLE_BTN_CANCEL: m_answer = AP_Dialog_FormatTable::a_CLOSE; destroy(); EndDialog(hWnd,0); return 1; case AP_RID_DIALOG_FORMATTABLE_BTN_APPLY: { int nSelected, nData = FORMAT_TABLE_SELECTION; HWND hCombo = GetDlgItem(hWnd, AP_RID_DIALOG_FORMATTABLE_COMBO_APPLYTO); nSelected = SendMessage(hCombo, CB_GETCURSEL, 0, 0); if (nSelected!=CB_ERR) nData = SendMessage(hCombo, CB_GETITEMDATA, nSelected, 0); setApplyFormatTo((_FormatTable) nData); m_answer = AP_Dialog_FormatTable::a_OK; applyChanges(); return 1; } case AP_RID_DIALOG_FORMATTABLE_BUTTON_SELIMAGE: askForGraphicPathName(); return 1; case AP_RID_DIALOG_FORMATTABLE_BUTTON_NOIMAGE: clearImage(); return 1; default: // we did not handle this notification UT_DEBUGMSG(("WM_Command for id %ld\n",wId)); return 0; // return zero to let windows take care of it. } }
void AP_FormatTable_preview::draw(const UT_Rect *clip) { UT_UNUSED(clip); GR_Painter painter(m_gc); UT_sint32 iWidth = m_gc->tlu (getWindowWidth()); UT_sint32 iHeight = m_gc->tlu (getWindowHeight()); UT_Rect pageRect(m_gc->tlu(7), m_gc->tlu(7), iWidth - m_gc->tlu(14), iHeight - m_gc->tlu(14)); painter.fillRect(GR_Graphics::CLR3D_Background, 0, 0, iWidth, iHeight); painter.clearArea(pageRect.left, pageRect.top, pageRect.width, pageRect.height); UT_RGBColor tmpCol; UT_RGBColor black(0, 0, 0); m_gc->setLineWidth(m_gc->tlu(1)); int border = m_gc->tlu(20); int cornerLength = m_gc->tlu(5); // // Draw the cell background // const gchar * pszBGCol = NULL; if(m_pFormatTable->getImage()) { GR_Image * pImg = m_pFormatTable->getImage(); FG_Graphic * pFG = m_pFormatTable->getGraphic(); const char * szName = pFG->getDataId(); const UT_ByteBuf * pBB = pFG->getBuffer(); if(pFG->getType() == FGT_Raster) { pImg = static_cast<GR_Image *>( m_gc->createNewImage( szName, pBB, pFG->getMimeType(), pageRect.width - 2*border, pageRect.height - 2*border, GR_Image::GRT_Raster)); } else { pImg = static_cast<GR_Image *>( m_gc->createNewImage( szName, pBB, pFG->getMimeType(), pageRect.width - 2*border, pageRect.height - 2*border, GR_Image::GRT_Vector)); } UT_Rect rec(pageRect.left + border, pageRect.top + border, pageRect.width - 2*border, pageRect.height - 2*border); painter.drawImage(pImg,pageRect.left + border, pageRect.top + border); delete pImg; } else { m_pFormatTable->getPropVector().getProp(static_cast<const gchar *>("background-color"), pszBGCol); if (pszBGCol && *pszBGCol) { UT_parseColor(pszBGCol, tmpCol); painter.fillRect(tmpCol, pageRect.left + border, pageRect.top + border, pageRect.width - 2*border, pageRect.height - 2*border); } } // // Draw the cell corners // m_gc->setColor(UT_RGBColor(127,127,127)); // top left corner painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + border, pageRect.left + border, pageRect.top + border); painter.drawLine(pageRect.left + border, pageRect.top + border - cornerLength, pageRect.left + border, pageRect.top + border); // top right corner painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + border, pageRect.left + pageRect.width - border, pageRect.top + border); painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border - cornerLength, pageRect.left + pageRect.width - border, pageRect.top + border); // bottom left corner painter.drawLine(pageRect.left + border - cornerLength, pageRect.top + pageRect.height - border, pageRect.left + border, pageRect.top + pageRect.height - border); painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border + cornerLength, pageRect.left + border, pageRect.top + pageRect.height - border); // bottom right corner painter.drawLine(pageRect.left + pageRect.width - border + cornerLength, pageRect.top + pageRect.height - border, pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border); painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border + cornerLength, pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border); // // Draw the cell borders // // top border if (m_pFormatTable->getTopToggled()) { const gchar * pszTopColor = NULL; m_pFormatTable->getPropVector().getProp("top-color", pszTopColor); if (pszTopColor) { UT_parseColor(pszTopColor, tmpCol); m_gc->setColor(tmpCol); } else m_gc->setColor(black); const gchar * pszTopThickness = NULL; m_pFormatTable->getPropVector().getProp("top-thickness", pszTopThickness); if(pszTopThickness) { UT_sint32 iTopThickness = UT_convertToLogicalUnits(pszTopThickness); m_gc->setLineWidth(iTopThickness); } else { m_gc->setLineWidth(m_gc->tlu(1)); } painter.drawLine(pageRect.left + border, pageRect.top + border, pageRect.left + pageRect.width - border, pageRect.top + border); } // left border if (m_pFormatTable->getLeftToggled()) { const gchar * pszLeftColor = NULL; m_pFormatTable->getPropVector().getProp("left-color", pszLeftColor); if (pszLeftColor) { UT_parseColor(pszLeftColor, tmpCol); m_gc->setColor(tmpCol); } else m_gc->setColor(black); const gchar * pszLeftThickness = NULL; m_pFormatTable->getPropVector().getProp("left-thickness", pszLeftThickness); if(pszLeftThickness) { UT_sint32 iLeftThickness = UT_convertToLogicalUnits(pszLeftThickness); m_gc->setLineWidth(iLeftThickness); } else { m_gc->setLineWidth(m_gc->tlu(1)); } painter.drawLine(pageRect.left + border, pageRect.top + border, pageRect.left + border, pageRect.top + pageRect.height - border); } // right border if (m_pFormatTable->getRightToggled()) { const gchar * pszRightColor = NULL; m_pFormatTable->getPropVector().getProp("right-color", pszRightColor); if (pszRightColor) { UT_parseColor(pszRightColor, tmpCol); m_gc->setColor(tmpCol); } else m_gc->setColor(black); const gchar * pszRightThickness = NULL; m_pFormatTable->getPropVector().getProp("right-thickness", pszRightThickness); if(pszRightThickness) { UT_sint32 iRightThickness = UT_convertToLogicalUnits(pszRightThickness); m_gc->setLineWidth(iRightThickness); } else { m_gc->setLineWidth(m_gc->tlu(1)); } painter.drawLine(pageRect.left + pageRect.width - border, pageRect.top + border, pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border); } // bottom border if (m_pFormatTable->getBottomToggled()) { const gchar * pszBottomColor = NULL; m_pFormatTable->getPropVector().getProp("bot-color", pszBottomColor); if (pszBottomColor) { UT_parseColor(pszBottomColor, tmpCol); m_gc->setColor(tmpCol); } else m_gc->setColor(black); const gchar * pszBotThickness = NULL; m_pFormatTable->getPropVector().getProp("bot-thickness", pszBotThickness); if(pszBotThickness) { UT_sint32 iBotThickness = UT_convertToLogicalUnits(pszBotThickness); m_gc->setLineWidth(iBotThickness); } else { m_gc->setLineWidth(m_gc->tlu(1)); } painter.drawLine(pageRect.left + border, pageRect.top + pageRect.height - border, pageRect.left + pageRect.width - border, pageRect.top + pageRect.height - border); } }
void AP_Dialog_FormatTable::setCurCellProps(void) { XAP_Frame *frame = XAP_App::getApp()->getLastFocussedFrame(); if (frame) { FV_View * pView = static_cast<FV_View *>(frame->getCurrentView()); if (m_bSettingsChanged || m_iOldPos == pView->getPoint()) // comparing the actual cell pos would be even better; but who cares :) return; m_iOldPos = pView->getPoint(); /* * update the border colors */ gchar * color = NULL; if (pView->getCellProperty("left-color", color)) m_vecProps.addOrReplaceProp("left-color", color); else m_vecProps.removeProp("left-color"); if (pView->getCellProperty("right-color", color)) m_vecProps.addOrReplaceProp("right-color", color); else m_vecProps.removeProp("right-color"); if (pView->getCellProperty("top-color", color)) m_vecProps.addOrReplaceProp("top-color", color); else m_vecProps.removeProp("top-color"); if (pView->getCellProperty("bot-color", color)) m_vecProps.addOrReplaceProp("bot-color", color); else m_vecProps.removeProp("bot-color"); /* * update the background color */ UT_RGBColor clr; gchar * bgColor = NULL; if (pView->getCellProperty("background-color", bgColor)) { m_vecProps.addOrReplaceProp("background-color", bgColor); clr.setColor(bgColor); setBackgroundColorInGUI(clr); } else { m_vecProps.removeProp("background-color"); setBackgroundColorInGUI(UT_RGBColor(255,255,255)); // No color == white for now - MARCM } if(pView->isImageAtStrux(m_iOldPos,PTX_SectionCell)) { if(pView->isInTable()) { fl_BlockLayout * pBL = pView->getCurrentBlock(); fl_CellLayout * pCell = static_cast<fl_CellLayout *>(pBL->myContainingLayout()); if(pCell->getContainerType() != FL_CONTAINER_CELL) { UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN); DELETEP(m_pGraphic); DELETEP(m_pImage); m_sImagePath.clear(); } else { FG_Graphic * pFG = FG_GraphicRaster::createFromStrux(pCell); if(pFG) { DELETEP(m_pGraphic); DELETEP(m_pImage); m_sImagePath.clear(); m_pGraphic = pFG; m_sImagePath = pFG->getDataId(); GR_Graphics * pG = m_pFormatTablePreview->getGraphics(); const UT_ByteBuf * pBB = pFG->getBuffer(); if(m_pGraphic->getType() == FGT_Raster) { m_pImage = static_cast<GR_Image *>( pG->createNewImage( m_sImagePath.c_str(), pBB, pFG->getMimeType(), pFG->getWidth(), pFG->getHeight(), GR_Image::GRT_Raster)); } else { m_pImage = static_cast<GR_Image *>( pG->createNewImage( m_sImagePath.c_str(), pBB, pFG->getMimeType(), m_pFormatTablePreview->getWindowWidth()-2, m_pFormatTablePreview->getWindowHeight()-2, GR_Image::GRT_Vector)); } } } } else { DELETEP(m_pGraphic); DELETEP(m_pImage); m_sImagePath.clear(); } } else { DELETEP(m_pGraphic); DELETEP(m_pImage); m_sImagePath.clear(); } UT_String bstmp = UT_String_sprintf("%d", FS_FILL); m_vecProps.addOrReplaceProp("bg-style", bstmp.c_str()); // draw the preview with the changed properties if(m_pFormatTablePreview) m_pFormatTablePreview->queueDraw(); } }
void AP_Lists_preview::draw(void) { UT_return_if_fail(m_pFont); GR_Painter painter(m_gc); m_gc->setFont(m_pFont); UT_RGBColor clrGrey = UT_RGBColor(128,128,128); UT_RGBColor clrBlack = UT_RGBColor(0,0,0); UT_sint32 iWidth = m_gc->tlu(getWindowWidth()); UT_sint32 iHeight = m_gc->tlu(getWindowHeight()); UT_UCSChar ucs_label[50]; UT_sint32 iDescent = m_gc->getFontDescent(); UT_sint32 iAscent = m_gc->getFontAscent(); UT_sint32 iFont = iDescent + iAscent; m_iLine_height = iFont; // // clear our screen // if (m_bFirst == true) { painter.clearArea(0, 0, iWidth, iHeight); } m_gc->setColor(clrBlack); UT_sint32 yoff = m_gc->tlu(5) ; UT_sint32 xoff = m_gc->tlu(5) ; UT_sint32 i,ii,yloc,awidth,aheight,maxw; UT_sint32 twidth =0; UT_sint32 j,xy; float z,fwidth; // todo 6.5 should be the page width in inches float pagew = 2.0; aheight = m_gc->tlu(16); fwidth = static_cast<float>(m_gc->tdu(iWidth)); z = (float)((fwidth - 2.0*static_cast<float>(m_gc->tdu(xoff))) /pagew); UT_sint32 indent = m_gc->tlu(static_cast<UT_sint32>( z*(m_fAlign+m_fIndent))); if(indent < 0) indent = 0; maxw = 0; for(i=0; i<4; i++) { UT_UCSChar * lv = getLists()->getListLabel(i); UT_sint32 len =0; if(lv != NULL) { // // This code is here because UT_UCS_copy_char is broken // len = UT_MIN(UT_UCS4_strlen(lv),51); for(j=0; j<=len;j++) { ucs_label[j] = *lv++; } ucs_label[len] = 0; len = UT_UCS4_strlen(ucs_label); yloc = yoff + iAscent + (iHeight - 2*yoff -iFont)*i/4; // painter.drawChars(ucs_label,0,len,xoff+indent,yloc); twidth = m_gc->measureString(ucs_label,0,len,NULL); if(twidth > maxw) maxw = twidth; } } // // Work out where to put grey areas to represent text // UT_sint32 xx,yy; if(maxw > 0) maxw++; // UT_sint32 vspace = (iHeight - 2*yoff -iFont)*i/16; z = (float)((fwidth - 2.0*static_cast<float>(m_gc->tdu(xoff))) /(float)pagew); UT_sint32 ialign = m_gc->tlu(static_cast<UT_sint32>( z*m_fAlign)); xx = xoff + ialign; xy = xoff + ialign; if(xx < (xoff + maxw + indent)) xy = xoff + maxw + indent + m_gc->tlu(1); ii = 0; for(i=0; i<4; i++) { yloc = yoff + iAscent + (iHeight - 2*yoff -iFont)*i/4; for(j=0; j< 2; j++) { yy = yloc + m_gc->tlu(5) + j*m_gc->tlu(21); m_iLine_pos[ii++] = yy; } } // // Now finally draw the preview // UT_BidiCharType iDirection = getLists()->getBlock()->getDominantDirection(); for(i=0; i<8; i++) { // // First clear the line // painter.clearArea(0, m_iLine_pos[i], iWidth, iHeight); if((i & 1) == 0) { // // Draw the text // UT_UCSChar * lv = getLists()->getListLabel(i/2); UT_sint32 len =0; if(lv != NULL) { len = UT_MIN(UT_UCS4_strlen(lv),49); if(len > 1 && XAP_App::getApp()->theOSHasBidiSupport() == XAP_App::BIDI_SUPPORT_GUI) { UT_bidiReorderString(lv, len, iDirection, ucs_label); } else { for(j=0; j<=len;j++) ucs_label[j] = *lv++; } ucs_label[len] = 0; len = UT_UCS4_strlen(ucs_label); yloc = yoff + iAscent + (iHeight - 2*yoff -iFont)*i/8; if(iDirection == UT_BIDI_RTL) painter.drawChars(ucs_label,0,len,iWidth - xoff - indent - maxw,yloc); else painter.drawChars(ucs_label,0,len,xoff+indent,yloc); yy = m_iLine_pos[i]; awidth = iWidth - 2*xoff - xy; if(iDirection == UT_BIDI_RTL) painter.fillRect(clrGrey,xoff,yy,awidth,aheight); else painter.fillRect(clrGrey,xy,yy,awidth,aheight); } else { yy = m_iLine_pos[i]; awidth = iWidth - 2*xoff - xy; if(iDirection == UT_BIDI_RTL) painter.fillRect(clrGrey,xoff,yy,awidth,aheight); else painter.fillRect(clrGrey,xy,yy,awidth,aheight); } } else { yy = m_iLine_pos[i]; awidth = iWidth - 2*xoff - xx; if(iDirection == UT_BIDI_RTL) painter.fillRect(clrGrey,xoff,yy,awidth,aheight); else painter.fillRect(clrGrey,xy,yy,awidth,aheight); } } }
BOOL AP_Win32Dialog_FormatFrame::_onCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { WORD wNotifyCode = HIWORD(wParam); WORD wId = LOWORD(wParam); switch (wId) { case AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_BOTTOM)==BST_CHECKED); toggleLineType(AP_Dialog_FormatFrame::toggle_bottom, bChecked); event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATFRAME_BMP_TOP: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_TOP)==BST_CHECKED); toggleLineType(AP_Dialog_FormatFrame::toggle_top, bChecked); event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATFRAME_BMP_RIGHT: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_RIGHT)==BST_CHECKED); toggleLineType(AP_Dialog_FormatFrame::toggle_right, bChecked); event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATFRAME_BMP_LEFT: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_BMP_LEFT)==BST_CHECKED); toggleLineType(AP_Dialog_FormatFrame::toggle_left, bChecked); event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATFRAME_BTN_BORDERCOLOR: { CHOOSECOLORW cc; static COLORREF acrCustClr[16]; /* Initialize CHOOSECOLOR */ ZeroMemory(&cc, sizeof(CHOOSECOLORW)); cc.lStructSize = sizeof(CHOOSECOLORW); cc.hwndOwner = m_hDlg; cc.lpCustColors = (LPDWORD) acrCustClr; cc.rgbResult = 0; cc.Flags = CC_FULLOPEN | CC_RGBINIT; if(ChooseColorW(&cc)) { setBorderColor(UT_RGBColor(GetRValue( cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult))); m_borderButton.setColour(cc.rgbResult); /*Force redraw*/ InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATFRAME_BTN_BORDERCOLOR), NULL, FALSE); event_previewExposed(); } return 1; } case AP_RID_DIALOG_FORMATFRAME_BTN_BACKCOLOR: { CHOOSECOLORW cc; static COLORREF acrCustClr2[16]; /* Initialize CHOOSECOLOR */ ZeroMemory(&cc, sizeof(CHOOSECOLORW)); cc.lStructSize = sizeof(CHOOSECOLORW); cc.hwndOwner = m_hDlg; cc.lpCustColors = (LPDWORD) acrCustClr2; cc.rgbResult = 0; cc.Flags = CC_FULLOPEN | CC_RGBINIT; if(ChooseColorW(&cc)) { setBGColor(UT_RGBColor(GetRValue( cc.rgbResult), GetGValue(cc.rgbResult), GetBValue(cc.rgbResult))); m_backgButton.setColour(cc.rgbResult); /*Force redraw*/ InvalidateRect(GetDlgItem(hWnd, AP_RID_DIALOG_FORMATFRAME_BTN_BACKCOLOR), NULL, FALSE); event_previewExposed(); } return 1; } case AP_RID_DIALOG_FORMATFRAME_CHK_TEXTWRAP: { bool bChecked; bChecked = (bool)(IsDlgButtonChecked(m_hDlg, AP_RID_DIALOG_FORMATFRAME_CHK_TEXTWRAP)==BST_CHECKED); setWrapping(bChecked); // Not necessary now, but we may some day show // text wrapping in the preview. event_previewExposed(); return 1; } case AP_RID_DIALOG_FORMATFRAME_BTN_CANCEL: m_answer = AP_Dialog_FormatFrame::a_CLOSE; destroy(); event_Close(); EndDialog(hWnd,0); return 1; case AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS: { if (wNotifyCode == CBN_SELCHANGE) { int nSelected = getComboSelectedIndex (AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS); if (nSelected != CB_ERR) { UT_LocaleTransactor t(LC_NUMERIC, "C"); UT_Win32LocaleString thickness; UT_UTF8String thickness_utf8 = thickness.utf8_str (); getComboTextItem(AP_RID_DIALOG_FORMATFRAME_COMBO_THICKNESS, nSelected, thickness); setBorderThicknessAll(thickness_utf8); event_previewExposed(); } } return 1; } case AP_RID_DIALOG_FORMATFRAME_BUTTON_SELIMAGE: askForGraphicPathName(); return 1; case AP_RID_DIALOG_FORMATFRAME_BUTTON_NOIMAGE: clearImage(); return 1; case AP_RID_DIALOG_FORMATFRAME_RADIO_PARA: setPositionMode(FL_FRAME_POSITIONED_TO_BLOCK); return 1; case AP_RID_DIALOG_FORMATFRAME_RADIO_COLUMN: setPositionMode(FL_FRAME_POSITIONED_TO_COLUMN); return 1; case AP_RID_DIALOG_FORMATFRAME_RADIO_PAGE: setPositionMode(FL_FRAME_POSITIONED_TO_PAGE); return 1; case AP_RID_DIALOG_FORMATFRAME_BTN_APPLY: applyChanges(); return 1; default: // we did not handle this notification UT_DEBUGMSG(("WM_Command for id %ld\n",wId)); return 0; // return zero to let windows take care of it. } }