Author: gedmurphy
Date: Wed Nov 8 22:27:57 2006
New Revision: 24703
URL:
http://svn.reactos.org/svn/reactos?rev=24703&view=rev
Log:
- create a pretty combobox custom control which resembles the one in MS Office as the
standard Windows/ReactOS combo box is ugly
- change ShowHideWindow to make it more reliable
- fix the second combobox positioning within the text toolbar
- hide all windows except the toolbar at startup (these will eventually be read from the
registry)
Added:
trunk/reactos/base/applications/imagesoft/custcombo.c
Modified:
trunk/reactos/base/applications/imagesoft/floatwindow.c
trunk/reactos/base/applications/imagesoft/imagesoft.c
trunk/reactos/base/applications/imagesoft/imagesoft.rbuild
trunk/reactos/base/applications/imagesoft/imgedwnd.c
trunk/reactos/base/applications/imagesoft/mainwnd.c
trunk/reactos/base/applications/imagesoft/opensave.c
trunk/reactos/base/applications/imagesoft/precomp.h
trunk/reactos/base/applications/imagesoft/resource.h
Added: trunk/reactos/base/applications/imagesoft/custcombo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/custcombo.c (added)
+++ trunk/reactos/base/applications/imagesoft/custcombo.c Wed Nov 8 22:27:57 2006
@@ -1,0 +1,213 @@
+#include "precomp.h"
+
+
+LRESULT WINAPI
+FlatComboProc(HWND hwnd,
+ UINT msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ HDC hdc;
+ PAINTSTRUCT ps;
+ RECT rect, rect2;
+ POINT pt;
+
+ WNDPROC OldComboProc = (WNDPROC)GetWindowLong(hwnd, GWL_USERDATA);
+
+ static BOOL fMouseDown = FALSE;
+ static BOOL fButtonDown = FALSE;
+
+ switch(msg)
+ {
+ case WM_PAINT:
+ {
+ if(wParam == 0) hdc = BeginPaint(hwnd, &ps);
+ else hdc = (HDC)wParam;
+
+ /* mask off the borders and draw ComboBox normally */
+ GetClientRect(hwnd, &rect);
+
+ InflateRect(&rect,
+ -GetSystemMetrics(SM_CXEDGE)*2,
+ -GetSystemMetrics(SM_CYEDGE)*2);
+
+ rect.right -= GetSystemMetrics(SM_CXVSCROLL);
+
+ IntersectClipRect(hdc,
+ rect.left,
+ rect.top,
+ rect.right,
+ rect.bottom);
+
+ /* Draw the ComboBox */
+ CallWindowProc(OldComboProc,
+ hwnd,
+ msg,
+ (WPARAM)hdc,
+ lParam);
+
+ /* Now mask off inside and draw the borders */
+ SelectClipRgn(hdc,
+ NULL);
+ rect.right += GetSystemMetrics(SM_CXVSCROLL);
+
+ ExcludeClipRect(hdc,
+ rect.left,
+ rect.top,
+ rect.right,
+ rect.bottom);
+
+ /* draw borders */
+ GetClientRect(hwnd,
+ &rect2);
+ FillRect(hdc,
+ &rect2,
+ //CreateSolidBrush(RGB(0,0,0)));
+ GetSysColorBrush(COLOR_3DFACE));
+
+ /* now draw the button */
+ SelectClipRgn(hdc,
+ NULL);
+ rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
+
+ if(fButtonDown)
+ {
+ HBRUSH oldBrush;
+ HPEN oldPen;
+ POINT pt[3];
+
+ FillRect(hdc, &rect, CreateSolidBrush(RGB(182,189,210)));
+ rect.top -= 1;
+ rect.bottom += 1;
+ FrameRect(hdc, &rect, GetStockBrush(WHITE_BRUSH));
+
+ pt[0].x = rect.right - ((GetSystemMetrics(SM_CXVSCROLL) / 2) + 2);
+ pt[0].y = rect.bottom / 2;
+ pt[1].x = pt[0].x + 4;
+ pt[1].y = pt[0].y;
+ pt[2].x = pt[1].x - 2;
+ pt[2].y = pt[1].y + 2;
+
+ oldPen = SelectObject(hdc, GetStockPen(WHITE_PEN));
+ oldBrush = SelectObject(hdc, GetStockBrush(WHITE_BRUSH));
+ Polygon(hdc, pt, 3);
+
+ SelectObject(hdc, oldPen);
+ SelectObject(hdc, oldBrush);
+ }
+ else
+ {
+ HBRUSH oldBrush;
+ POINT pt[3];
+
+ FillRect(hdc, &rect, GetSysColorBrush(COLOR_3DFACE));
+ rect.top -= 1;
+ rect.bottom += 1;
+ FrameRect(hdc, &rect, GetStockBrush(WHITE_BRUSH));
+
+ pt[0].x = rect.right - ((GetSystemMetrics(SM_CXVSCROLL) / 2) + 2);
+ pt[0].y = rect.bottom / 2;
+ pt[1].x = pt[0].x + 4;
+ pt[1].y = pt[0].y;
+ pt[2].x = pt[1].x - 2;
+ pt[2].y = pt[1].y + 2;
+
+ oldBrush = SelectObject(hdc, GetStockBrush(BLACK_BRUSH));
+ Polygon(hdc, pt, 3);
+
+ SelectObject(hdc, oldBrush);
+ }
+
+
+ if(wParam == 0)
+ EndPaint(hwnd, &ps);
+
+ return 0;
+ }
+
+ /* check if mouse is within drop-arrow area, toggle
+ * a flag to say if the mouse is up/down. Then invalidate
+ * the window so it redraws to show the changes. */
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+ {
+
+ pt.x = (short)LOWORD(lParam);
+ pt.y = (short)HIWORD(lParam);
+
+ GetClientRect(hwnd, &rect);
+
+ InflateRect(&rect,
+ -GetSystemMetrics(SM_CXEDGE),
+ -GetSystemMetrics(SM_CYEDGE));
+ rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
+
+ if(PtInRect(&rect, pt))
+ {
+ /* we *should* call SetCapture, but the ComboBox does it for us */
+ fMouseDown = TRUE;
+ fButtonDown = TRUE;
+ InvalidateRect(hwnd, 0, 0);
+ }
+ }
+ break;
+
+ /* mouse has moved. Check to see if it is in/out of the drop-arrow */
+ case WM_MOUSEMOVE:
+ {
+
+ pt.x = (short)LOWORD(lParam);
+ pt.y = (short)HIWORD(lParam);
+
+ if(fMouseDown && (wParam & MK_LBUTTON))
+ {
+ GetClientRect(hwnd, &rect);
+
+ InflateRect(&rect, -GetSystemMetrics(SM_CXEDGE),
-GetSystemMetrics(SM_CYEDGE));
+ rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
+
+ if(fButtonDown != PtInRect(&rect, pt))
+ {
+ fButtonDown = PtInRect(&rect, pt);
+ InvalidateRect(hwnd, 0, 0);
+ }
+ }
+ }
+ break;
+
+ case WM_LBUTTONUP:
+ {
+
+ if(fMouseDown)
+ {
+ /* No need to call ReleaseCapture, the ComboBox does it for us */
+ fMouseDown = FALSE;
+ fButtonDown = FALSE;
+ InvalidateRect(hwnd, 0, 0);
+ }
+ }
+ break;
+ }
+
+ return CallWindowProc(OldComboProc,
+ hwnd,
+ msg,
+ wParam,
+ lParam);
+}
+
+VOID MakeFlatCombo(HWND hwndCombo)
+{
+ LONG OldComboProc;
+
+ /* Remember old window procedure */
+ OldComboProc = GetWindowLong(hwndCombo, GWL_WNDPROC);
+ SetWindowLong(hwndCombo,
+ GWL_USERDATA,
+ OldComboProc);
+
+ /* Perform the subclass */
+ OldComboProc = SetWindowLong(hwndCombo,
+ GWL_WNDPROC,
+ (LONG)FlatComboProc);
+}
Modified: trunk/reactos/base/applications/imagesoft/floatwindow.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/floatwindow.c (original)
+++ trunk/reactos/base/applications/imagesoft/floatwindow.c Wed Nov 8 22:27:57 2006
@@ -42,10 +42,10 @@
BOOL
ShowHideWindow(PFLT_WND FltInfo)
{
- ShowWindow(FltInfo->hSelf, FltInfo->bShow ? SW_HIDE : SW_SHOW);
- FltInfo->bShow = ~FltInfo->bShow;
-
- return FltInfo->bShow;
+ if (IsWindowVisible(FltInfo->hSelf))
+ return ShowWindow(FltInfo->hSelf, SW_HIDE);
+ else
+ return ShowWindow(FltInfo->hSelf, SW_SHOW);
}
@@ -219,7 +219,7 @@
if (hMouseButton == NULL)
return FALSE;
- //MakeFlatCombo(hMouseButton);
+ MakeFlatCombo(hMouseButton);
/* temp, just testing */
SendMessage(hMouseButton, CB_ADDSTRING, 0, (LPARAM)_T("Primary"));
@@ -361,7 +361,7 @@
FltInfo = (PFLT_WND)(((LPCREATESTRUCT)lParam)->lpCreateParams);
/*FIXME: read this from registry */
- FltInfo->bShow = TRUE;
+// FltInfo->bShow = TRUE;
FltInfo->bOpaque = FALSE;
Modified: trunk/reactos/base/applications/imagesoft/imagesoft.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/imagesoft.c (original)
+++ trunk/reactos/base/applications/imagesoft/imagesoft.c Wed Nov 8 22:27:57 2006
@@ -95,8 +95,8 @@
TbdUninitImpl();
}
- HeapFree(GetProcessHeap(),
- 0,
+ HeapFree(GetProcessHeap(),
+ 0,
lpTitle);
return Ret;
Modified: trunk/reactos/base/applications/imagesoft/imagesoft.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/imagesoft.rbuild (original)
+++ trunk/reactos/base/applications/imagesoft/imagesoft.rbuild Wed Nov 8 22:27:57 2006
@@ -17,6 +17,7 @@
<library>comdlg32</library>
<compilationunit name="unit.c">
<file>about.c</file>
+ <file>custcombo.c</file>
<file>floatwindow.c</file>
<file>imageprop.c</file>
<file>imagesoft.c</file>
Modified: trunk/reactos/base/applications/imagesoft/imgedwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/imgedwnd.c (original)
+++ trunk/reactos/base/applications/imagesoft/imgedwnd.c Wed Nov 8 22:27:57 2006
@@ -262,14 +262,14 @@
}
break;
}
-
+/*
case WM_ERASEBKGND:
if (Info->Width != 0 && Info->Height != 0)
{
Ret = TRUE;
}
break;
-
+*/
case WM_LBUTTONDOWN:
if (! bRightButtonDown)
SetCapture(Info->hSelf);
@@ -536,4 +536,3 @@
UnregisterClass(szImageEditWndClass,
hInstance);
}
-
Modified: trunk/reactos/base/applications/imagesoft/mainwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/mainwnd.c (original)
+++ trunk/reactos/base/applications/imagesoft/mainwnd.c Wed Nov 8 22:27:57 2006
@@ -123,7 +123,6 @@
UNREFERENCED_PARAMETER(Context);
- /* Standard toolbar */
switch (Dockbar->BarId)
{
case ID_TOOLBAR_STANDARD:
@@ -143,7 +142,7 @@
}
case ID_TOOLBAR_TEST:
- {
+ {/*
hWndClient = CreateWindowEx(WS_EX_TOOLWINDOW,
TEXT("BUTTON"),
TEXT("Test Button"),
@@ -155,7 +154,7 @@
hParent,
NULL,
hInstance,
- NULL);
+ NULL);*/
break;
}
}
@@ -185,7 +184,6 @@
0,
TBSTYLE_EX_HIDECLIPPEDBUTTONS);
- /* Send the TB_BUTTONSTRUCTSIZE message, which is required for backward
compatibility */
SendMessage(hWndClient,
TB_BUTTONSTRUCTSIZE,
sizeof(Buttons[0]),
@@ -209,8 +207,6 @@
NumButtons,
(LPARAM)Buttons);
-
-
}
}
@@ -221,19 +217,21 @@
HWND hFontType;
HWND hFontSize;
- /* drop combo box into container window */
+ /* font selection combo */
hFontType = CreateWindowEx(0,
WC_COMBOBOX,
NULL,
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
- 0, 0, 120, 25,
+ 0, 0, 120, 0,
hParent,
NULL,
hInstance,
NULL);
- //MakeFlatCombo(hFontType);
+
if (hFontType != NULL)
{
+ MakeFlatCombo(hFontType);
+
SetParent(hFontType,
hWndClient);
@@ -247,24 +245,26 @@
}
}
- /* drop combo box into container window */
+ /* font size combo */
hFontSize = CreateWindowEx(0,
WC_COMBOBOX,
NULL,
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
- 0, 0, 40, 25,
+ 0, 0, 50, 0,
hParent,
NULL,
hInstance,
NULL);
if (hFontSize != NULL)
{
+ MakeFlatCombo(hFontSize);
+
SetParent(hFontSize,
hWndClient);
if (!ToolbarInsertSpaceForControl(hWndClient,
hFontSize,
- 0,
+ 1,
ID_TXTFONTSIZE,
TRUE))
{
@@ -593,7 +593,7 @@
NULL,
hInstance,
WndArr[i]);
-
+ ShowWindow(WndArr[i]->hSelf, SW_HIDE);
}
hMenu = GetMenu(Info->hSelf);
@@ -602,11 +602,10 @@
{
if (FloatToolbarCreateToolsGui(Info))
{
- //CheckMenuItem(hMenu,
- // ID_TOOLS,
- // MF_CHECKED);
-
- /* temp disable windows until they are useful */
+ CheckMenuItem(hMenu,
+ ID_TOOLS,
+ MF_CHECKED);
+
ShowHideWindow(Info->fltTools);
}
}
@@ -615,12 +614,7 @@
{
if (FloatToolbarCreateColorsGui(Info))
{
- //CheckMenuItem(hMenu,
- // ID_COLOR,
- // MF_CHECKED);
-
- /* temp disable windows until they are useful */
- ShowHideWindow(Info->fltColors);
+
}
}
@@ -628,12 +622,7 @@
{
if (FloatToolbarCreateHistoryGui(Info))
{
- //CheckMenuItem(hMenu,
- // ID_HISTORY,
- // MF_CHECKED);
-
- /* temp disable windows until they are useful */
- ShowHideWindow(Info->fltHistory);
+
}
}
@@ -895,11 +884,11 @@
if (hMenu != NULL)
{
- UINT uCheck;
-
- ShowHideWindow(Info->fltTools);
-
- uCheck = Info->fltTools->bShow ? MF_CHECKED : MF_UNCHECKED;
+ UINT uCheck = MF_CHECKED;
+
+ if (ShowHideWindow(Info->fltTools))
+ uCheck = MF_UNCHECKED;
+
CheckMenuItem(hMenu,
ID_TOOLS,
uCheck);
@@ -913,11 +902,11 @@
if (hMenu != NULL)
{
- UINT uCheck;
-
- ShowHideWindow(Info->fltColors);
-
- uCheck = Info->fltColors->bShow ? MF_CHECKED : MF_UNCHECKED;
+ UINT uCheck = MF_CHECKED;
+
+ if (ShowHideWindow(Info->fltColors))
+ uCheck = MF_UNCHECKED;
+
CheckMenuItem(hMenu,
ID_COLOR,
uCheck);
@@ -931,11 +920,11 @@
if (hMenu != NULL)
{
- UINT uCheck;
-
- ShowHideWindow(Info->fltHistory);
-
- uCheck = Info->fltHistory->bShow ? MF_CHECKED : MF_UNCHECKED;
+ UINT uCheck = MF_CHECKED;
+
+ if (ShowHideWindow(Info->fltHistory))
+ uCheck = MF_UNCHECKED;
+
CheckMenuItem(hMenu,
ID_HISTORY,
uCheck);
Modified: trunk/reactos/base/applications/imagesoft/opensave.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/opensave.c (original)
+++ trunk/reactos/base/applications/imagesoft/opensave.c Wed Nov 8 22:27:57 2006
@@ -29,7 +29,7 @@
LPTSTR szTitleName)
{
DWORD err;
- /*static TCHAR Filter[] = _T("All image files
(*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png)\0*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png\0") \
+ /*static TCHAR Filter[] = _T("All image files
(*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png)\0*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png\0") \
_T("All files (*.*)\0*.*\0") \
_T("Graphics Interchange format (*gif)\0*.gif\0")
\
_T("Windows Bitmap (*bmp)\0*.bmp\0") \
@@ -39,19 +39,19 @@
static TCHAR Filter[] = _T("Windows Bitmap (*.bmp)\0*.bmp\0");
- ofn.lpstrFilter = Filter;
- ofn.lpstrFile = szFileName;
- ofn.lpstrFileTitle = szTitleName;
- ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
+ ofn.lpstrFilter = Filter;
+ ofn.lpstrFile = szFileName;
+ ofn.lpstrFileTitle = szTitleName;
+ ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
- if (GetOpenFileName(&ofn))
- {
- return TRUE;
- }
+ if (GetOpenFileName(&ofn))
+ {
+ return TRUE;
+ }
- err = CommDlgExtendedError();
+ err = CommDlgExtendedError();
- if (err != CDERR_GENERALCODES)
+ if (err != CDERR_GENERALCODES)
MessageBox(NULL, _T("Open file failed"), NULL, 0);
return FALSE;
@@ -62,24 +62,24 @@
BOOL
DoSaveFile(HWND hwnd)
{
- TCHAR szFileName[MAX_PATH] = _T("");
- static TCHAR Filter[] = _T("Graphics Interchange format (*gif)\0*.gif\0") \
+ TCHAR szFileName[MAX_PATH] = _T("");
+ static TCHAR Filter[] = _T("Graphics Interchange format (*gif)\0*.gif\0")
\
_T("Windows Bitmap (*bmp)\0*.bmp\0") \
_T("JPEG File Interchange Format
(*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \
_T("TAG Image File Format (*tif)\0*.tif\0") \
_T("Portable Network Graphics (*png)\0*.png\0\0");
- ofn.lpstrFilter = Filter;
- ofn.lpstrFile = szFileName;
- ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+ ofn.lpstrFilter = Filter;
+ ofn.lpstrFile = szFileName;
+ ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
OFN_OVERWRITEPROMPT;
- if (GetSaveFileName(&ofn))
- {
+ if (GetSaveFileName(&ofn))
+ {
if (DoWriteFile(szFileName))
return TRUE;
- }
+ }
- if (CommDlgExtendedError() != CDERR_GENERALCODES)
+ if (CommDlgExtendedError() != CDERR_GENERALCODES)
MessageBox(NULL, _T("Save to file failed"), NULL, 0);
return FALSE;
Modified: trunk/reactos/base/applications/imagesoft/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/precomp.h (original)
+++ trunk/reactos/base/applications/imagesoft/precomp.h Wed Nov 8 22:27:57 2006
@@ -380,7 +380,6 @@
INT y;
INT Width;
INT Height;
- BOOL bShow : 1;
BOOL bOpaque;
} FLT_WND, *PFLT_WND;
Modified: trunk/reactos/base/applications/imagesoft/resource.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/imagesof…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/resource.h (original)
+++ trunk/reactos/base/applications/imagesoft/resource.h Wed Nov 8 22:27:57 2006
@@ -2,7 +2,7 @@
/* Main Windows */
#define IDC_TOOLBAR 10
-#define IDC_STATUSBAR 11
+#define IDC_STATUSBAR 11
#define IDC_MAIN_MDI 12
/* these need to be kept consecutive */
#define IDS_FLT_TOOLS 20
@@ -271,8 +271,8 @@
#define IDS_APPNAME 4202
#define IDS_VERSION 4203
#define IDS_LICENSE 4204
-#define IDS_READY 4205
+#define IDS_READY 42050
#define IDS_TOOLBAR_STANDARD 4206
#define IDS_TOOLBAR_TEST 4207
-#define IDS_TOOLBAR_TEXT 4208
+#define IDS_TOOLBAR_TEXT 4205
#define IDS_IMAGE_NAME 4209