blob: f93207ed660ac51bb33d48350f6e0fafe399adbf [file] [log] [blame]
Alexandre Julliard75a839a1993-07-15 11:13:45 +00001/*
2 * Windows widgets (built-in window classes)
3 *
4 * Copyright 1993 Alexandre Julliard
Alexandre Julliard2787be81995-05-22 18:23:01 +00005 */
Alexandre Julliard75a839a1993-07-15 11:13:45 +00006
Jeff Garzikc3e1f721999-02-19 15:42:11 +00007#include <string.h>
Alexandre Julliarddf2673b1997-03-29 17:20:20 +00008#include <assert.h>
9
Alexandre Julliardfb9a9191994-03-01 19:48:04 +000010#include "win.h"
Alexandre Julliardaca05781994-10-17 18:12:41 +000011#include "button.h"
12#include "static.h"
Alexandre Julliardecc37121994-11-22 16:31:29 +000013#include "scroll.h"
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000014#include "desktop.h"
15#include "mdi.h"
16#include "gdi.h"
Alexandre Julliardc981d0b1996-03-31 16:40:13 +000017#include "module.h"
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +000018#include "heap.h"
Alexandre Julliard75a839a1993-07-15 11:13:45 +000019
Alexandre Julliardda0cfb31996-12-01 17:17:47 +000020/* Window procedures */
21
Alexandre Julliarda3960291999-02-26 11:11:13 +000022extern LRESULT WINAPI EditWndProc( HWND hwnd, UINT msg,
23 WPARAM wParam, LPARAM lParam );
24extern LRESULT WINAPI ComboWndProc( HWND hwnd, UINT msg,
25 WPARAM wParam, LPARAM lParam );
26extern LRESULT WINAPI ComboLBWndProc( HWND hwnd, UINT msg,
27 WPARAM wParam, LPARAM lParam );
28extern LRESULT WINAPI ListBoxWndProc( HWND hwnd, UINT msg,
29 WPARAM wParam, LPARAM lParam );
30extern LRESULT WINAPI PopupMenuWndProc( HWND hwnd, UINT msg,
31 WPARAM wParam, LPARAM lParam );
32extern LRESULT WINAPI IconTitleWndProc( HWND hwnd, UINT msg,
33 WPARAM wParam, LPARAM lParam );
Alexandre Julliardda0cfb31996-12-01 17:17:47 +000034
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000035/* Built-in classes */
Alexandre Julliard75d86e11996-11-17 18:59:11 +000036
Alexandre Julliarda3960291999-02-26 11:11:13 +000037static WNDCLASSA WIDGETS_BuiltinClasses[BIC32_NB_CLASSES] =
Alexandre Julliard2d93d001996-05-21 15:01:41 +000038{
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000039 /* BIC32_BUTTON */
Alexandre Julliard2d93d001996-05-21 15:01:41 +000040 { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000041 ButtonWndProc, 0, sizeof(BUTTONINFO), 0, 0,
Alexandre Julliarda3960291999-02-26 11:11:13 +000042 (HCURSOR)IDC_ARROWA, 0, 0, "Button" },
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000043 /* BIC32_EDIT */
Alexandre Julliard75d86e11996-11-17 18:59:11 +000044 { CS_GLOBALCLASS | CS_DBLCLKS /*| CS_PARENTDC*/,
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000045 EditWndProc, 0, sizeof(void *), 0, 0,
Alexandre Julliarda3960291999-02-26 11:11:13 +000046 (HCURSOR)IDC_IBEAMA, 0, 0, "Edit" },
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000047 /* BIC32_LISTBOX */
Alexandre Julliardc6c09441997-01-12 18:32:19 +000048 { CS_GLOBALCLASS | CS_DBLCLKS /*| CS_PARENTDC*/,
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000049 ListBoxWndProc, 0, sizeof(void *), 0, 0,
Alexandre Julliarda3960291999-02-26 11:11:13 +000050 (HCURSOR)IDC_ARROWA, 0, 0, "ListBox" },
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000051 /* BIC32_COMBO */
52 { CS_GLOBALCLASS | CS_PARENTDC | CS_DBLCLKS,
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000053 ComboWndProc, 0, sizeof(void *), 0, 0,
Alexandre Julliarda3960291999-02-26 11:11:13 +000054 (HCURSOR)IDC_ARROWA, 0, 0, "ComboBox" },
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000055 /* BIC32_COMBOLB */
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000056 { CS_GLOBALCLASS | CS_DBLCLKS | CS_SAVEBITS, ComboLBWndProc,
Alexandre Julliarda3960291999-02-26 11:11:13 +000057 0, sizeof(void *), 0, 0, (HCURSOR)IDC_ARROWA, 0, 0, "ComboLBox" },
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000058 /* BIC32_POPUPMENU */
Alexandre Julliarda3960291999-02-26 11:11:13 +000059 { CS_GLOBALCLASS | CS_SAVEBITS, PopupMenuWndProc, 0, sizeof(HMENU),
60 0, 0, (HCURSOR)IDC_ARROWA, NULL_BRUSH, 0, POPUPMENU_CLASS_NAME },
Alexandre Julliardd37eb361997-07-20 16:23:21 +000061 /* BIC32_STATIC */
62 { CS_GLOBALCLASS | CS_PARENTDC, StaticWndProc,
Alexandre Julliarda3960291999-02-26 11:11:13 +000063 0, sizeof(STATICINFO), 0, 0, (HCURSOR)IDC_ARROWA, 0, 0, "Static" },
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000064 /* BIC32_SCROLL */
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +000065 { CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW | CS_HREDRAW | CS_PARENTDC,
Alexandre Julliardc7c217b1998-04-13 12:21:30 +000066 ScrollBarWndProc, 0, sizeof(SCROLLBAR_INFO), 0, 0,
Alexandre Julliarda3960291999-02-26 11:11:13 +000067 (HCURSOR)IDC_ARROWA, 0, 0, "ScrollBar"},
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000068 /* BIC32_MDICLIENT */
69 { CS_GLOBALCLASS, MDIClientWndProc,
70 0, sizeof(MDICLIENTINFO), 0, 0, 0, STOCK_LTGRAY_BRUSH, 0, "MDIClient" },
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000071 /* BIC32_DESKTOP */
Patrik Stridvall8d8703c1999-02-04 14:05:38 +000072 { CS_GLOBALCLASS, DesktopWndProc, 0, sizeof(DESKTOP),
Alexandre Julliarda3960291999-02-26 11:11:13 +000073 0, 0, (HCURSOR)IDC_ARROWA, 0, 0, DESKTOP_CLASS_NAME },
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000074 /* BIC32_DIALOG */
Alexandre Julliarda3960291999-02-26 11:11:13 +000075 { CS_GLOBALCLASS | CS_SAVEBITS, DefDlgProcA, 0, DLGWINDOWEXTRA,
76 0, 0, (HCURSOR)IDC_ARROWA, 0, 0, DIALOG_CLASS_NAME },
Alexandre Julliard23946ad1997-06-16 17:43:53 +000077 /* BIC32_ICONTITLE */
78 { CS_GLOBALCLASS, IconTitleWndProc, 0, 0,
Alexandre Julliarda3960291999-02-26 11:11:13 +000079 0, 0, (HCURSOR)IDC_ARROWA, 0, 0, ICONTITLE_CLASS_NAME }
Alexandre Julliard2d93d001996-05-21 15:01:41 +000080};
81
Alexandre Julliarddf2673b1997-03-29 17:20:20 +000082static ATOM bicAtomTable[BIC32_NB_CLASSES];
Alexandre Julliard75a839a1993-07-15 11:13:45 +000083
84/***********************************************************************
85 * WIDGETS_Init
86 *
87 * Initialize the built-in window classes.
88 */
Alexandre Julliarda3960291999-02-26 11:11:13 +000089BOOL WIDGETS_Init(void)
Alexandre Julliard75a839a1993-07-15 11:13:45 +000090{
91 int i;
Alexandre Julliarda3960291999-02-26 11:11:13 +000092 WNDCLASSA *cls = WIDGETS_BuiltinClasses;
Alexandre Julliard940d58c1994-09-16 09:24:37 +000093
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000094 /* Create builtin classes */
Alexandre Julliard2d93d001996-05-21 15:01:41 +000095
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000096 for (i = 0; i < BIC32_NB_CLASSES; i++, cls++)
Alexandre Julliard75a839a1993-07-15 11:13:45 +000097 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000098 char name[20];
Alexandre Julliard2d93d001996-05-21 15:01:41 +000099 /* Just to make sure the string is > 0x10000 */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000100 strcpy( name, (char *)cls->lpszClassName );
101 cls->lpszClassName = name;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000102 cls->hCursor = LoadCursorA( 0, (LPCSTR)cls->hCursor );
103 if (!(bicAtomTable[i] = RegisterClassA( cls ))) return FALSE;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000104 }
105
Alexandre Julliard75a839a1993-07-15 11:13:45 +0000106 return TRUE;
107}
Alexandre Julliard8cc3a5e1996-08-11 15:49:51 +0000108
109
110/***********************************************************************
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000111 * WIDGETS_IsControl32
112 *
113 * Check whether pWnd is a built-in control or not.
114 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000115BOOL WIDGETS_IsControl( WND* pWnd, BUILTIN_CLASS32 cls )
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000116{
117 assert( cls < BIC32_NB_CLASSES );
118 return (pWnd->class->atomName == bicAtomTable[cls]);
119}