Mercurial > dwindows
comparison mac/dw.m @ 1128:7d7535f6bc4e
Added ability to set background color of MLE; setting foreground still outstanding.
Fixed dw_mle_export to respect startpoint parameter.
author | mhessling@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 02 Sep 2011 01:17:31 +0000 |
parents | b2e060f43329 |
children | ab73d0269a5b |
comparison
equal
deleted
inserted
replaced
1127:ed7cbdc37a75 | 1128:7d7535f6bc4e |
---|---|
1627 if(node && ([node isKindOfClass:[NSArray class]])) | 1627 if(node && ([node isKindOfClass:[NSArray class]])) |
1628 { | 1628 { |
1629 int count = (int)[node count]; | 1629 int count = (int)[node count]; |
1630 NSInteger index = -1; | 1630 NSInteger index = -1; |
1631 int z; | 1631 int z; |
1632 | 1632 |
1633 if(item) | 1633 if(item) |
1634 index = [node indexOfObject:item]; | 1634 index = [node indexOfObject:item]; |
1635 | 1635 |
1636 for(z=0;z<count;z++) | 1636 for(z=0;z<count;z++) |
1637 { | 1637 { |
2576 dw_splitbar_set(handle, percent); | 2576 dw_splitbar_set(handle, percent); |
2577 [split setPercent:0]; | 2577 [split setPercent:0]; |
2578 } | 2578 } |
2579 else if([window redraw]) | 2579 else if([window redraw]) |
2580 { | 2580 { |
2581 [split splitViewDidResizeSubviews:nil]; | 2581 [split splitViewDidResizeSubviews:nil]; |
2582 } | 2582 } |
2583 } | 2583 } |
2584 if(thisbox->type == DW_HORZ) | 2584 if(thisbox->type == DW_HORZ) |
2585 currentx += width + vectorx + (pad * 2); | 2585 currentx += width + vectorx + (pad * 2); |
2586 if(thisbox->type == DW_VERT) | 2586 if(thisbox->type == DW_VERT) |
3194 if(box == item) | 3194 if(box == item) |
3195 { | 3195 { |
3196 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!"); | 3196 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!"); |
3197 return; | 3197 return; |
3198 } | 3198 } |
3199 | 3199 |
3200 /* Query the objects */ | 3200 /* Query the objects */ |
3201 if([ object isKindOfClass:[ NSWindow class ] ]) | 3201 if([ object isKindOfClass:[ NSWindow class ] ]) |
3202 { | 3202 { |
3203 NSWindow *window = box; | 3203 NSWindow *window = box; |
3204 view = [window contentView]; | 3204 view = [window contentView]; |
3228 /* Do some sanity bounds checking */ | 3228 /* Do some sanity bounds checking */ |
3229 if(index < 0) | 3229 if(index < 0) |
3230 index = 0; | 3230 index = 0; |
3231 if(index > thisbox->count) | 3231 if(index > thisbox->count) |
3232 index = thisbox->count; | 3232 index = thisbox->count; |
3233 | 3233 |
3234 /* Duplicate the existing data */ | 3234 /* Duplicate the existing data */ |
3235 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); | 3235 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
3236 | 3236 |
3237 for(z=0;z<thisbox->count;z++) | 3237 for(z=0;z<thisbox->count;z++) |
3238 { | 3238 { |
3255 { | 3255 { |
3256 if ( width == 0 && hsize == FALSE ) | 3256 if ( width == 0 && hsize == FALSE ) |
3257 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); | 3257 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item); |
3258 if ( height == 0 && vsize == FALSE ) | 3258 if ( height == 0 && vsize == FALSE ) |
3259 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); | 3259 dw_messagebox(funcname, DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item); |
3260 | 3260 |
3261 tmpitem[index].type = TYPEITEM; | 3261 tmpitem[index].type = TYPEITEM; |
3262 } | 3262 } |
3263 | 3263 |
3264 tmpitem[index].hwnd = item; | 3264 tmpitem[index].hwnd = item; |
3265 tmpitem[index].origwidth = tmpitem[index].width = width; | 3265 tmpitem[index].origwidth = tmpitem[index].width = width; |
3302 /* | 3302 /* |
3303 * Pack windows (widgets) into a box at an arbitrary location. | 3303 * Pack windows (widgets) into a box at an arbitrary location. |
3304 * Parameters: | 3304 * Parameters: |
3305 * box: Window handle of the box to be packed into. | 3305 * box: Window handle of the box to be packed into. |
3306 * item: Window handle of the item to be back. | 3306 * item: Window handle of the item to be back. |
3307 * index: 0 based index of packed items. | 3307 * index: 0 based index of packed items. |
3308 * width: Width in pixels of the item or -1 to be self determined. | 3308 * width: Width in pixels of the item or -1 to be self determined. |
3309 * height: Height in pixels of the item or -1 to be self determined. | 3309 * height: Height in pixels of the item or -1 to be self determined. |
3310 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. | 3310 * hsize: TRUE if the window (widget) should expand horizontally to fill space given. |
3311 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | 3311 * vsize: TRUE if the window (widget) should expand vertically to fill space given. |
3312 * pad: Number of pixels of padding around the item. | 3312 * pad: Number of pixels of padding around the item. |
3327 * vsize: TRUE if the window (widget) should expand vertically to fill space given. | 3327 * vsize: TRUE if the window (widget) should expand vertically to fill space given. |
3328 * pad: Number of pixels of padding around the item. | 3328 * pad: Number of pixels of padding around the item. |
3329 */ | 3329 */ |
3330 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) | 3330 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) |
3331 { | 3331 { |
3332 /* 65536 is the table limit on GTK... | 3332 /* 65536 is the table limit on GTK... |
3333 * seems like a high enough value we will never hit it here either. | 3333 * seems like a high enough value we will never hit it here either. |
3334 */ | 3334 */ |
3335 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()"); | 3335 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()"); |
3336 } | 3336 } |
3337 | 3337 |
4294 { | 4294 { |
4295 NSScrollView *sv = handle; | 4295 NSScrollView *sv = handle; |
4296 DWMLE *mle = [sv documentView]; | 4296 DWMLE *mle = [sv documentView]; |
4297 NSTextStorage *ts = [mle textStorage]; | 4297 NSTextStorage *ts = [mle textStorage]; |
4298 NSMutableString *ms = [ts mutableString]; | 4298 NSMutableString *ms = [ts mutableString]; |
4299 strncpy(buffer, [ms UTF8String], length); | 4299 const char *tmp = [ms UTF8String]; |
4300 strncpy(buffer, tmp+startpoint, length); | |
4300 } | 4301 } |
4301 | 4302 |
4302 /* | 4303 /* |
4303 * Obtains information about an MLE box. | 4304 * Obtains information about an MLE box. |
4304 * Parameters: | 4305 * Parameters: |
7052 if(fg) | 7053 if(fg) |
7053 { | 7054 { |
7054 [cont setForegroundColor:fg]; | 7055 [cont setForegroundColor:fg]; |
7055 } | 7056 } |
7056 } | 7057 } |
7058 else if([object isKindOfClass:[NSScrollView class]]) | |
7059 { | |
7060 NSScrollView *sv = handle; | |
7061 id dv = [sv documentView]; | |
7062 if(bg) | |
7063 { | |
7064 [dv setBackgroundColor:bg]; | |
7065 } | |
7066 // TODO don't know how to set foreground colour of documentview | |
7067 } | |
7057 return 0; | 7068 return 0; |
7058 } | 7069 } |
7059 | 7070 |
7060 /* | 7071 /* |
7061 * Sets the font used by a specified window (widget) handle. | 7072 * Sets the font used by a specified window (widget) handle. |
8941 /* Correct the startup path if run from a bundle */ | 8952 /* Correct the startup path if run from a bundle */ |
8942 if(argc > 0 && argv[0]) | 8953 if(argc > 0 && argv[0]) |
8943 { | 8954 { |
8944 char *pathcopy = strdup(argv[0]); | 8955 char *pathcopy = strdup(argv[0]); |
8945 char *app = strstr(pathcopy, ".app/"); | 8956 char *app = strstr(pathcopy, ".app/"); |
8946 | 8957 |
8947 if(app) | 8958 if(app) |
8948 { | 8959 { |
8949 char pathbuf[PATH_MAX]; | 8960 char pathbuf[PATH_MAX]; |
8950 | 8961 |
8951 *app = 0; | 8962 *app = 0; |
8952 | 8963 |
8953 getcwd(pathbuf, PATH_MAX); | 8964 getcwd(pathbuf, PATH_MAX); |
8954 | 8965 |
8955 /* If run from a bundle the path seems to be / */ | 8966 /* If run from a bundle the path seems to be / */ |
8956 if(strcmp(pathbuf, "/") == 0) | 8967 if(strcmp(pathbuf, "/") == 0) |
8957 { | 8968 { |
8958 size_t len; | 8969 size_t len; |
8959 | 8970 |
8960 strncpy(pathbuf, pathcopy, PATH_MAX); | 8971 strncpy(pathbuf, pathcopy, PATH_MAX); |
8961 | 8972 |
8962 len = strlen(pathbuf); | 8973 len = strlen(pathbuf); |
8963 | 8974 |
8964 while(len > 0 && pathbuf[len] != '/') | 8975 while(len > 0 && pathbuf[len] != '/') |
8965 { | 8976 { |
8966 len--; | 8977 len--; |
8967 } | 8978 } |
8968 pathbuf[len] = '\0'; | 8979 pathbuf[len] = '\0'; |