/[enigma]/enigma/src/gui.cc
ViewVC logotype

Diff of /enigma/src/gui.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by dheck, Thu Jun 19 14:27:59 2003 UTC revision 1.10 by dheck, Thu Jun 19 22:19:18 2003 UTC
# Line 178  Container::boundingbox() Line 178  Container::boundingbox()
178          return get_area();          return get_area();
179  }  }
180    
181    
182    //----------------------------------------
183    // Label implementation
184    //----------------------------------------
185    
186    Label::Label (const std::string &text)
187    : m_text (text),
188      m_font(enigma::GetFont("menufont"))
189    {}
190    
191    
192    void Label::set_text (const std::string &text)
193    {
194        if (text != m_text) {
195            m_text = text;
196            redraw();
197        }
198    }
199    
200    void Label::set_font (px::Font *font)
201    {
202        if (m_font != font) {
203            m_font = font;
204            redraw();
205        }
206    }
207    
208    void Label::draw (px::GC &gc, const px::Rect &r)
209    {
210        Font *f = m_font;
211        int h = f->get_height();
212        int w = f->get_width(m_text.c_str());
213    
214        int x = get_x(), y=get_y();
215        switch (m_halign) {
216        case ALIGN_LEFT: break;
217        case ALIGN_RIGHT: x += get_w() - w; break;
218        case ALIGN_CENTER: x += (get_w()-w)/2; break;
219        }
220        switch (m_valign) {
221        case ALIGN_LEFT: break;
222        case ALIGN_RIGHT: y += get_h() - h; break;
223        case ALIGN_CENTER: y += (get_h()-h)/2; break;
224        }
225    
226        f->render (gc, x, y, m_text.c_str());
227    }
228    
229    void Label::set_alignment (Alignment horizontal, Alignment vertical)
230    {
231        if (horizontal != m_halign || vertical != m_valign) {
232            m_halign = horizontal;
233            m_valign = vertical;
234            redraw();
235        }
236    }
237    
238    
239  //----------------------------------------  //----------------------------------------
240  // Button implementation  // Button implementation
# Line 308  px::Font *TextButton::menufont = 0; Line 365  px::Font *TextButton::menufont = 0;
365  px::Font *TextButton::menufont_pressed = 0;  px::Font *TextButton::menufont_pressed = 0;
366    
367  TextButton::TextButton(const string &t, ActionListener *al)  TextButton::TextButton(const string &t, ActionListener *al)
368      : text(t)  : text(t)
369  {  {
370      if (menufont == 0) {      if (menufont == 0) {
371          menufont = enigma::GetFont("menufont"); //menufont");          menufont = enigma::GetFont("menufont"); //menufont");
# Line 343  TextButton::draw(px::GC &gc, const px::R Line 400  TextButton::draw(px::GC &gc, const px::R
400  // ImageButton implementation.  // ImageButton implementation.
401  //----------------------------------------  //----------------------------------------
402  ImageButton::ImageButton(const std::string &unselected,  ImageButton::ImageButton(const std::string &unselected,
403                           const std::string &selected)                           const std::string &selected,
404                             ActionListener *al)
405  : fname_sel(selected),  : fname_sel(selected),
406    fname_unsel(unselected)    fname_unsel(unselected)
407  {}  {
408        set_listener(al);
409    }
410    
411  void  void
412  ImageButton::draw(px::GC &gc, const px::Rect &r)  ImageButton::draw(px::GC &gc, const px::Rect &r)

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26