class NavBar(Composite):

    def __init__(self, owner):
        Composite.__init__(self)
        self.owner = owner
        self.bar = DockPanel()
        self.gotoFirst = Button("<<", self)
        self.gotoNext = Button(">", self)
        self.gotoPrev = Button("<", self)
        self.status = HTML()
        
        self.initWidget(self.bar)
        self.bar.setStyleName("navbar")
        self.status.setStyleName("status")
        
        buttons = HorizontalPanel()
        buttons.add(self.gotoFirst)
        buttons.add(self.gotoPrev)
        buttons.add(self.gotoNext)
        self.bar.add(buttons, DockPanel.EAST)
        self.bar.setCellHorizontalAlignment(buttons, HasAlignment.ALIGN_RIGHT)
        self.bar.add(self.status, DockPanel.CENTER)
        self.bar.setVerticalAlignment(HasAlignment.ALIGN_MIDDLE)
        self.bar.setCellHorizontalAlignment(self.status, HasAlignment.ALIGN_RIGHT)
        self.bar.setCellVerticalAlignment(self.status, HasAlignment.ALIGN_MIDDLE)
        self.bar.setCellWidth(self.status, "100%")
        
        self.gotoPrev.setEnabled(False)
        self.gotoFirst.setEnabled(False)
        
    def onClick(self, sender):
        if sender == self.gotoNext:
            self.owner.startRow += self.owner.getDataRowCount()
            self.owner.refresh()
        elif sender == self.gotoPrev:
            self.owner.startRow -= self.owner.getDataRowCount()
            if self.owner.startRow < 0:
                self.owner.startRow = 0
            self.owner.refresh()
        elif sender == self.gotoFirst:
            self.owner.startRow = 0
            self.owner.refresh()
Пример #2
0
class DockPanelTest:

    def onModuleLoad(self):
        self.panel=DockPanel()
        
        east = Label("east")
        self.panel.add(east, DockPanel.EAST)
        self.panel.add(Label("west"), DockPanel.WEST)
        self.panel.add(Label("north"), DockPanel.NORTH)
        self.panel.add(Label("south"), DockPanel.SOUTH)
        self.south2 = Label("south2")
        self.panel.add(self.south2, DockPanel.SOUTH)
        self.center = Label("center")
        self.panel.add(self.center, DockPanel.CENTER)

        self.panel.setWidth("300px")
        self.panel.setHeight("300px")

        self.panel.setBorderWidth("1px")

        self.panel.setCellVerticalAlignment(east, HasAlignment.ALIGN_BOTTOM)
        self.panel.setCellHorizontalAlignment(east, HasAlignment.ALIGN_RIGHT)


        self.r = Button("remove", self)
        self.a = Button("add", self)

        RootPanel().add(self.panel)
        RootPanel().add(self.r)
        RootPanel().add(self.a)

    def onClick(self, sender):

        if sender == self.r:
            self.center.removeFromParent()
            self.south2.removeFromParent()
        if sender == self.a:
            self.panel.add(self.south2, DockPanel.SOUTH)
            self.panel.add(self.center, DockPanel.CENTER)
Пример #3
0
class KitchenSink:

    def onHistoryChanged(self, token):
        print "history changed", token
        info = self.sink_list.find(token)
        if info:
            self.show(info, False)
        else:
            self.showInfo()

    def onModuleLoad(self):
        self.curInfo=''
        self.curSink=None
        self.description=HTML()
        self.sink_list=SinkList()
        self.panel=DockPanel()
        
        self.loadSinks()
        self.sinkContainer = DockPanel()
        self.sinkContainer.setStyleName("ks-Sink")

        vp=VerticalPanel()
        vp.setWidth("100%")
        vp.add(self.description)
        vp.add(self.sinkContainer)

        self.description.setStyleName("ks-Info")

        self.panel.add(self.sink_list, DockPanel.WEST)
        self.panel.add(vp, DockPanel.CENTER)

        self.panel.setCellVerticalAlignment(self.sink_list, HasAlignment.ALIGN_TOP)
        self.panel.setCellWidth(vp, "100%")

        History().addHistoryListener(self)
        RootPanel().add(self.panel)
        #RootPanel().add(Logger())

        #Show the initial screen.
        initToken = History().getToken()
        if len(initToken):
            self.onHistoryChanged(initToken)
        else:
			self.showInfo()

    def show(self, info, affectHistory):
        if info == self.curInfo: return
        self.curInfo = info

        #Logger().write("", "showing " + info.getName())
        if self.curSink <> None:
            self.curSink.onHide()
            #Logger().write("", "removing " + self.curSink)
            self.sinkContainer.remove(self.curSink)

        self.curSink = info.getInstance()
        self.sink_list.setSinkSelection(info.getName())
        self.description.setHTML(info.getDescription())

        if (affectHistory):
            History().newItem(info.getName())

        self.sinkContainer.add(self.curSink, DockPanel.CENTER)
        self.sinkContainer.setCellWidth(self.curSink, "100%")
        self.sinkContainer.setCellHeight(self.curSink, "100%")
        self.sinkContainer.setCellVerticalAlignment(self.curSink, HasAlignment.ALIGN_TOP)
        self.curSink.onShow()
        
    def loadSinks(self):
        self.sink_list.addSink(Info.init())
        self.sink_list.addSink(Buttons.init())
        self.sink_list.addSink(Menus.init())
        self.sink_list.addSink(Images.init())
        self.sink_list.addSink(Layouts.init())
        self.sink_list.addSink(Lists.init())
        self.sink_list.addSink(Popups.init())
        self.sink_list.addSink(Tables.init())
        self.sink_list.addSink(Text.init())
        self.sink_list.addSink(Trees.init())
        self.sink_list.addSink(Frames.init())
        self.sink_list.addSink(Tabs.init())

    def showInfo(self):
        self.show(self.sink_list.find("Info"), False)