Button changed to a FbWindow

This commit is contained in:
fluxgen 2003-08-13 10:14:54 +00:00
parent 225e89d775
commit 662be09609
2 changed files with 81 additions and 80 deletions

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: TextButton.cc,v 1.3 2003/08/11 14:34:46 fluxgen Exp $ // $Id: TextButton.cc,v 1.4 2003/08/13 10:12:36 fluxgen Exp $
#include "TextButton.hh" #include "TextButton.hh"
#include "Font.hh" #include "Font.hh"
@ -80,10 +80,12 @@ void TextButton::drawText(int x_offset, int y_offset) {
text().c_str(), text().size(), text().c_str(), text().size(),
textlen // return new text len textlen // return new text len
); );
// center text by default // center text by default
int center_pos = height()/2 + font().ascent()/2; int center_pos = height()/2 + font().ascent()/2;
font().drawText(window().window(), // drawable
window().screenNumber(), font().drawText(window(), // drawable
screenNumber(),
gc(), // graphic context gc(), // graphic context
text().c_str(), textlen, // string and string size text().c_str(), textlen, // string and string size
align_x + x_offset, center_pos + y_offset); // position align_x + x_offset, center_pos + y_offset); // position

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
/// $Id: WinButton.cc,v 1.7 2003/08/04 12:52:39 fluxgen Exp $ /// $Id: WinButton.cc,v 1.8 2003/08/13 10:14:54 fluxgen Exp $
#include "WinButton.hh" #include "WinButton.hh"
#include "App.hh" #include "App.hh"
@ -82,7 +82,7 @@ WinButton::WinButton(const FluxboxWindow &listen_to,
void WinButton::exposeEvent(XExposeEvent &event) { void WinButton::exposeEvent(XExposeEvent &event) {
FbTk::Button::exposeEvent(event); FbTk::Button::exposeEvent(event);
drawType(); drawType();
window().updateTransparent(); updateTransparent();
} }
void WinButton::buttonReleaseEvent(XButtonEvent &event) { void WinButton::buttonReleaseEvent(XButtonEvent &event) {
@ -92,12 +92,11 @@ void WinButton::buttonReleaseEvent(XButtonEvent &event) {
void WinButton::drawType() { void WinButton::drawType() {
switch (m_type) { switch (m_type) {
case MAXIMIZE: case MAXIMIZE:
if (m_theme.maximizePixmap().pixmap_scaled.drawable() != 0) { if (m_theme.maximizePixmap().pixmap_scaled.drawable() != 0) {
if (pressed()) { if (pressed()) {
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
maximizePressedPixmap(). maximizePressedPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else if (m_theme.maximizePixmap().pixmap_scaled.drawable()) { } else if (m_theme.maximizePixmap().pixmap_scaled.drawable()) {
@ -105,31 +104,31 @@ void WinButton::drawType() {
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.maximizeUnfocusPixmap().pixmap_scaled.drawable() != 0) { m_theme.maximizeUnfocusPixmap().pixmap_scaled.drawable() != 0) {
// not focused // not focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
maximizeUnfocusPixmap(). maximizeUnfocusPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else { // focused } else { // focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
maximizePixmap(). maximizePixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} }
} }
window().clear(); FbTk::FbWindow::clear();
} else { } else {
if (gc() == 0) // must have valid graphic context if (gc() == 0) // must have valid graphic context
return; return;
window().drawRectangle(gc(), drawRectangle(gc(),
2, 2, width() - 5, height() - 5); 2, 2, width() - 5, height() - 5);
window().drawLine(gc(), drawLine(gc(),
2, 3, width() - 3, 3); 2, 3, width() - 3, 3);
} }
break; break;
case MINIMIZE: case MINIMIZE:
if (m_theme.iconifyPixmap().pixmap_scaled.drawable() != 0) { if (m_theme.iconifyPixmap().pixmap_scaled.drawable() != 0) {
if (pressed()) { if (pressed()) {
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
iconifyPressedPixmap(). iconifyPressedPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else if (m_theme.iconifyPixmap().pixmap_scaled.drawable()){ } else if (m_theme.iconifyPixmap().pixmap_scaled.drawable()){
@ -137,22 +136,22 @@ void WinButton::drawType() {
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.iconifyUnfocusPixmap().pixmap_scaled.drawable() != 0) { m_theme.iconifyUnfocusPixmap().pixmap_scaled.drawable() != 0) {
// not focused // not focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
iconifyUnfocusPixmap(). iconifyUnfocusPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else { // focused } else { // focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
iconifyPixmap(). iconifyPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} }
} }
window().clear(); FbTk::FbWindow::clear();
} else { } else {
if (gc() == 0) // must have valid graphic context if (gc() == 0) // must have valid graphic context
return; return;
window().drawRectangle(gc(), FbTk::FbWindow::drawRectangle(gc(),
2, height() - 5, width() - 5, 2); 2, height() - 5, width() - 5, 2);
} }
break; break;
@ -165,18 +164,18 @@ void WinButton::drawType() {
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.stuckUnfocusPixmap().pixmap_scaled.drawable() != 0) { m_theme.stuckUnfocusPixmap().pixmap_scaled.drawable() != 0) {
// not focused // not focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stuckUnfocusPixmap(). stuckUnfocusPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else { // focused } else { // focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stuckPixmap(). stuckPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} }
} else { // not stuck } else { // not stuck
if (pressed()) { if (pressed()) {
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stickPressedPixmap(). stickPressedPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
@ -185,11 +184,11 @@ void WinButton::drawType() {
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.stickUnfocusPixmap().pixmap_scaled.drawable() != 0) { m_theme.stickUnfocusPixmap().pixmap_scaled.drawable() != 0) {
// not focused // not focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stickUnfocusPixmap(). stickUnfocusPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else { // focused } else { // focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
stickPixmap(). stickPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} }
@ -197,17 +196,17 @@ void WinButton::drawType() {
} }
} // end if stuck } // end if stuck
window().clear(); FbTk::FbWindow::clear();
} else { } else {
if (m_listen_to.isStuck()) { if (m_listen_to.isStuck()) {
window().fillRectangle(gc(), fillRectangle(gc(),
width()/2 - width()/4, height()/2 - height()/4, width()/2 - width()/4, height()/2 - height()/4,
width()/2, height()/2); width()/2, height()/2);
} else { } else {
if (gc() == 0) // must have valid graphic context if (gc() == 0) // must have valid graphic context
return; return;
window().fillRectangle(gc(), fillRectangle(gc(),
width()/2 - width()/10, height()/2 - height()/10, width()/2 - width()/10, height()/2 - height()/10,
width()/5, height()/5); width()/5, height()/5);
} }
@ -217,7 +216,7 @@ void WinButton::drawType() {
if (m_theme.closePixmap().pixmap_scaled.drawable() != 0) { if (m_theme.closePixmap().pixmap_scaled.drawable() != 0) {
if (pressed()) { if (pressed()) {
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
closePressedPixmap(). closePressedPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
@ -226,25 +225,25 @@ void WinButton::drawType() {
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.closeUnfocusPixmap().pixmap_scaled.drawable() != 0) { m_theme.closeUnfocusPixmap().pixmap_scaled.drawable() != 0) {
// not focused // not focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
closeUnfocusPixmap(). closeUnfocusPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else { // focused } else { // focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
closePixmap(). closePixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} }
} }
window().clear(); FbTk::FbWindow::clear();
} else { } else {
if (gc() == 0) // must have valid graphic context if (gc() == 0) // must have valid graphic context
return; return;
window().drawLine(gc(), drawLine(gc(),
2, 2, 2, 2,
width() - 3, height() - 3); width() - 3, height() - 3);
window().drawLine(gc(), drawLine(gc(),
2, width() - 3, 2, width() - 3,
height() - 3, 2); height() - 3, 2);
} }
@ -252,7 +251,7 @@ void WinButton::drawType() {
case SHADE: case SHADE:
if (m_theme.shadePixmap().pixmap_scaled.drawable() != 0) { if (m_theme.shadePixmap().pixmap_scaled.drawable() != 0) {
if (pressed()) { if (pressed()) {
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
shadePressedPixmap(). shadePressedPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else if (m_theme.shadePixmap().pixmap_scaled.drawable()) { } else if (m_theme.shadePixmap().pixmap_scaled.drawable()) {
@ -260,17 +259,17 @@ void WinButton::drawType() {
if (!m_listen_to.isFocused() && if (!m_listen_to.isFocused() &&
m_theme.shadeUnfocusPixmap().pixmap_scaled.drawable() != 0) { m_theme.shadeUnfocusPixmap().pixmap_scaled.drawable() != 0) {
// not focused // not focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
shadeUnfocusPixmap(). shadeUnfocusPixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} else { // focused } else { // focused
window().setBackgroundPixmap(m_theme. FbTk::FbWindow::setBackgroundPixmap(m_theme.
shadePixmap(). shadePixmap().
pixmap_scaled.drawable()); pixmap_scaled.drawable());
} }
} }
window().clear(); FbTk::FbWindow::clear();
} }
break; break;
} }