ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

theme_edit.c
Go to the documentation of this file.
00001 /*
00002  * Theming - Edit control
00003  *
00004  * Copyright (c) 2005 by Frank Richter
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  *
00020  */
00021 
00022 #include <stdarg.h>
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 #include "windef.h"
00027 #include "winbase.h"
00028 #include "wingdi.h"
00029 #include "winuser.h"
00030 #include "uxtheme.h"
00031 #include "vssym32.h"
00032 #include "comctl32.h"
00033 #include "wine/debug.h"
00034 
00035 /* Draw themed border */
00036 static void nc_paint (HTHEME theme, HWND hwnd, HRGN region)
00037 {
00038     HRGN cliprgn = region;
00039     DWORD exStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
00040     if (exStyle & WS_EX_CLIENTEDGE)
00041     {
00042         HDC dc;
00043         RECT r;
00044         int cxEdge = GetSystemMetrics (SM_CXEDGE),
00045             cyEdge = GetSystemMetrics (SM_CYEDGE);
00046         int part = EP_EDITTEXT;
00047         int state = ETS_NORMAL;
00048         DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
00049     
00050         if (!IsWindowEnabled (hwnd))
00051             state = ETS_DISABLED;
00052         else if (dwStyle & ES_READONLY)
00053             state = ETS_READONLY;
00054         else if (GetFocus() == hwnd)
00055             state = ETS_FOCUSED;
00056     
00057         GetWindowRect(hwnd, &r);
00058     
00059         /* New clipping region passed to default proc to exclude border */
00060         cliprgn = CreateRectRgn (r.left + cxEdge, r.top + cyEdge,
00061             r.right - cxEdge, r.bottom - cyEdge);
00062         if (region != (HRGN)1)
00063             CombineRgn (cliprgn, cliprgn, region, RGN_AND);
00064         OffsetRect(&r, -r.left, -r.top);
00065     
00066         dc = GetDCEx(hwnd, region, DCX_WINDOW|DCX_INTERSECTRGN);
00067         OffsetRect(&r, -r.left, -r.top);
00068     
00069         if (IsThemeBackgroundPartiallyTransparent (theme, part, state))
00070             DrawThemeParentBackground(hwnd, dc, &r);
00071         DrawThemeBackground (theme, dc, part, state, &r, 0);
00072         ReleaseDC(hwnd, dc);
00073     }
00074 
00075     /* Call default proc to get the scrollbars etc. also painted */
00076     DefWindowProcW (hwnd, WM_NCPAINT, (WPARAM)cliprgn, 0);
00077 }
00078 
00079 /**********************************************************************
00080  * The edit control subclass window proc.
00081  */
00082 LRESULT CALLBACK THEMING_EditSubclassProc (HWND hwnd, UINT msg, 
00083                                            WPARAM wParam, LPARAM lParam, 
00084                                            ULONG_PTR dwRefData)
00085 {
00086     const WCHAR* themeClass = WC_EDITW;
00087     HTHEME theme;
00088     LRESULT result;
00089       
00090     switch (msg)
00091     {
00092     case WM_CREATE:
00093         result = THEMING_CallOriginalClass  (hwnd, msg, wParam, lParam);
00094         OpenThemeData( hwnd, themeClass );
00095         return result;
00096     
00097     case WM_DESTROY:
00098         theme = GetWindowTheme( hwnd );
00099         CloseThemeData ( theme );
00100         return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam);
00101 
00102     case WM_THEMECHANGED:
00103         theme = GetWindowTheme( hwnd );
00104         CloseThemeData ( theme );
00105         OpenThemeData( hwnd, themeClass );
00106         break;
00107         
00108     case WM_SYSCOLORCHANGE:
00109         theme = GetWindowTheme( hwnd );
00110     if (!theme) return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam);
00111         /* Do nothing. When themed, a WM_THEMECHANGED will be received, too,
00112      * which will do the repaint. */
00113         break;
00114         
00115     case WM_NCPAINT:
00116         theme = GetWindowTheme( hwnd );
00117         if (!theme) return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam);
00118         nc_paint (theme, hwnd, (HRGN)wParam);
00119         break;
00120 
00121     case WM_ENABLE:
00122         theme = GetWindowTheme( hwnd );
00123         if (theme) RedrawWindow (hwnd, NULL, NULL, 
00124             RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);
00125         return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam);
00126         
00127     default: 
00128     /* Call old proc */
00129     return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam);
00130     }
00131     return 0;
00132 }

Generated on Sat May 26 2012 04:21:39 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.