# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1318207222 0 # Node ID 67ff39b9577cf47fd6b605829feab3a680b5b0ad # Parent 7714403162064274b8f8e32cbb52bf348f571d11 Initial implementation of dw_taskbar_* for the Mac. Also added code in the test program to test. diff -r 771440316206 -r 67ff39b9577c dwtest.c --- a/dwtest.c Sun Oct 09 12:52:16 2011 +0000 +++ b/dwtest.c Mon Oct 10 00:40:22 2011 +0000 @@ -507,6 +507,7 @@ int DWSIGNAL exit_callback(HWND window, void *data) { + dw_taskbar_delete(textbox1, fileicon); dw_window_destroy((HWND)data); exit(0); return -1; @@ -847,6 +848,18 @@ return 0; } +int API context_menu_event(HWND window, int x, int y, int buttonmask, void *data) +{ + HMENUI hwndMenu = dw_menu_new(0L); + HWND menuitem = dw_menu_append_item(hwndMenu, "~Quit", 1019, 0L, TRUE, FALSE, DW_NOMENU); + long px, py; + + dw_signal_connect(menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow); + dw_pointer_query_pos(&px, &py); + dw_menu_popup(&hwndMenu, window, (int)px, (int)py); + return 0; +} + void text_add(void) { unsigned long depth = dw_color_depth_get(); @@ -934,6 +947,7 @@ dw_messagebox("DWTest", DW_MB_OK|DW_MB_INFORMATION, "Width: %d Height: %d\n", font_width, font_height); dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows); dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows); + dw_signal_connect(textbox1, DW_SIGNAL_BUTTON_PRESS, DW_SIGNAL_FUNC(context_menu_event), NULL); dw_signal_connect(textbox1, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL); dw_signal_connect(textbox2, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL); dw_signal_connect(textbox2, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(configure_event), text2pm); @@ -945,6 +959,8 @@ dw_signal_connect(button2, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(print_callback), NULL); dw_signal_connect(rendcombo, DW_SIGNAL_LIST_SELECT, DW_SIGNAL_FUNC(render_select_event_callback), NULL ); dw_signal_connect(mainwindow, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(keypress_callback), NULL); + + dw_taskbar_insert(textbox1, fileicon, "DWTest"); } void tree_add(void) @@ -973,9 +989,6 @@ tree_status = dw_status_text_new("", 0); dw_box_pack_start( notebookbox3, tree_status, 100, 20, TRUE, FALSE, 1); - foldericon = dw_icon_load_from_file( FOLDER_ICON_NAME ); - fileicon = dw_icon_load_from_file( FILE_ICON_NAME ); - /* set up our signal trappers... */ dw_signal_connect(tree, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)tree_status); dw_signal_connect(tree, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)tree_status); @@ -1519,6 +1532,10 @@ notebookbox = dw_box_new( BOXVERT, 5 ); dw_box_pack_start( mainwindow, notebookbox, 0, 0, TRUE, TRUE, 0); + + foldericon = dw_icon_load_from_file( FOLDER_ICON_NAME ); + fileicon = dw_icon_load_from_file( FILE_ICON_NAME ); + /* MUST pack a box into the mainwindow BEFORE adding menus */ menu_add(); diff -r 771440316206 -r 67ff39b9577c mac/dw.m --- a/mac/dw.m Sun Oct 09 12:52:16 2011 +0000 +++ b/mac/dw.m Mon Oct 10 00:40:22 2011 +0000 @@ -6076,7 +6076,16 @@ */ void API dw_taskbar_insert(HWND handle, HICN icon, char *bubbletext) { - NSLog(@"dw_taskbar_insert() unimplemented\n"); + NSStatusItem *item = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength] retain]; + NSImage *image = icon; + [item setImage:image]; + if(bubbletext) + [item setToolTip:[NSString stringWithUTF8String:bubbletext]]; + [item setTarget:handle]; + [item setEnabled:YES]; + [item setHighlightMode:YES]; + [item sendActionOn:(NSLeftMouseUpMask|NSLeftMouseDownMask|NSRightMouseUpMask|NSRightMouseDownMask)]; + dw_window_set_data(handle, "_dw_taskbar", item); } /* @@ -6087,7 +6096,8 @@ */ void API dw_taskbar_delete(HWND handle, HICN icon) { - NSLog(@"dw_taskbar_delete() unimplemented\n"); + NSStatusItem *item = dw_window_get_data(handle, "_dw_taskbar"); + [item release]; } /*