Mercurial > dwindows
comparison os2/dw.c @ 1056:240bd5fb8453
Ugg... tabs got enabled in my editor and I didn't notice until after I committed.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 02 Jun 2011 10:58:43 +0000 |
parents | 140d04226c86 |
children | 3d117071a50b |
comparison
equal
deleted
inserted
replaced
1055:140d04226c86 | 1056:240bd5fb8453 |
---|---|
4079 * Returns: | 4079 * Returns: |
4080 * A malloced buffer with the selected font or NULL on error. | 4080 * A malloced buffer with the selected font or NULL on error. |
4081 */ | 4081 */ |
4082 char * API dw_font_choose(char *currfont) | 4082 char * API dw_font_choose(char *currfont) |
4083 { | 4083 { |
4084 FONTDLG fd = { 0 }; | 4084 FONTDLG fd = { 0 }; |
4085 char *buf = calloc(1,100); | 4085 char *buf = calloc(1,100); |
4086 int size = 9; | 4086 int size = 9; |
4087 | 4087 |
4088 /* Fill in the family name if possible */ | 4088 /* Fill in the family name if possible */ |
4089 if(currfont) | 4089 if(currfont) |
4090 { | 4090 { |
4091 char *name = strchr(currfont, "."); | 4091 char *name = strchr(currfont, "."); |
4092 if(name) | 4092 if(name) |
4093 { | 4093 { |
4094 int newsize = atoi(currfont); | 4094 int newsize = atoi(currfont); |
4095 if(newsize > 0) | 4095 if(newsize > 0) |
4096 size = newsize; | 4096 size = newsize; |
4097 name++; | 4097 name++; |
4098 strcpy(buf, name); | 4098 strcpy(buf, name); |
4099 strcpy(fd.fAttrs.szFacename, name); | 4099 strcpy(fd.fAttrs.szFacename, name); |
4100 } | 4100 } |
4101 else | 4101 else |
4102 { | 4102 { |
4103 strcpy(buf, currfont); | 4103 strcpy(buf, currfont); |
4104 strcpy(fd.fAttrs.szFacename, currfont); | 4104 strcpy(fd.fAttrs.szFacename, currfont); |
4105 } | 4105 } |
4106 } | 4106 } |
4107 | 4107 |
4108 /* Fill in the font dialog struct */ | 4108 /* Fill in the font dialog struct */ |
4109 fd.cbSize = sizeof(fd); | 4109 fd.cbSize = sizeof(fd); |
4110 fd.hpsScreen = WinGetScreenPS(HWND_DESKTOP); | 4110 fd.hpsScreen = WinGetScreenPS(HWND_DESKTOP); |
4111 fd.pszTitle = "Choose Font"; | 4111 fd.pszTitle = "Choose Font"; |
4112 fd.clrFore = CLR_BLACK; | 4112 fd.clrFore = CLR_BLACK; |
4113 fd.clrBack = CLR_WHITE; | 4113 fd.clrBack = CLR_WHITE; |
4114 fd.pszFamilyname = buf; | 4114 fd.pszFamilyname = buf; |
4115 fd.usFamilyBufLen = 100; | 4115 fd.usFamilyBufLen = 100; |
4116 fd.fxPointSize = MAKEFIXED(size,0); | 4116 fd.fxPointSize = MAKEFIXED(size,0); |
4117 fd.fl = FNTS_INITFROMFATTRS; | 4117 fd.fl = FNTS_INITFROMFATTRS; |
4118 | 4118 |
4119 /* Show the dialog and wait for a response */ | 4119 /* Show the dialog and wait for a response */ |
4120 if(!WinFontDlg(HWND_DESKTOP, HWND_OBJECT, &fd) || fd.lReturn != DID_OK) | 4120 if(!WinFontDlg(HWND_DESKTOP, HWND_OBJECT, &fd) || fd.lReturn != DID_OK) |
4121 { | 4121 { |
4122 WinReleasePS(fd.hpsScreen); | 4122 WinReleasePS(fd.hpsScreen); |
4123 free(buf); | 4123 free(buf); |
4124 return NULL; | 4124 return NULL; |
4125 } | 4125 } |
4126 WinReleasePS(fd.hpsScreen); | 4126 WinReleasePS(fd.hpsScreen); |
4127 /* Figure out what the user selected and return that */ | 4127 /* Figure out what the user selected and return that */ |
4128 size = FIXEDINT(fd.fxPointSize); | 4128 size = FIXEDINT(fd.fxPointSize); |
4129 sprintf(buf, "%d.%s", size, fd.fAttrs.szFacename); | 4129 sprintf(buf, "%d.%s", size, fd.fAttrs.szFacename); |
4130 return buf; | 4130 return buf; |
4131 } | 4131 } |
4132 | 4132 |
4133 /* | 4133 /* |
4134 * Sets the font used by a specified window (widget) handle. | 4134 * Sets the font used by a specified window (widget) handle. |