~ubuntu-branches/debian/squeeze/stella/squeeze

« back to all changes in this revision

Viewing changes to src/win32/StellaX/PropertySheet.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Mario Iseli
  • Date: 2006-04-08 18:38:25 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20060408183825-vu1jk57rk929derx
* New Maintainer (Closes: #361345)
* New upstream release (Closes: #349725)
* Build-Depend now on libslang2-dev (Closes: #325577)
* Complete rebuild of debian/, upgraded to policy-standards
  3.6.2 and compat-level 5.
* Removed stellarc since stella only reads ~/.stellarc and even
  works without a first config.
* New debian/watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//============================================================================
2
 
//
3
 
//   SSSS    tt          lll  lll          XX     XX
4
 
//  SS  SS   tt           ll   ll           XX   XX
5
 
//  SS     tttttt  eeee   ll   ll   aaaa     XX XX
6
 
//   SSSS    tt   ee  ee  ll   ll      aa     XXX
7
 
//      SS   tt   eeeeee  ll   ll   aaaaa    XX XX
8
 
//  SS  SS   tt   ee      ll   ll  aa  aa   XX   XX
9
 
//   SSSS     ttt  eeeee llll llll  aaaaa  XX     XX
10
 
//
11
 
// Copyright (c) 1995-2000 by Jeff Miller
12
 
// Copyright (c) 2004 by Stephen Anthony
13
 
//
14
 
// See the file "license" for information on usage and redistribution of
15
 
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16
 
//
17
 
// $Id: PropertySheet.cxx,v 1.2 2004/07/15 03:03:27 stephena Exp $
18
 
//============================================================================
19
 
 
20
 
#include "pch.hxx"
21
 
#include "PropertySheet.hxx"
22
 
 
23
 
#pragma comment(lib, "comctl32")
24
 
#include <pshpack1.h>
25
 
 
26
 
typedef struct DLGTEMPLATEEX
27
 
{
28
 
  WORD dlgVer;
29
 
  WORD signature;
30
 
  DWORD helpID;
31
 
  DWORD exStyle;
32
 
  DWORD style;
33
 
  WORD cDlgItems;
34
 
  short x;
35
 
  short y;
36
 
  short cx;
37
 
  short cy;
38
 
} DLGTEMPLATEEX, *LPDLGTEMPLATEEX;
39
 
 
40
 
#include <poppack.h>
41
 
 
42
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
43
 
CPropertyPage::CPropertyPage( UINT nIDTemplate, UINT nIDCaption /* = 0 */ )
44
 
{
45
 
  UNUSED_ALWAYS( nIDCaption );
46
 
 
47
 
  ZeroMemory(&m_psp, sizeof(m_psp));
48
 
  m_psp.dwSize = sizeof(m_psp);
49
 
  m_psp.dwFlags = PSP_USECALLBACK;
50
 
  // m_psp.hInstance = hInstance;
51
 
  m_psp.pszTemplate = MAKEINTRESOURCE(nIDTemplate);
52
 
  m_psp.pfnDlgProc = StaticDlgProc;
53
 
  m_psp.lParam = (LPARAM)this;
54
 
  m_psp.pfnCallback = StaticCallback;
55
 
}
56
 
 
57
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
58
 
UINT CALLBACK
59
 
CPropertyPage::StaticCallback( HWND hwnd, UINT uMsg, LPPROPSHEETPAGE ppsp )
60
 
{
61
 
  UNUSED_ALWAYS( hwnd );
62
 
  UNUSED_ALWAYS( ppsp );
63
 
 
64
 
  switch (uMsg)
65
 
  {
66
 
    case PSPCB_CREATE:
67
 
      // ppsp->lParam holds create lParam
68
 
      return TRUE;
69
 
 
70
 
    case PSPCB_RELEASE:
71
 
      break;
72
 
  }
73
 
 
74
 
  return 0;
75
 
}
76
 
 
77
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
78
 
BOOL CALLBACK
79
 
CPropertyPage::StaticDlgProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
80
 
{
81
 
  CPropertyPage* pPage = NULL;
82
 
 
83
 
  switch ( uMsg )
84
 
  {
85
 
    case WM_INITDIALOG:
86
 
      pPage = reinterpret_cast<CPropertyPage*>( 
87
 
                reinterpret_cast<PROPSHEETPAGE*>( lParam )->lParam );
88
 
      (void)::SetWindowLong( hwnd, DWL_USER, reinterpret_cast<LONG>( pPage ) );
89
 
      break;
90
 
 
91
 
    default:
92
 
      pPage = reinterpret_cast<CPropertyPage*>( GetWindowLong( hwnd, DWL_USER ) );
93
 
      if ( pPage == NULL )
94
 
        return FALSE;
95
 
      break;
96
 
  }
97
 
 
98
 
  return pPage->DlgProc( hwnd, uMsg, wParam, lParam );
99
 
}
100
 
 
101
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
102
 
BOOL CALLBACK
103
 
CPropertyPage::DlgProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
104
 
{
105
 
  switch (msg)
106
 
  {
107
 
    case WM_ACTIVATE:
108
 
      OnActivate( (UINT)LOWORD(wParam), (HWND)lParam, (BOOL)HIWORD(wParam) );
109
 
      return TRUE;
110
 
 
111
 
    case WM_INITDIALOG:
112
 
      return OnInitDialog( hwnd );
113
 
 
114
 
    case WM_DESTROY:
115
 
      OnDestroy( );
116
 
      return TRUE;
117
 
 
118
 
    case WM_COMMAND:
119
 
      return OnCommand( HIWORD(wParam), LOWORD(wParam), (HWND)lParam );
120
 
 
121
 
    case WM_NOTIFY:
122
 
      // Handle PSN_QUERYCANCEL?
123
 
      // Handle PSN_KILLACTIVE?
124
 
      switch (((LPNMHDR)lParam)->code)
125
 
      {
126
 
        case PSN_SETACTIVE:
127
 
          SetWindowLong(hwnd, DWL_MSGRESULT, OnSetActive( (LPPSHNOTIFY)lParam ) );
128
 
          return TRUE;
129
 
 
130
 
        case PSN_KILLACTIVE:
131
 
          SetWindowLong(hwnd, DWL_MSGRESULT, OnKillActive( (LPPSHNOTIFY)lParam ) );
132
 
          return TRUE;
133
 
 
134
 
        case PSN_APPLY:
135
 
          SetWindowLong( hwnd, DWL_MSGRESULT, OnApply( (LPPSHNOTIFY)lParam) );
136
 
          return TRUE;
137
 
 
138
 
        case PSN_RESET:
139
 
          OnReset( (LPPSHNOTIFY)lParam );
140
 
          return TRUE;
141
 
      }
142
 
      return OnNotify( (int)wParam, (LPNMHDR)lParam );
143
 
  }
144
 
 
145
 
        return FALSE;
146
 
}
147
 
 
148
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
149
 
CPropertySheet::CPropertySheet( LPCTSTR pszCaption, HWND hwndParent,
150
 
                                UINT nStartPage /* = 0 */ )
151
 
              : m_strCaption( pszCaption )
152
 
{
153
 
  ZeroMemory(&m_psh, sizeof(m_psh));
154
 
  m_psh.dwSize = sizeof(m_psh);
155
 
  m_psh.dwFlags = PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
156
 
  m_psh.hwndParent = hwndParent;
157
 
  m_psh.hInstance = (HINSTANCE)GetWindowLong(hwndParent, GWL_HINSTANCE);
158
 
  m_psh.pszCaption = m_strCaption.c_str();
159
 
  m_psh.nStartPage = nStartPage;
160
 
  m_psh.pfnCallback = StaticCallback;
161
 
}
162
 
 
163
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
164
 
CPropertySheet::~CPropertySheet()
165
 
{
166
 
  // BUGBUG: This is static!
167
 
 
168
 
/*  if ( m_hfontLogo )
169
 
  {
170
 
    DeleteObject( m_hfontLogo );
171
 
    m_hfontLogo = NULL;
172
 
  }*/
173
 
}
174
 
 
175
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
176
 
void CPropertySheet::AddPage( CPropertyPage* pPage )
177
 
{
178
 
  if (pPage)
179
 
    m_pages.push_back(pPage);
180
 
}
181
 
 
182
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
183
 
int CPropertySheet::DoModal()
184
 
{
185
 
  int nSize = m_pages.size();
186
 
 
187
 
  if (nSize == 0)
188
 
    return IDCANCEL;
189
 
 
190
 
  PROPSHEETPAGE* pspage = new PROPSHEETPAGE[nSize];
191
 
  for (int i = 0; i < nSize; ++i)
192
 
  {
193
 
    CopyMemory(&(pspage[i]), m_pages[i]->GetPropSheetPage(),
194
 
               sizeof(PROPSHEETPAGE));
195
 
    pspage[i].hInstance = m_psh.hInstance;
196
 
  }
197
 
 
198
 
  m_psh.nPages = nSize;
199
 
  m_psh.ppsp = pspage;
200
 
 
201
 
  int nRet = ::PropertySheet( &m_psh );
202
 
 
203
 
  delete[] pspage;
204
 
 
205
 
  return nRet;
206
 
}
207
 
 
208
 
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
209
 
int CALLBACK
210
 
CPropertySheet::StaticCallback( HWND hwnd, UINT uMsg, LPARAM lParam )
211
 
{
212
 
  UNUSED_ALWAYS( hwnd );
213
 
 
214
 
  switch (uMsg)
215
 
  {
216
 
    case PSCB_INITIALIZED:
217
 
      // Property sheet is being initialized
218
 
      return TRUE;
219
 
 
220
 
    case PSCB_PRECREATE:
221
 
      // Property sheet is about to be created
222
 
      // Remove the DS_CONTEXTHELP style from the dialog template
223
 
      // (This will remove the "?" in the top right corner)
224
 
      if ( ( (LPDLGTEMPLATEEX)lParam )->signature == 0xFFFF)
225
 
        ( (LPDLGTEMPLATEEX)lParam )->style &= ~DS_CONTEXTHELP;
226
 
      else 
227
 
        ( (LPDLGTEMPLATE)lParam )->style &= ~DS_CONTEXTHELP;
228
 
 
229
 
      return TRUE;
230
 
  }
231
 
        
232
 
  return 0;
233
 
}