Mercurial > dwindows
comparison win/dw.c @ 1036:c2013f1ef354
Remove creation of bold default font at startup.
Remove setting bold font on groupbox title.
Change dw_window_get_font() to use grouphwnd for groupbox; doesn't work however.
author | mhessling@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 26 May 2011 07:49:54 +0000 |
parents | 4d49504d76dd |
children | 860d6e73f8bb |
comparison
equal
deleted
inserted
replaced
1035:31dc5b4f6cfc | 1036:c2013f1ef354 |
---|---|
36 HINSTANCE DWInstance = NULL; | 36 HINSTANCE DWInstance = NULL; |
37 | 37 |
38 DWORD dwVersion = 0, dwComctlVer = 0; | 38 DWORD dwVersion = 0, dwComctlVer = 0; |
39 DWTID _dwtid = -1; | 39 DWTID _dwtid = -1; |
40 SECURITY_DESCRIPTOR _dwsd; | 40 SECURITY_DESCRIPTOR _dwsd; |
41 | |
42 static HFONT DefaultBoldFont; | |
43 static LOGFONT lfDefaultBoldFont = { 0 }; | |
44 | 41 |
45 #define PACKVERSION(major,minor) MAKELONG(minor,major) | 42 #define PACKVERSION(major,minor) MAKELONG(minor,major) |
46 | 43 |
47 #define IS_XPPLUS (dwComctlVer >= PACKVERSION(5,82)) | 44 #define IS_XPPLUS (dwComctlVer >= PACKVERSION(5,82)) |
48 | 45 |
3672 * and dw_screen-height() quicker, but to alos limit the | 3669 * and dw_screen-height() quicker, but to alos limit the |
3673 * default size of windows. | 3670 * default size of windows. |
3674 */ | 3671 */ |
3675 screenx = GetSystemMetrics(SM_CXSCREEN); | 3672 screenx = GetSystemMetrics(SM_CXSCREEN); |
3676 screeny = GetSystemMetrics(SM_CYSCREEN); | 3673 screeny = GetSystemMetrics(SM_CYSCREEN); |
3677 /* | |
3678 * Create a default bold font | |
3679 */ | |
3680 oldfont = GetStockObject(DEFAULT_GUI_FONT); | |
3681 GetObject( oldfont, sizeof(lfDefaultBoldFont), &lfDefaultBoldFont ); | |
3682 lfDefaultBoldFont.lfWeight = FW_BOLD; | |
3683 DefaultBoldFont = CreateFontIndirect(&lfDefaultBoldFont); | |
3684 return 0; | 3674 return 0; |
3685 } | 3675 } |
3686 | 3676 |
3687 /* | 3677 /* |
3688 * Runs a message loop for Dynamic Windows. | 3678 * Runs a message loop for Dynamic Windows. |
4121 * handle: The window (widget) handle. | 4111 * handle: The window (widget) handle. |
4122 * fontname: Name and size of the font in the form "size.fontname" | 4112 * fontname: Name and size of the font in the form "size.fontname" |
4123 */ | 4113 */ |
4124 char * API dw_window_get_font(HWND handle) | 4114 char * API dw_window_get_font(HWND handle) |
4125 { | 4115 { |
4126 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | 4116 HFONT oldfont = NULL; |
4127 char *str = NULL; | 4117 char *str = NULL; |
4128 char *bold = ""; | 4118 char *bold = ""; |
4129 char *italic = ""; | 4119 char *italic = ""; |
4130 LOGFONT lf = { 0 }; | 4120 LOGFONT lf = { 0 }; |
4131 | 4121 Box *thisbox; |
4122 char tmpbuf[100]; | |
4123 | |
4124 GetClassName(handle, tmpbuf, 99); | |
4125 if ( strnicmp( tmpbuf, FRAMECLASSNAME, strlen(FRAMECLASSNAME)) == 0 ) | |
4126 { | |
4127 /* groupbox */ | |
4128 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA ); | |
4129 if ( thisbox && thisbox->grouphwnd != (HWND)NULL ) | |
4130 { | |
4131 handle = thisbox->grouphwnd; | |
4132 } | |
4133 } | |
4134 oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0); | |
4132 if ( GetObject( oldfont, sizeof(lf), &lf ) ) | 4135 if ( GetObject( oldfont, sizeof(lf), &lf ) ) |
4133 { | 4136 { |
4134 str = (char *)malloc( 100 ); | 4137 str = (char *)malloc( 100 ); |
4135 if ( str ) | 4138 if ( str ) |
4136 { | 4139 { |
4498 NULL, | 4501 NULL, |
4499 DWInstance, | 4502 DWInstance, |
4500 NULL); | 4503 NULL); |
4501 | 4504 |
4502 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); | 4505 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox); |
4503 /* | 4506 fprintf(stderr,"in groupbox\n"); |
4504 * Set the text on the frame to our default bold font | |
4505 */ | |
4506 SendMessage(newbox->grouphwnd, WM_SETFONT, (WPARAM)DefaultBoldFont, (LPARAM)TRUE); | |
4507 return hwndframe; | 4507 return hwndframe; |
4508 } | 4508 } |
4509 | 4509 |
4510 /* | 4510 /* |
4511 * Create a new MDI Frame to be packed. | 4511 * Create a new MDI Frame to be packed. |
5819 { | 5819 { |
5820 char tmpbuf[100], *tempbuf; | 5820 char tmpbuf[100], *tempbuf; |
5821 int len; | 5821 int len; |
5822 | 5822 |
5823 GetClassName(handle, tmpbuf, 99); | 5823 GetClassName(handle, tmpbuf, 99); |
5824 | 5824 |
5825 if ( strnicmp( tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1) == 0 ) | 5825 if ( strnicmp( tmpbuf, UPDOWN_CLASS, strlen(UPDOWN_CLASS)+1) == 0 ) |
5826 { | 5826 { |
5827 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); | 5827 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA); |
5828 | 5828 |
5829 if( cinfo && cinfo->buddy ) | 5829 if( cinfo && cinfo->buddy ) |
5830 handle = cinfo->buddy; | 5830 handle = cinfo->buddy; |
5831 else | 5831 else |
5832 return NULL; | 5832 return NULL; |
5833 } | 5833 } |
5834 | 5834 |
5835 len = GetWindowTextLength(handle); | 5835 len = GetWindowTextLength(handle); |
5836 tempbuf = calloc(1, len + 2); | 5836 tempbuf = calloc(1, len + 2); |
5837 | 5837 |
5838 GetWindowText(handle, tempbuf, len + 1); | 5838 GetWindowText(handle, tempbuf, len + 1); |
5839 | 5839 |
8297 HBRUSH hBrush = TlsGetValue(_hBrush); | 8297 HBRUSH hBrush = TlsGetValue(_hBrush); |
8298 COLORREF foreground; | 8298 COLORREF foreground; |
8299 | 8299 |
8300 value = _internal_color(value); | 8300 value = _internal_color(value); |
8301 foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); | 8301 foreground = RGB(DW_RED_VALUE(value), DW_GREEN_VALUE(value), DW_BLUE_VALUE(value)); |
8302 | 8302 |
8303 DeleteObject(hPen); | 8303 DeleteObject(hPen); |
8304 DeleteObject(hBrush); | 8304 DeleteObject(hBrush); |
8305 TlsSetValue(_foreground, (LPVOID)foreground); | 8305 TlsSetValue(_foreground, (LPVOID)foreground); |
8306 TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground)); | 8306 TlsSetValue(_hPen, CreatePen(PS_SOLID, 1, foreground)); |
8307 TlsSetValue(_hBrush, CreateSolidBrush(foreground)); | 8307 TlsSetValue(_hBrush, CreateSolidBrush(foreground)); |
8675 /* Couldn't read the file header */ | 8675 /* Couldn't read the file header */ |
8676 fclose(fp); | 8676 fclose(fp); |
8677 return 0; | 8677 return 0; |
8678 } | 8678 } |
8679 | 8679 |
8680 if(header.bfType != 'MB') /* Check for BM reversed... */ | 8680 if(header.bfType != 'MB') /* Check for BM reversed... */ |
8681 { | 8681 { |
8682 /* Not a bitmap file */ | 8682 /* Not a bitmap file */ |
8683 fclose(fp); | 8683 fclose(fp); |
8684 return 0; | 8684 return 0; |
8685 } | 8685 } |
9387 * Parameters: | 9387 * Parameters: |
9388 * exitcode: Exit code reported to the operating system. | 9388 * exitcode: Exit code reported to the operating system. |
9389 */ | 9389 */ |
9390 void API dw_exit(int exitcode) | 9390 void API dw_exit(int exitcode) |
9391 { | 9391 { |
9392 DeleteObject( DefaultBoldFont ); | |
9393 OleUninitialize(); | 9392 OleUninitialize(); |
9394 if ( dbgfp != NULL ) | 9393 if ( dbgfp != NULL ) |
9395 { | 9394 { |
9396 fclose( dbgfp ); | 9395 fclose( dbgfp ); |
9397 } | 9396 } |
10012 static char _user_dir[1024] = ""; | 10011 static char _user_dir[1024] = ""; |
10013 | 10012 |
10014 if(!_user_dir[0]) | 10013 if(!_user_dir[0]) |
10015 { | 10014 { |
10016 HANDLE hToken = 0; | 10015 HANDLE hToken = 0; |
10017 | 10016 |
10018 /* Use the Windows API to get the user's profile directory */ | 10017 /* Use the Windows API to get the user's profile directory */ |
10019 if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) | 10018 if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) |
10020 { | 10019 { |
10021 DWORD BufSize = 1024; | 10020 DWORD BufSize = 1024; |
10022 | 10021 |
10023 GetUserProfileDirectory(hToken, _user_dir, &BufSize); | 10022 GetUserProfileDirectory(hToken, _user_dir, &BufSize); |
10024 CloseHandle(hToken); | 10023 CloseHandle(hToken); |
10025 } | 10024 } |
10026 /* If it fails set it to the root directory */ | 10025 /* If it fails set it to the root directory */ |
10027 if(!_user_dir[0]) | 10026 if(!_user_dir[0]) |