+
+/* instantiate a tab control */
+static int
+add_tab_item (Lisp_Object image_instance,
+ HWND wnd, Lisp_Object item,
+ Lisp_Object domain, int i)
+{
+ TC_ITEM tvitem;
+ int ret = 0;
+
+ tvitem.mask = TCIF_TEXT;
+
+ if (GUI_ITEMP (item))
+ {
+ tvitem.lParam = mswindows_register_gui_item (image_instance,
+ item, domain);
+ tvitem.mask |= TCIF_PARAM;
+ TO_EXTERNAL_FORMAT (LISP_STRING, XGUI_ITEM (item)->name,
+ C_STRING_ALLOCA, tvitem.pszText,
+ Qnative);
+ }
+ else
+ {
+ CHECK_STRING (item);
+ TO_EXTERNAL_FORMAT (LISP_STRING, item,
+ C_STRING_ALLOCA, tvitem.pszText,
+ Qnative);
+ }
+
+ tvitem.cchTextMax = strlen (tvitem.pszText);
+
+ if ((ret = SendMessage (wnd, TCM_INSERTITEM,
+ i, (LPARAM)&tvitem)) < 0)
+ signal_simple_error ("error adding tab entry", item);
+
+ return ret;
+}
+
+static void
+mswindows_tab_control_instantiate (Lisp_Object image_instance, Lisp_Object instantiator,
+ Lisp_Object pointer_fg, Lisp_Object pointer_bg,
+ int dest_mask, Lisp_Object domain)
+{
+ /* This function can call lisp */
+ Lisp_Object rest;
+ HWND wnd;
+ int i = 0, selected = 0;
+ Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+ Lisp_Object orient = find_keyword_in_vector (instantiator, Q_orientation);
+ unsigned int flags = WS_TABSTOP;
+
+ if (EQ (orient, Qleft) || EQ (orient, Qright))
+ {
+ flags |= TCS_VERTICAL | TCS_MULTILINE;
+ }
+ if (EQ (orient, Qright) || EQ (orient, Qbottom))
+ {
+ flags |= TCS_BOTTOM;
+ }
+
+ mswindows_widget_instantiate (image_instance, instantiator, pointer_fg,
+ pointer_bg, dest_mask, domain, WC_TABCONTROL,
+ /* borders don't suit tabs so well */
+ flags, 0);
+ wnd = WIDGET_INSTANCE_MSWINDOWS_HANDLE (ii);
+ /* add items to the tab */
+ LIST_LOOP (rest, XCDR (IMAGE_INSTANCE_WIDGET_ITEMS (ii)))
+ {
+ int idx = add_tab_item (image_instance, wnd, XCAR (rest), domain, i);
+ assert (idx == i);
+ if (gui_item_selected_p (XCAR (rest)))
+ selected = i;
+ i++;
+ }
+ SendMessage (wnd, TCM_SETCURSEL, selected, 0);
+}
+
+/* Set the properties of a tab control. */
+static void
+mswindows_tab_control_redisplay (Lisp_Object image_instance)
+{
+ /* This function can GC if IN_REDISPLAY is false. */
+ Lisp_Image_Instance *ii = XIMAGE_INSTANCE (image_instance);
+#ifdef DEBUG_WIDGET_OUTPUT
+ stderr_out ("tab control %p redisplayed\n", IMAGE_INSTANCE_SUBWINDOW_ID (ii));