summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-05-26 10:16:51 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-05-26 10:16:51 +0000
commita3d1ea22c42ed9bb4af11a301db195f67137f85e (patch)
treee712cf38fd1e3ddf6db762e9996a88d7a2aa8687
parent5e4d176d195b6cc666c48c5cd69aeb3030909324 (diff)
downloadfpGUI-a3d1ea22c42ed9bb4af11a301db195f67137f85e.tar.xz
* TextFlagsDflt now contains txtEnabled
* DrawText now takes the txtEnabled flag into account. Before it always assumed Enabled = True. * gui_tab now uses Canvas.DrawText instead of Canvas.DrawString * gui_label now paints disabled text correctly.
-rw-r--r--src/corelib/fpgfx.pas43
-rw-r--r--src/gui/gui_label.pas8
-rw-r--r--src/gui/gui_tab.pas10
3 files changed, 38 insertions, 23 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas
index d0145018..d0d4001f 100644
--- a/src/corelib/fpgfx.pas
+++ b/src/corelib/fpgfx.pas
@@ -40,7 +40,7 @@ type
const
AllAnchors = [anLeft, anRight, anTop, anBottom];
- TextFlagsDflt = [txtLeft, txtTop];
+ TextFlagsDflt = [txtLeft, txtTop, txtEnabled];
// Used for the internal message queue
cMessageQueueSize = 512;
@@ -1158,7 +1158,9 @@ var
wtxt, htxt, i, wt, l: integer;
wraptxt: TfpgString;
wraplst: TStringList;
+ lEnabled: Boolean;
begin
+ lEnabled := txtEnabled in AFlags;
if (txtWrap in AFlags) then
begin
wraplst := TStringList.Create;
@@ -1292,57 +1294,60 @@ begin
end;
end;
htxt := (Font.Height * wraplst.Count) + (ALineSpace * Pred(wraplst.Count));
+ // Now paint the actual text
for i := 0 to Pred(wraplst.Count) do
begin
l := (Font.Height + ALineSpace) * i;
wtxt := Font.TextWidth(wraplst[i]);
if (txtLeft in AFlags) and (txtTop in AFlags) then
- fpgStyle.DrawString(self, x, y + l, wraplst[i]);
+ fpgStyle.DrawString(self, x, y + l, wraplst[i], lEnabled);
if (txtLeft in AFlags) and (txtVCenter in AFlags) then
- fpgStyle.DrawString(self, x, y + l + (h - htxt) div 2, wraplst[i]);
+ fpgStyle.DrawString(self, x, y + l + (h - htxt) div 2, wraplst[i], lEnabled);
if (txtLeft in AFlags) and (txtBottom in AFlags) then
- fpgStyle.DrawString(self, x, y + l + h - htxt, wraplst[i]);
+ fpgStyle.DrawString(self, x, y + l + h - htxt, wraplst[i], lEnabled);
if (txtHCenter in AFlags) and (txtTop in AFlags) then
- fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + l, wraplst[i]);
+ fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + l, wraplst[i], lEnabled);
if (txtHCenter in AFlags) and (txtVCenter in AFlags) then
- fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + l + (h - htxt) div 2, wraplst[i]);
+ fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + l + (h - htxt) div 2, wraplst[i], lEnabled);
if (txtHCenter in AFlags) and (txtBottom in AFlags) then
- fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + l + h - htxt, wraplst[i]);
+ fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + l + h - htxt, wraplst[i], lEnabled);
if (txtRight in AFlags) and (txtTop in AFlags) then
- fpgStyle.DrawString(self, x + w - wtxt, y + l, wraplst[i]);
+ fpgStyle.DrawString(self, x + w - wtxt, y + l, wraplst[i], lEnabled);
if (txtRight in AFlags) and (txtVCenter in AFlags) then
- fpgStyle.DrawString(self, x + w - wtxt, y + l + (h - htxt) div 2, wraplst[i]);
+ fpgStyle.DrawString(self, x + w - wtxt, y + l + (h - htxt) div 2, wraplst[i], lEnabled);
if (txtRight in AFlags) and (txtBottom in AFlags) then
- fpgStyle.DrawString(self, x + w - wtxt, y + l + h - htxt, wraplst[i]);
+ fpgStyle.DrawString(self, x + w - wtxt, y + l + h - htxt, wraplst[i], lEnabled);
end;
wraplst.Free;
end
else
begin
+ // No wraping was required
wtxt := self.Font.TextWidth(AText);
htxt := self.Font.Height;
if (txtAutoSize in AFlags) or (w = 0) then
w := wtxt;
if (txtAutoSize in AFlags) or (h = 0) then
h := htxt;
+ // Now lets paint the actual text
if (txtLeft in AFlags) and (txtTop in AFlags) then
- fpgStyle.DrawString(self, x, y, AText);
+ fpgStyle.DrawString(self, x, y, AText, lEnabled);
if (txtLeft in AFlags) and (txtVCenter in AFlags) then
- fpgStyle.DrawString(self, x, y + (h - htxt) div 2, AText);
+ fpgStyle.DrawString(self, x, y + (h - htxt) div 2, AText, lEnabled);
if (txtLeft in AFlags) and (txtBottom in AFlags) then
- fpgStyle.DrawString(self, x, y + h - htxt, AText);
+ fpgStyle.DrawString(self, x, y + h - htxt, AText, lEnabled);
if (txtHCenter in AFlags) and (txtTop in AFlags) then
- fpgStyle.DrawString(self, x + (w - wtxt) div 2, y, AText);
+ fpgStyle.DrawString(self, x + (w - wtxt) div 2, y, AText, lEnabled);
if (txtHCenter in AFlags) and (txtVCenter in AFlags) then
- fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + (h - htxt) div 2, AText);
+ fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + (h - htxt) div 2, AText, lEnabled);
if (txtHCenter in AFlags) and (txtBottom in AFlags) then
- fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + h - htxt, AText);
+ fpgStyle.DrawString(self, x + (w - wtxt) div 2, y + h - htxt, AText, lEnabled);
if (txtRight in AFlags) and (txtTop in AFlags) then
- fpgStyle.DrawString(self, x + w - wtxt, y, AText);
+ fpgStyle.DrawString(self, x + w - wtxt, y, AText, lEnabled);
if (txtRight in AFlags) and (txtVCenter in AFlags) then
- fpgStyle.DrawString(self, x + w - wtxt, y + (h - htxt) div 2, AText);
+ fpgStyle.DrawString(self, x + w - wtxt, y + (h - htxt) div 2, AText, lEnabled);
if (txtRight in AFlags) and (txtBottom in AFlags) then
- fpgStyle.DrawString(self, x + w - wtxt, y + h - htxt, AText);
+ fpgStyle.DrawString(self, x + w - wtxt, y + h - htxt, AText, lEnabled);
Result := htxt;
end;
end;
diff --git a/src/gui/gui_label.pas b/src/gui/gui_label.pas
index 09fc21ff..6d08ec11 100644
--- a/src/gui/gui_label.pas
+++ b/src/gui/gui_label.pas
@@ -220,9 +220,15 @@ begin
r.SetRect(0, 0, Width, Height);
Canvas.Clear(FBackgroundColor);
Canvas.SetFont(Font);
- Canvas.SetTextColor(FTextColor);
+ if Enabled then
+ Canvas.SetTextColor(FTextColor)
+ else
+ Canvas.SetTextColor(clShadow1);
lTxtFlags:= [];
+ if Enabled then
+ Include(lTxtFlags, txtEnabled);
+
if FWrapText then
Include(lTxtFlags, txtWrap);
case FAlignment of
diff --git a/src/gui/gui_tab.pas b/src/gui/gui_tab.pas
index 52bd8885..adda9f58 100644
--- a/src/gui/gui_tab.pas
+++ b/src/gui/gui_tab.pas
@@ -463,6 +463,7 @@ var
lp: integer;
toffset: integer;
dx: integer;
+ lTxtFlags: TFTextFlags;
begin
if not HasHandle then
Exit; //==>
@@ -475,6 +476,9 @@ begin
Exit;
Canvas.BeginDraw;
Canvas.SetTextColor(TextColor);
+ lTxtFlags := TextFlagsDflt;
+ if not Enabled then
+ Exclude(lTxtFlags, txtEnabled);
case TabPosition of
tpBottom:
@@ -610,9 +614,9 @@ begin
r2.Width := ButtonWidth(h.Text);
r3 := DrawTab(r2, h = ActivePage);
- // paint text
+ // paint text on non-active tabs
if h <> ActivePage then
- Canvas.DrawString(lp + (ButtonWidth(h.Text) div 2) - FFont.TextWidth(GetTabText(h.Text)) div 2, FMargin+toffset, GetTabText(h.Text));
+ Canvas.DrawText(lp + (ButtonWidth(h.Text) div 2) - FFont.TextWidth(GetTabText(h.Text)) div 2, FMargin+toffset, GetTabText(h.Text), lTxtFlags);
r2.Left := r2.Left + r2.Width;
lp := lp + ButtonWidth(h.Text);
@@ -630,7 +634,7 @@ begin
// Draw text of ActivePage, because we didn't before.
DrawTab(r3, false, 2);
- Canvas.DrawText(r3.Left+4, r3.Top+3, r3.Width, r3.Height, ActivePage.Text, [txtLeft, txtTop]);
+ Canvas.DrawText(r3.Left+4, r3.Top+3, r3.Width, r3.Height, ActivePage.Text, lTxtFlags);
end;
end;