void Frame::repaint() { if (this->__g == NULL) return; /* 矩形ウィンドウ */ int w = getWidth(); int h = getHeight(); /* 外枠 */ __g->setColor(Color::lightGray); __g->fillRect(0, 0, w, h); __g->setColor(Color::black); __g->drawRect(0, 0, w, h); /* 内枠 */ __g->setColor(Color::black); __g->drawRect(5, 21, w - 10, h - 26); /* 枠 */ __g->setColor(Color::white); __g->drawLine(1, 1, w - 2, 1); __g->drawLine(1, 1, 1, h - 2); __g->drawLine(w - 5, 21, w - 5, h - 5); __g->drawLine(5, h - 5, w - 5, h - 5); __g->setColor(Color::gray); __g->drawLine(w - 2, 2, w - 2, h - 2); __g->drawLine(2, h - 2, w - 2, h - 2); __g->drawLine(4, 20, w - 6, 20); __g->drawLine(4, 20, 4, h - 6); if (getFocused() == true) { /* タイトルバー */ for (int i = 4; i <= 14; i = i + 2) { __g->setColor(Color::gray); __g->drawLine(20, i, w - 7, i); __g->setColor(Color::white); __g->drawLine(21, i + 1, w - 6, i + 1); } drawCloseButton(__g); } /* タイトル */ int fw = getFontMetrics()->getWidth(getTitle()); int fh = getFontMetrics()->getHeight(getTitle()); __g->setColor(Color::lightGray); __g->fillRect(((w - fw) / 2) - 4, 2, fw + 8, getInsets()->top - 4); if (getFocused() == true) { __g->setColor(Color::black); } else { __g->setColor(Color::gray); } __g->drawString(getTitle(), ((w - fw) / 2), ((getInsets()->top - fh) / 2)); Container::repaint(); }
/** * Returns the preferred size of the TextArea. This is the * maximum of the size needed to display the text and the * size requested for the viewport. * * @return the size */ /*public*/ Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d = (d == NULL) ? new Dimension(400,400) : d; Insets insets = getInsets(); if (columns != 0) { d.width = Math.max(d.width, columns * getColumnWidth() + insets.left + insets.right); } if (rows != 0) { d.height = Math.max(d.height, rows * getRowHeight() + insets.top + insets.bottom); } return d; }
virtual void paintComponent(gluit::Graphics g) { Panel::paintComponent(g); boost::mutex::scoped_lock lock(updateMutex); gluit::Size inputSize = gluit::Size::fromDouble(inputBounds.getWidth(), inputBounds.getHeight()); if (inputSize.isZero()) { return; } gluit::Rectangle innerBounds = gluit::Rectangle(getSize()).shrink(getInsets()); gluit::Rectangle inputBounds = innerBounds.center(inputSize.shrinkToFitIn(innerBounds.size)); g.translate(inputBounds.upperLeftCorner.x, inputBounds.upperLeftCorner.y); g.scale(float(inputBounds.size.width) / float(inputSize.width), float(inputBounds.size.height) / float(inputSize.height)); g.setColor(gluit::Color::GREEN); for (std::vector<Vector2D>::const_iterator point = inputPoints.begin(); point != inputPoints.end(); ++point) { g.drawEllipse(gluit::Rectangle(gluit::Size(10, 10)).centerOn(convert(*point)), true); } }