Grammalecte  Check-in [f015dc603b]

Overview
Comment:[lo] options dialog: tabs (draft)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: f015dc603b562ff1a6dc8ce22efd2d48b1747a6be44bb9cda3c9b0d737978ec5
User & Date: olr on 2019-07-17 10:19:51
Other Links: manifest | tags
Context
2019-07-17
10:25
[fr] phonet_simil: scan / scanne check-in: b49a83c9df user: olr tags: fr, trunk
10:19
[lo] options dialog: tabs (draft) check-in: f015dc603b user: olr tags: lo, trunk
10:19
[lo] helpers: get product name and version check-in: f249f05cff user: olr tags: lo, trunk
Changes

Modified gc_core/py/oxt/Options.py from [baf12f1015] to [1edac42d1a].

    51     51   
    52     52       def __init__ (self, ctx):
    53     53           self.ctx = ctx
    54     54           self.xSvMgr = self.ctx.ServiceManager
    55     55           self.xContainer = None
    56     56   
    57     57       def _addWidget (self, name, wtype, x, y, w, h, **kwargs):
    58         -        xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
           58  +        if wtype.startswith("com."):
           59  +            xWidget = self.xDialog.createInstance(wtype)
           60  +        else:
           61  +            xWidget = self.xDialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
    59     62           xWidget.Name = name
    60     63           xWidget.PositionX = x
    61     64           xWidget.PositionY = y
    62     65           xWidget.Width = w
    63     66           xWidget.Height = h
    64     67           for k, w in kwargs.items():
    65     68               setattr(xWidget, k, w)
................................................................................
    91     94               # build
    92     95               y = 0
    93     96               nWidth = self.xDialog.Width - 20
    94     97               nHeight = 10
    95     98   
    96     99               self.lOptionWidgets = []
    97    100   
    98         -            for t in gce.gc_options.lStructOpt:
    99         -                x = 10
   100         -                y += 10
   101         -                self._addWidget(t[0], 'FixedLine', x, y, nWidth, nHeight, Label = dOptionUI.get(t[0], "#err")[0], FontDescriptor= xFDTitle)
   102         -                y += 3
   103         -                for lOptLine in t[1]:
   104         -                    x = 15
          101  +            sProdName, sVersion = helpers.getProductNameAndVersion()
          102  +            if True:
          103  +                # no tab available (bug)
          104  +                for sOptionType, lOptions in gce.gc_options.lStructOpt:
          105  +                    x = 10
   105    106                       y += 10
   106         -                    n = len(lOptLine)
   107         -                    for sOpt in lOptLine:
   108         -                        w = self._addWidget(sOpt, 'CheckBox', x, y, nWidth/n, nHeight, \
   109         -                                            Label = dOptionUI.get(sOpt, "#err")[0], HelpText = dOptionUI.get(sOpt, "#err")[1])
   110         -                        self.lOptionWidgets.append(w)
   111         -                        x += nWidth / n
   112         -
   113         -            self.xDialog.Height = y + 40
          107  +                    self._addWidget(sOptionType, 'FixedLine', x, y, nWidth, nHeight, Label = dOptionUI.get(sOptionType, "#err")[0], FontDescriptor= xFDTitle)
          108  +                    y += 3
          109  +                    for lOptLine in lOptions:
          110  +                        x = 15
          111  +                        y += 10
          112  +                        n = len(lOptLine)
          113  +                        for sOpt in lOptLine:
          114  +                            sLabel, sHelpText = dOptionUI.get(sOpt, "#err")
          115  +                            xOpt = self._addWidget(sOpt, 'CheckBox', x, y, nWidth/n, nHeight, Label = sLabel, HelpText = sHelpText)
          116  +                            self.lOptionWidgets.append(xOpt)
          117  +                            x += nWidth / n
          118  +                self.xDialog.Height = y + 40
          119  +            else:
          120  +                # we can use tabs
          121  +                xTabPageContainer = self._addWidget("tabs", "com.sun.star.awt.tab.UnoControlTabPageContainerModel", 10, 10, nWidth, 100)
          122  +                xTabPage1 = xTabPageContainer.createTabPage(0);
          123  +                xTabPage1.Title = "Page 1"
          124  +                xTabPage2 = xTabPageContainer.createTabPage(1);
          125  +                xTabPage2.Title = "Page 2"
          126  +                xTabPageContainer.insertByIndex(0, xTabPage1);
          127  +                xTabPageContainer.insertByIndex(1, xTabPage2);
          128  +                self.xDialog.Height = 300
   114    129   
   115    130               xWindowSize = helpers.getWindowSize()
   116    131               self.xDialog.PositionX = int((xWindowSize.Width / 2) - (self.xDialog.Width / 2))
   117    132               self.xDialog.PositionY = int((xWindowSize.Height / 2) - (self.xDialog.Height / 2))
   118    133   
   119    134               self._addWidget('default', 'Button', 10, self.xDialog.Height-20, 50, 14, \
   120    135                               Label = dUI.get('default', "#err"), FontDescriptor = xFDBut, TextColor = 0x000044)