gecko-dev/cmd/winfe/srchdlg.cpp

322 lines
7.4 KiB
C++
Raw Normal View History

1998-03-28 02:44:41 +00:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// srchdlg.cpp : implementation file
//
#include "stdafx.h"
#include "srchdlg.h"
#include "template.h"
#include "wfemsg.h"
#include "msg_srch.h"
#include "dirprefs.h"
#include "nethelp.h"
#include "xp_help.h"
#include "prefapi.h"
#include "intlwin.h"
#include "xp_time.h"
#include "xplocale.h"
#include "dateedit.h"
#include "intl_csi.h"
1998-06-22 21:19:46 +00:00
#define BOTTOM_BORDER 15
1998-03-28 02:44:41 +00:00
////////////////////////////////////////////////////////////////////////////
// CAddrEditProperities
1998-06-22 21:19:46 +00:00
CSearchDialog::CSearchDialog (LPCTSTR lpszCaption, MSG_Pane* pSearchPane, DIR_Server* pServer, CWnd * parent)
:CDialog ( CSearchDialog::IDD, parent)
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
m_pTitle = XP_STRDUP(lpszCaption);
1998-03-28 02:44:41 +00:00
m_pServer = pServer;
m_pSearchPane = pSearchPane;
1998-06-22 21:19:46 +00:00
m_iMoreCount = 0;
m_bLogicType = 1;
m_bChanged = FALSE;
1998-03-28 02:44:41 +00:00
}
1998-06-22 21:19:46 +00:00
CSearchDialog::CSearchDialog (UINT nIDCaption, MSG_Pane* pSearchPane, DIR_Server* pServer, CWnd * parent)
:CDialog ( CSearchDialog::IDD, parent)
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
m_pTitle = XP_STRDUP(::szLoadString(nIDCaption));
1998-03-28 02:44:41 +00:00
m_pServer = pServer;
m_pSearchPane = pSearchPane;
1998-06-22 21:19:46 +00:00
m_iMoreCount = 0;
m_bLogicType = 1;
m_bChanged = FALSE;
1998-03-28 02:44:41 +00:00
}
1998-06-22 21:19:46 +00:00
CSearchDialog::~CSearchDialog ( )
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
if(m_pTitle)
{
XP_FREE(m_pTitle);
1998-03-28 02:44:41 +00:00
}
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::PostNcDestroy( )
1998-03-28 02:44:41 +00:00
{
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::DoDataExchange(CDataExchange* pDX)
1998-03-28 02:44:41 +00:00
{
CDialog::DoDataExchange(pDX);
1998-06-22 21:19:46 +00:00
//{{AFX_DATA_MAP(CSearchDialog)
1998-03-28 02:44:41 +00:00
//}}AFX_DATA_MAP
}
1998-06-22 21:19:46 +00:00
BEGIN_MESSAGE_MAP(CSearchDialog, CDialog)
//{{AFX_MSG_MAP(CSearchDialog)
1998-03-28 02:44:41 +00:00
// NOTE: the ClassWizard will add message map macros here
1998-06-22 21:19:46 +00:00
ON_WM_CREATE()
ON_BN_CLICKED(IDC_MORE, OnMore)
ON_BN_CLICKED(IDC_FEWER, OnFewer)
ON_BN_CLICKED(IDC_CLEAR_SEARCH, OnClearSearch)
ON_BN_CLICKED(IDC_SEARCH, OnSearch)
ON_CBN_SELCHANGE(IDC_COMBO_ATTRIB1, OnAttrib1)
ON_CBN_SELCHANGE(IDC_COMBO_ATTRIB2, OnAttrib2)
ON_CBN_SELCHANGE(IDC_COMBO_ATTRIB3, OnAttrib3)
ON_CBN_SELCHANGE(IDC_COMBO_ATTRIB4, OnAttrib4)
ON_CBN_SELCHANGE(IDC_COMBO_ATTRIB5, OnAttrib5)
ON_CBN_SELCHANGE(IDC_COMBO_OP1, OnOperatorValueChanged)
ON_CBN_SELCHANGE(IDC_COMBO_OP2, OnOperatorValueChanged)
ON_CBN_SELCHANGE(IDC_COMBO_OP3, OnOperatorValueChanged)
ON_CBN_SELCHANGE(IDC_COMBO_OP4, OnOperatorValueChanged)
ON_CBN_SELCHANGE(IDC_COMBO_OP5, OnOperatorValueChanged)
ON_BN_CLICKED(IDC_RADIO_ALL, OnAndOr)
ON_BN_CLICKED(IDC_RADIO_ANY, OnAndOr)
ON_EN_CHANGE( IDC_EDIT_VALUE1, OnEditValueChanged )
ON_EN_CHANGE( IDC_EDIT_VALUE2, OnEditValueChanged )
ON_EN_CHANGE( IDC_EDIT_VALUE3, OnEditValueChanged )
ON_EN_CHANGE( IDC_EDIT_VALUE4, OnEditValueChanged )
1998-03-28 02:44:41 +00:00
#ifdef ON_UPDATE_COMMAND_UI_RANGE
1998-06-22 21:19:46 +00:00
ON_UPDATE_COMMAND_UI_RANGE( IDC_COMBO_ATTRIB1, IDC_EDIT_VALUE5, OnUpdateQuery )
1998-03-28 02:44:41 +00:00
#endif
1998-06-22 21:19:46 +00:00
1998-03-28 02:44:41 +00:00
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#ifndef ON_UPDATE_COMMAND_UI_RANGE
BOOL CAdvancedSearch::OnCmdMsg( UINT nID, int nCode, void* pExtra,
AFX_CMDHANDLERINFO* pHandlerInfo )
{
if ((nID >= IDC_COMBO_ATTRIB1) && (nID <= IDC_EDIT_VALUE5) &&
( nCode == CN_UPDATE_COMMAND_UI) ) {
OnUpdateQuery( (CCmdUI *) pExtra );
return TRUE;
}
return CDialog::OnCmdMsg( nID, nCode, pExtra, pHandlerInfo );
}
#endif
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnUpdateQuery( CCmdUI *pCmdUI )
1998-03-28 02:44:41 +00:00
{
pCmdUI->Enable( TRUE );
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::AdjustHeight(int dy)
1998-03-28 02:44:41 +00:00
{
CRect rect;
GetWindowRect(&rect);
CSize size = rect.Size();
size.cy += dy;
1998-06-22 21:19:46 +00:00
SetWindowPos( NULL, 0, 0, size.cx, size.cy, SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW|SWP_NOMOVE);
1998-03-28 02:44:41 +00:00
GetWindowRect(&rect);
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnSearch()
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
MSG_SearchFree (m_pSearchPane);
MSG_SearchAlloc (m_pSearchPane);
MSG_AddLdapScope(m_pSearchPane, m_pServer);
m_searchObj.BuildQuery(m_pSearchPane, m_iMoreCount, m_bLogicType);
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
CDialog::OnOK();
1998-03-28 02:44:41 +00:00
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnAndOr()
1998-03-28 02:44:41 +00:00
{
m_searchObj.OnAndOr(m_iMoreCount, &m_bLogicType);
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnMore()
1998-03-28 02:44:41 +00:00
{
int dy = 0;
dy = m_searchObj.More(&m_iMoreCount, m_bLogicType);
if (m_iMoreCount < 4)
GetDlgItem(IDC_MORE)->EnableWindow (TRUE);
else
GetDlgItem(IDC_MORE)->EnableWindow (FALSE);
if (m_iMoreCount > 0)
GetDlgItem(IDC_FEWER)->EnableWindow (TRUE);
else
GetDlgItem(IDC_FEWER)->EnableWindow (FALSE);
AdjustHeight (dy);
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnFewer()
1998-03-28 02:44:41 +00:00
{
int dy = 0;
dy = m_searchObj.Fewer(&m_iMoreCount, m_bLogicType);
if (m_iMoreCount < 4)
GetDlgItem(IDC_MORE)->EnableWindow (TRUE);
else
GetDlgItem(IDC_MORE)->EnableWindow (FALSE);
if (m_iMoreCount > 0)
GetDlgItem(IDC_FEWER)->EnableWindow (TRUE);
else
GetDlgItem(IDC_FEWER)->EnableWindow (FALSE);
AdjustHeight (dy);
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnClearSearch()
1998-03-28 02:44:41 +00:00
{
int dy = 0;
1998-06-22 21:19:46 +00:00
MSG_SearchFree (m_pSearchPane);
1998-03-28 02:44:41 +00:00
dy = m_searchObj.ClearSearch(&m_iMoreCount, TRUE);
AdjustHeight (dy);
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnEditValueChanged ()
1998-03-28 02:44:41 +00:00
{
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnOperatorValueChanged ()
1998-03-28 02:44:41 +00:00
{
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnAttrib1()
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
m_searchObj.UpdateOpList(0, scopeLdapDirectory, m_pServer);
1998-03-28 02:44:41 +00:00
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnAttrib2()
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
m_searchObj.UpdateOpList(1, scopeLdapDirectory, m_pServer);
1998-03-28 02:44:41 +00:00
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnAttrib3()
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
m_searchObj.UpdateOpList(2, scopeLdapDirectory, m_pServer);
1998-03-28 02:44:41 +00:00
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnAttrib4()
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
m_searchObj.UpdateOpList(3, scopeLdapDirectory, m_pServer);
1998-03-28 02:44:41 +00:00
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
void CSearchDialog::OnAttrib5()
1998-03-28 02:44:41 +00:00
{
DIR_Server * server = NULL;
1998-06-22 21:19:46 +00:00
m_searchObj.UpdateOpList(4, scopeLdapDirectory, m_pServer);
1998-03-28 02:44:41 +00:00
m_bChanged = TRUE;
}
1998-06-22 21:19:46 +00:00
int CSearchDialog::OnCreate( LPCREATESTRUCT lpCreateStruct )
{
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
int16 guicsid = 0;
CString cs;
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
guicsid = CIntlWin::GetSystemLocaleCsid();
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
HDC hDC = ::GetDC(m_hWnd);
LOGFONT lf;
memset(&lf,0,sizeof(LOGFONT));
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
lf.lfPitchAndFamily = FF_SWISS;
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = IntlGetLfCharset(CIntlWin::GetSystemLocaleCsid());
if (CIntlWin::GetSystemLocaleCsid() == CS_LATIN1)
_tcscpy(lf.lfFaceName, "MS Sans Serif");
else
_tcscpy(lf.lfFaceName, IntlGetUIPropFaceName(CIntlWin::GetSystemLocaleCsid()));
lf.lfHeight = -MulDiv(9, ::GetDeviceCaps(hDC, LOGPIXELSY), 72);
m_pFont = theApp.CreateAppFont( lf );
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
::ReleaseDC(m_hWnd,hDC);
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
return 0;
1998-03-28 02:44:41 +00:00
}
1998-06-22 21:19:46 +00:00
BOOL CSearchDialog::OnInitDialog()
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
CDialog::OnInitDialog();
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
m_searchObj.InitializeAttributes (widgetText, attribCommonName);
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
m_searchObj.New (this);
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
m_searchObj.UpdateAttribList(scopeLdapDirectory, m_pServer);
m_searchObj.UpdateOpList(scopeLdapDirectory, m_pServer);
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
SetWindowText(m_pTitle);
GetDlgItem(IDC_STATIC1)->SetWindowText(m_pServer->description);
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
CWnd* pWidget = GetDlgItem(IDC_STATIC_DESC);
if(pWidget)
1998-03-28 02:44:41 +00:00
{
1998-06-22 21:19:46 +00:00
CRect widgetRect, windowRect;
pWidget->GetWindowRect(widgetRect);
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
GetWindowRect(windowRect);
int dy = windowRect.BottomRight().y - widgetRect.BottomRight().y;
1998-03-28 02:44:41 +00:00
1998-06-22 21:19:46 +00:00
SetWindowPos(NULL, 0, 0, windowRect.Width(),
windowRect.Height() - dy + BOTTOM_BORDER, SWP_NOMOVE);
1998-03-28 02:44:41 +00:00
}
1998-06-22 21:19:46 +00:00
return TRUE;
1998-03-28 02:44:41 +00:00
}