示例#1
0
 /// <summary>
 /// Inserts s horizontal scroll bar.
 /// </summary>
 /// <param id="_nPosX">The X position.</param>
 /// <param id="_nPosY">The Y position.</param>
 /// <param id="_nWidth">Width of the Scrollbar.</param>
 /// <param id="sName">Name of the XControl - can be empty.</param>
 private XScrollBar insertHorizontalScrollBar(XAdjustmentListener _xAdjustmentListener, int _nPosX, int _nPosY, int _nWidth, String sName = "")
 {
     try
     {
         // create a unique id by means of an own implementation...
         if (String.IsNullOrWhiteSpace(sName))
         {
             sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "HORIZONTAL_SCROLLBAR");
         }
         else
         {
             sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName);
         }
         return(insertScrollBar(_xAdjustmentListener, _nPosX, _nPosY, defaultScrollBarwidth, _nWidth, unoidl.com.sun.star.awt.ScrollBarOrientation.HORIZONTAL, sName));
     }
     catch { }
     return(null);
 }
示例#2
0
        /// <summary>
        /// Adds a control element to the scrollable container.
        /// ATTENTION: The pos and size you have given to the control are getting lost!
        /// The position and the size have to be set after adding the control inside the container.
        /// The values of position and size are pixel based values. The position is relative to
        /// the top left corner of the container.
        /// </summary>
        /// <param id="cntrl">The XControll you want to add.</param>
        /// <param id="sName">The supposed id of the controll - will be changed if it is not unique!.</param>
        /// <param id="posX">The x position - pixel based value relative to the top left corner of the container.</param>
        /// <param id="posY">The y position - pixel based value relative to the top left corner of the container..</param>
        /// <param id="width">The width in pixel.</param>
        /// <param id="height">The height in pixel.</param>
        public XControl AddElement(XControl cntrl, String sName, int posX, int posY, int width, int height)
        {
            // create a unique id by means of an own implementation...
            if (String.IsNullOrWhiteSpace(sName))
            {
                sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLLABLE_CONTROL_ENTRY");
            }
            else
            {
                sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName);
            }

            //System.Diagnostics.Debug.WriteLine("added control: ____________________________");
            //Debug.GetAllInterfacesOfObject(cntrl);
            //Debug.GetAllServicesOfObject(cntrl);
            //Debug.GetAllProperties(cntrl);

            if (cntrl != null && InnerScrlContr != null)
            {
                if (InnerScrlContr is XControlContainer)
                {
                    ((XControlContainer)InnerScrlContr).addControl(sName, cntrl);
                    OoUtils.SetProperty(cntrl, "Name", sName);
                }

                if (cntrl is XWindow)
                {
                    ((XWindow)cntrl).setPosSize(posX, posY, width, height, PosSize.POSSIZE);

                    Rectangle contrPos = ((XWindow)cntrl).getPosSize();

                    if (InnerWidth < (contrPos.X + contrPos.Width))
                    {
                        InnerWidth = contrPos.X + contrPos.Width;
                    }
                    if (InnerHeight < (contrPos.Y + contrPos.Height))
                    {
                        InnerHeight = contrPos.Y + contrPos.Height;
                    }
                }
            }

            return(cntrl);
        }
示例#3
0
        /// <summary>
        /// Inserts the scroll bar.
        /// </summary>
        /// <param id="_nPosX">The X position.</param>
        /// <param id="_nPosY">The Y position.</param>
        /// <param id="_nHeight">Height of the Scrollbar.</param>
        /// <param id="_nWidth">Width of the Scrollbar.</param>
        /// <param id="sName">Name of the XControl - can be empty.</param>
        private XScrollBar insertScrollBar(XAdjustmentListener _xAdjustmentListener, int _nPosX, int _nPosY, int _nHeight, int _nWidth, int orientation = unoidl.com.sun.star.awt.ScrollBarOrientation.VERTICAL, String sName = "", bool liveScroll = true)
        {
            try
            {
                // create a unique id by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLLBAR");
                }
                else
                {
                    sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName);
                }

                // create a control model at the multiservicefactory of the dialog model...
                Object            oSBModel = parentMCF.createInstanceWithContext(OO.Services.AWT_CONTROL_SCROLLBAR_MODEL, _mXContext);
                XMultiPropertySet xRBMPSet = (XMultiPropertySet)oSBModel;
                // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                xRBMPSet.setPropertyValues(
                    new String[] { "BlockIncrement", "Height", "LineIncrement", "LiveScroll", "Name", "Orientation", "PositionX", "PositionY", "Width" },
                    Any.Get(new Object[] { 30, _nHeight, 10, liveScroll, sName, orientation, _nPosX, _nPosY, _nWidth }));
                // add the model to the NameContainer of the dialog model
                MXDlgModelNameContainer.insertByName(sName, Any.Get(oSBModel));

                XControl xSBControl = (parentCnt != null) ? parentCnt.getControl(sName) : null;

                if (xSBControl != null && xSBControl is XScrollBar && _xAdjustmentListener != null)
                {
                    ((XScrollBar)xSBControl).addAdjustmentListener(_xAdjustmentListener);
                }

                return(xSBControl as XScrollBar);
            }
            catch { }

            return(null);
        }
