/**************************************************************************** ** COPYRIGHT (C): 1997 Cay S. Horstmann. All Rights Reserved. ** PROJECT: Practical OO Development with C++ and Java ** FILE: hello.cpp ** PURPOSE: test graphics package ** VERSION 1.0 ** PROGRAMMERS: Cay Horstmann (CSH) ** RELEASE DATE: 3-15-97 (CSH) ** UPDATE HISTORY: ****************************************************************************/ /* Project: GUI Application Add files hello.cpp \PracticalOOBook\cpplib\graphics.cpp Additional include directory: \PracticalOOBook\cpplib */ #include "setup.h" #include "graphics.h" void paint(Graphics& g) { string msg = "Hello, World"; FontMetrics fm = g.getFontMetrics(); int xleft = 10; int ytop = 10; int ybase = ytop + fm.getAscent(); int xwidth = fm.stringWidth(msg); int yheight = fm.getAscent() + fm.getDescent(); g.drawString(msg, xleft, ybase); g.drawRect(xleft, ytop, xwidth, yheight); }