Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- MCNet Mail UI
- Read message pane
- ]]--
- ui = ui or {}
- local ReadPane = common.newClass({
- horizontal = false,
- message = nil,
- -- Field labels
- fromLabel = "From:",
- toLabel = "To: "
- }, ccgui.FlowContainer)
- ui.ReadPane = ReadPane
- function ReadPane:init()
- ccgui.FlowContainer.init(self)
- self.header = ccgui.FlowContainer:new{
- horizontal = true,
- padding = ccgui.newMargins(0, 0, 1),
- spacing = 1
- }
- self.fields = ccgui.FlowContainer:new{
- horizontal = false,
- stretch = true
- }
- local from = ccgui.FlowContainer:new{
- horizontal = true,
- spacing = 1
- }
- self.fromLabel = ccgui.TextElement:new{
- text = self.fromLabel
- }
- self.fromField = ccgui.TextElement:new{
- stretch = true
- }
- local to = ccgui.FlowContainer:new{
- horizontal = true,
- spacing = 1
- }
- self.toLabel = ccgui.TextElement:new{
- text = self.toLabel
- }
- self.toField = ccgui.TextElement:new{
- stretch = true
- }
- self.messageField = ccgui.TextViewer:new{
- stretch = true
- }
- -- Set message
- self:setMessage(self.message)
- -- Add elements
- from:add(self.fromLabel, self.fromField)
- to:add(self.toLabel, self.toField)
- self.fields:add(from, to)
- self.header:add(self.fields, self:toolbar())
- self:add(self.header, self.messageField)
- end
- function ReadPane:setMessage(msg)
- self.message = msg
- msg = mcnet.message.pack(msg)
- self.fromField:setText(tostring(msg.from))
- self.toField:setText(tostring(msg.to))
- self.messageField:setText(tostring(msg.data))
- end
- function ReadPane:toolbar()
- return ccgui.TextElement:new()
- end
Advertisement
Add Comment
Please, Sign In to add comment