mirror of
https://github.com/tnodir/fort
synced 2024-11-15 03:46:13 +00:00
UI: Add some controls to window.
This commit is contained in:
parent
7899c7a5dd
commit
8f5b7493a8
@ -31,6 +31,7 @@ end
|
||||
-- Initialize IUP
|
||||
iup.SetGlobal("UTF8MODE", "YES")
|
||||
iup.SetGlobal("UTF8MODE_FILE", "YES")
|
||||
iup.SetGlobal("DEFAULTFONTSIZE", 11)
|
||||
|
||||
|
||||
-- Check running instance
|
||||
@ -65,6 +66,7 @@ do
|
||||
if iup.LoopStep() == iup.CLOSE then
|
||||
evq:stop()
|
||||
end
|
||||
iup.Flush()
|
||||
end
|
||||
|
||||
local evq = sys.event_queue()
|
||||
|
@ -9,3 +9,13 @@ err_conf_size = "Size of configuration is too big"
|
||||
|
||||
ui_tray_show = "Show"
|
||||
ui_tray_quit = "Quit"
|
||||
|
||||
ui_tab_options = "Options"
|
||||
ui_tab_addresses = "IPv4 Addresses"
|
||||
ui_tab_apps = "Applications"
|
||||
|
||||
ui_opt_autostart = "Start with Windows"
|
||||
ui_opt_filter_disabled = "Filtering disabled"
|
||||
|
||||
ui_win_ok = "OK"
|
||||
ui_win_cancel = "Cancel"
|
||||
|
@ -14,6 +14,10 @@ local function window_show()
|
||||
window:show()
|
||||
end
|
||||
|
||||
local function window_hide()
|
||||
window:hide()
|
||||
end
|
||||
|
||||
local function window_quit()
|
||||
window:destroy()
|
||||
return iup.CLOSE
|
||||
@ -23,8 +27,8 @@ local function menu_show()
|
||||
menu:popup(iup.MOUSEPOS, iup.MOUSEPOS)
|
||||
end
|
||||
|
||||
local function on_trayclick(self, b, press)
|
||||
if press == 0 then
|
||||
local function on_tray_click(self, b, press)
|
||||
if press == 1 then
|
||||
if b == 1 then
|
||||
window_show()
|
||||
else
|
||||
@ -34,11 +38,34 @@ local function on_trayclick(self, b, press)
|
||||
return iup.DEFAULT
|
||||
end
|
||||
|
||||
local function on_windowclose()
|
||||
window:hide()
|
||||
local function on_window_close()
|
||||
window_hide()
|
||||
return iup.IGNORE
|
||||
end
|
||||
|
||||
local function on_window_apply()
|
||||
window_hide()
|
||||
end
|
||||
|
||||
local function on_window_cancel()
|
||||
window_hide()
|
||||
end
|
||||
|
||||
|
||||
local function create_toggle(title, action_cb)
|
||||
return iup.toggle{
|
||||
title = title, padding = 8,
|
||||
action = action_cb
|
||||
}
|
||||
end
|
||||
|
||||
local function create_button(title, action_cb)
|
||||
return iup.button{
|
||||
title = title, padding = 8,
|
||||
action = action_cb
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
-- Menu
|
||||
local function menu_init()
|
||||
@ -62,12 +89,41 @@ end
|
||||
function ui_window.init(window_title)
|
||||
|
||||
-- Initialize Window
|
||||
local btn_apply = create_button(i18n.tr("ui_win_ok"), on_window_apply)
|
||||
local btn_cancel = create_button(i18n.tr("ui_win_cancel"), on_window_cancel)
|
||||
|
||||
window = iup.dialog{
|
||||
iup.label{title = "Test Main Window"};
|
||||
title = window_title, tray = "YES", hidetaskbar = "YES",
|
||||
iup.vbox{
|
||||
iup.tabs{
|
||||
-- Options
|
||||
iup.vbox{
|
||||
create_toggle(i18n.tr("ui_opt_autostart"), on_opt_autostart),
|
||||
create_toggle(i18n.tr("ui_opt_filter_disabled"), on_opt_filter_disabled);
|
||||
tabtitle = i18n.tr("ui_tab_options")
|
||||
},
|
||||
-- IPv4 Addresses
|
||||
iup.hbox{
|
||||
iup.multiline{expand = "YES"},
|
||||
iup.multiline{expand = "YES"};
|
||||
tabtitle = i18n.tr("ui_tab_addresses")
|
||||
},
|
||||
-- Applications
|
||||
iup.vbox{
|
||||
tabtitle = i18n.tr("ui_tab_apps")
|
||||
}
|
||||
},
|
||||
iup.hbox{
|
||||
iup.fill{}, btn_apply, btn_cancel;
|
||||
gap = 10
|
||||
};
|
||||
gap = 2, margin = "2x2"
|
||||
};
|
||||
title = window_title, traytip = window_title,
|
||||
shrink = "YES", hidetaskbar = "YES", tray = "YES",
|
||||
icon = "images/shield.ico", trayimage = "images/shield.ico",
|
||||
traytip = window_title,
|
||||
trayclick_cb = on_trayclick, close_cb = on_windowclose,
|
||||
size = "HALFxHALF", minsize = "750x750", saveunder = "NO",
|
||||
defaultenter = btn_apply, defaultesc = btn_cancel,
|
||||
trayclick_cb = on_tray_click, close_cb = on_window_close,
|
||||
copydata_cb = window_show
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user