1 #include "FirstUiBuilder.h"
8 static UIColor CurrentGridColor
;
9 static HBRUSH gBrush
= 0;
11 extern bool gDrawGrid
;
12 extern bool gSnapToGrid
;
13 extern UIColor gGridColor
;
14 extern unsigned long gXGridStep
;
15 extern unsigned long gYGridStep
;
16 extern unsigned long gGridMajorTicks
;
18 static void LoadData( HWND hwndDlg
)
20 SetDlgItemInt( hwndDlg
, IDC_HORIZONTAL_GRID_RESOLUTION
, gXGridStep
, FALSE
);
21 SetDlgItemInt( hwndDlg
, IDC_VERTICAL_GRID_RESOLUTION
, gYGridStep
, FALSE
);
22 SetDlgItemInt( hwndDlg
, IDC_GRID_MAJORTICKS
, gGridMajorTicks
, FALSE
);
25 CheckDlgButton( hwndDlg
, IDC_DRAWGRID
, BST_CHECKED
);
27 CheckDlgButton( hwndDlg
, IDC_DRAWGRID
, BST_UNCHECKED
);
30 CheckDlgButton( hwndDlg
, IDC_SNAPTOGRID2
, BST_CHECKED
);
32 CheckDlgButton( hwndDlg
, IDC_SNAPTOGRID2
, BST_UNCHECKED
);
34 SendDlgItemMessage( hwndDlg
, IDC_OPACITY_SLIDER
, TBM_SETRANGE
, FALSE
, MAKELONG( 0, 255 ) );
35 SendDlgItemMessage( hwndDlg
, IDC_OPACITY_SLIDER
, TBM_SETPOS
, TRUE
, gGridColor
.a
);
37 CurrentGridColor
= gGridColor
;
40 static void SaveData( HWND hwndDlg
)
45 NewValue
= GetDlgItemInt( hwndDlg
, IDC_HORIZONTAL_GRID_RESOLUTION
, &Worked
, FALSE
);
48 gXGridStep
= NewValue
;
50 NewValue
= GetDlgItemInt( hwndDlg
, IDC_VERTICAL_GRID_RESOLUTION
, &Worked
, FALSE
);
53 gYGridStep
= NewValue
;
55 NewValue
= GetDlgItemInt( hwndDlg
, IDC_GRID_MAJORTICKS
, &Worked
, FALSE
);
58 gGridMajorTicks
= NewValue
;
60 CurrentGridColor
.a
= (unsigned char)SendDlgItemMessage( hwndDlg
, IDC_OPACITY_SLIDER
, TBM_GETPOS
, 0, 0 );
62 gDrawGrid
= IsDlgButtonChecked( hwndDlg
, IDC_DRAWGRID
) != 0;
63 gSnapToGrid
= IsDlgButtonChecked( hwndDlg
, IDC_SNAPTOGRID2
) != 0;
64 gGridColor
= CurrentGridColor
;
67 static void ChangeGridColor( HWND hwndDlg
)
69 CHOOSECOLOR cc
= {sizeof(cc
)};
72 ZeroMemory( sc
, sizeof( sc
) );
74 cc
.hwndOwner
= hwndDlg
;
75 cc
.rgbResult
= RGB( CurrentGridColor
.r
, CurrentGridColor
.g
, CurrentGridColor
.b
);
76 cc
.Flags
= CC_RGBINIT
;
79 if( ChooseColor( &cc
) )
81 CurrentGridColor
.r
= GetRValue( cc
.rgbResult
);
82 CurrentGridColor
.g
= GetGValue( cc
.rgbResult
);
83 CurrentGridColor
.b
= GetBValue( cc
.rgbResult
);
87 static void Cleanup( void )
91 DeleteObject( gBrush
);
96 BOOL CALLBACK
GridSettingsDlgProc( HWND hwndDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
105 // Equivalent to pressing cancel
106 EndDialog( hwndDlg
, 0 );
111 if( LOWORD( wParam
) == IDOK
)
114 EndDialog( hwndDlg
, 0 );
117 else if( LOWORD( wParam
) == IDCANCEL
)
119 EndDialog( hwndDlg
, 0 );
122 else if( LOWORD( wParam
) == IDC_CHANGE_GRIDCOLOR
)
124 ChangeGridColor( hwndDlg
);
125 InvalidateRect( GetDlgItem( hwndDlg
, IDC_GRIDCOLOR
), 0, TRUE
);
129 case WM_CTLCOLORSTATIC
:
130 if( (HWND
)lParam
== GetDlgItem( hwndDlg
, IDC_GRIDCOLOR
) )
132 COLORREF col
= RGB( CurrentGridColor
.r
, CurrentGridColor
.g
, CurrentGridColor
.b
);
135 DeleteObject( gBrush
);
137 gBrush
= CreateSolidBrush( col
);
138 SetTextColor( (HDC
)wParam
, col
);
139 SetBkColor( (HDC
)wParam
, col
);