OSDN Git Service

・リスト部分の文字列の縦方向の描画位置を、表示出来る行数が1行のときは中央、複数行のときは上寄せに変更。
authoranis774 <anis774@users.sourceforge.jp>
Wed, 13 Oct 2010 23:46:49 +0000 (23:46 +0000)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 18 Feb 2012 14:15:56 +0000 (23:15 +0900)
git-svn-id: http://svn.sourceforge.jp/svnroot/tween/trunk@965 e39ad16e-3079-482e-bb30-4b4d378143b6

Tween/Tween.vb

index 868ff99..b191426 100644 (file)
@@ -574,6 +574,7 @@ Public Class TweenMain
         ' StringFormatオブジェクトへの事前設定
         sf.Alignment = StringAlignment.Near
         sf.LineAlignment = StringAlignment.Near
+        sf.FormatFlags = StringFormatFlags.LineLimit
         sfTab.Alignment = StringAlignment.Center
         sfTab.LineAlignment = StringAlignment.Center
 
@@ -3844,8 +3845,17 @@ Public Class TweenMain
             rctB.Width = e.Header.Width
             If _iconCol Then rctB.Height = e.Item.Font.Height
 
-            Dim heightDiff As Integer = CType(rct.Height Mod CType(e.Item.Font.Height, Single), Integer)
-            rct.Inflate(0, CType(heightDiff / -2, Integer))
+            Dim heightDiff As Integer
+            Dim drawLineCount As Integer = Math.Max(1, Math.DivRem(CType(rct.Height, Integer), e.Item.Font.Height, heightDiff))
+
+            'フォントの高さの半分を足してるのは保険。無くてもいいかも。
+            If Not _iconCol AndAlso drawLineCount <= 1 Then
+                rct.Inflate(0, CType(heightDiff / -2, Integer))
+                rct.Height += CType(e.Item.Font.Height / 2, Integer)
+            Else
+                rct.Height = CType((e.Item.Font.Height * drawLineCount) + (e.Item.Font.Height / 2), Single)
+            End If
+
             If Not e.Item.Selected Then     'e.ItemStateでうまく判定できない???
                 '選択されていない行
                 '文字色