void AP_Dialog_FormatTable::setBackgroundColor(UT_RGBColor clr)
{
    UT_String bgcol = UT_String_sprintf("%02x%02x%02x", clr.m_red, clr.m_grn, clr.m_blu);

    m_vecProps.removeProp ("bg-style"); // Why do we remove this property?  We still use it in frames. -MG
    m_vecProps.removeProp ("bgcolor"); // this is only here for backward compatibility with AbiWord < 2.0. Could be removed as far as I can see - MARCM

    if (clr.isTransparent ())
        m_vecProps.removeProp ("background-color");
    else
        m_vecProps.addOrReplaceProp ("background-color", bgcol.c_str ());

    m_bSettingsChanged = true;
}
Exemple #2
0
void AP_Dialog_FormatFrame::setBGColor(UT_RGBColor clr)
{
	m_backgroundColor = clr;

	UT_String bgcol = UT_String_sprintf("%02x%02x%02x", clr.m_red, clr.m_grn, clr.m_blu);

	m_vecProps.removeProp ("bg-style");
	m_vecProps.removeProp ("bgcolor");

	if (clr.isTransparent ())
		m_vecProps.removeProp ("background-color");
	else
		m_vecProps.addOrReplaceProp ("background-color", bgcol.c_str ());

	m_bSettingsChanged = true;
}
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();
    }
}