Back to index

plt-scheme  4.2.1
Item.cc
Go to the documentation of this file.
00001 /*                                                      -*- C++ -*-
00002  *
00003  * Purpose: base class for all panel items
00004  *
00005  * Authors: Markus Holzem and Julian Smart
00006  *
00007  * Copyright: (C) 2004-2009 PLT Scheme Inc.
00008  * Copyright: (C) 1995, AIAI, University of Edinburgh (Julian)
00009  * Copyright: (C) 1995, GNU (Markus)
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00027 #ifdef __GNUG__
00028 #pragma implementation "Item.h"
00029 #endif
00030 
00031 #define  Uses_XtIntrinsic
00032 #define  Uses_wxItem
00033 #define  Uses_wxPanel
00034 #define  Uses_wxBitmap
00035 #include "wx.h"
00036 #include "widgets.h" // for <X11/StringDefs.h>
00037 
00038 //-----------------------------------------------------------------------------
00039 // wxItem constructor
00040 //-----------------------------------------------------------------------------
00041 
00042 wxItem::wxItem(wxFont *_font) : wxWindow()
00043 { 
00044     __type = wxTYPE_ITEM;
00045     font = (_font ? _font : wxSYSTEM_FONT);
00046     callback = NULL;
00047 };
00048 
00049 //-----------------------------------------------------------------------------
00050 // get and set colours
00051 //-----------------------------------------------------------------------------
00052 
00053 void wxItem::ChainToPanel(wxPanel *panel, long _style, char *name)
00054 {
00055     if (!panel)
00056        wxFatalError("created without a panel!", name ? name : "item");
00057     parent = panel;
00058     parent->AddChild(this);
00059 
00060     style       = _style;
00061 }
00062 
00063 //-----------------------------------------------------------------------------
00064 // functions to execute item
00065 //-----------------------------------------------------------------------------
00066 
00067 void wxItem::Command(wxCommandEvent *WXUNUSED(event))
00068 {
00069 }
00070 
00071 void wxItem::ProcessCommand(wxCommandEvent *event)
00072 {
00073   if (callback) {
00074     callback(this, event);
00075   } else {
00076     if (parent)
00077       parent->OnCommand(this, event);
00078   }
00079 }
00080 
00081 char *wxGetCtlLabel(char *label)
00082 {
00083   if (!label)
00084     return NULL;
00085 
00086 #if 0
00087   wxGetLabelAndKey(label, &label, NULL);
00088 #endif
00089 
00090   return label;
00091 }
00092 
00093 wxBitmap *wxItem::CheckMask(wxBitmap *bm)
00094 {
00095   int can_x_render;
00096   wxBitmap *mbm;
00097 
00098   if (!bm)
00099     return NULL;
00100 
00101   mbm = bm->GetMask();
00102   if (!mbm)
00103     return NULL;
00104 
00105 #ifdef WX_USE_XRENDER
00106   can_x_render = wxXRenderHere();
00107 #else
00108   can_x_render = 0;
00109 #endif
00110 
00111   /* If no X render and non-mono mask, then we have to manually apply
00112      the alpha mask. See wxBitmap::GetLabelPixmap(). */
00113   if (!can_x_render && (mbm->GetDepth() != 1))
00114     return NULL;
00115 
00116   if ((mbm->GetWidth() == bm->GetWidth())
00117       && (mbm->GetHeight() == bm->GetHeight())) {
00118     if (mbm->selectedIntoDC >= 0) {
00119       if (mbm->GetDepth() > 1) {
00120        /* Need mask */
00121        mbm = mbm->GetMaskBit();
00122        if (!mbm)
00123          return NULL;
00124       }
00125       mbm->selectedIntoDC++;
00126       return mbm;
00127     }
00128   }
00129 
00130   return NULL;
00131 }