1
0
mirror of https://github.com/gryf/wmdocklib.git synced 2025-12-19 12:28:10 +01:00

1580293: initialization of pixmask - drawing areas

more cleaning up...
This commit is contained in:
mfrasca
2006-10-21 07:44:45 +00:00
parent c89b35ff1e
commit 6c71547b58

View File

@@ -62,7 +62,7 @@ width = 64
height = 64 height = 64
xOffset = 4 xOffset = 4
yOffset = 4 yOffset = 5
graphStartX = 7 graphStartX = 7
graphStartY = 53 graphStartY = 53
@@ -89,11 +89,12 @@ class PywmHDMon:
self._pathsToMonitor = pathsToMonitor self._pathsToMonitor = pathsToMonitor
self._actMonEnabled = actMonEnabled self._actMonEnabled = actMonEnabled
self._skipping = skipping self._skipping = skipping
self._lineCount = (height - yOffset*2 - 2) / (char_height+1)
self._statFile = procStat self._statFile = procStat
self._maxIODiff = 0 self._maxIODiff = 0
self._lastIO = -1 self._lastIO = -1
for i in range(len(self._pathsToMonitor)): for i in range(max(self._lineCount, len(pathsToMonitor)-skipping)):
wmdocklib.addMouseRegion(i+1, 8, self.getY(i+1)+yOffset, wmdocklib.addMouseRegion(i+1, 8, self.getY(i+1)+yOffset,
58, self.getY(i+1)+char_height+yOffset) 58, self.getY(i+1)+char_height+yOffset)
@@ -150,10 +151,11 @@ class PywmHDMon:
def getY(self, line): def getY(self, line):
"returns the y coordinate of the top line for the box" "returns the y coordinate of the top line for the box"
lineCount = (height - yOffset*2) / (char_height+2) interlinea = (height - yOffset*2 - 2 - self._lineCount * char_height) / (self._lineCount-1)
interlinea = (height - yOffset*2) / lineCount interlinea += char_height
lastBaseline = yOffset + lineCount * interlinea lastBaseline = yOffset + self._lineCount * interlinea
extraYOffset = (height - yOffset - lastBaseline) / 2 from math import ceil
extraYOffset = int(ceil((height - yOffset - lastBaseline) / 2.0))
return extraYOffset + (line - 1) * interlinea return extraYOffset + (line - 1) * interlinea
def paintLabel(self, line, label): def paintLabel(self, line, label):
@@ -163,7 +165,7 @@ class PywmHDMon:
total, free = data total, free = data
xStart = (width*2)/5 xStart = (width*2)/5
if total==0: if total==0:
self.addString(' ', xStart, self.getY(line)) self.addString(' ', width-yOffset*2-5*char_width-1, self.getY(line))
self.paintGraph(0, xStart, self.getY(line) + 4, self.paintGraph(0, xStart, self.getY(line) + 4,
width - xOffset*2 - xStart - 2, width - xOffset*2 - xStart - 2,
thin=1) thin=1)
@@ -285,7 +287,7 @@ class PywmHDMon:
"Can't get hd data from %s: %s\n" % (path, str(e))) "Can't get hd data from %s: %s\n" % (path, str(e)))
hdData = (0, 0) hdData = (0, 0)
self.paintHdData(index-pageoffset, hdData, mode) self.paintHdData(index-pageoffset, hdData, mode)
if index - pageoffset == 5: if index - pageoffset == self._lineCount:
break break
def mainLoop(self): def mainLoop(self):