示例#4
0
        public void CreateScrollableContainer(int _nPosX, int _nPosY, int _nWidth, int _nHeight, String sName)
        {
            try
            {
                // create a unique id by means of an own implementation...
                if (String.IsNullOrWhiteSpace(sName))
                {
                    sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, "SCROLL_CONTAINER");
                }
                else
                {
                    sName = AbstactUnoDialogBase.createUniqueName(MXDlgModelNameContainer, sName);
                }

                //XMultiServiceFactory _xMSF = OO.GetMultiServiceFactory(MXContext);
                XMultiComponentFactory _xMcf = OO.GetMultiComponentFactory(MXContext, true);

                #region Outer Container

                // create a UnoControlContainerModel. A thing which differs from other dialog-controls in many aspects
                // Position and size of the model have no effect, so we apply setPosSize() on it's view later.
                // Unlike a dialog-model the container-model can not have any control-models.
                // As an instance of a dialog-model it can have the property "Step"(among other things),
                // provided by service awt.UnoControlDialogElement, without actually supporting this service!

                // create a control model at the multi service factory of the dialog model...
                outerScrlContrModel = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER_Model, MXContext) as XControlModel;
                OuterScrlContr      = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER, MXContext) as XControl;


                if (OuterScrlContr != null && outerScrlContrModel != null)
                {
                    OuterScrlContr.setModel(outerScrlContrModel);
                }

                XMultiPropertySet xoScrlContMPSet = outerScrlContrModel as XMultiPropertySet;

                if (xoScrlContMPSet != null)
                {
                    // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
                    xoScrlContMPSet.setPropertyValues(
                        new String[] { "Height", "Name", "PositionX", "PositionY", "State", "Width" },
                        Any.Get(new Object[] { 0, sName, 0, 0, ((short)0), 0, 0 }));
                }

                //add to the dialog
                XControlContainer xCntrCont = parentCnt as XControlContainer;
                if (xCntrCont != null)
                {
                    xCntrCont.addControl(sName, OuterScrlContr as XControl);
                }

                #endregion

                #region Scroll bars

                //insert scroll bars
                HorizontalScrlBar = insertHorizontalScrollBar(this, _nPosX, _nPosY + _nHeight, _nWidth);
                VerticalScrlBar   = insertVerticalScrollBar(this, _nPosX + _nWidth, _nPosY, _nHeight);

                #endregion

                #region Set Size of outer Container

                //make the outer container pos and size via the pos and size of the scroll bars
                if (HorizontalScrlBar is XWindow)
                {
                    Rectangle hSBPos = ((XWindow)HorizontalScrlBar).getPosSize();
                    _width = hSBPos.Width;
                    _posX  = hSBPos.X;
                }
                if (VerticalScrlBar is XWindow)
                {
                    Rectangle vSBPos = ((XWindow)VerticalScrlBar).getPosSize();
                    _height = vSBPos.Height;
                    _posY   = vSBPos.Y;
                }

                // Set the size of the surrounding container
                if (OuterScrlContr is XWindow)
                {
                    ((XWindow)OuterScrlContr).setPosSize(PosX, PosY, Width, Height, PosSize.POSSIZE);
                    ((XWindow)OuterScrlContr).addMouseListener(this);
                }
                #endregion

                #region inner Container


                // create a control model at the multi service factory of the dialog model...
                innerScrlContrModel = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER_Model, MXContext) as XControlModel;
                InnerScrlContr      = _xMcf.createInstanceWithContext(AWT_UNO_CONTROL_CONTAINER, MXContext) as XControl;


                if (InnerScrlContr != null && innerScrlContrModel != null)
                {
                    InnerScrlContr.setModel(innerScrlContrModel);
                }

                XMultiPropertySet xinnerScrlContMPSet = innerScrlContrModel as XMultiPropertySet;

                if (xinnerScrlContMPSet != null)
                {
                    xinnerScrlContMPSet.setPropertyValues(
                        new String[] { "Name", "State" },
                        Any.Get(new Object[] { sName + "_S", ((short)0) }));
                }

                //// FIXME: only for fixing

                //util.Debug.GetAllServicesOfObject(parentCnt);

                //Object oDialogModel = OO.GetMultiComponentFactory().createInstanceWithContext(OO.Services.AWT_CONTROL_DIALOG_MODEL, MXContext);

                //// The named container is used to insert the created controls into...
                //MXDlgModelNameContainer = (XNameContainer)oDialogModel;

                //System.Diagnostics.Debug.WriteLine("_________");

                //util.Debug.GetAllServicesOfObject(MXDlgModelNameContainer);

                //// END

                //add inner container to the outer scroll container
                XControlContainer outerCntrCont = OuterScrlContr as XControlContainer;
                if (outerCntrCont != null)
                {
                    outerCntrCont.addControl(sName + "_S", InnerScrlContr as XControl);

                    InnerWidth  = Width;
                    InnerHeight = Height;

                    // Set the size of the surrounding container
                    if (InnerScrlContr is XWindow)
                    {
                        ((XWindow)InnerScrlContr).setPosSize(0, 0, InnerWidth, InnerHeight, PosSize.POSSIZE);
                        ((XWindow)InnerScrlContr).addMouseListener(this);
                    }
                }

                #endregion
            }
            catch (System.Exception) { }
        }