1 #ifndef _WIDGET_SERVICE_PROVIDER_ 2 #define _WIDGET_SERVICE_PROVIDER_ 3 4 class screen_generator; // forward reference 5 6 #define RESIZE_MODE_ALL 1 7 #define RESIZE_MODE_HEIGHT 2 8 #define RESIZE_MODE_WIDTH 3 9 10 11 class widget_service_provider 12 { 13 public: 14 widget_service_provider(); ~widget_service_provider()15 virtual ~widget_service_provider() {} 16 widget_info *InitWidgetInfo(GX_WIDGET *child); 17 GetType()18 virtual int GetType() {return GX_TYPE_WIDGET;} GetTypeName(widget_info *)19 virtual CString GetTypeName(widget_info *) {return CString("GX_TYPE_WIDGET");} GetShortName()20 virtual CString GetShortName() {return CString("widget");} 21 virtual CString GetVarDeclaration(); GetControlBlockName()22 virtual CString GetControlBlockName() {return CString("GX_WIDGET");} 23 static CString GetDefaultEventProcess(int widget_type); 24 25 virtual CString DeclarePropertiesStruct(); WriteExtendedProperties(screen_generator * gen,CString & scope,widget_info * info)26 virtual CString WriteExtendedProperties(screen_generator *gen, CString &scope, widget_info *info) {return CString("");} 27 virtual CString GetCreateFromDefFunctionName(); 28 virtual CString GetCreateFromDefFunction(int version); 29 GX_RESOURCE_ID GetStringId(char *string); 30 void GetStringText(CHAR *put, int limit, widget_info *info); 31 static void GetTextDimension(int base_type, GX_CONST GX_CHAR *string, GX_FONT *normal_font, GX_FONT *selected_font, INT &max_width, INT &max_height); 32 static void GetTextDrawDimension(widget_info *info, GX_DISPLAY *display, INT &draw_width, INT &draw_height); 33 static GX_RECTANGLE CalculateTextFitSize(widget_info *info, int display_index); 34 BOOL CheckResizeToText(widget_info *info, int resize_mode = RESIZE_MODE_ALL); 35 BOOL CheckResizeToPixelmap(widget_info *info, int resize_mode = RESIZE_MODE_ALL, BOOL DontShrink = FALSE); 36 37 virtual widget_info *CreateNewInstance(GX_WIDGET *parent); 38 virtual GX_WIDGET *GenerateFromInfo(GX_WIDGET *parent, widget_info *info); 39 40 static void WriteStringId(xml_writer &writer, studiox_project *project, int display, char *tag, GX_RESOURCE_ID resid); 41 static void WriteFontId(xml_writer &writer, studiox_project *project, int display, char *tag, GX_RESOURCE_ID resid); 42 static void WritePixelmapId(xml_writer &writer, studiox_project *project, int display, char *tag, GX_RESOURCE_ID resid); 43 static void WriteColorId(xml_writer &writer, studiox_project *project, int display, char *tag, GX_RESOURCE_ID resid); 44 45 static GX_RESOURCE_ID ReadStringId(xml_reader &reader, studiox_project *project, int display, char *tag); 46 static GX_RESOURCE_ID ReadFontId(xml_reader &reader, studiox_project *project, int display, char *tag); 47 static GX_RESOURCE_ID ReadPixelmapId(xml_reader &reader, studiox_project *project, int display, char *tag); 48 static GX_RESOURCE_ID ReadColorId(xml_reader &reader, studiox_project *project, int display, char *tag); 49 50 virtual void SaveToProject(xml_writer &, studiox_project *project, int display, widget_info *); 51 virtual void ReadFromProject(xml_reader &, studiox_project *projet, int display, widget_info *info, ULONG valid_styles); Reset()52 virtual void Reset() {}; 53 54 void MakeCreatePreamble(char *name, int version, CString &out); 55 AssignText(widget_info * info,int index,GX_RESOURCE_ID string_id)56 virtual void AssignText(widget_info *info, int index, GX_RESOURCE_ID string_id) {} AssignFont(widget_info * info,int index,GX_RESOURCE_ID font_id)57 virtual void AssignFont(widget_info *info, int index, GX_RESOURCE_ID font_id) {} 58 virtual void AssignColor(widget_info *info, int index, GX_RESOURCE_ID color_id); AssignPixelmap(widget_info * info,int index,GX_RESOURCE_ID pixmap_id)59 virtual void AssignPixelmap(widget_info *info, int index, GX_RESOURCE_ID pixmap_id) {} Autosize(widget_info * info)60 virtual void Autosize(widget_info *info) {} 61 62 static int GetBorderWidth(DWORD style); 63 }; 64 65 #endif 66