diff options
author | pixel <pixel> | 2003-03-15 20:54:35 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-03-15 20:54:35 +0000 |
commit | a0ec1cffa6b75030344632083b2b1b63c0cfcf0a (patch) | |
tree | 9f8f02708502d9774d6d089e62a3f23ad30162b0 /lib | |
parent | 9e10d2993989a4f6d1b72a8c9d5f7480b0c0f006 (diff) |
Toying
Diffstat (limited to 'lib')
-rw-r--r-- | lib/glfont.cc | 8 | ||||
-rw-r--r-- | lib/glshape.cc | 84 |
2 files changed, 74 insertions, 18 deletions
diff --git a/lib/glfont.cc b/lib/glfont.cc index d8dbb5b..9b77c8c 100644 --- a/lib/glfont.cc +++ b/lib/glfont.cc @@ -77,7 +77,7 @@ nbT = number of textures */ -mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255) { +mogltk::font::font(Handle * ffont) : textcolor(255, 255, 255, 255), shadow(0), wspace(0) { int i; nbentries = ffont->readU16(); @@ -210,7 +210,7 @@ void mogltk::font::putcursor(int x, int y) { void mogltk::font::putentry(Uint16 entry, ColorP c) { drawentry(entry, cx, cy, c); - cx += sizes[entry]; + cx += sizes[entry] + wspace; } void mogltk::font::putchar(char ch, ColorP c) { @@ -298,6 +298,10 @@ void mogltk::font::setshadow(int s) { shadow = s; } +void mogltk::font::setwspace(int w) { + wspace = w; +} + int mogltk::font::singletextsize(const String & s) const { unsigned int i; int r = 0; diff --git a/lib/glshape.cc b/lib/glshape.cc index 55a02cf..6c314fb 100644 --- a/lib/glshape.cc +++ b/lib/glshape.cc @@ -39,7 +39,7 @@ void mogltk::shape::hline(int x1, int x2, int y, ColorP c) { box(x1, y, x2, y, c); } -void mogltk::shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2, int bevel) { +void mogltk::shape::hline3d(int x1, int x2, int y, ColorP shade1, ColorP shade2, bool bevel) { ENTER; if (!bevel) { @@ -57,7 +57,7 @@ void mogltk::shape::vline(int x, int y1, int y2, ColorP c) { box(x, y1, x, y2, c); } -void mogltk::shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2, int bevel) { +void mogltk::shape::vline3d(int x, int y1, int y2, ColorP shade1, ColorP shade2, bool bevel) { ENTER; if (!bevel) { @@ -79,6 +79,10 @@ void mogltk::shape::vline(int x, int y1, int y2, ColorP c1, ColorP c2) { box(x, y1, x, y2, c1, c1, c2, c2); } +void mogltk::shape::pixel(int x, int y, ColorP c) { + box(x, y, x, y, c); +} + void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c) { ENTER; @@ -102,11 +106,11 @@ void mogltk::shape::obox(int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, C } void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, int tx, int ty, double f, ColorP c) { - tbox(t, x1, y1, x2, y2, tx, ty, tx + (x2 - x1) * f, ty + (y2 - y1) * f, c); + tbox(t, x1, y1, x2, y2, tx, ty, tx + (int) ((x2 - x1) * f), ty + (int) ((y2 - y1) * f), c); } void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, ColorP c1, ColorP c2, ColorP c3, ColorP c4, int tx, int ty, double f) { - tbox(t, x1, y1, x2, y2, c1, c2, c3, c4, tx, ty, tx + (x2 - x1) * f, ty + (y2 - y1) * f); + tbox(t, x1, y1, x2, y2, c1, c2, c3, c4, tx, ty, tx + (int) ((x2 - x1) * f), ty + (int) ((y2 - y1) * f)); } void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP c) { @@ -138,7 +142,7 @@ void mogltk::shape::tbox(mogltk::texture * t, int x1, int y1, int x2, int y2, Co LEAVE; } -void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, int bevel) { +void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP shade1, ColorP shade2, int depth, bool bevel) { ENTER; if (!bevel) { @@ -178,7 +182,7 @@ void mogltk::shape::box3d(int x1, int y1, int x2, int y2, ColorP face, ColorP sh LEAVE; } -void mogltk::shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP shade2, int bevel) { +void mogltk::shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP shade2, bool bevel) { ENTER; if (!bevel) { @@ -192,27 +196,75 @@ void mogltk::shape::obox3d(int x1, int y1, int x2, int y2, ColorP shade1, ColorP LEAVE; } -void mogltk::shape::window(int x1, int y1, int x2, int y2, String title, +void mogltk::shape::window(int x1, int y1, int x2, int y2, const String & title, ColorP titlecolor, ColorP titlebackcolor, ColorP front, ColorP shade1, ColorP shade2) { ENTER; box3d(x1, y1, x2, y2, front, shade1, shade2); - hline3d(x1 + 2, x2 - 2, y1 + 18, shade1, shade2, 1); - box(x1 + 2, y1 + 2, x2 - 2, y1 + 17, titlebackcolor); - int tsize = SystemFont->singletextsize(title); - SystemFont->putcursor((x2 + x1 - tsize) / 2, y1 + 2); - SystemFont->setcolor(titlecolor); - SystemFont->setshadow(0); - SystemFont->printf(title); + hline3d(x1 + 2, x2 - 2, y1 + 19, shade1, shade2, 1); + box(x1 + 2, y1 + 2, x2 - 2, y1 + 18, titlebackcolor); + text((x1 + x2) / 2, y1 + 2, title, titlecolor, CENTER); LEAVE; } -void mogltk::shape::text3d(int x, int y, String text, ColorP textcolor, +void mogltk::shape::text(int x, int y, const String & text, ColorP textcolor, align_t align) { + int tsize = SystemFont->singletextsize(text); + switch (align) { + case LEFT: + SystemFont->putcursor(x, y); + break; + case CENTER: + SystemFont->putcursor(x - (tsize / 2), y); + break; + case RIGHT: + SystemFont->putcursor(x - tsize, y); + break; + } + SystemFont->setcolor(textcolor); + SystemFont->setshadow(0); + SystemFont->printf(text); +} + +void mogltk::shape::text3d(int x, int y, const String & atext, ColorP textcolor, ColorP shade1, ColorP shade2, - align_t align, int bevel) { + align_t align, bool bevel) { + ENTER; + + SystemFont->setwspace(1); + if (!bevel) { + text(x - 1, y - 1, atext, shade2, align); + text(x + 1, y + 1, atext, shade1, align); + } else { + text(x - 1, y - 1, atext, shade1, align); + text(x + 1, y + 1, atext, shade2, align); + } + text(x, y, atext, textcolor, align); + SystemFont->setwspace(0); + + LEAVE; +} +void mogltk::shape::button(int x1, int y1, int x2, int y2, + const String & atext, bool bevel, + ColorP front, ColorP shade1, ColorP shade2, + ColorP round, ColorP textcolor, + ColorP tshade1, ColorP tshade2) { + ENTER; + + box3d(x1, y1, x2, y2, front, shade1, shade2, 2, bevel); + hline(x1, x2, y1 - 1, round); + hline(x1, x2, y2 + 1, round); + vline(x1 - 1, y1, y2, round); + vline(x2 + 1, y1, y2, round); + pixel(x1, y1, round); + pixel(x1, y2, round); + pixel(x2, y1, round); + pixel(x2, y2, round); + text3d((x1 + x2) / 2, (y1 + y2) / 2 - 8, atext, textcolor, tshade1, tshade2, CENTER, bevel); + + LEAVE; } bool mogltk::shape::in2D(bool unbind) { |