svc_fontmaker.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _SVC_FONTMAKER_H
  2. #define _SVC_FONTMAKER_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/string/string.h>
  5. #include <api/service/svc_enum.h>
  6. #include <api/service/services.h>
  7. #include <api/service/servicei.h>
  8. class svc_font;
  9. //
  10. // This class doesn't do anything fantastic. It's just the way
  11. // you make your OS-Specific font class available to the system.
  12. class NOVTABLE svc_fontMaker : public Dispatchable {
  13. public:
  14. static FOURCC getServiceType() { return WaSvc::FONTRENDER; }
  15. // You implement these:
  16. const char *getFontMakerName();
  17. svc_font *newTrueTypeFont();
  18. int deleteTrueTypeFont(svc_font *font);
  19. protected:
  20. enum {
  21. GETFONTMAKERNAME,
  22. NEWTRUETYPEFONT,
  23. DELETETRUETYPEFONT,
  24. };
  25. };
  26. inline const char *svc_fontMaker::getFontMakerName() {
  27. return _call(GETFONTMAKERNAME, (const char *)0);
  28. }
  29. inline svc_font *svc_fontMaker::newTrueTypeFont() {
  30. return _call(NEWTRUETYPEFONT, (svc_font *)0);
  31. }
  32. inline int svc_fontMaker::deleteTrueTypeFont(svc_font *font) {
  33. return _call(DELETETRUETYPEFONT, (int)0, font);
  34. }
  35. // implementor derives from this one
  36. class NOVTABLE svc_fontMakerI : public svc_fontMaker {
  37. public:
  38. virtual const char *getFontMakerName() = 0;
  39. virtual svc_font *newTrueTypeFont() = 0;
  40. virtual int deleteTrueTypeFont(svc_font *font) = 0;
  41. protected:
  42. RECVS_DISPATCH;
  43. };
  44. class FontMakerEnum : public SvcEnumT<svc_fontMaker> {
  45. public:
  46. FontMakerEnum(const char *_maker_name = NULL) : maker_name(_maker_name) {}
  47. protected:
  48. virtual int testService(svc_fontMaker *svc) {
  49. if (!maker_name.len()) return 1; // blank name returns all services.
  50. return (STRCASEEQL(svc->getFontMakerName(),maker_name));
  51. }
  52. private:
  53. String maker_name;
  54. };
  55. template <class T>
  56. class FontMakerCreator : public waServiceFactoryTSingle<svc_fontMaker, T> {};
  57. #endif // _SVC_FONTMAKER_H