comparison src/glyphs-msw.c @ 438:84b14dcb0985 r21-2-27

Import from CVS: tag r21-2-27
author cvs
date Mon, 13 Aug 2007 11:32:25 +0200
parents 9d177e8d4150
children 8de8e3f6228a
comparison
equal deleted inserted replaced
437:e2a4e8b94b82 438:84b14dcb0985
1 /* mswindows-specific glyph objects. 1 /* mswindows-specific glyph objects.
2 Copyright (C) 1998, 1999 Andy Piper. 2 Copyright (C) 1998, 1999, 2000 Andy Piper.
3 3
4 This file is part of XEmacs. 4 This file is part of XEmacs.
5 5
6 XEmacs is free software; you can redistribute it and/or modify it 6 XEmacs is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the 7 under the terms of the GNU General Public License as published by the
437 437
438 static void set_mono_pixel ( unsigned char* bits, 438 static void set_mono_pixel ( unsigned char* bits,
439 int bpline, int height, 439 int bpline, int height,
440 int x, int y, int white ) 440 int x, int y, int white )
441 { 441 {
442 int index; 442 int i;
443 unsigned char bitnum; 443 unsigned char bitnum;
444 /* Find the byte on which this scanline begins */ 444 /* Find the byte on which this scanline begins */
445 index = (height - y - 1) * bpline; 445 i = (height - y - 1) * bpline;
446 /* Find the byte containing this pixel */ 446 /* Find the byte containing this pixel */
447 index += (x >> 3); 447 i += (x >> 3);
448 /* Which bit is it? */ 448 /* Which bit is it? */
449 bitnum = (unsigned char)( 7 - (x % 8) ); 449 bitnum = (unsigned char)( 7 - (x % 8) );
450 if( white ) /* Turn it on */ 450 if( white ) /* Turn it on */
451 bits[index] |= (1<<bitnum); 451 bits[i] |= (1<<bitnum);
452 else /* Turn it off */ 452 else /* Turn it off */
453 bits[index] &= ~(1<<bitnum); 453 bits[i] &= ~(1<<bitnum);
454 } 454 }
455 455
456 static void 456 static void
457 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image, 457 mswindows_initialize_image_instance_mask (struct Lisp_Image_Instance* image,
458 struct frame* f) 458 struct frame* f)
1328 && 1328 &&
1329 !resource_name_to_resource (data, IMAGE_BITMAP)) 1329 !resource_name_to_resource (data, IMAGE_BITMAP))
1330 signal_simple_error ("invalid resource identifier", data); 1330 signal_simple_error ("invalid resource identifier", data);
1331 } 1331 }
1332 1332
1333 void
1334 check_valid_string_or_int (Lisp_Object data)
1335 {
1336 if (!INTP (data))
1337 CHECK_STRING (data);
1338 else
1339 CHECK_INT (data);
1340 }
1341
1342 /********************************************************************** 1333 /**********************************************************************
1343 * XBM * 1334 * XBM *
1344 **********************************************************************/ 1335 **********************************************************************/
1345 #ifndef HAVE_X_WINDOWS 1336 #ifndef HAVE_X_WINDOWS
1346 /* $XConsortium: RdBitF.c,v 1.10 94/04/17 20:16:13 kaleb Exp $ */ 1337 /* $XConsortium: RdBitF.c,v 1.10 94/04/17 20:16:13 kaleb Exp $ */
1626 from left to right, little-endian within a byte. 0 = white, 1 = 1617 from left to right, little-endian within a byte. 0 = white, 1 =
1627 black. It must be converted to the following format: Widths are 1618 black. It must be converted to the following format: Widths are
1628 padded to a multiple of 16. Scan lines are stored in increasing 1619 padded to a multiple of 16. Scan lines are stored in increasing
1629 byte order from left to right, big-endian within a byte. 0 = 1620 byte order from left to right, big-endian within a byte. 0 =
1630 black, 1 = white. */ 1621 black, 1 = white. */
1631 HBITMAP 1622 static HBITMAP
1632 xbm_create_bitmap_from_data (HDC hdc, char *data, 1623 xbm_create_bitmap_from_data (HDC hdc, char *data,
1633 unsigned int width, unsigned int height, 1624 unsigned int width, unsigned int height,
1634 int mask, COLORREF fg, COLORREF bg) 1625 int mask, COLORREF fg, COLORREF bg)
1635 { 1626 {
1636 int old_width = (width + 7)/8; 1627 int old_width = (width + 7)/8;
2104 redisplay_output_subwindow */ 2095 redisplay_output_subwindow */
2105 static void 2096 static void
2106 mswindows_map_subwindow (struct Lisp_Image_Instance *p, int x, int y, 2097 mswindows_map_subwindow (struct Lisp_Image_Instance *p, int x, int y,
2107 struct display_glyph_area* dga) 2098 struct display_glyph_area* dga)
2108 { 2099 {
2100 SetFocus (GetParent (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p)));
2109 /* move the window before mapping it ... */ 2101 /* move the window before mapping it ... */
2110 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p), 2102 SetWindowPos (IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (p),
2111 NULL, 2103 NULL,
2112 x, y, dga->width, dga->height, 2104 x, y, dga->width, dga->height,
2113 SWP_NOZORDER 2105 SWP_NOZORDER
2142 /* when you click on a widget you may activate another widget this 2134 /* when you click on a widget you may activate another widget this
2143 needs to be checked and all appropriate widgets updated */ 2135 needs to be checked and all appropriate widgets updated */
2144 static void 2136 static void
2145 mswindows_update_subwindow (struct Lisp_Image_Instance *p) 2137 mswindows_update_subwindow (struct Lisp_Image_Instance *p)
2146 { 2138 {
2139 /* Now do widget specific updates. */
2147 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET) 2140 if (IMAGE_INSTANCE_TYPE (p) == IMAGE_WIDGET)
2148 { 2141 {
2149 /* buttons checked or otherwise */ 2142 /* buttons checked or otherwise */
2150 if ( EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qbutton)) 2143 if ( EQ (IMAGE_INSTANCE_WIDGET_TYPE (p), Qbutton))
2151 { 2144 {
2159 2152
2160 /* set the widget font from the widget face */ 2153 /* set the widget font from the widget face */
2161 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p), 2154 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (p),
2162 WM_SETFONT, 2155 WM_SETFONT,
2163 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT 2156 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT
2164 (XFONT_INSTANCE (widget_face_font_info 2157 (XFONT_INSTANCE (query_string_font
2165 (IMAGE_INSTANCE_SUBWINDOW_FRAME (p), 2158 (IMAGE_INSTANCE_WIDGET_TEXT (p),
2166 IMAGE_INSTANCE_WIDGET_FACE (p), 2159 IMAGE_INSTANCE_WIDGET_FACE (p),
2167 0, 0))), 2160 IMAGE_INSTANCE_SUBWINDOW_FRAME (p)))),
2168 MAKELPARAM (TRUE, 0)); 2161 MAKELPARAM (TRUE, 0));
2169 } 2162 }
2170 } 2163 }
2171 2164
2172 /* register widgets into our hastable so that we can cope with the 2165 /* register widgets into our hastable so that we can cope with the
2342 2335
2343 if (!NILP (pgui->callback)) 2336 if (!NILP (pgui->callback))
2344 { 2337 {
2345 id = mswindows_register_widget_instance (image_instance, domain); 2338 id = mswindows_register_widget_instance (image_instance, domain);
2346 } 2339 }
2347 /* have to set the type this late in case there is no device 2340
2348 instantiation for a widget */
2349 IMAGE_INSTANCE_TYPE (ii) = IMAGE_WIDGET;
2350 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii))) 2341 if (!NILP (IMAGE_INSTANCE_WIDGET_TEXT (ii)))
2351 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm); 2342 GET_C_STRING_OS_DATA_ALLOCA (IMAGE_INSTANCE_WIDGET_TEXT (ii), nm);
2352 2343
2353 /* allocate space for the clip window and then allocate the clip window */ 2344 /* allocate space for the clip window and then allocate the clip window */
2354 ii->data = xnew_and_zero (struct mswindows_subwindow_data); 2345 ii->data = xnew_and_zero (struct mswindows_subwindow_data);
2355 2346
2356 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii) 2347 if ((IMAGE_INSTANCE_MSWINDOWS_CLIPWINDOW (ii)
2357 = CreateWindowEx( 2348 = CreateWindowEx(
2358 0, /* EX flags */ 2349 WS_EX_CONTROLPARENT, /* EX flags */
2359 XEMACS_CONTROL_CLASS, 2350 XEMACS_CONTROL_CLASS,
2360 0, /* text */ 2351 0, /* text */
2361 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD, 2352 WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD,
2362 0, /* starting x position */ 2353 0, /* starting x position */
2363 0, /* starting y position */ 2354 0, /* starting y position */
2394 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd; 2385 IMAGE_INSTANCE_SUBWINDOW_ID (ii) = wnd;
2395 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance)); 2386 SetWindowLong (wnd, GWL_USERDATA, (LONG)LISP_TO_VOID(image_instance));
2396 /* set the widget font from the widget face */ 2387 /* set the widget font from the widget face */
2397 SendMessage (wnd, WM_SETFONT, 2388 SendMessage (wnd, WM_SETFONT,
2398 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT 2389 (WPARAM)FONT_INSTANCE_MSWINDOWS_HFONT
2399 (XFONT_INSTANCE (widget_face_font_info 2390 (XFONT_INSTANCE (query_string_font
2400 (domain, 2391 (IMAGE_INSTANCE_WIDGET_TEXT (ii),
2401 IMAGE_INSTANCE_WIDGET_FACE (ii), 2392 IMAGE_INSTANCE_WIDGET_FACE (ii),
2402 0, 0))), 2393 domain))),
2403 MAKELPARAM (TRUE, 0)); 2394 MAKELPARAM (TRUE, 0));
2404 } 2395 }
2405 2396
2406 /* Instantiate a button widget. Unfortunately instantiated widgets are 2397 /* Instantiate a button widget. Unfortunately instantiated widgets are
2407 particular to a frame since they need to have a parent. It's not 2398 particular to a frame since they need to have a parent. It's not
2408 like images where you just select the image into the context you 2399 like images where you just select the image into the context you
2409 want to display it in and BitBlt it. So images instances can have a 2400 want to display it in and BitBlt it. So image instances can have a
2410 many-to-one relationship with things you see, whereas widgets can 2401 many-to-one relationship with things you see, whereas widgets can
2411 only be one-to-one (i.e. per frame) */ 2402 only be one-to-one (i.e. per frame) */
2412 static void 2403 static void
2413 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2404 mswindows_button_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2414 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2405 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2415 int dest_mask, Lisp_Object domain) 2406 int dest_mask, Lisp_Object domain)
2416 { 2407 {
2417 /* this function can call lisp */ 2408 /* this function can call lisp */
2418 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2409 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2419 HWND wnd; 2410 HWND wnd;
2420 int flags = BS_NOTIFY; 2411 int flags = WS_TABSTOP;/* BS_NOTIFY #### is needed to get exotic feedback
2412 only. Since we seem to want nothing beyond BN_CLICK,
2413 the style is perhaps not necessary -- kkm */
2421 Lisp_Object style; 2414 Lisp_Object style;
2422 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii); 2415 Lisp_Object gui = IMAGE_INSTANCE_WIDGET_ITEM (ii);
2423 struct Lisp_Gui_Item* pgui = XGUI_ITEM (gui); 2416 struct Lisp_Gui_Item* pgui = XGUI_ITEM (gui);
2424 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image); 2417 Lisp_Object glyph = find_keyword_in_vector (instantiator, Q_image);
2425 2418
2426 if (!gui_item_active_p (gui))
2427 flags |= WS_DISABLED;
2428
2429 if (!NILP (glyph)) 2419 if (!NILP (glyph))
2430 { 2420 {
2431 if (!IMAGE_INSTANCEP (glyph)) 2421 if (!IMAGE_INSTANCEP (glyph))
2432 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1); 2422 glyph = glyph_image_instance (glyph, domain, ERROR_ME, 1);
2433 2423
2436 BS_BITMAP : BS_ICON; 2426 BS_BITMAP : BS_ICON;
2437 } 2427 }
2438 2428
2439 style = pgui->style; 2429 style = pgui->style;
2440 2430
2431 /* #### consider using the default face for radio and toggle
2432 buttons. */
2441 if (EQ (style, Qradio)) 2433 if (EQ (style, Qradio))
2442 { 2434 {
2443 flags |= BS_RADIOBUTTON; 2435 flags |= BS_RADIOBUTTON;
2444 } 2436 }
2445 else if (EQ (style, Qtoggle)) 2437 else if (EQ (style, Qtoggle))
2446 { 2438 {
2447 flags |= BS_AUTOCHECKBOX; 2439 flags |= BS_AUTOCHECKBOX;
2448 } 2440 }
2449 else 2441 else
2450 flags |= BS_DEFPUSHBUTTON; 2442 {
2443 flags |= BS_DEFPUSHBUTTON;
2444 }
2451 2445
2452 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2446 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2453 pointer_bg, dest_mask, domain, "BUTTON", flags, 2447 pointer_bg, dest_mask, domain, "BUTTON",
2454 WS_EX_CONTROLPARENT); 2448 flags, 0);
2455 2449
2456 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2450 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2457 /* set the checked state */ 2451 /* set the checked state */
2458 if (gui_item_selected_p (gui)) 2452 if (gui_item_selected_p (gui))
2459 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); 2453 SendMessage (wnd, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
2463 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph)) 2457 if (!NILP (glyph) && IMAGE_INSTANCEP (glyph))
2464 { 2458 {
2465 SendMessage (wnd, BM_SETIMAGE, 2459 SendMessage (wnd, BM_SETIMAGE,
2466 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? 2460 (WPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
2467 IMAGE_BITMAP : IMAGE_ICON), 2461 IMAGE_BITMAP : IMAGE_ICON),
2468 (LPARAM) (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ? 2462 (XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) ?
2469 XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) : 2463 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_BITMAP (glyph) :
2470 XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph))); 2464 (LPARAM) XIMAGE_INSTANCE_MSWINDOWS_ICON (glyph)));
2471 } 2465 }
2472 } 2466 }
2473 2467
2474 /* instantiate an edit control */ 2468 /* instantiate an edit control */
2475 static void 2469 static void
2478 int dest_mask, Lisp_Object domain) 2472 int dest_mask, Lisp_Object domain)
2479 { 2473 {
2480 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2474 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2481 pointer_bg, dest_mask, domain, "EDIT", 2475 pointer_bg, dest_mask, domain, "EDIT",
2482 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP 2476 ES_LEFT | ES_AUTOHSCROLL | WS_TABSTOP
2483 | WS_BORDER, 2477 | WS_BORDER, WS_EX_CLIENTEDGE);
2484 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT);
2485 } 2478 }
2486 2479
2487 /* instantiate a progress gauge */ 2480 /* instantiate a progress gauge */
2488 static void 2481 static void
2489 mswindows_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2482 mswindows_progress_gauge_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2492 { 2485 {
2493 HWND wnd; 2486 HWND wnd;
2494 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2487 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2495 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2488 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2496 pointer_bg, dest_mask, domain, PROGRESS_CLASS, 2489 pointer_bg, dest_mask, domain, PROGRESS_CLASS,
2497 WS_TABSTOP | WS_BORDER | PBS_SMOOTH, 2490 WS_BORDER | PBS_SMOOTH, WS_EX_CLIENTEDGE);
2498 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT);
2499 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2491 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2500 /* set the colors */ 2492 /* set the colors */
2501 #ifdef PBS_SETBKCOLOR 2493 #ifdef PBS_SETBKCOLOR
2502 SendMessage (wnd, PBS_SETBKCOLOR, 0, 2494 SendMessage (wnd, PBS_SETBKCOLOR, 0,
2503 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR 2495 (LPARAM) (COLOR_INSTANCE_MSWINDOWS_COLOR
2577 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2569 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2578 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2570 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2579 pointer_bg, dest_mask, domain, WC_TREEVIEW, 2571 pointer_bg, dest_mask, domain, WC_TREEVIEW,
2580 WS_TABSTOP | WS_BORDER | PBS_SMOOTH 2572 WS_TABSTOP | WS_BORDER | PBS_SMOOTH
2581 | TVS_HASLINES | TVS_HASBUTTONS, 2573 | TVS_HASLINES | TVS_HASBUTTONS,
2582 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT); 2574 WS_EX_CLIENTEDGE);
2583 2575
2584 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2576 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2585 2577
2586 /* define a root */ 2578 /* define a root */
2587 parent = add_tree_item (image_instance, wnd, NULL, 2579 parent = add_tree_item (image_instance, wnd, NULL,
2600 } 2592 }
2601 2593
2602 /* instantiate a tab control */ 2594 /* instantiate a tab control */
2603 static TC_ITEM* add_tab_item (Lisp_Object image_instance, 2595 static TC_ITEM* add_tab_item (Lisp_Object image_instance,
2604 HWND wnd, Lisp_Object item, 2596 HWND wnd, Lisp_Object item,
2605 Lisp_Object domain, int index) 2597 Lisp_Object domain, int i)
2606 { 2598 {
2607 TC_ITEM tvitem, *ret; 2599 TC_ITEM tvitem, *ret;
2608 2600
2609 tvitem.mask = TCIF_TEXT; 2601 tvitem.mask = TCIF_TEXT;
2610 2602
2622 } 2614 }
2623 2615
2624 tvitem.cchTextMax = strlen (tvitem.pszText); 2616 tvitem.cchTextMax = strlen (tvitem.pszText);
2625 2617
2626 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM, 2618 if ((ret = (TC_ITEM*)SendMessage (wnd, TCM_INSERTITEM,
2627 index, (LPARAM)&tvitem)) < 0) 2619 i, (LPARAM)&tvitem)) < 0)
2628 signal_simple_error ("error adding tab entry", item); 2620 signal_simple_error ("error adding tab entry", item);
2629 2621
2630 return ret; 2622 return ret;
2631 } 2623 }
2632 2624
2635 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2627 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2636 int dest_mask, Lisp_Object domain) 2628 int dest_mask, Lisp_Object domain)
2637 { 2629 {
2638 Lisp_Object rest; 2630 Lisp_Object rest;
2639 HWND wnd; 2631 HWND wnd;
2640 int index = 0; 2632 int i = 0;
2641 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2633 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2634 Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
2635 unsigned int flags = WS_TABSTOP;
2636
2637 if (EQ (orient, Qleft) || EQ (orient, Qright))
2638 {
2639 flags |= TCS_VERTICAL | TCS_MULTILINE;
2640 }
2641 if (EQ (orient, Qright) || EQ (orient, Qbottom))
2642 {
2643 flags |= TCS_BOTTOM;
2644 }
2645
2642 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2646 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2643 pointer_bg, dest_mask, domain, WC_TABCONTROL, 2647 pointer_bg, dest_mask, domain, WC_TABCONTROL,
2644 /* borders don't suit tabs so well */ 2648 /* borders don't suit tabs so well */
2645 WS_TABSTOP, 2649 flags, 0);
2646 WS_EX_CONTROLPARENT);
2647 2650
2648 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2651 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2649 /* add items to the tab */ 2652 /* add items to the tab */
2650 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) 2653 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2651 { 2654 {
2652 add_tab_item (image_instance, wnd, XCAR (rest), domain, index); 2655 add_tab_item (image_instance, wnd, XCAR (rest), domain, i);
2653 index++; 2656 i++;
2654 } 2657 }
2655 } 2658 }
2656 2659
2657 /* set the properties of a tab control */ 2660 /* set the properties of a tab control */
2658 static Lisp_Object 2661 static Lisp_Object
2662 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2665 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2663 2666
2664 if (EQ (prop, Q_items)) 2667 if (EQ (prop, Q_items))
2665 { 2668 {
2666 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2669 HWND wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2667 int index = 0; 2670 int i = 0;
2668 Lisp_Object rest; 2671 Lisp_Object rest;
2669 check_valid_item_list_1 (val); 2672 check_valid_item_list_1 (val);
2670 2673
2671 /* delete the pre-existing items */ 2674 /* delete the pre-existing items */
2672 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0); 2675 SendMessage (wnd, TCM_DELETEALLITEMS, 0, 0);
2677 2680
2678 /* add items to the tab */ 2681 /* add items to the tab */
2679 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii))) 2682 LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
2680 { 2683 {
2681 add_tab_item (image_instance, wnd, XCAR (rest), 2684 add_tab_item (image_instance, wnd, XCAR (rest),
2682 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii), index); 2685 IMAGE_INSTANCE_SUBWINDOW_FRAME (ii), i);
2683 index++; 2686 i++;
2684 } 2687 }
2685 2688
2686 return Qt; 2689 return Qt;
2687 } 2690 }
2688 return Qunbound; 2691 return Qunbound;
2705 Lisp_Object pointer_fg, Lisp_Object pointer_bg, 2708 Lisp_Object pointer_fg, Lisp_Object pointer_bg,
2706 int dest_mask, Lisp_Object domain) 2709 int dest_mask, Lisp_Object domain)
2707 { 2710 {
2708 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2711 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2709 pointer_bg, dest_mask, domain, "SCROLLBAR", 2712 pointer_bg, dest_mask, domain, "SCROLLBAR",
2710 0, 2713 WS_TABSTOP, WS_EX_CLIENTEDGE);
2711 WS_EX_CLIENTEDGE );
2712 } 2714 }
2713 2715
2714 /* instantiate a combo control */ 2716 /* instantiate a combo control */
2715 static void 2717 static void
2716 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator, 2718 mswindows_combo_box_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
2720 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance); 2722 struct Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
2721 HANDLE wnd; 2723 HANDLE wnd;
2722 Lisp_Object rest; 2724 Lisp_Object rest;
2723 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties), 2725 Lisp_Object data = Fplist_get (find_keyword_in_vector (instantiator, Q_properties),
2724 Q_items, Qnil); 2726 Q_items, Qnil);
2725 int len; 2727 int len, height;
2726 GET_LIST_LENGTH (data, len);
2727 2728
2728 /* Maybe ought to generalise this more but it may be very windows 2729 /* Maybe ought to generalise this more but it may be very windows
2729 specific. In windows the window height of a combo box is the 2730 specific. In windows the window height of a combo box is the
2730 height when the combo box is open. Thus we need to set the height 2731 height when the combo box is open. Thus we need to set the height
2731 before creating the window and then reset it to a single line 2732 before creating the window and then reset it to a single line
2732 after the window is created so that redisplay does the right 2733 after the window is created so that redisplay does the right
2733 thing. */ 2734 thing. */
2734 widget_instantiate_1 (image_instance, instantiator, pointer_fg, 2735 widget_instantiate (image_instance, instantiator, pointer_fg,
2735 pointer_bg, dest_mask, domain, len + 1, 0, 0); 2736 pointer_bg, dest_mask, domain);
2736 2737
2738 /* We now have everything right apart from the height. */
2739 default_face_font_info (domain, 0, 0, &height, 0, 0);
2740 GET_LIST_LENGTH (data, len);
2741
2742 height = (height + WIDGET_BORDER_HEIGHT * 2 ) * len;
2743 IMAGE_INSTANCE_HEIGHT (ii) = height;
2744
2745 /* Now create the widget. */
2737 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg, 2746 mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
2738 pointer_bg, dest_mask, domain, "COMBOBOX", 2747 pointer_bg, dest_mask, domain, "COMBOBOX",
2739 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN 2748 WS_BORDER | WS_TABSTOP | CBS_DROPDOWN
2740 | CBS_AUTOHSCROLL 2749 | CBS_AUTOHSCROLL
2741 | CBS_HASSTRINGS | WS_VSCROLL, 2750 | CBS_HASSTRINGS | WS_VSCROLL,
2742 WS_EX_CLIENTEDGE | WS_EX_CONTROLPARENT); 2751 WS_EX_CLIENTEDGE);
2743 /* reset the height */ 2752 /* Reset the height. layout will probably do this safely, but better make sure. */
2744 widget_text_to_pixel_conversion (domain, 2753 image_instance_layout (image_instance,
2745 IMAGE_INSTANCE_WIDGET_FACE (ii), 1, 0, 2754 IMAGE_UNSPECIFIED_GEOMETRY,
2746 &IMAGE_INSTANCE_SUBWINDOW_HEIGHT (ii), 0); 2755 IMAGE_UNSPECIFIED_GEOMETRY,
2756 domain);
2757
2747 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii); 2758 wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
2748 /* add items to the combo box */ 2759 /* add items to the combo box */
2749 SendMessage (wnd, CB_RESETCONTENT, 0, 0); 2760 SendMessage (wnd, CB_RESETCONTENT, 0, 0);
2750 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil)) 2761 LIST_LOOP (rest, Fplist_get (IMAGE_INSTANCE_WIDGET_PROPS (ii), Q_items, Qnil))
2751 { 2762 {
2821 Extbyte* lparam=0; 2832 Extbyte* lparam=0;
2822 CHECK_STRING (val); 2833 CHECK_STRING (val);
2823 GET_C_STRING_OS_DATA_ALLOCA (val, lparam); 2834 GET_C_STRING_OS_DATA_ALLOCA (val, lparam);
2824 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii), 2835 SendMessage (WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii),
2825 WM_SETTEXT, 0, (LPARAM)lparam); 2836 WM_SETTEXT, 0, (LPARAM)lparam);
2826 return Qt; 2837 /* We don't return Qt here so that other widget methods can be
2838 called afterwards. */
2827 } 2839 }
2828 return Qunbound; 2840 return Qunbound;
2829 } 2841 }
2830 2842
2831 /* set the properties of a progres guage */ 2843 /* set the properties of a progres guage */
2844 } 2856 }
2845 return Qunbound; 2857 return Qunbound;
2846 } 2858 }
2847 2859
2848 LRESULT WINAPI 2860 LRESULT WINAPI
2849 mswindows_control_wnd_proc (HWND hwnd, UINT message, 2861 mswindows_control_wnd_proc (HWND hwnd, UINT msg,
2850 WPARAM wParam, LPARAM lParam) 2862 WPARAM wParam, LPARAM lParam)
2851 { 2863 {
2852 switch (message) 2864 switch (msg)
2853 { 2865 {
2854 case WM_NOTIFY: 2866 case WM_NOTIFY:
2855 case WM_COMMAND: 2867 case WM_COMMAND:
2856 case WM_CTLCOLORBTN: 2868 case WM_CTLCOLORBTN:
2857 case WM_CTLCOLORLISTBOX: 2869 case WM_CTLCOLORLISTBOX:
2858 case WM_CTLCOLOREDIT: 2870 case WM_CTLCOLOREDIT:
2859 case WM_CTLCOLORSTATIC: 2871 case WM_CTLCOLORSTATIC:
2860 case WM_CTLCOLORSCROLLBAR: 2872 case WM_CTLCOLORSCROLLBAR:
2861 2873
2862 return mswindows_wnd_proc (GetParent (hwnd), message, wParam, lParam); 2874 return mswindows_wnd_proc (GetParent (hwnd), msg, wParam, lParam);
2863 default: 2875 default:
2864 return DefWindowProc (hwnd, message, wParam, lParam); 2876 return DefWindowProc (hwnd, msg, wParam, lParam);
2865 } 2877 }
2866 } 2878 }
2867 2879
2868 #endif /* HAVE_WIDGETS */ 2880 #endif /* HAVE_WIDGETS */
2869 2881