Jianw
2025-05-13 3b39fe3810c3ee2ec9ec97236c1769c5c85e062c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
-- Copyright 2011-17 Paul Kulchenko, ZeroBrane LLC
---------------------------------------------------------
 
local ide = ide
-- ---------------------------------------------------------------------------
-- Create the Help menu and attach the callback functions
 
local frame = ide.frame
local menuBar = frame.menuBar
local mobdebug = require "mobdebug"
 
local product = ide:GetProperty("help", "zerobranestudio")
local url = "http://zerobrane.com/r/"..product.."-"
local urls = {
  [ID_HELPPROJECT] = "main",
  [ID_HELPDOCUMENTATION] =  "documentation",
  [ID_HELPGETTINGSTARTED] = "gettingstarted",
  [ID_HELPTUTORIALS] = "tutorials",
  [ID_HELPFAQ] = "faq",
  [ID_HELPCOMMUNITY] = "community",
}
 
local helpMenu = ide:MakeMenu {
  { ID_ABOUT, TR("&About")..KSC(ID_ABOUT), TR("About %s"):format(ide:GetProperty("editor")) },
  { ID_HELPPROJECT, TR("&Project Page")..KSC(ID_HELPPROJECT) },
  { ID_HELPDOCUMENTATION, TR("&Documentation")..KSC(ID_HELPDOCUMENTATION) },
  { ID_HELPGETTINGSTARTED, TR("&Getting Started Guide")..KSC(ID_HELPGETTINGSTARTED) },
  { ID_HELPTUTORIALS, TR("&Tutorials")..KSC(ID_HELPTUTORIALS) },
  { ID_HELPFAQ, TR("&Frequently Asked Questions")..KSC(ID_HELPFAQ) },
  { ID_HELPCOMMUNITY, TR("&Community")..KSC(ID_HELPCOMMUNITY) },
}
-- do not translate Help menu on Mac as it won't merge with "standard" menus
menuBar:Append(helpMenu, ide.osname == 'Macintosh' and "&Help" or TR("&Help"))
 
local function displayAbout(event)
  local logo = ide:GetAppName().."/"..ide:GetProperty("logo")
  local logoimg = wx.wxFileName(logo):FileExists() and
    ([[<tr><td><img src="%s"></td></tr>]]):format(logo) or ""
  local ed = ide:GetEditor() or ide:CreateBareEditor()
  local page = ([[
    <html>
      <body text="#777777">
    <table border="0" width="100%%">
      %s
      <tr><td>
    <table cellspacing="3" cellpadding="3" width="100%%">
      <tr>
        <td>
        <b>ZeroBrane Studio (%s; MobDebug %s)</b><br>
        <b>Copyright &copy; 2011-2020 ZeroBrane LLC</b><br>
        Paul Kulchenko<br>
        Licensed under the MIT License.
        </td>
      </tr>
      <tr>
        <td>
                <b>Built with %s</b>
        </td>
      </tr>
      <tr>
        <td>
        <b>Based on Estrela Editor</b><br>
        <b>Copyright &copy; 2008-2011 Luxinia DevTeam</b><br>
        Christoph Kubisch, Eike Decker<br>
        Licensed under the MIT License.
        </td>
        <td><img align="right" src="%s/res/estrela.png"></td>
      </tr>
      <tr>
        <td>
        <b>Based on wxLua editor</b><br>
        <b>Copyright &copy; 2002-2005 Lomtick Software</b><br>
        J. Winwood, John Labenski<br>
        Licensed under wxWindows Library License, v3.
        </td>
      </tr>
    </table>
    </td></tr></table>
      </body>
    </html>]])
  :format(logoimg, ide.VERSION, mobdebug._VERSION, table.concat({
      wx.wxVERSION_STRING,
      wxlua.wxLUA_VERSION_STRING,
      ide:IsValidProperty(ed, "GetLibraryVersionInfo") and ed:GetLibraryVersionInfo():GetVersionString() or nil,
    }, ", "), ide:GetAppName())
 
  local dlg = wx.wxDialog(frame, wx.wxID_ANY, TR("About %s"):format(ide:GetProperty("editor")))
 
  -- this is needed because wxLuaHtmlWindow only seems to take into account
  -- the initial size, but not the one set with SetSize using
  -- wxlua 2.8.12.2 and wxwidgets 2.9.5+.
  local tmp = wx.wxLuaHtmlWindow(dlg, wx.wxID_ANY, wx.wxDefaultPosition, wx.wxSize(450, 260))
  tmp:SetPage(page)
  local w = tmp:GetInternalRepresentation():GetWidth()
  local h = tmp:GetInternalRepresentation():GetHeight()
  tmp:Destroy()
 
  local html = wx.wxLuaHtmlWindow(dlg, wx.wxID_ANY,
    wx.wxDefaultPosition, wx.wxSize(w, h), wx.wxHW_SCROLLBAR_NEVER)
 
  html:SetBorders(0)
  html:SetPage(page)
 
  local line = wx.wxStaticLine(dlg, wx.wxID_ANY)
  local button = wx.wxButton(dlg, wx.wxID_OK, "OK")
  button:SetDefault()
 
  local topsizer = wx.wxBoxSizer(wx.wxVERTICAL)
  topsizer:Add(html, 1, wx.wxEXPAND + wx.wxALL, 10)
  topsizer:Add(line, 0, wx.wxEXPAND + wx.wxLEFT + wx.wxRIGHT, 10)
  topsizer:Add(button, 0, wx.wxALL + wx.wxALIGN_RIGHT, 10)
 
  dlg:SetSizerAndFit(topsizer)
  dlg:ShowModal()
  dlg:Destroy()
end
 
frame:Connect(ID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, displayAbout)
for item, page in pairs(urls) do
  frame:Connect(item, wx.wxEVT_COMMAND_MENU_SELECTED,
    function() wx.wxLaunchDefaultBrowser(url..page, 0) end)
end