[GB.FORM]
* NEW: the text of IconView items is now automatically ellipsized. [GB.QT4] * BUG: Rich text size is now computed with no default margin around the text. git-svn-id: svn://localhost/gambas/trunk@3585 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
724ac370ce
commit
b5abdc2478
9 changed files with 55 additions and 46 deletions
2
TODO
2
TODO
|
@ -44,8 +44,6 @@ GUI RELATED STUFF
|
||||||
- ListView and GridView selection interface should be the same.
|
- ListView and GridView selection interface should be the same.
|
||||||
- Keep ListView.SelectAll(Boolean) for compatibility.
|
- Keep ListView.SelectAll(Boolean) for compatibility.
|
||||||
- Remove ScreenShot() method.
|
- Remove ScreenShot() method.
|
||||||
- Fix infinite loop when clicking with the right mouse button in an iconview.
|
|
||||||
- Clean up gb.db.form component. Use the Proxy property in controls.
|
|
||||||
|
|
||||||
DESKTOP COMPONENT
|
DESKTOP COMPONENT
|
||||||
|
|
||||||
|
|
|
@ -2238,3 +2238,7 @@ MoveLast
|
||||||
m
|
m
|
||||||
|
|
||||||
|
|
||||||
|
_IsEllipsized
|
||||||
|
m
|
||||||
|
b
|
||||||
|
|
||||||
|
|
|
@ -207,18 +207,6 @@ msgstr ""
|
||||||
msgid "How quickly daft jumping zebras vex"
|
msgid "How quickly daft jumping zebras vex"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: FMain.class:27
|
|
||||||
msgid "Item 0"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: FMain.class:34
|
|
||||||
msgid "Item 1"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: FMain.class:41
|
|
||||||
msgid "Item 2"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: FMessage.class:132
|
#: FMessage.class:132
|
||||||
msgid "Do not display this message again"
|
msgid "Do not display this message again"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Gambas Project File 3.0
|
# Gambas Project File 3.0
|
||||||
# Compiled with Gambas 2.99.0
|
# Compiled with Gambas 2.99.0
|
||||||
Title=More controls for graphical components
|
Title=More controls for graphical components
|
||||||
Startup=FIconView
|
Startup=FMain
|
||||||
Version=2.99.0
|
Version=2.99.0
|
||||||
VersionProgram=gbx3 -V
|
VersionProgram=gbx3 -V
|
||||||
Component=gb.image
|
Component=gb.image
|
||||||
|
@ -9,7 +9,7 @@ Component=gb.gui
|
||||||
Component=gb.form
|
Component=gb.form
|
||||||
Component=gb.settings
|
Component=gb.settings
|
||||||
Authors="Benoît Minisini"
|
Authors="Benoît Minisini"
|
||||||
Environment="GB_GUI=gb.gtk"
|
Environment="GB_GUI=gb.qt4"
|
||||||
TabSize=2
|
TabSize=2
|
||||||
Translate=1
|
Translate=1
|
||||||
Language=en
|
Language=en
|
||||||
|
|
|
@ -562,6 +562,8 @@ End
|
||||||
|
|
||||||
Private Sub SetHoverItem(iPos As Integer)
|
Private Sub SetHoverItem(iPos As Integer)
|
||||||
|
|
||||||
|
Dim hItem As _IconViewItem
|
||||||
|
|
||||||
If iPos = $iHover Then Return
|
If iPos = $iHover Then Return
|
||||||
|
|
||||||
Swap iPos, $iHover
|
Swap iPos, $iHover
|
||||||
|
@ -570,7 +572,10 @@ Private Sub SetHoverItem(iPos As Integer)
|
||||||
RefreshIcon($iHover)
|
RefreshIcon($iHover)
|
||||||
|
|
||||||
$hView.Tooltip = ""
|
$hView.Tooltip = ""
|
||||||
If $iHover >= 0 Then $hView.Tooltip = $aItems[$iHover].Text
|
If $iHover >= 0 Then
|
||||||
|
hItem = $aItems[$iHover]
|
||||||
|
If hItem._IsEllipsized() Then $hView.Tooltip = hItem.Text
|
||||||
|
Endif
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ Private $sText As String
|
||||||
Private $hPicture As Picture
|
Private $hPicture As Picture
|
||||||
Private $bSelected As Boolean
|
Private $bSelected As Boolean
|
||||||
Private $bEditable As Boolean
|
Private $bEditable As Boolean
|
||||||
|
Private $bEllipsized As Boolean
|
||||||
|
|
||||||
Event _Foo
|
Event _Foo
|
||||||
|
|
||||||
|
@ -207,9 +208,10 @@ End
|
||||||
|
|
||||||
Public Sub _Draw(hRect As Rect, hClip As Rect, hIconView As IconView, bHorizontal As Boolean, bFocus As Boolean, bHover As Boolean)
|
Public Sub _Draw(hRect As Rect, hClip As Rect, hIconView As IconView, bHorizontal As Boolean, bFocus As Boolean, bHover As Boolean)
|
||||||
|
|
||||||
Dim X, Y, W As Integer
|
Dim X, Y, W, H, HT As Integer
|
||||||
Dim iColor As Integer
|
Dim iColor As Integer
|
||||||
Dim bFrame As Boolean
|
Dim bFrame As Boolean
|
||||||
|
Dim sText As String
|
||||||
|
|
||||||
hRect.Adjust(4)
|
hRect.Adjust(4)
|
||||||
|
|
||||||
|
@ -288,12 +290,24 @@ Public Sub _Draw(hRect As Rect, hClip As Rect, hIconView As IconView, bHorizonta
|
||||||
If $sText Then
|
If $sText Then
|
||||||
'Draw.Clip(hRect.X, Y, hRect.W, hRect.H - Y)
|
'Draw.Clip(hRect.X, Y, hRect.W, hRect.H - Y)
|
||||||
Draw.Font = hIconView.Font
|
Draw.Font = hIconView.Font
|
||||||
|
|
||||||
|
sText = $sText
|
||||||
|
|
||||||
|
H = Draw.Font.RichTextHeight(sText, hRect.W)
|
||||||
|
HT = hRect.H - (Y - hRect.Y)
|
||||||
|
If H > HT Then
|
||||||
|
sText = Ellipsize(sText, Draw.Font, hRect.W, HT)
|
||||||
|
$bEllipsized = True
|
||||||
|
Else
|
||||||
|
$bEllipsized = False
|
||||||
|
Endif
|
||||||
|
|
||||||
If Not bFrame Then
|
If Not bFrame Then
|
||||||
Draw.Foreground = If($bSelected, Color.SelectedBackground, Color.TextBackground)
|
Draw.Foreground = If($bSelected, Color.SelectedBackground, Color.TextBackground)
|
||||||
Draw.RichText($sText, hRect.X + 1, Y + 1, hRect.W, hRect.H - (Y - hRect.Y), Align.Top)
|
Draw.RichText(sText, hRect.X + 1, Y + 1, hRect.W, HT, Align.Top)
|
||||||
Endif
|
Endif
|
||||||
Draw.Foreground = If($bSelected, Color.SelectedForeground, Color.TextForeground)
|
Draw.Foreground = If($bSelected, Color.SelectedForeground, Color.TextForeground)
|
||||||
Draw.RichText($sText, hRect.X, Y, hRect.W, hRect.H - (Y - hRect.Y), Align.Top)
|
Draw.RichText(sText, hRect.X, Y, hRect.W, HT, Align.Top)
|
||||||
'Draw.Clip.Enabled = False
|
'Draw.Clip.Enabled = False
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
|
@ -458,3 +472,23 @@ Public Sub MoveLast()
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Private Sub Ellipsize(sText As String, hFont As Font, W As Integer, H As Integer) As String
|
||||||
|
|
||||||
|
Dim sCar As String = "…"
|
||||||
|
Dim iPos As Integer
|
||||||
|
|
||||||
|
If Not sText Then Return
|
||||||
|
|
||||||
|
For iPos = 1 To Len(sText)
|
||||||
|
If hFont.RichTextHeight(Left(sText, iPos) & sCar, W) > H Then Break
|
||||||
|
Next
|
||||||
|
|
||||||
|
Return Left(sText, iPos - 1) & sCar
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Public Sub _IsEllipsized() As Boolean
|
||||||
|
|
||||||
|
Return $bEllipsized
|
||||||
|
|
||||||
|
End
|
||||||
|
|
|
@ -2,33 +2,10 @@
|
||||||
|
|
||||||
{ Form Form
|
{ Form Form
|
||||||
MoveScaled(0,0,96,51)
|
MoveScaled(0,0,96,51)
|
||||||
Arrangement = Arrange.Horizontal
|
Arrangement = Arrange.Fill
|
||||||
Spacing = True
|
Spacing = True
|
||||||
Margin = True
|
Margin = True
|
||||||
{ IconPanel1 IconPanel
|
{ FileChooser1 FileChooser
|
||||||
MoveScaled(5,5,79,40)
|
MoveScaled(5,2,64,46)
|
||||||
Expand = True
|
|
||||||
Arrangement = Arrange.Fill
|
|
||||||
Count = 3
|
|
||||||
Border = True
|
|
||||||
Index = 0
|
|
||||||
Text = ("Item 0")
|
|
||||||
Picture = Picture["icon:/large/access"]
|
|
||||||
{ Button1 Button
|
|
||||||
MoveScaled(1,3,16,4)
|
|
||||||
}
|
|
||||||
Index = 1
|
|
||||||
Text = ("Item 1")
|
|
||||||
Picture = Picture["icon:/large/battery"]
|
|
||||||
{ TextBox1 TextBox
|
|
||||||
MoveScaled(2,9,24,4)
|
|
||||||
}
|
|
||||||
Index = 2
|
|
||||||
Text = ("Item 2")
|
|
||||||
Picture = Picture["icon:/large/book"]
|
|
||||||
{ ColorChooser1 ColorChooser
|
|
||||||
MoveScaled(1,1,49,36)
|
|
||||||
}
|
|
||||||
Index = 0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -892,6 +892,7 @@ void DRAW_rich_text(QPainter *p, const QString &text, float x, float y, float w,
|
||||||
t = "<div align=\"" + a + "\">" + t + "</div>";
|
t = "<div align=\"" + a + "\">" + t + "</div>";
|
||||||
|
|
||||||
QTextDocument rt;
|
QTextDocument rt;
|
||||||
|
rt.setDocumentMargin(0);
|
||||||
rt.setHtml(t);
|
rt.setHtml(t);
|
||||||
rt.setDefaultFont(p->font());
|
rt.setDefaultFont(p->font());
|
||||||
|
|
||||||
|
@ -938,6 +939,7 @@ static void rich_text_size(GB_DRAW *d, char *text, int len, int sw, int *w, int
|
||||||
{
|
{
|
||||||
QTextDocument rt;
|
QTextDocument rt;
|
||||||
|
|
||||||
|
rt.setDocumentMargin(0);
|
||||||
rt.setHtml(QString::fromUtf8((const char *)text, len));
|
rt.setHtml(QString::fromUtf8((const char *)text, len));
|
||||||
rt.setDefaultFont(DP(d)->font());
|
rt.setDefaultFont(DP(d)->font());
|
||||||
|
|
||||||
|
|
|
@ -439,6 +439,7 @@ static void rich_text_size(CFONT *_object, char *text, int len, int sw, int *w,
|
||||||
{
|
{
|
||||||
QTextDocument rt;
|
QTextDocument rt;
|
||||||
|
|
||||||
|
rt.setDocumentMargin(0);
|
||||||
rt.setHtml(QString::fromUtf8((const char *)text, len));
|
rt.setHtml(QString::fromUtf8((const char *)text, len));
|
||||||
rt.setDefaultFont(*(THIS->font));
|
rt.setDefaultFont(*(THIS->font));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue