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

splitter.c
Go to the documentation of this file.
00001 /*
00002  * PROJECT:         ReactOS Applications Manager
00003  * LICENSE:         GPL - See COPYING in the top level directory
00004  * FILE:            base/applications/rapps/splitter.c
00005  * PURPOSE:         SplitterBar functions
00006  * PROGRAMMERS:     Dmitry Chapyshev (dmitry@reactos.org)
00007  */
00008 
00009 #include "rapps.h"
00010 
00011 HWND hVSplitter = NULL;
00012 HWND hHSplitter = NULL;
00013 
00014 static int HSplitterPos = 0;
00015 
00016 int
00017 GetHSplitterPos(VOID)
00018 {
00019     return HSplitterPos;
00020 }
00021 
00022 VOID
00023 SetHSplitterPos(int Pos)
00024 {
00025     HSplitterPos = Pos;
00026 }
00027 
00028 /* Callback for horizontal splitter bar */
00029 LRESULT CALLBACK
00030 HSplitterWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
00031 {
00032     switch (Msg)
00033     {
00034         case WM_CREATE:
00035         {
00036             SetHSplitterPos(GetWindowHeight(hListView));
00037         }
00038         break;
00039 
00040         case WM_LBUTTONDOWN:
00041         {
00042             SetCapture(hwnd);
00043         }
00044         break;
00045 
00046         case WM_LBUTTONUP:
00047         case WM_RBUTTONDOWN:
00048             if (GetCapture() == hwnd)
00049             {
00050                 ReleaseCapture();
00051             }
00052         break;
00053 
00054         case WM_MOUSEMOVE:
00055             if (GetCapture() == hwnd)
00056             {
00057                 int Width = GetClientWindowWidth(hMainWnd) - GetWindowWidth(hTreeView) - SPLIT_WIDTH;
00058                 int NewPos;
00059                 HDWP hdwp;
00060                 POINT Point;
00061 
00062                 GetCursorPos(&Point);
00063                 ScreenToClient(hMainWnd, &Point);
00064 
00065                 NewPos = Point.y;
00066 
00067                 if ((GetClientWindowHeight(hMainWnd) - GetWindowHeight(hStatusBar) - SPLIT_WIDTH) < NewPos)
00068                     break;
00069 
00070                 if ((GetWindowHeight(hToolBar) + SPLIT_WIDTH) > NewPos)
00071                     break;
00072 
00073                 SetHSplitterPos(NewPos);
00074 
00075                 hdwp = BeginDeferWindowPos(3);
00076 
00077                 /* Size HSplitBar */
00078                 DeferWindowPos(hdwp,
00079                                hHSplitter,
00080                                0,
00081                                GetWindowWidth(hTreeView) + SPLIT_WIDTH,
00082                                Point.y,
00083                                Width,
00084                                SPLIT_WIDTH,
00085                                SWP_NOZORDER|SWP_NOACTIVATE);
00086 
00087                 /* Size ListView */
00088                 DeferWindowPos(hdwp,
00089                                hListView,
00090                                0,
00091                                GetWindowWidth(hTreeView) + SPLIT_WIDTH,
00092                                GetWindowHeight(hToolBar),
00093                                Width,
00094                                Point.y - GetWindowHeight(hToolBar),
00095                                SWP_NOZORDER|SWP_NOACTIVATE);
00096 
00097                 /* Size RichEdit */
00098                 DeferWindowPos(hdwp,
00099                                hRichEdit,
00100                                0,
00101                                GetWindowWidth(hTreeView) + SPLIT_WIDTH,
00102                                Point.y + SPLIT_WIDTH,
00103                                Width,
00104                                GetClientWindowHeight(hMainWnd) - (Point.y + SPLIT_WIDTH + GetWindowHeight(hStatusBar)),
00105                                SWP_NOZORDER|SWP_NOACTIVATE);
00106 
00107                 EndDeferWindowPos(hdwp);
00108             }
00109         break;
00110     }
00111 
00112     return DefWindowProc(hwnd, Msg, wParam, lParam);
00113 }
00114 
00115 /* Create horizontal splitter bar */
00116 BOOL
00117 CreateHSplitBar(HWND hwnd)
00118 {
00119     WCHAR szWindowClass[] = L"HSplitterWindowClass";
00120     WNDCLASSEXW WndClass = {0};
00121 
00122     WndClass.cbSize        = sizeof(WNDCLASSEXW);
00123     WndClass.lpszClassName = szWindowClass;
00124     WndClass.lpfnWndProc   = HSplitterWindowProc;
00125     WndClass.hInstance     = hInst;
00126     WndClass.style         = CS_HREDRAW | CS_VREDRAW;
00127     WndClass.hCursor       = LoadCursor(0, IDC_SIZENS);
00128     WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
00129 
00130     if (RegisterClassExW(&WndClass) == (ATOM) 0)
00131     {
00132         /* TODO: Show error message */
00133         return FALSE;
00134     }
00135 
00136     hHSplitter = CreateWindowExW(WS_EX_TRANSPARENT,
00137                                  szWindowClass,
00138                                  NULL,
00139                                  WS_CHILD | WS_VISIBLE,
00140                                  205, 180, 465, SPLIT_WIDTH,
00141                                  hwnd,
00142                                  NULL,
00143                                  hInst,
00144                                  NULL);
00145 
00146 
00147     if (hHSplitter == NULL)
00148     {
00149         /* TODO: Show error message */
00150         return FALSE;
00151     }
00152 
00153     ShowWindow(hHSplitter, SW_SHOW);
00154     UpdateWindow(hHSplitter);
00155 
00156     return TRUE;
00157 }
00158 
00159 /* Callback for vertical splitter bar */
00160 LRESULT CALLBACK
00161 VSplitterWindowProc(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
00162 {
00163     switch (Msg)
00164     {
00165         case WM_LBUTTONDOWN:
00166             SetCapture(hwnd);
00167         break;
00168 
00169         case WM_LBUTTONUP:
00170         case WM_RBUTTONDOWN:
00171             if (GetCapture() == hwnd)
00172             {
00173                 ReleaseCapture();
00174             }
00175         break;
00176 
00177         case WM_MOUSEMOVE:
00178             if (GetCapture() == hwnd)
00179             {
00180                 HDWP hdwp;
00181                 POINT Point;
00182 
00183                 GetCursorPos(&Point);
00184                 ScreenToClient(hMainWnd, &Point);
00185 
00186                 if ((GetClientWindowWidth(hMainWnd) - SPLIT_WIDTH) < Point.x)
00187                     break;
00188 
00189                 if (SPLIT_WIDTH > Point.x)
00190                     break;
00191 
00192                 hdwp = BeginDeferWindowPos(5);
00193 
00194                 /* Size VSplitBar */
00195                 DeferWindowPos(hdwp,
00196                                hwnd,
00197                                0,
00198                                Point.x,
00199                                GetWindowHeight(hToolBar),
00200                                SPLIT_WIDTH,
00201                                GetClientWindowHeight(hMainWnd) - GetWindowHeight(hToolBar) - GetWindowHeight(hStatusBar),
00202                                SWP_NOZORDER|SWP_NOACTIVATE);
00203 
00204                 /* Size TreeView */
00205                 DeferWindowPos(hdwp,
00206                                hTreeView,
00207                                0,
00208                                0,
00209                                GetWindowHeight(hToolBar),
00210                                Point.x,
00211                                GetClientWindowHeight(hMainWnd) - GetWindowHeight(hToolBar) - GetWindowHeight(hStatusBar),
00212                                SWP_NOZORDER|SWP_NOACTIVATE);
00213 
00214                 /* Size ListView */
00215                 DeferWindowPos(hdwp,
00216                                hListView,
00217                                0,
00218                                Point.x + SPLIT_WIDTH,
00219                                GetWindowHeight(hToolBar),
00220                                GetClientWindowWidth(hMainWnd) - (Point.x + SPLIT_WIDTH),
00221                                GetHSplitterPos() - GetWindowHeight(hToolBar),
00222                                SWP_NOZORDER|SWP_NOACTIVATE);
00223 
00224                 DeferWindowPos(hdwp,
00225                                hRichEdit,
00226                                0,
00227                                Point.x + SPLIT_WIDTH,
00228                                GetHSplitterPos() + SPLIT_WIDTH,
00229                                GetClientWindowWidth(hMainWnd) - (Point.x + SPLIT_WIDTH),
00230                                GetClientWindowHeight(hMainWnd) - (GetHSplitterPos() + SPLIT_WIDTH + GetWindowHeight(hStatusBar)),
00231                                SWP_NOZORDER|SWP_NOACTIVATE);
00232 
00233                 DeferWindowPos(hdwp,
00234                                hHSplitter,
00235                                0,
00236                                Point.x + SPLIT_WIDTH,
00237                                GetHSplitterPos(),
00238                                GetClientWindowWidth(hMainWnd) - (Point.x + SPLIT_WIDTH),
00239                                SPLIT_WIDTH,
00240                                SWP_NOZORDER|SWP_NOACTIVATE);
00241 
00242                 EndDeferWindowPos(hdwp);
00243             }
00244         break;
00245     }
00246 
00247     return DefWindowProc(hwnd, Msg, wParam, lParam);
00248 }
00249 
00250 /* Create vertical splitter bar */
00251 BOOL
00252 CreateVSplitBar(HWND hwnd)
00253 {
00254     WCHAR szWindowClass[] = L"VSplitterWindowClass";
00255     WNDCLASSEXW WndClass = {0};
00256 
00257     WndClass.cbSize        = sizeof(WNDCLASSEXW);
00258     WndClass.lpszClassName = szWindowClass;
00259     WndClass.lpfnWndProc   = VSplitterWindowProc;
00260     WndClass.hInstance     = hInst;
00261     WndClass.style         = CS_HREDRAW | CS_VREDRAW;
00262     WndClass.hCursor       = LoadCursor(0, IDC_SIZEWE);
00263     WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
00264 
00265     if (RegisterClassExW(&WndClass) == (ATOM) 0)
00266     {
00267         /* TODO: Show error message */
00268         return FALSE;
00269     }
00270 
00271     hVSplitter = CreateWindowExW(WS_EX_TRANSPARENT,
00272                                  szWindowClass,
00273                                  NULL,
00274                                  WS_CHILD | WS_VISIBLE,
00275                                  201, 28, SPLIT_WIDTH, 350,
00276                                  hwnd,
00277                                  NULL,
00278                                  hInst,
00279                                  NULL);
00280 
00281 
00282     if (!hVSplitter)
00283     {
00284         /* TODO: Show error message */
00285         return FALSE;
00286     }
00287 
00288     ShowWindow(hVSplitter, SW_SHOW);
00289     UpdateWindow(hVSplitter);
00290 
00291     return TRUE;
00292 }

Generated on Fri May 25 2012 04:15:42 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.