Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BKeyboard.h

Go to the documentation of this file.
00001 // BKeyboard.h (this is -*- C++ -*-)
00002 // 
00003 // \author: Bjoern Giesler <bjoern@giesler.de>
00004 // 
00005 // 
00006 // 
00007 // $Author: giesler $
00008 // $Locker$
00009 // $Revision$
00010 // $Date: 2002-08-19 10:41:28 +0200 (Mon, 19 Aug 2002) $
00011 
00012 #ifndef BKEYBOARD_H
00013 #define BKEYBOARD_H
00014 
00015 /* system includes */
00016 #include <string>
00017 #include <vector>
00018 #include <deque>
00019 
00020 /* my includes */
00021 #include "BButton.h"
00022 
00023 
00064 class BKeyboard:
00065   public BWidget,
00066   public BButton::Delegate
00067 {
00068 public:
00069   typedef enum {
00070     KEY_SHIFT = 'S',
00071     KEY_CAPSLOCK = 'L',
00072     KEY_BACKSPACE = 'K',
00073     KEY_DEL = 'E',
00074     KEY_RETURN = 'R',
00075     KEY_NEXTLAYOUT = 'N',
00076     KEY_CHOOSELAYOUT_0 = 'A',
00077     KEY_CHOOSELAYOUT_1 = 'B',
00078     KEY_CHOOSELAYOUT_2 = 'C',
00079     KEY_CHOOSELAYOUT_3 = 'D'
00080   } SpecialKey;
00081   
00082   class Delegate {
00083   public:
00084     virtual ~Delegate() {}
00085     virtual bool validateButton(BButton* button) { return true; }
00086     virtual void onKeyboardPressGlyph(BKeyboard* keyboard,
00087                                       const std::string& glyph) {}
00088     virtual void onKeyboardPressSpecial(BKeyboard* keyboard,
00089                                         SpecialKey specialKey) {}
00090   };
00091 
00092   static std::string qwertzLayout;
00093   static std::string numLayout;
00094   static std::string specialLayout;
00095 
00096   static std::vector<std::string> defaultLayouts();
00097 
00098   BKeyboard(BWidget* parent, const BRect& frame);
00099 
00100   void setLayout(const std::string& layout);
00101   void setLayouts(const std::vector<std::string>& layouts);
00102   void chooseLayoutNum(unsigned int num);
00103   void chooseNextLayout();
00104 
00105   void onButtonClick(BButton* button);
00106 
00107   void setDelegate(Delegate* deleg);
00108   Delegate* delegate() { return _deleg; }
00109 
00110   static std::deque<std::string> loadLayouts(BVirtualFile* file);
00111 
00112 protected:
00113   BSize sizeOfLayoutCell(const std::string& layout);
00114   void setupSpecialButton(BButton* button);
00115   void uppercaseVisibleButtons();
00116   void lowercaseVisibleButtons();
00117   
00118   std::vector<std::vector<BButton*> > _buttons;
00119   std::vector<std::string> _layouts;
00120   Delegate* _deleg;
00121   unsigned int _curLayoutnum;
00122 };
00123 
00124 #endif /* BKEYBOARD_H */

Generated on Sat Dec 29 09:59:23 2007 for DSGUI by doxygen1.3-rc3