comparison win/dw.c @ 1075:3d117071a50b

Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows. Function added to the public export list... GTK2/3 support will be added shortly.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 26 Jun 2011 02:07:49 +0000
parents 659b3c6a8959
children 34f1d6f5f1c3
comparison
equal deleted inserted replaced
1074:53fc692279fc 1075:3d117071a50b
71 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xff, 0xaa, 0x00}; 71 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xff, 0xaa, 0x00};
72 72
73 HBRUSH _colors[18]; 73 HBRUSH _colors[18];
74 74
75 static int screenx, screeny; 75 static int screenx, screeny;
76 HFONT _DefaultFont = NULL;
76 77
77 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 78 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
78 void _resize_notebook_page(HWND handle, int pageid); 79 void _resize_notebook_page(HWND handle, int pageid);
79 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y); 80 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y);
80 int _lookup_icon(HWND handle, HICON hicon, int type); 81 int _lookup_icon(HWND handle, HICON hicon, int type);
4036 strcpy(lf.lfFaceName, myFontName); 4037 strcpy(lf.lfFaceName, myFontName);
4037 free(myFontName); 4038 free(myFontName);
4038 return lf; 4039 return lf;
4039 } 4040 }
4040 4041
4042 /* Create a duplicate of an existing font handle
4043 * that is safe to call DeleteObject() on.
4044 */
4045 HFONT _DupFontHandle(HFONT hfont)
4046 {
4047 LOGFONT lf = {0};
4048 return GetObject(hfont, sizeof(lf), &lf) ? CreateFontIndirect(&lf) : NULL;
4049 }
4050
4051 /* Create a font handle from specified font name..
4052 * or return a handle to the default font.
4053 */
4041 HFONT _acquire_font(HWND handle, char *fontname) 4054 HFONT _acquire_font(HWND handle, char *fontname)
4042 { 4055 {
4043 HFONT hfont = 0; 4056 HFONT hfont = 0;
4044 4057
4045 if(fontname != DefaultFont && fontname[0]) 4058 if(fontname != DefaultFont && fontname[0])
4046 { 4059 {
4047 LOGFONT lf = _get_logfont(handle, fontname); 4060 LOGFONT lf = _get_logfont(handle, fontname);
4048 hfont = CreateFontIndirect(&lf); 4061 hfont = CreateFontIndirect(&lf);
4049 } 4062 }
4063 if(!hfont && _DefaultFont)
4064 hfont = _DupFontHandle(_DefaultFont);
4050 if(!hfont) 4065 if(!hfont)
4051 hfont = GetStockObject(DEFAULT_GUI_FONT); 4066 hfont = GetStockObject(DEFAULT_GUI_FONT);
4052 return hfont; 4067 return hfont;
4068 }
4069
4070 /*
4071 * Sets the default font used on text based widgets.
4072 * Parameters:
4073 * fontname: Font name in Dynamic Windows format.
4074 */
4075 void API dw_font_set_default(char *fontname)
4076 {
4077 HFONT oldfont = _DefaultFont;
4078
4079 _DefaultFont = _acquire_font(HWND_DESKTOP, fontname);
4080 if(oldfont)
4081 {
4082 DeleteObject(oldfont);
4083 }
4053 } 4084 }
4054 4085
4055 /* 4086 /*
4056 * Sets the font used by a specified window (widget) handle. 4087 * Sets the font used by a specified window (widget) handle.
4057 * Parameters: 4088 * Parameters: