2012-09-27 20:32:27 +00:00
|
|
|
/*
|
|
|
|
bug.n -- tiling window management
|
2015-01-25 12:07:37 +00:00
|
|
|
Copyright (c) 2010-2015 Joshua Fuhs, joten
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-01-25 12:07:37 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-09-27 20:32:27 +00:00
|
|
|
GNU General Public License for more details.
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-01-25 12:07:37 +00:00
|
|
|
@license GNU General Public License version 3
|
|
|
|
../LICENSE.md or <http://www.gnu.org/licenses/>
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2015-01-25 13:04:17 +00:00
|
|
|
@version 9.0.0
|
2012-09-27 20:32:27 +00:00
|
|
|
*/
|
2011-07-27 17:43:34 +00:00
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_init(m)
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Local appBarMsg, GuiN, h1, h2, i, text, titleWidth, trayWndId, w, wndId, wndTitle, wndWidth, x1, x2, y1, y2
|
2012-12-05 12:39:51 +00:00
|
|
|
|
|
|
|
If (SubStr(Config_barWidth, 0) = "%")
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
StringTrimRight, wndWidth, Config_barWidth, 1
|
|
|
|
wndWidth := Round(Monitor_#%m%_width * wndWidth / 100)
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
2012-10-02 10:11:00 +00:00
|
|
|
Else
|
2012-09-27 20:32:27 +00:00
|
|
|
wndWidth := Config_barWidth
|
2014-12-13 15:12:38 +00:00
|
|
|
|
|
|
|
wndWidth := Round(wndWidth * Config_scalingFactor)
|
|
|
|
If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor) {
|
|
|
|
Bar_ctrlHeight := Round(Bar_ctrlHeight * Config_scalingFactor)
|
|
|
|
Bar_height := Round(Bar_height * Config_scalingFactor)
|
|
|
|
}
|
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
Monitor_#%m%_barWidth := wndWidth
|
|
|
|
titleWidth := wndWidth
|
|
|
|
h1 := Bar_ctrlHeight
|
|
|
|
x1 := 0
|
|
|
|
x2 := wndWidth
|
|
|
|
y1 := 0
|
|
|
|
y2 := (Bar_ctrlHeight - Bar_textHeight) / 2
|
|
|
|
h2 := Bar_ctrlHeight - 2 * y2
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-10-02 10:11:00 +00:00
|
|
|
;; Create the GUI window
|
2012-09-27 20:32:27 +00:00
|
|
|
wndTitle := "bug.n_BAR_" m
|
|
|
|
GuiN := (m - 1) + 1
|
2012-09-28 15:46:17 +00:00
|
|
|
Debug_logMessage("DEBUG[6] Bar_init(): Gui, " . GuiN . ": Default", 6)
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, %GuiN%: Default
|
2012-10-01 19:20:45 +00:00
|
|
|
Gui, Destroy
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, +AlwaysOnTop -Caption +LabelBar_Gui +LastFound +ToolWindow
|
|
|
|
Gui, Color, %Config_normBgColor1%
|
|
|
|
Gui, Font, c%Config_normFgColor1% s%Config_fontSize%, %Config_fontName%
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-10-02 10:11:00 +00:00
|
|
|
;; Tags
|
2012-12-05 12:39:51 +00:00
|
|
|
Loop, % Config_viewCount
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
i := A_Index
|
|
|
|
text := " " Config_viewNames_#%i% " "
|
|
|
|
w := Bar_getTextWidth(text)
|
2012-12-05 12:39:51 +00:00
|
|
|
Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_view gBar_GuiClick,
|
2012-09-27 20:32:27 +00:00
|
|
|
If (w <= h1)
|
|
|
|
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor1% Vertical vBar_#%m%_#%i%_tagged
|
|
|
|
Else
|
|
|
|
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor1% vBar_#%m%_#%i%_tagged
|
|
|
|
Gui, Add, Text, x%x1% y%y2% w%w% h%h2% -Wrap Center BackgroundTrans vBar_#%m%_#%i%, %text%
|
|
|
|
titleWidth -= w
|
|
|
|
x1 += w
|
|
|
|
}
|
2012-10-02 10:11:00 +00:00
|
|
|
;; Layout
|
2012-09-27 20:32:27 +00:00
|
|
|
i := Config_viewCount + 1
|
2012-09-30 20:36:42 +00:00
|
|
|
text := " ?????? "
|
2012-09-27 20:32:27 +00:00
|
|
|
w := Bar_getTextWidth(text)
|
2012-12-05 12:39:51 +00:00
|
|
|
Gui, Add, Text, x%x1% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i%_layout gBar_GuiClick,
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, Add, Progress, x%x1% y%y1% w%w% h%h1% Background%Config_normBgColor2%
|
|
|
|
Gui, Font, c%Config_normFgColor2%
|
|
|
|
Gui, Add, Text, x%x1% y%y2% w%w% h%h2% -Wrap Center BackgroundTrans vBar_#%m%_#%i%, %text%
|
|
|
|
titleWidth -= w
|
|
|
|
x1 += w
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-10-02 10:11:00 +00:00
|
|
|
;; The x-position and width of the sub-windows right of the window title are set from the right.
|
2014-10-02 08:14:57 +00:00
|
|
|
;; @TODO [v9] Maybe add a field (including a progress bar) for sound volume information.
|
2012-12-05 12:39:51 +00:00
|
|
|
Loop, 4
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
i := Config_viewCount + 7 - A_Index
|
|
|
|
w := 0
|
2012-12-05 12:39:51 +00:00
|
|
|
If (i = Config_viewCount + 6)
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; Command gui
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, -Disabled
|
|
|
|
w := Bar_getTextWidth(" ?? ")
|
|
|
|
x2 -= w
|
|
|
|
titleWidth -= w
|
2012-12-05 12:39:51 +00:00
|
|
|
Gui, Add, Text, x%x2% y%y1% w%w% h%h1% BackgroundTrans vBar_#%m%_#%i% gBar_toggleCommandGui,
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2%
|
|
|
|
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans, #!
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else If (i = Config_viewCount + 5) And Config_readinTime
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; Time
|
2012-09-27 20:32:27 +00:00
|
|
|
w := Bar_getTextWidth(" ??:?? ")
|
|
|
|
x2 -= w
|
|
|
|
titleWidth -= w
|
2012-12-05 12:39:51 +00:00
|
|
|
If Config_readinAny() Or Config_readinBat
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, Font, c%Config_normFgColor1%
|
2012-12-05 12:39:51 +00:00
|
|
|
Gui, Add, Text, x%x2% y%y1% w%w% h%h1%,
|
2012-09-27 20:32:27 +00:00
|
|
|
}
|
|
|
|
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, ??:??
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else If (i = Config_viewCount + 4) And Config_readinAny()
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; Any
|
2012-09-27 20:32:27 +00:00
|
|
|
text := Config_readinAny()
|
|
|
|
w := Bar_getTextWidth(text)
|
|
|
|
x2 -= w
|
|
|
|
titleWidth -= w
|
|
|
|
Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2%
|
|
|
|
Gui, Font, c%Config_normFgColor2%
|
|
|
|
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% Center BackgroundTrans vBar_#%m%_#%i%, %text%
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else If (i = Config_viewCount + 3) And Config_readinBat
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; Battery level
|
2012-09-27 20:32:27 +00:00
|
|
|
w := Bar_getTextWidth(" BAT: ???% ")
|
|
|
|
x2 -= w
|
|
|
|
titleWidth -= w
|
|
|
|
Gui, Add, Progress, x%x2% y%y1% w%w% h%h1% Background%Config_normBgColor2% c%Config_normFgColor3% vBar_#%m%_#%i%_tagged
|
|
|
|
Gui, Font, c%Config_normFgColor2%
|
|
|
|
Gui, Add, Text, x%x2% y%y2% w%w% h%h2% BackgroundTrans Center vBar_#%m%_#%i%, BAT: ???`%
|
|
|
|
}
|
|
|
|
}
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-10-02 10:11:00 +00:00
|
|
|
;; Window title (remaining space)
|
2012-12-05 12:39:51 +00:00
|
|
|
Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%,
|
|
|
|
If Not Config_singleRowBar
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
titleWidth := wndWidth
|
|
|
|
x1 := 0
|
|
|
|
y1 += h1
|
|
|
|
y2 += h1
|
|
|
|
}
|
|
|
|
i := Config_viewCount + 2
|
|
|
|
Gui, Font, c%Config_normFgColor1%
|
2012-12-05 12:39:51 +00:00
|
|
|
Gui, Add, Text, x%x1% y%y1% w%titleWidth% h%h1%,
|
|
|
|
Gui, Add, Text, x%x1% y%y2% w%titleWidth% h%h2% BackgroundTrans Center vBar_#%m%_#%i%,
|
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
If (Config_horizontalBarPos = "left")
|
|
|
|
x1 := 0
|
|
|
|
Else If (Config_horizontalBarPos = "right")
|
2014-12-13 15:12:38 +00:00
|
|
|
x1 := Monitor_#%m%_width - wndWidth / Config_scalingFactor
|
2012-09-27 20:32:27 +00:00
|
|
|
Else If (Config_horizontalBarPos = "center")
|
2014-12-13 15:12:38 +00:00
|
|
|
x1 := (Monitor_#%m%_width - wndWidth / Config_scalingFactor) / 2
|
|
|
|
Else If (Config_horizontalBarPos >= 0)
|
2012-09-27 20:32:27 +00:00
|
|
|
x1 := Config_horizontalBarPos
|
|
|
|
Else If (Config_horizontalBarPos < 0)
|
2014-12-13 15:12:38 +00:00
|
|
|
x1 := Monitor_#%m%_width - wndWidth / Config_scalingFactor + Config_horizontalBarPos
|
2012-09-27 20:32:27 +00:00
|
|
|
If Not (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor)
|
|
|
|
x1 += Monitor_#%m%_x
|
2014-12-13 15:12:38 +00:00
|
|
|
x1 := Round(x1)
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_#%m%_titleWidth := titleWidth
|
|
|
|
Monitor_#%m%_barX := x1
|
|
|
|
y1 := Monitor_#%m%_barY
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
If Monitor_#%m%_showBar
|
|
|
|
Gui, Show, NoActivate x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
|
|
|
|
Else
|
|
|
|
Gui, Show, NoActivate Hide x%x1% y%y1% w%wndWidth% h%Bar_height%, %wndTitle%
|
2014-09-30 11:08:48 +00:00
|
|
|
WinSet, Transparent, %Config_barTransparency%, %wndTitle%
|
2012-09-27 20:32:27 +00:00
|
|
|
wndId := WinExist(wndTitle)
|
2012-12-05 12:39:51 +00:00
|
|
|
If (Config_verticalBarPos = "tray" And m = Manager_taskBarMonitor)
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
trayWndId := WinExist("ahk_class Shell_TrayWnd")
|
|
|
|
DllCall("SetParent", "UInt", wndId, "UInt", trayWndId)
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
appBarMsg := DllCall("RegisterWindowMessage", Str, "AppBarMsg")
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-10-02 10:11:00 +00:00
|
|
|
;; appBarData: http://msdn2.microsoft.com/en-us/library/ms538008.aspx
|
2012-09-27 20:32:27 +00:00
|
|
|
VarSetCapacity(Bar_appBarData, 36, 0)
|
2012-12-15 19:56:18 +00:00
|
|
|
offset := NumPut( 36, Bar_appBarData)
|
|
|
|
offset := NumPut( wndId, offset+0)
|
|
|
|
offset := NumPut( appBarMsg, offset+0)
|
|
|
|
offset := NumPut( 1, offset+0)
|
|
|
|
offset := NumPut( x1, offset+0)
|
|
|
|
offset := NumPut( y1, offset+0)
|
|
|
|
offset := NumPut( x1 + wndWidth, offset+0)
|
|
|
|
offset := NumPut(y1 + Bar_height, offset+0)
|
|
|
|
offset := NumPut( 1, offset+0)
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_NEW := 0x0) , "UInt", &Bar_appBarData)
|
|
|
|
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_QUERYPOS := 0x2), "UInt", &Bar_appBarData)
|
|
|
|
DllCall("Shell32.dll\SHAppBarMessage", "UInt", (ABM_SETPOS := 0x3) , "UInt", &Bar_appBarData)
|
2012-10-02 10:11:00 +00:00
|
|
|
;; SKAN: Crazy Scripting : Quick Launcher for Portable Apps (http://www.autohotkey.com/forum/topic22398.html)
|
2012-09-27 20:32:27 +00:00
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_initCmdGui()
|
2012-10-01 18:06:48 +00:00
|
|
|
{
|
|
|
|
Global Bar_#0_#0, Bar_#0_#0H, Bar_#0_#0W, Bar_cmdGuiIsVisible, Config_barCommands, Config_fontName, Config_fontSize, Config_normBgColor1, Config_normFgColor1
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_cmdGuiIsVisible := False
|
|
|
|
wndTitle := "bug.n_BAR_0"
|
|
|
|
Gui, 99: Default
|
|
|
|
Gui, +LabelBar_cmdGui
|
|
|
|
IfWinExist, %wndTitle%
|
|
|
|
Gui, Destroy
|
2012-10-01 18:06:48 +00:00
|
|
|
Gui, +LastFound -Caption +ToolWindow +AlwaysOnTop +Delimiter`;
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, Color, Default
|
|
|
|
Gui, Font, s%Config_fontSize%, %Config_fontName%
|
2012-10-01 18:06:48 +00:00
|
|
|
StringSplit, cmd, Config_barCommands, `;
|
|
|
|
Gui, Add, ComboBox, x10 y0 r%cmd0% w300 Background%Config_normBgColor1% c%Config_normFgColor1% Simple vBar_#0_#0 gBar_cmdGuiEnter, % Config_barCommands
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, Add, Button, Y0 Hidden Default gBar_cmdGuiEnter, OK
|
|
|
|
GuiControlGet, Bar_#0_#0, Pos
|
2012-10-01 18:06:48 +00:00
|
|
|
Bar_#0_#0W += 20
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, Show, Hide w%Bar_#0_#0W% h%Bar_#0_#0H%, %wndTitle%
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Bar_cmdGuiEnter:
|
2015-01-25 21:26:17 +00:00
|
|
|
If (A_GuiControl = "OK") Or (A_GuiControl = "Bar_#0_#0" And A_GuiControlEvent = "DoubleClick") {
|
2012-10-01 18:06:48 +00:00
|
|
|
Gui, Submit, NoHide
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_cmdGuiIsVisible := False
|
|
|
|
Gui, Cancel
|
|
|
|
WinActivate, ahk_id %Bar_aWndId%
|
2012-10-01 18:06:48 +00:00
|
|
|
Main_evalCommand(Bar_#0_#0)
|
|
|
|
Bar_#0_#0 := ""
|
2012-09-27 20:32:27 +00:00
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
Return
|
|
|
|
|
2015-01-25 21:26:17 +00:00
|
|
|
Bar_cmdGuiEscape:
|
|
|
|
Bar_cmdGuiIsVisible := False
|
|
|
|
Gui, Cancel
|
|
|
|
WinActivate, ahk_id %Bar_aWndId%
|
|
|
|
Return
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_getHeight()
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Global Bar_#0_#1, Bar_#0_#1H, Bar_#0_#2, Bar_#0_#2H, Bar_ctrlHeight, Bar_height, Bar_textHeight
|
|
|
|
Global Config_fontName, Config_fontSize, Config_singleRowBar, Config_spaciousBar, Config_verticalBarPos
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
wndTitle := "bug.n_BAR_0"
|
|
|
|
Gui, 99: Default
|
|
|
|
Gui, Font, s%Config_fontSize%, %Config_fontName%
|
|
|
|
Gui, Add, Text, x0 y0 vBar_#0_#1, |
|
|
|
|
GuiControlGet, Bar_#0_#1, Pos
|
|
|
|
Bar_textHeight := Bar_#0_#1H
|
2012-12-05 12:39:51 +00:00
|
|
|
If Config_spaciousBar
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, Add, ComboBox, r9 x0 y0 vBar_#0_#2, |
|
|
|
|
GuiControlGet, Bar_#0_#2, Pos
|
|
|
|
Bar_ctrlHeight := Bar_#0_#2H
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
2012-10-02 10:11:00 +00:00
|
|
|
Else
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_ctrlHeight := Bar_textHeight
|
|
|
|
Gui, Destroy
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_height := Bar_ctrlHeight
|
|
|
|
If Not Config_singleRowBar
|
|
|
|
Bar_height *= 2
|
2012-12-05 12:39:51 +00:00
|
|
|
If (Config_verticalBarPos = "tray")
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
WinGetPos, , , , buttonH, Start ahk_class Button
|
|
|
|
WinGetPos, , , , barH, ahk_class Shell_TrayWnd
|
2013-01-17 20:21:28 +00:00
|
|
|
If WinExist("Start ahk_class Button") And (buttonH < barH)
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_height := buttonH
|
|
|
|
Else
|
|
|
|
Bar_height := barH
|
|
|
|
Bar_ctrlHeight := Bar_height
|
|
|
|
If Not Config_singleRowBar
|
|
|
|
Bar_ctrlHeight := Bar_height / 2
|
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_getTextWidth(x, reverse=False)
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Global Config_fontSize
|
2012-12-05 12:39:51 +00:00
|
|
|
|
|
|
|
If reverse
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; 'reverse' calculates the number of characters to a given width.
|
2012-09-27 20:32:27 +00:00
|
|
|
w := x
|
|
|
|
i := w / (Config_fontSize - 1)
|
|
|
|
If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13))
|
|
|
|
i := w / (Config_fontSize - 2)
|
|
|
|
Else If (Config_fontSize > 12 And Config_fontSize < 18)
|
|
|
|
i := w / (Config_fontSize - 3)
|
|
|
|
Else If (Config_fontSize > 17)
|
|
|
|
i := w / (Config_fontSize - 4)
|
|
|
|
textWidth := i
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; 'else' calculates the width to a given string.
|
2012-09-27 20:32:27 +00:00
|
|
|
textWidth := StrLen(x) * (Config_fontSize - 1)
|
|
|
|
If (Config_fontSize = 7 Or (Config_fontSize > 8 And Config_fontSize < 13))
|
|
|
|
textWidth := StrLen(x) * (Config_fontSize - 2)
|
|
|
|
Else If (Config_fontSize > 12 And Config_fontSize < 18)
|
|
|
|
textWidth := StrLen(x) * (Config_fontSize - 3)
|
|
|
|
Else If (Config_fontSize > 17)
|
|
|
|
textWidth := StrLen(x) * (Config_fontSize - 4)
|
|
|
|
}
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
Return, textWidth
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2011-09-02 17:46:07 +00:00
|
|
|
Bar_GuiClick:
|
2012-09-27 20:32:27 +00:00
|
|
|
Manager_winActivate(Bar_aWndId)
|
2012-12-05 12:39:51 +00:00
|
|
|
If (A_GuiEvent = "Normal")
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
|
|
|
|
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
|
|
|
|
If (SubStr(A_GuiControl, -6) = "_layout")
|
|
|
|
View_setLayout(-1)
|
|
|
|
Else If (SubStr(A_GuiControl, -4) = "_view")
|
|
|
|
Monitor_activateView(SubStr(A_GuiControl, InStr(A_GuiControl, "_#", False, 0) + 2, 1))
|
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
Return
|
|
|
|
|
2011-09-02 17:46:07 +00:00
|
|
|
Bar_GuiContextMenu:
|
2012-09-27 20:32:27 +00:00
|
|
|
Manager_winActivate(Bar_aWndId)
|
2012-12-05 12:39:51 +00:00
|
|
|
If (A_GuiEvent = "RightClick")
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-12-05 12:39:51 +00:00
|
|
|
If (SubStr(A_GuiControl, -6) = "_layout")
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
|
|
|
|
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
|
|
|
|
View_setLayout(">")
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else If (SubStr(A_GuiControl, -4) = "_view")
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
|
|
|
|
Manager_setWindowMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
|
|
|
|
Monitor_setWindowTag(SubStr(A_GuiControl, InStr(A_GuiControl, "_#", False, 0) + 2, 1))
|
|
|
|
}
|
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
Return
|
|
|
|
|
|
|
|
Bar_loop:
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_updateStatus()
|
2011-07-27 17:43:34 +00:00
|
|
|
Return
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_move(m)
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Local wndTitle, x, y
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
x := Monitor_#%m%_barX
|
|
|
|
y := Monitor_#%m%_barY
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
wndTitle := "bug.n_BAR_" m
|
|
|
|
WinMove, %wndTitle%, , %x%, %y%
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Bar_toggleCommandGui:
|
2012-09-27 20:32:27 +00:00
|
|
|
If Not Bar_cmdGuiIsVisible
|
|
|
|
If Not (SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) = Manager_aMonitor)
|
|
|
|
Manager_activateMonitor(SubStr(A_GuiControl, 6, InStr(A_GuiControl, "_#", False, 0) - 6) - Manager_aMonitor)
|
|
|
|
Bar_toggleCommandGui()
|
2011-07-27 17:43:34 +00:00
|
|
|
Return
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_toggleCommandGui()
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Local wndId, x, y
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, 99: Default
|
2012-12-05 12:39:51 +00:00
|
|
|
If Bar_cmdGuiIsVisible
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_cmdGuiIsVisible := False
|
|
|
|
Gui, Cancel
|
|
|
|
Manager_winActivate(Bar_aWndId)
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Bar_cmdGuiIsVisible := True
|
|
|
|
x := Monitor_#%Manager_aMonitor%_barX + Monitor_#%Manager_aMonitor%_barWidth - Bar_#0_#0W
|
2012-10-01 19:48:24 +00:00
|
|
|
If (Config_verticalBarPos = "top") Or (Config_verticalBarPos = "tray" And (Manager_taskBarPos = "top" Or Not Manager_aMonitor = Manager_taskBarMonitor))
|
2012-09-27 20:32:27 +00:00
|
|
|
y := Monitor_#%Manager_aMonitor%_y
|
|
|
|
Else
|
|
|
|
y := Monitor_#%Manager_aMonitor%_y + Monitor_#%Manager_aMonitor%_height - Bar_#0_#0H
|
|
|
|
Gui, Show
|
|
|
|
WinMove, bug.n_BAR_0, , %x%, %y%
|
|
|
|
GuiControl, Focus, % Bar_#0_#0
|
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_toggleVisibility(m)
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Local GuiN
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiN := (m - 1) + 1
|
2012-12-05 12:39:51 +00:00
|
|
|
If Monitor_#%m%_showBar
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
If Not (GuiN = 99) Or Bar_cmdGuiIsVisible
|
|
|
|
Gui, %GuiN%: Show
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
2012-10-02 10:11:00 +00:00
|
|
|
Else
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, %GuiN%: Cancel
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_updateLayout(m)
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Local aView, GuiN, i
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
aView := Monitor_#%m%_aView_#1
|
|
|
|
i := Config_viewCount + 1
|
|
|
|
GuiN := (m - 1) + 1
|
|
|
|
GuiControl, %GuiN%: , Bar_#%m%_#%i%, % View_#%m%_#%aView%_layoutSymbol
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_updateStatus()
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Local anyContent, anyText, b1, b2, b3, GuiN, i, m
|
2012-12-05 12:39:51 +00:00
|
|
|
|
|
|
|
Loop, % Manager_monitorCount
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
m := A_Index
|
|
|
|
GuiN := (m - 1) + 1
|
2012-09-28 15:46:17 +00:00
|
|
|
Debug_logMessage("DEBUG[6] Bar_updateStatus(): Gui, " . GuiN . ": Default", 6)
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, %GuiN%: Default
|
2012-12-05 12:39:51 +00:00
|
|
|
If Config_readinBat
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2015-01-25 19:44:07 +00:00
|
|
|
ResourceMonitor_getBatteryStatus(b1, b2)
|
2012-09-27 20:32:27 +00:00
|
|
|
b3 := SubStr(" " b1, -2)
|
|
|
|
i := Config_viewCount + 3
|
2012-12-05 12:39:51 +00:00
|
|
|
If (b1 < 10) And (b2 = "off")
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; Change the color, if the battery level is below 10%
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiControl, +Background%Config_normBgColor4% +c%Config_normBgColor2%, Bar_#%m%_#%i%_tagged
|
|
|
|
GuiControl, +c%Config_selFgColor6%, Bar_#%m%_#%i%
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else If (b2 = "off")
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; Change the color, if the pc is not plugged in
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiControl, +Background%Config_normBgColor2% +c%Config_normFgColor5%, Bar_#%m%_#%i%_tagged
|
|
|
|
GuiControl, +c%Config_normFgColor4%, Bar_#%m%_#%i%
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiControl, +Background%Config_normBgColor3% +c%Config_normFgColor3%, Bar_#%m%_#%i%_tagged
|
|
|
|
GuiControl, +c%Config_normFgColor2%, Bar_#%m%_#%i%
|
|
|
|
}
|
|
|
|
GuiControl, , Bar_#%m%_#%i%_tagged, %b3%
|
|
|
|
GuiControl, , Bar_#%m%_#%i%, % " BAT: " b3 "% "
|
|
|
|
}
|
|
|
|
anyText := Config_readinAny()
|
2012-12-05 12:39:51 +00:00
|
|
|
If anyText
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
i := Config_viewCount + 4
|
|
|
|
GuiControlGet, anyContent, , Bar_#%m%_#%i%
|
|
|
|
If Not (anyText = anyContent)
|
|
|
|
GuiControl, , Bar_#%m%_#%i%, % anyText
|
|
|
|
}
|
2012-12-05 12:39:51 +00:00
|
|
|
If Config_readinTime
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
i := Config_viewCount + 5
|
|
|
|
GuiControl, , Bar_#%m%_#%i%, % " " A_Hour ":" A_Min " "
|
|
|
|
}
|
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2014-03-09 18:16:35 +00:00
|
|
|
Bar_updateTitle()
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
Local aWndId, aWndTitle, content, GuiN, i, title
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2014-03-09 18:16:35 +00:00
|
|
|
WinGet, aWndId, ID, A
|
|
|
|
WinGetTitle, aWndTitle, ahk_id %aWndId%
|
|
|
|
If InStr(Bar_hideTitleWndIds, aWndId ";") Or (aWndTitle = "bug.n_BAR_0")
|
|
|
|
aWndTitle := ""
|
2015-01-25 18:38:10 +00:00
|
|
|
If Window_#%aWndId%_isFloating
|
2014-03-09 18:16:35 +00:00
|
|
|
aWndTitle := "~ " aWndTitle
|
|
|
|
If (Manager_monitorCount > 1)
|
|
|
|
aWndTitle := "[" Manager_aMonitor "] " aWndTitle
|
2012-09-27 20:32:27 +00:00
|
|
|
title := " " . aWndTitle . " "
|
2012-12-05 12:39:51 +00:00
|
|
|
|
|
|
|
If (Bar_getTextWidth(title) > Bar_#%Manager_aMonitor%_titleWidth)
|
2012-10-02 10:11:00 +00:00
|
|
|
{ ;; Shorten the window title if its length exceeds the width of the bar
|
2012-09-27 20:32:27 +00:00
|
|
|
i := Bar_getTextWidth(Bar_#%Manager_aMonitor%_titleWidth, True) - 6
|
|
|
|
StringLeft, title, aWndTitle, i
|
|
|
|
title := " " . title . " ... "
|
|
|
|
}
|
2014-03-25 19:47:07 +00:00
|
|
|
StringReplace, title, title, &, &&, All ;; Special character '&', which would underline the next letter.
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
i := Config_viewCount + 2
|
2012-12-05 12:39:51 +00:00
|
|
|
Loop, % Manager_monitorCount
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiN := (A_Index - 1) + 1
|
2012-09-28 15:46:17 +00:00
|
|
|
Debug_logMessage("DEBUG[6] Bar_updateTitle(): Gui, " . GuiN . ": Default", 6)
|
2012-09-27 20:32:27 +00:00
|
|
|
Gui, %GuiN%: Default
|
|
|
|
GuiControlGet, content, , Bar_#%A_Index%_#%i%
|
2012-12-05 12:39:51 +00:00
|
|
|
If (A_Index = Manager_aMonitor)
|
2012-10-02 10:11:00 +00:00
|
|
|
{
|
2012-09-27 20:32:27 +00:00
|
|
|
If Not (content = title)
|
|
|
|
GuiControl, , Bar_#%A_Index%_#%i%, % title
|
|
|
|
} Else If Not (content = "")
|
2012-12-05 12:39:51 +00:00
|
|
|
GuiControl, , Bar_#%A_Index%_#%i%,
|
2012-09-27 20:32:27 +00:00
|
|
|
}
|
|
|
|
Bar_aWndId := aWndId
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-05 12:39:51 +00:00
|
|
|
Bar_updateView(m, v)
|
2012-09-30 20:36:42 +00:00
|
|
|
{
|
|
|
|
Local managedWndId0, wndId0, wndIds
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiN := (m - 1) + 1
|
|
|
|
Gui, %GuiN%: Default
|
2012-09-30 20:36:42 +00:00
|
|
|
Debug_logMessage("DEBUG[6] Bar_updateView(): m: " . m . "; Gui, " . GuiN . ": Default", 6)
|
2012-12-05 12:39:51 +00:00
|
|
|
|
2012-09-30 20:36:42 +00:00
|
|
|
StringTrimRight, wndIds, Manager_managedWndIds, 1
|
|
|
|
StringSplit, managedWndId, wndIds, `;
|
2012-12-05 12:39:51 +00:00
|
|
|
|
|
|
|
If (v = Monitor_#%m%_aView_#1)
|
2012-09-30 20:36:42 +00:00
|
|
|
{ ;; Set foreground/background colors if the view is the current view.
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiControl, +Background%Config_selBgColor1% +c%Config_selFgColor2%, Bar_#%m%_#%v%_tagged
|
|
|
|
GuiControl, +c%Config_selFgColor1%, Bar_#%m%_#%v%
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else If wndId0
|
2012-09-30 20:36:42 +00:00
|
|
|
{ ;; Set foreground/background colors if the view contains windows.
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiControl, +Background%Config_normBgColor5% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
|
|
|
|
GuiControl, +c%Config_normFgColor7%, Bar_#%m%_#%v%
|
2012-12-05 12:39:51 +00:00
|
|
|
}
|
|
|
|
Else
|
2012-09-30 20:36:42 +00:00
|
|
|
{ ;; Set foreground/background colors if the view is empty.
|
2012-09-27 20:32:27 +00:00
|
|
|
GuiControl, +Background%Config_normBgColor1% +c%Config_normFgColor8%, Bar_#%m%_#%v%_tagged
|
|
|
|
GuiControl, +c%Config_normFgColor1%, Bar_#%m%_#%v%
|
|
|
|
}
|
2012-12-05 12:39:51 +00:00
|
|
|
|
|
|
|
Loop, %Config_viewCount%
|
2012-09-30 20:36:42 +00:00
|
|
|
{
|
|
|
|
StringTrimRight, wndIds, View_#%m%_#%A_Index%_wndIds, 1
|
|
|
|
StringSplit, wndId, wndIds, `;
|
|
|
|
GuiControl, , Bar_#%m%_#%A_Index%_tagged, % wndId0 / managedWndId0 * 100 ;; Update the percentage fill for the view.
|
|
|
|
GuiControl, , Bar_#%m%_#%A_Index%, % Config_viewNames_#%A_Index% ;; Refresh the number on the bar.
|
2012-09-27 20:32:27 +00:00
|
|
|
}
|
2011-07-27 17:43:34 +00:00
|
|
|
}
|