public ResizingContainer(int width, int height, string sName)
        {
            #region inner Container

            // create a control model at the multi service factory of the dialog model...
            innerScrlContrModel = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER_Model) as XControlModel;
            innerScrlContr      = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER) 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, ((short)0) }));
            }

            innerWidth  = width;
            innerHeight = height;

            // Set the size of the surrounding container
            if (innerScrlContr is XWindow)
            {
                ((XWindow)innerScrlContr).setPosSize(0, 0, innerWidth, innerHeight, PosSize.POSSIZE);
            }

            #endregion
        }
Beispiel #2
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) { }
        }
        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) { }
        }
        public ResizingContainer(int width, int height, string sName)
        {

            #region inner Container

            // create a control model at the multi service factory of the dialog model...
            innerScrlContrModel = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER_Model) as XControlModel;
            innerScrlContr = OO.GetMultiServiceFactory(MXContext).createInstance(AWT_UNO_CONTROL_CONTAINER) 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 , ((short)0) }));
            }

            innerWidth = width;
            innerHeight = height;

            // Set the size of the surrounding container
            if (innerScrlContr is XWindow)
            {
                ((XWindow)innerScrlContr).setPosSize(0, 0, innerWidth, innerHeight, PosSize.POSSIZE);
            }

            #endregion

        }
        public static XControlContainer createDialog(XMultiComponentFactory xMultiComponentFactory, XComponentContext xContext,
                                                     int posX, int posY, int width, int height, string title
                                                     )
        {
            //dialog model
            Object oDialogModel = xMultiComponentFactory.createInstanceWithContext(
                "com.sun.star.awt.UnoControlDialogModel", xContext);


            XPropertySet xPSetDialog = (XPropertySet)oDialogModel;

            xPSetDialog.setPropertyValue("PositionX", Any.Get(posX));
            xPSetDialog.setPropertyValue("PositionY", Any.Get(posY));
            xPSetDialog.setPropertyValue("Width", Any.Get(width));
            xPSetDialog.setPropertyValue("Height", Any.Get(height));
            xPSetDialog.setPropertyValue("Title", Any.Get(title));

            // get service manager from  dialog model
            XMultiServiceFactory MXMsfDialogModel = (XMultiServiceFactory)oDialogModel;

            // dialog control model
            Object oUnoDialog = xMultiComponentFactory.createInstanceWithContext(
                "com.sun.star.awt.UnoControlDialog", xContext);


            XControl      MXDialogControl = (XControl)oUnoDialog;
            XControlModel xControlModel   = (XControlModel)oDialogModel;

            MXDialogControl.setModel(xControlModel);



            XToolkit xToolkit = (XToolkit)xMultiComponentFactory
                                .createInstanceWithContext("com.sun.star.awt.Toolkit",
                                                           xContext);

            WindowDescriptor aDescriptor = new WindowDescriptor();

            aDescriptor.Type = WindowClass.TOP;
            aDescriptor.WindowServiceName = "";
            aDescriptor.ParentIndex       = -1;
            aDescriptor.Parent            = xToolkit.getDesktopWindow();
            aDescriptor.Bounds            = new Rectangle(100, 200, 300, 400);

            aDescriptor.WindowAttributes = WindowAttribute.BORDER
                                           | WindowAttribute.MOVEABLE | WindowAttribute.SIZEABLE
                                           | WindowAttribute.CLOSEABLE;

            XWindowPeer xPeer = xToolkit.createWindow(aDescriptor);

            XWindow xWindow = (XWindow)xPeer;

            xWindow.setVisible(false);
            MXDialogControl.createPeer(xToolkit, xPeer);

            // execute the dialog
            XDialog xDialog = (XDialog)oUnoDialog;

            xDialog.execute();

            // dispose the dialog
            XComponent xComponent = (XComponent)oUnoDialog;

            xComponent.dispose();

            return(oUnoDialog as XControlContainer);
        }