INT_PTR DialogInstall::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
	HICON hIcon = (HICON)LoadImage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_SKININSTALLER), IMAGE_ICON, 16, 16, LR_SHARED);
	SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);

	if (GetOSPlatform() >= OSPLATFORM_VISTA)
	{
		SetDialogFont();
	}

	HWND item = GetDlgItem(m_Window, IDC_INSTALL_ADVANCED_BUTTON);
	Dialog::SetMenuButton(item);

	if (ReadPackage())
	{
		item = GetDlgItem(m_Window, IDC_INSTALL_HEADER_BITMAP);
		if (m_HeaderBitmap)
		{
			SendMessage(item, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)m_HeaderBitmap);
		}
		else
		{
			RECT r;
			GetClientRect(item, &r);
			ShowWindow(item, SW_HIDE);
			int yDiff = r.bottom;

			// Move all controls on the main dialog up to "fill" header area.
			int controlIds[] = { IDC_INSTALL_TAB, IDC_INSTALL_ADVANCED_BUTTON, IDC_INSTALL_INSTALL_BUTTON, IDCANCEL, 0 };
			for (int i = 0; i < _countof(controlIds); ++i)
			{
				HWND control = controlIds[i] ? GetDlgItem(m_Window, controlIds[i]) : m_TabInstall.GetWindow();
				GetWindowRect(control, &r);
				MapWindowPoints(nullptr, m_Window, (POINT*)&r, sizeof(RECT) / sizeof(POINT));
				MoveWindow(control, r.left, r.top - yDiff, r.right - r.left, r.bottom - r.top, TRUE);
			}

			// Remove blank area at the bottom of the dialog and center it.
			GetWindowRect(m_Window, &r);
			MoveWindow(m_Window, r.left, r.top + (yDiff / 2), r.right - r.left, r.bottom - r.top - yDiff, TRUE);
		}

		m_TabInstall.Activate();
	}
	else
	{
		if (m_ErrorMessage.empty())
		{
			m_ErrorMessage = L"Invalid package:\n";
			m_ErrorMessage += PathFindFileName(m_PackageFileName.c_str());
			m_ErrorMessage += L"\n\nThe Skin Packager tool must be used to create valid .rmskin packages.";
		}

		MessageBox(nullptr, m_ErrorMessage.c_str(), L"Rainmeter Skin Installer", MB_ERROR);
		EndDialog(m_Window, 0);
	}


	return TRUE;
}
Esempio n. 2
0
INT_PTR DialogPackage::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
	HICON hIcon = (HICON)LoadImage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_SKININSTALLER), IMAGE_ICON, 16, 16, LR_SHARED);
	SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);

	SetDialogFont();

	m_TabInfo.Activate();

	return FALSE;
}
Esempio n. 3
0
INT_PTR CDialogPackage::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
    HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_SKININSTALLER), IMAGE_ICON, 16, 16, LR_SHARED);
    SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);

    if (GetOSPlatform() >= OSPLATFORM_VISTA)
    {
        SetDialogFont();
    }

    m_TabInfo.Activate();

    return FALSE;
}
Esempio n. 4
0
INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
	HWND item = GetDlgItem(m_Window, IDCLOSE);
	SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);

	HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_RAINMETER), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED);
	SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);

	if (*GetString(ID_STR_ISRTL) == L'1')
	{
		// Use RTL layout if using a RTL language
		SetDialogRTL();
	}

	item = GetDlgItem(m_Window, IDC_ABOUT_TAB);
	TCITEM tci = {0};
	tci.mask = TCIF_TEXT;
	tci.pszText = GetString(ID_STR_LOG);
	TabCtrl_InsertItem(item, 0, &tci);
	tci.pszText = GetString(ID_STR_SKINS);
	TabCtrl_InsertItem(item, 1, &tci);
	tci.pszText = GetString(ID_STR_PLUGINS);
	TabCtrl_InsertItem(item, 2, &tci);
	tci.pszText = GetString(ID_STR_VERSION);
	TabCtrl_InsertItem(item, 3, &tci);

	if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
	{
		// Use UI font (Segoe UI) on Vista+
		SetDialogFont();

		HWND item = GetDlgItem(m_TabLog.GetWindow(), IDC_ABOUTLOG_ITEMS_LISTVIEW);
		SetWindowTheme(item, L"explorer", NULL);
		item = GetDlgItem(m_TabSkins.GetWindow(), IDC_ABOUTSKINS_ITEMS_LISTVIEW);
		SetWindowTheme(item, L"explorer", NULL);
	}

	if (c_WindowPlacement.length == 0)
	{
		c_WindowPlacement.length = sizeof(WINDOWPLACEMENT);
		GetWindowPlacement(m_Window, &c_WindowPlacement);
	}

	SetWindowPlacement(m_Window, &c_WindowPlacement);

	return FALSE;
}
Esempio n. 5
0
INT_PTR CDialogManage::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
	HWND item = GetDlgItem(m_Window, IDCLOSE);
	SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);

	HICON hIcon = GetIcon(IDI_RAINMETER);
	SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);

	item = GetDlgItem(m_Window, IDC_MANAGE_TAB);
	TCITEM tci = {0};
	tci.mask = TCIF_TEXT;
	tci.pszText = GetString(ID_STR_SKINS);
	TabCtrl_InsertItem(item, 0, &tci);
	tci.pszText = GetString(ID_STR_THEMES);
	TabCtrl_InsertItem(item, 1, &tci);
	tci.pszText = GetString(ID_STR_SETTINGS);
	TabCtrl_InsertItem(item, 2, &tci);

	if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
	{
		// Use UI font (Segoe UI) on Vista+
		SetDialogFont();

		// Use arrows instead of plus/minus in the tree for Vista+
		item = GetDlgItem(m_TabSkins.GetWindow(), IDC_MANAGESKINS_SKINS_TREEVIEW);
		SetWindowTheme(item, L"explorer", NULL);
	}

	item = GetDlgItem(m_TabSkins.GetWindow(), IDC_MANAGESKINS_FILE_TEXT);
	SendMessage(item, WM_SETFONT, (WPARAM)m_FontBold, 0);

	if (c_WindowPlacement.length == 0)
	{
		c_WindowPlacement.length = sizeof(WINDOWPLACEMENT);
		GetWindowPlacement(m_Window, &c_WindowPlacement);
	}

	SetWindowPlacement(m_Window, &c_WindowPlacement);

	return FALSE;
}
Esempio n. 6
0
INT_PTR CDialogAbout::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
    HWND item = GetDlgItem(m_Window, IDCLOSE);
    SendMessage(m_Window, WM_NEXTDLGCTL, (WPARAM)item, TRUE);

    HICON hIcon = GetIcon(IDI_RAINMETER);
    SendMessage(m_Window, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);

    item = GetDlgItem(m_Window, IDC_ABOUT_TAB);
    TCITEM tci = {0};
    tci.mask = TCIF_TEXT;
    tci.pszText = GetString(ID_STR_LOG);
    TabCtrl_InsertItem(item, 0, &tci);
    tci.pszText = GetString(ID_STR_SKINS);
    TabCtrl_InsertItem(item, 1, &tci);
    tci.pszText = GetString(ID_STR_PLUGINS);
    TabCtrl_InsertItem(item, 2, &tci);
    tci.pszText = GetString(ID_STR_VERSION);
    TabCtrl_InsertItem(item, 3, &tci);

    if (CSystem::GetOSPlatform() >= OSPLATFORM_VISTA)
    {
        // Use UI font (Segoe UI) on Vista+
        SetDialogFont();

        HWND item = GetDlgItem(m_TabLog.GetWindow(), IDC_ABOUTLOG_ITEMS_LISTVIEW);
        SetWindowTheme(item, L"explorer", NULL);
        item = GetDlgItem(m_TabSkins.GetWindow(), IDC_ABOUTSKINS_ITEMS_LISTVIEW);
        SetWindowTheme(item, L"explorer", NULL);
    }

    if (c_WindowPlacement.length == 0)
    {
        c_WindowPlacement.length = sizeof(WINDOWPLACEMENT);
        GetWindowPlacement(m_Window, &c_WindowPlacement);
    }

    SetWindowPlacement(m_Window, &c_WindowPlacement);

    return FALSE;
}
Esempio n. 7
0
void grib_pi::OnToolbarToolCallback(int id)
{
    if( !::wxIsBusy() ) ::wxBeginBusyCursor();

    bool starting = false;

    double scale_factor = GetOCPNGUIToolScaleFactor_PlugIn();
    if( scale_factor != m_GUIScaleFactor ) starting = true;

    m_GUIScaleFactor = scale_factor;
    
    if(!m_pGribCtrlBar)
    {
        starting = true;
        long style = m_DialogStyle == ATTACHED_HAS_CAPTION ? wxCAPTION|wxCLOSE_BOX|wxSYSTEM_MENU : wxBORDER_NONE|wxSYSTEM_MENU;
        m_pGribCtrlBar = new GRIBUICtrlBar(m_parent_window, wxID_ANY, wxEmptyString, wxDefaultPosition,
                wxDefaultSize, style, this);
        m_pGribCtrlBar->SetScaledBitmap(m_GUIScaleFactor);
        
        wxMenu* dummy = new wxMenu(_T("Plugin"));
        wxMenuItem* table = new wxMenuItem( dummy, wxID_ANY, wxString( _("Weather table") ), wxEmptyString, wxITEM_NORMAL );
#ifdef __WXMSW__
        wxFont *qFont = OCPNGetFont(_("Menu"), 10);
        table->SetFont(*qFont);
#endif
        m_MenuItem = AddCanvasContextMenuItem(table, this);
        SetCanvasContextMenuItemViz(m_MenuItem, false);

        // Create the drawing factory
        m_pGRIBOverlayFactory = new GRIBOverlayFactory( *m_pGribCtrlBar );
        m_pGRIBOverlayFactory->SetTimeZone( m_bTimeZone );
        m_pGRIBOverlayFactory->SetParentSize( m_display_width, m_display_height);
        m_pGRIBOverlayFactory->SetSettings( m_bGRIBUseHiDef, m_bGRIBUseGradualColors );

        m_pGribCtrlBar->OpenFile( m_bLoadLastOpenFile == 0 );

    }

    if( m_pGribCtrlBar->GetFont() != *OCPNGetFont(_("Dialog"), 10) ) starting = true;

    //Toggle GRIB overlay display
    m_bShowGrib = !m_bShowGrib;

    //    Toggle dialog?
    if(m_bShowGrib) {
        if( starting ) {
            SetDialogFont( m_pGribCtrlBar );
	    m_pGribCtrlBar->SetScaledBitmap( m_GUIScaleFactor );
            m_pGribCtrlBar->SetDialogsStyleSizePosition( true );
            m_pGribCtrlBar->Refresh();
        } else {
            MoveDialog( m_pGribCtrlBar, GetCtrlBarXY(), wxPoint( 20, 60) );
            if( m_DialogStyle >> 1 == SEPARATED ) {
                MoveDialog( m_pGribCtrlBar->GetCDataDialog(), GetCursorDataXY(), wxPoint( 20, 170));
                m_pGribCtrlBar->GetCDataDialog()->Show( m_pGribCtrlBar->m_CDataIsShown );
                }
        }
        m_pGribCtrlBar->Show();
        if( m_pGribCtrlBar->m_bGRIBActiveFile ) {
            if( m_pGribCtrlBar->m_bGRIBActiveFile->IsOK() ) {
                ArrayOfGribRecordSets *rsa = m_pGribCtrlBar->m_bGRIBActiveFile->GetRecordSetArrayPtr();
                if(rsa->GetCount() > 1) SetCanvasContextMenuItemViz( m_MenuItem, true);
            }
        }
        // Toggle is handled by the CtrlBar but we must keep plugin manager b_toggle updated
        // to actual status to ensure correct status upon CtrlBar rebuild
        SetToolbarItemState( m_leftclick_tool_id, m_bShowGrib );
        RequestRefresh(m_parent_window); // refresh main window
    } else
Esempio n. 8
0
void grib_pi::ShowPreferencesDialog( wxWindow* parent )
{
    GribPreferencesDialog *Pref = new GribPreferencesDialog(parent);

    DimeWindow( Pref );                                     //aplly global colours scheme
    SetDialogFont( Pref );                                  //Apply global font

    Pref->m_cbUseHiDef->SetValue(m_bGRIBUseHiDef);
    Pref->m_cbUseGradualColors->SetValue(m_bGRIBUseGradualColors);
    Pref->m_cbCopyFirstCumulativeRecord->SetValue(m_bCopyFirstCumRec);
    Pref->m_cbCopyMissingWaveRecord->SetValue(m_bCopyMissWaveRec);
    Pref->m_rbTimeFormat->SetSelection( m_bTimeZone );
    Pref->m_rbLoadOptions->SetSelection( m_bLoadLastOpenFile );
    Pref->m_rbStartOptions->SetSelection( m_bStartOptions );

     if( Pref->ShowModal() == wxID_OK ) {
         m_bGRIBUseHiDef= Pref->m_cbUseHiDef->GetValue();
         m_bGRIBUseGradualColors= Pref->m_cbUseGradualColors->GetValue();
         m_bLoadLastOpenFile= Pref->m_rbLoadOptions->GetSelection();
          if( m_pGRIBOverlayFactory )
              m_pGRIBOverlayFactory->SetSettings( m_bGRIBUseHiDef, m_bGRIBUseGradualColors );

         int updatelevel = 0;

         if( m_bStartOptions != Pref->m_rbStartOptions->GetSelection() ) {
             m_bStartOptions = Pref->m_rbStartOptions->GetSelection();
             updatelevel = 1;
         }

         if( m_bTimeZone != Pref->m_rbTimeFormat->GetSelection() ) {
             m_bTimeZone = Pref->m_rbTimeFormat->GetSelection();
             if( m_pGRIBOverlayFactory )
                m_pGRIBOverlayFactory->SetTimeZone( m_bTimeZone );
             updatelevel = 2;
         }

         bool copyrec = Pref->m_cbCopyFirstCumulativeRecord->GetValue();
         bool copywave = Pref->m_cbCopyMissingWaveRecord->GetValue();
         if( m_bCopyFirstCumRec != copyrec || m_bCopyMissWaveRec != copywave ) {
             m_bCopyFirstCumRec = copyrec;
             m_bCopyMissWaveRec = copywave;
             updatelevel = 3;
         }

         if(m_pGribCtrlBar ) {
             switch( updatelevel ) {
             case 0:
                 break;
             case 3:
                 //rebuild current activefile with new parameters and rebuil data list with current index
                 m_pGribCtrlBar->CreateActiveFileFromName( m_pGribCtrlBar->m_bGRIBActiveFile->GetFileName() );
                 m_pGribCtrlBar->PopulateComboDataList();
                 m_pGribCtrlBar->TimelineChanged();
                 break;
             case 2 :
                 //only rebuild  data list with current index and new timezone
                 m_pGribCtrlBar->PopulateComboDataList();
                 m_pGribCtrlBar->TimelineChanged();
                 break;
             case 1:
                 //only re-compute the best forecast
                 m_pGribCtrlBar->ComputeBestForecastForNow();
                 break;
             }
         }

         SaveConfig();
     }
}
Esempio n. 9
0
/* Handles browse Tycons dialog box */
LRESULT CALLBACK BrowseTyconsDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
  static        	List tyconList = NIL;
  List          	tycons=NIL;
  Tycon         	tc;
  UINT          	theTycon;
  WORD          	NotifyCode, wId;
  RECT          	aRect, DlgRect;
  HBITMAP       	hBitmap;
  HBITMAP       	hBmp;
  BITMAP	       	bm;
  static HBITMAP 	hTCBm, hTCSelBm, hDBm, hDSelBm, hTSBm, hTSSelBm,
			hNTBm, hNTSelBm, hSBm, hSSelBm, hIBm, hISelBm;
  CHAR	        	Buffer[300];
  DRAWITEMSTRUCT FAR    *lpdis;
  LPMEASUREITEMSTRUCT 	lpmis;
  BOOL                	Selected = FALSE;
  Inst			theInst;

  NotifyCode = HIWORD (wParam);
  wId        = LOWORD (wParam);

  switch (msg) {

    case WM_INITDIALOG:
      CenterDialogInParent(hDlg);
      SetDialogFont (hDlg, hDialogFont);
      tyconList = addTyconsMatching((String)0, NIL);

      /* Clear the redraw flag */
      SendDlgItemMessage(hDlg, LB_TYCONS ,WM_SETREDRAW, FALSE, 0L);

      for (tycons=tyconList; nonNull(tycons); tycons=tl(tycons)) {
	if (nonNull(tycons)) {
	  tc = hd(tycons);
	  fprintf(stdstr, "%s   -- in %s\n",textToStr(tycon(tc).text),textToStr(module(tycon(tc).mod).text));
	  SendDlgItemMessage(hDlg, LB_TYCONS ,LB_ADDSTRING, 0, (LONG)(LPSTR) stdstrbuff);
	  SendDlgItemMessage(hDlg, LB_TYCONS, LB_SETCURSEL, 0, 0L);
	}
      /* Set the redraw flag and force repaint. */
      SendDlgItemMessage(hDlg, LB_TYCONS ,WM_SETREDRAW, TRUE, 0L);
      InvalidateRect(GetDlgItem(hDlg, LB_TYCONS), NULL, TRUE);
      }

      theTycon = 0;
      SetTycon(hDlg, theTycon, tyconList);

      hTCBm = LoadBitmap (hThisInstance, "TYPECONSBMP");
      MapBitmap (hTCBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hTCSelBm = LoadBitmap (hThisInstance, "TYPECONSBMP");
      MapBitmap (hTCSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hDBm = LoadBitmap (hThisInstance, "DATACONSBMP");
      MapBitmap (hDBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hDSelBm = LoadBitmap (hThisInstance, "DATACONSBMP");
      MapBitmap (hDSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hTSBm = LoadBitmap (hThisInstance, "TYPESINBMP");
      MapBitmap (hTSBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hTSSelBm = LoadBitmap (hThisInstance, "TYPESINBMP");
      MapBitmap (hTSSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hNTBm = LoadBitmap (hThisInstance, "NEWTYPEBMP");
      MapBitmap (hNTBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hNTSelBm = LoadBitmap (hThisInstance, "NEWTYPEBMP");
      MapBitmap (hNTSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hSBm = LoadBitmap (hThisInstance, "SELECTORBMP");
      MapBitmap (hSBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hSSelBm = LoadBitmap (hThisInstance, "SELECTORBMP");
      MapBitmap (hSSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hIBm = LoadBitmap (hThisInstance, "INSTANCEBMP");
      MapBitmap (hIBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hISelBm = LoadBitmap (hThisInstance, "INSTANCEBMP");
      MapBitmap (hISelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));

      /* set focus to search box (must return FALSE) */
      SetFocus (GetDlgItem(hDlg, IDC_SEARCHTYCON));
      return FALSE;

    case WM_DESTROY:
      DeleteObject(hTCBm);
      DeleteObject(hTCSelBm);
      DeleteObject(hDBm);
      DeleteObject(hDSelBm);
      DeleteObject(hTSBm);
      DeleteObject(hTSSelBm);
      DeleteObject(hNTBm);
      DeleteObject(hNTSelBm);
      DeleteObject(hSBm);
      DeleteObject(hSSelBm);
      DeleteObject(hIBm);
      DeleteObject(hISelBm);

      break;

    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
      break;


    case WM_MEASUREITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_TYCONS ||
	  lpdis->CtlID == LB_CONS   ||
	  lpdis->CtlID == LB_TYCONSINST) {

	lpmis = (LPMEASUREITEMSTRUCT) lParam;

	/* Set the height of the list box items to Bitmap height */
	hBmp = LoadBitmap(hThisInstance, "CLASSBMP");
	GetObject(hBmp, sizeof(BITMAP), &bm);
	DeleteObject(hBmp);

	lpmis->itemHeight = bm.bmHeight+1;

	return TRUE;
      }
      break;

    case WM_DRAWITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_TYCONS ||
	  lpdis->CtlID == LB_CONS   ||
	  lpdis->CtlID == LB_TYCONSINST) {

	if (lpdis->itemID == (UINT)-1) {
	  return TRUE;
	}

	switch (lpdis->itemAction) {
	  case ODA_DRAWENTIRE:
	  case ODA_SELECT:
	  case ODA_FOCUS:
	    if ((lpdis->itemState & ODS_SELECTED) /*&& (lpdis->itemState & ODS_FOCUS)*/) {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
	      Selected = TRUE;
	    }
	    else {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
	    }
	    break;

	  default:
	    return FALSE;
	}

	SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETTEXT, lpdis->itemID, (LPARAM) Buffer);

	ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), Buffer, strlen(Buffer), NULL);

	switch (lpdis->CtlID) {
	  case LB_TYCONS:   theTycon = (UINT) lpdis->itemID;
			    tc = nth(theTycon,tyconList);

			    switch(tycon(tc).what) {
			      case RESTRICTSYN:
			      case SYNONYM:     hBmp = Selected ? hTSSelBm : hTSBm;
					        break;
			      case DATATYPE:    hBmp = Selected ? hTCSelBm : hTCBm;
					        break;
			      case NEWTYPE:     hBmp = Selected ? hNTSelBm : hNTBm;
					        break;
			    }
			    break;

	  case LB_CONS:	    if (lpdis->itemID>=(UINT)numCfuns)
				hBmp = Selected ? hSSelBm : hSBm;
			    else
				hBmp = Selected ? hDSelBm : hDBm;
			    break;
          case LB_TYCONSINST:
			    theInst = (Inst) SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETITEMDATA, lpdis->itemID, 0);
                 	    if (nonNull(inst(theInst).specifics)) {
                        	printContext(stdstr,inst(theInst).specifics);
                        	fprintf(stdstr," => ");
                            }
       			    printPred(stdstr,inst(theInst).head);
			    fprintf  (stdstr, "   -- in %s \n", textToStr(module(moduleOfScript(scriptThisInst(theInst))).text));
			    ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), stdstrbuff, strlen(stdstrbuff), NULL);
			    
			    hBmp = Selected ? hISelBm : hIBm;
			    break;
	}

	DrawBitmap (lpdis->hDC, hBmp, (lpdis->rcItem.left)+4, lpdis->rcItem.top);

	/* If selected draw rectangle */
	if ((lpdis->itemState & ODS_SELECTED)&&(lpdis->itemState & ODS_FOCUS)) {
	  DrawFocusRect(lpdis->hDC, &(lpdis->rcItem));
	}

	return TRUE;
      }

    case WM_PAINT: {
      HDC 	   hDC;
      PAINTSTRUCT  Ps;

      BeginPaint(hDlg, &Ps);
      hDC = Ps.hdc;

      /* Paint classes Bitmap */
      GetWindowRect(hDlg, &DlgRect);
      GetWindowRect(GetDlgItem(hDlg, ID_PLACEBITMAP), &aRect);

      hBitmap = LoadMappedBitmap(hThisInstance, "TYCONSDLGBMP");
      DrawBitmap(hDC, hBitmap,
		 aRect.left-DlgRect.left-GetSystemMetrics(SM_CXDLGFRAME),
		 aRect.top-DlgRect.top-GetSystemMetrics(SM_CYDLGFRAME)-GetSystemMetrics(SM_CYCAPTION));

      DeleteObject(hBitmap);
      EndPaint(hDlg, &Ps);
    }
    break;

    case WM_COMMAND:
      switch (LOWORD(wId)) {
	case LB_TYCONS:
	  switch(NotifyCode) {
	    case LBN_SELCHANGE: {
	      /* A new tycon was selected */
	      theTycon = (UINT) SendDlgItemMessage(hDlg, LB_TYCONS ,LB_GETCURSEL, 0, 0L);
	      SetTycon(hDlg, theTycon, tyconList);
	    }
	    break;

	    case LBN_DBLCLK: {
	      /* Open in text editor script file with instance definition */
	      INT    TheTycon;
	      Tycon  tc;

	      /* Get selected tycon */
	      TheTycon = (UINT) SendDlgItemMessage(hDlg, LB_TYCONS ,LB_GETCURSEL, 0, 0L);
	      tc = nth(TheTycon,tyconList);

	      if (isTycon(tc) && tycon(tc).line) {
 	        setLastEdit(getScriptName(scriptThisTycon(tc)), tycon(tc).line);
	        runEditor();
	      }
	      else {
		MessageBox(hDlg, "Primitive type:\nNo definition available.", appName, MB_ICONINFORMATION | MB_OK);
	      }
	    }
	    break;
	}
	break;

	case LB_TYCONSINST:
	  switch(NotifyCode) {
	    case LBN_DBLCLK: {
	      Inst  currInst;

	      currInst = (Inst) SendDlgItemMessage(hDlg, LB_TYCONSINST, LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_TYCONSINST ,LB_GETCURSEL, 0, 0L), 0L);

	      /* Find instance module */
	      setLastEdit(getScriptName(scriptThisInst(currInst)), inst(currInst).line);
	      runEditor();
	    }
	    break;
	}
	break;


	case IDC_SEARCHTYCON:  /* Search a name */
	  switch(HIBYTE(wId)) {
	    case HIBYTE(EN_CHANGE): {
	      CHAR    Buffer[300];

	      /* Get edit control contents */
	      SendDlgItemMessage(hDlg, IDC_SEARCHTYCON, WM_GETTEXT, 300, (LPARAM) ((LPSTR) Buffer));

	      /* Search in names list box */
	      SendDlgItemMessage(hDlg, LB_TYCONS, LB_SELECTSTRING, 0, (LPARAM) ((LPSTR) Buffer));

	      /* Update window contents */
	      DlgSendMessage(hDlg, WM_COMMAND, LB_TYCONS, MAKELONG(0, LBN_SELCHANGE));
	    }
	    break;
	  }
	  break;

	case LB_CONS:
	  switch(NotifyCode) {
	    case LBN_DBLCLK: {

	      /* Open in text editor script file with constructor definition */
	      DlgSendMessage(hDlg, WM_COMMAND, ID_EDITTYCON, 0L);
	      break;
	    }
	  }
	  break;


	case ID_EDITTYCON: /* Pushed on Edit tycon button */
	  if (SendDlgItemMessage(hDlg, LB_TYCONS, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_TYCONS, MAKELONG(0, LBN_DBLCLK));
	    break;


        case ID_EDITTYCONSINST:
	  if (SendDlgItemMessage(hDlg, LB_TYCONSINST, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_TYCONSINST, MAKELONG(0, LBN_DBLCLK));
	    break;

	case IDCANCEL:  /* Close dialog */
	case IDOK:
	  EndDialog(hDlg, TRUE);
	  return TRUE;

	default:
	  return TRUE;
     }
  }
  return FALSE;
}
Esempio n. 10
0
/* Handles browse classes dialog box */
LRESULT CALLBACK BrowseClassesDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
  INT           	i;
  static Class 	     	currClass;
  Class	       	     	theClass;
  Inst	       	     	theInst;
  Name	       	     	theMember;
  WORD                	NotifyCode, wId;
  HBITMAP             	hBitmap;
  RECT                	aRect, DlgRect;
  HBITMAP             	hBmp;
  BITMAP	      	bm;
  DRAWITEMSTRUCT FAR   *lpdis;
  LPMEASUREITEMSTRUCT 	lpmis;
  LPCOMPAREITEMSTRUCT 	lpcis;
  BOOL                	Selected = FALSE;
  static HBITMAP      	hCBm, hCSelBm, hIBm, hISelBm, hMBm, hMSelBm;
  String		string;
  CHAR			string1[256];

  NotifyCode = HIWORD (wParam);
  wId        = LOWORD (wParam);

  switch (msg) {
    case WM_INITDIALOG:
      CenterDialogInParent(hDlg);
      SetDialogFont (hDlg, hDialogFont);

      SendDlgItemMessage(hDlg, LB_CLASS,   LB_SETHORIZONTALEXTENT, (WPARAM)300, 0L);
      SendDlgItemMessage(hDlg, LB_MEMBERS, LB_SETHORIZONTALEXTENT, (WPARAM)400, 0L);

      /* Create list of classes and set current class */
      for(i=CLASSMIN; i<classMax(); i++) {
	SendDlgItemMessage(hDlg, LB_CLASS ,LB_ADDSTRING, 0, (LPARAM)(LPSTR) i);
      }
      SendDlgItemMessage(hDlg, LB_CLASS, LB_SETCURSEL, 0, 0L);
      currClass = (Class) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETITEMDATA, (WPARAM) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETCURSEL, 0, 0L), 0L);
      SetClass(hDlg, currClass);

      /* Create Bitmaps */
      hCBm = LoadBitmap (hThisInstance, "CLASSBMP");
      MapBitmap (hCBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hCSelBm = LoadBitmap (hThisInstance, "CLASSBMP");
      MapBitmap (hCSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hIBm = LoadBitmap (hThisInstance, "INSTANCEBMP");
      MapBitmap (hIBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hISelBm = LoadBitmap (hThisInstance, "INSTANCEBMP");
      MapBitmap (hISelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hMBm = LoadBitmap (hThisInstance, "MEMBERBMP");
      MapBitmap (hMBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hMSelBm = LoadBitmap (hThisInstance, "MEMBERBMP");
      MapBitmap (hMSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      return TRUE;

    case WM_DESTROY:
      /* Destroy Bitmaps */
      DeleteObject (hCBm);
      DeleteObject (hCSelBm);
      DeleteObject (hIBm);
      DeleteObject (hISelBm);
      DeleteObject (hMBm);
      DeleteObject (hMSelBm);
      break;

    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
      break;

    case WM_PAINT: {
      HDC 	   hDC;
      PAINTSTRUCT  Ps;

      BeginPaint(hDlg, &Ps);
      hDC = Ps.hdc;

      /* Paint classes Bitmap */
      GetWindowRect(hDlg, &DlgRect);
      GetWindowRect(GetDlgItem(hDlg, ID_PLACEBITMAP), &aRect);

      hBitmap = LoadMappedBitmap(hThisInstance, "CLASSESDLGBMP");
      DrawBitmap(hDC, hBitmap,
		 aRect.left-DlgRect.left-GetSystemMetrics(SM_CXDLGFRAME),
		 aRect.top-DlgRect.top-GetSystemMetrics(SM_CYDLGFRAME)-GetSystemMetrics(SM_CYCAPTION));
      DeleteObject(hBitmap);
      EndPaint(hDlg, &Ps);
    }
    break;

    case WM_COMPAREITEM: {

      lpcis = (COMPAREITEMSTRUCT FAR *) lParam;

      switch (wParam) {
	case LB_CLASS:	    return strcmp (textToStr(cclass(lpcis->itemData1).text),
					   textToStr(cclass(lpcis->itemData2).text));

	case LB_INSTANCES:  if (nonNull(inst(lpcis->itemData1).specifics)) {
                        	printContext(stdstr,inst(lpcis->itemData1).specifics);
                        	fprintf(stdstr," => ");
                            }
                            printPred(stdstr,inst(lpcis->itemData1).head);
			    fprintf(stdstr,"\n");
			    strcpy (string1, stdstrbuff);
			    if (nonNull(inst(lpcis->itemData2).specifics)) {
                        	printContext(stdstr,inst(lpcis->itemData2).specifics);
                        	fprintf(stdstr," => ");
                            }
			    printPred(stdstr,inst(lpcis->itemData2).head);
			    fprintf(stdstr,"\n");
			    return strcmp (string1, stdstrbuff);

	case LB_MEMBERS:    printExp (stdstr, lpcis->itemData1);
			    fprintf(stdstr,"\n");
			    strcpy (string1, stdstrbuff);
			    printExp (stdstr, lpcis->itemData2);
			    fprintf(stdstr,"\n");
			    return strcmp (string1, stdstrbuff);

	}
      }
      break;

    case WM_MEASUREITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_CLASS ||
	  lpdis->CtlID == LB_INSTANCES ||
	  lpdis->CtlID == LB_MEMBERS ) {

	lpmis = (LPMEASUREITEMSTRUCT) lParam;

	/* Set the height of the list box items to Bitmap height */
	hBmp = LoadBitmap(hThisInstance, "CLASSBMP");
	GetObject(hBmp, sizeof(BITMAP), &bm);
	DeleteObject(hBmp);
	lpmis->itemHeight = bm.bmHeight+1;
	lpmis->itemWidth = 50000;

	return TRUE;
      }
      break;

    case WM_DRAWITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_CLASS ||
	  lpdis->CtlID == LB_INSTANCES ||
	  lpdis->CtlID == LB_MEMBERS ) {

	if (lpdis->itemID == (UINT)-1) {
	  return TRUE;
	}

	switch (lpdis->itemAction) {
	  case ODA_DRAWENTIRE:
	  case ODA_SELECT:
	  case ODA_FOCUS:
	    if ((lpdis->itemState & ODS_SELECTED) /*&& (lpdis->itemState & ODS_FOCUS)*/) {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
	      Selected = TRUE;
	    }
	    else {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
	    }
	    break;
	  default:
	    return FALSE;
	}

	switch (lpdis->CtlID) {
	  case LB_CLASS:     theClass = (Class) SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETITEMDATA, lpdis->itemID, 0);
			     printPred(stdstr,cclass(theClass).head);
			     fprintf (stdstr, "   -- in %s\n", textToStr(module(cclass(theClass).mod).text));
			     ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), stdstrbuff, strlen(stdstrbuff), NULL);
			     hBmp = Selected ? hCSelBm : hCBm;

			     break;

	  case LB_INSTANCES: theInst = (Inst) SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETITEMDATA, lpdis->itemID, 0);
                 	     if (nonNull(inst(theInst).specifics)) {
                        	printContext(stdstr,inst(theInst).specifics);
                        	fprintf(stdstr," => ");
                             }
      			     printPred(stdstr,inst(theInst).head);
			     fprintf  (stdstr, "   -- in %s \n", textToStr(module(moduleOfScript(scriptThisInst(theInst))).text));
			     ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), stdstrbuff, strlen(stdstrbuff), NULL);
			     hBmp = Selected ? hISelBm : hIBm;
			     break;


	  case LB_MEMBERS:   theMember = (Name) SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETITEMDATA, lpdis->itemID, 0);
			     printExp(stdstr,theMember);
			     fprintf(stdstr, " :: ");
			     printType(stdstr,name(theMember).type);
			     fprintf(stdstr,"\n");
			     ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), stdstrbuff, strlen(stdstrbuff), NULL);
			     hBmp = Selected ? hMSelBm : hMBm;
			     break;
	}
	DrawBitmap (lpdis->hDC, hBmp, (lpdis->rcItem.left)+4, lpdis->rcItem.top);

	/* If selected draw rectangle */
	if ((lpdis->itemState & ODS_SELECTED)&&(lpdis->itemState & ODS_FOCUS)) {
	  DrawFocusRect(lpdis->hDC, &(lpdis->rcItem));
	}

	return TRUE;
      }

    case WM_COMMAND:
      switch (wId) {
        case LB_CLASS:
	  switch(NotifyCode) {
	    case LBN_SELCHANGE: /* select a new class */
	      currClass = (Class) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETCURSEL, 0, 0L), 0L);
	      SetClass(hDlg, currClass);
	      break;

	    case LBN_DBLCLK: { /* Open in text editor script file with class definition */
	      currClass = (Class) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETCURSEL, 0, 0L), 0L);

	      currClass = (Class) SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_CLASS ,LB_GETCURSEL, 0, 0L), 0L);
	      setLastEdit(getScriptName(scriptThisClass(currClass)), cclass(currClass).line);
	      runEditor();
	      
	      
	    }
	    break;
	  }
	  break;

	case LB_MEMBERS:
	case LB_INSTANCES:
	  switch(NotifyCode) {/* Open in text editor script file with instance definition */
	    case LBN_DBLCLK: {
	      Inst  currInst;

	      currInst = (Inst) SendDlgItemMessage(hDlg, LB_INSTANCES, LB_GETITEMDATA, SendDlgItemMessage(hDlg, LB_INSTANCES ,LB_GETCURSEL, 0, 0L), 0L);

	      /* Find instance module */
	      setLastEdit(getScriptName(scriptThisInst(currInst)), inst(currInst).line);
	      runEditor();
	      
	    }
	    break;
	  }
	  break;

	case ID_HIERARCHY: /* Draw classes hierarchy */
	  DrawClassesHierarchy();
	  break;

	case ID_EDITCLASS: /* Pushed on Edit class button */
	  if (SendDlgItemMessage(hDlg, LB_CLASS, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_CLASS, MAKELONG(0, LBN_DBLCLK));
	  break;

	case ID_EDITINSTANCE: /* Pushed on Edit instance button */
	  if (SendDlgItemMessage(hDlg, LB_INSTANCES, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_INSTANCES, MAKELONG(0, LBN_DBLCLK));
	  break;

	case IDCANCEL: /* Close dialog */
	case IDOK:
	  EndDialog(hDlg, TRUE);
	  return TRUE;

	default:
	  return TRUE;
      }
  }
  return FALSE;
}
Esempio n. 11
0
/* Handles browse names dialog box */
LRESULT CALLBACK BrowseNamesDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
  static              List namesList = NIL;
  List                names=NIL;
  struct strName      nm;
  Name                n;
  UINT                theName;
  WORD                NotifyCode, wId;
  RECT                aRect, DlgRect;
  HBITMAP             hBitmap;
  HBITMAP             hBmp;
  BITMAP	      bm;
  static HBITMAP      hPBm, hPSelBm, hDBm, hDSelBm, hMBm, hMSelBm, hNBm, hNSelBm,
		      hSBm, hSSelBm;
  CHAR	              Buffer[300];
  DRAWITEMSTRUCT FAR *lpdis;
  LPMEASUREITEMSTRUCT lpmis;
  BOOL                Selected = FALSE;

  NotifyCode = HIWORD (wParam);
  wId        = LOWORD (wParam);

  switch (msg) {

    case WM_INITDIALOG:
      CenterDialogInParent(hDlg);
      SetDialogFont (hDlg, hDialogFont);
      namesList = addNamesMatching((String)0, NIL);

      /* Clear the redraw flag */
      SendDlgItemMessage(hDlg, LB_NAMES ,WM_SETREDRAW, FALSE, 0L);

      for (names=namesList; nonNull(names); names=tl(names)) {
	if (nonNull(names)) {
	  nm = name(hd(names));
	  fprintf(stdstr, "%s   -- in %s\n",textToStr(nm.text),textToStr(module(nm.mod).text));
	  SendDlgItemMessage(hDlg, LB_NAMES ,LB_ADDSTRING, 0, (LONG)(LPSTR) stdstrbuff);
	  SendDlgItemMessage(hDlg, LB_NAMES, LB_SETCURSEL, 0, 0L);
	}
      }

      /* Set the redraw flag and force repaint. */
      SendDlgItemMessage(hDlg, LB_NAMES ,WM_SETREDRAW, TRUE, 0L);
      InvalidateRect(GetDlgItem(hDlg, LB_NAMES), NULL, TRUE);

      theName = 0;
      SetName(hDlg, theName, namesList);

      hPBm = LoadBitmap (hThisInstance, "PRIMBMP");
      MapBitmap (hPBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hPSelBm = LoadBitmap (hThisInstance, "PRIMBMP");
      MapBitmap (hPSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hDBm = LoadBitmap (hThisInstance, "DATACONSBMP");
      MapBitmap (hDBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hDSelBm = LoadBitmap (hThisInstance, "DATACONSBMP");
      MapBitmap (hDSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hMBm = LoadBitmap (hThisInstance, "MEMBERBMP");
      MapBitmap (hMBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hMSelBm = LoadBitmap (hThisInstance, "MEMBERBMP");
      MapBitmap (hMSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hNBm = LoadBitmap (hThisInstance, "NAMEBMP");
      MapBitmap (hNBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hNSelBm = LoadBitmap (hThisInstance, "NAMEBMP");
      MapBitmap (hNSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));
      hSBm = LoadBitmap (hThisInstance, "SELECTORBMP");
      MapBitmap (hSBm, RGB(0,128,128), GetSysColor(COLOR_WINDOW));
      hSSelBm = LoadBitmap (hThisInstance, "SELECTORBMP");
      MapBitmap (hSSelBm, RGB(0,128,128), GetSysColor(COLOR_HIGHLIGHT));

      /* set focus to search box (must return FALSE) */
      SetFocus (GetDlgItem(hDlg, IDC_SEARCHNAME));
      return FALSE;

    case WM_DESTROY:
      DeleteObject(hPBm);
      DeleteObject(hPSelBm);
      DeleteObject(hDBm);
      DeleteObject(hDSelBm);
      DeleteObject(hMBm);
      DeleteObject(hMSelBm);
      DeleteObject(hNBm);
      DeleteObject(hNSelBm);
      DeleteObject(hSBm);
      DeleteObject(hSSelBm);
      break;

    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORMSGBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
      break;

    case WM_MEASUREITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_NAMES) {

	lpmis = (LPMEASUREITEMSTRUCT) lParam;

	/* Set the height of the list box items to Bitmap height */
	hBmp = LoadBitmap(hThisInstance, "PRIMBMP");
	GetObject(hBmp, sizeof(BITMAP), &bm);
	DeleteObject(hBmp);

	lpmis->itemHeight = bm.bmHeight+1;

	return TRUE;
      }
      break;

    case WM_DRAWITEM:

      lpdis = (DRAWITEMSTRUCT FAR *) lParam;

      if (lpdis->CtlID == LB_NAMES) {

	if (lpdis->itemID == (UINT)-1) {
	  return TRUE;
	}

	switch (lpdis->itemAction) {
	  case ODA_DRAWENTIRE:
	  case ODA_SELECT:
	  case ODA_FOCUS:
	    if ((lpdis->itemState & ODS_SELECTED) /*&& (lpdis->itemState & ODS_FOCUS)*/) {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
	      Selected = TRUE;
	    }
	    else {
	      SetBkColor(lpdis->hDC, GetSysColor(COLOR_WINDOW));
	      SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
	    }
	    break;

	  default:
	    return FALSE;
	}

	SendDlgItemMessage(hDlg, lpdis->CtlID, LB_GETTEXT, lpdis->itemID, (LPARAM) Buffer);
	ExtTextOut(lpdis->hDC, lpdis->rcItem.left+21, lpdis->rcItem.top, ETO_OPAQUE, &(lpdis->rcItem), Buffer, strlen(Buffer), NULL);

	n = nth(lpdis->itemID, namesList);

	if (isCfun(n)) 
	  hBmp = Selected ? hDSelBm : hDBm;
	else if (isMfun(n)) 
	  hBmp = Selected ? hMSelBm : hMBm;
	else if (isSfun(n)) 
	  hBmp = Selected ? hSSelBm : hSBm;
	else if (name(n).primDef) 
	  hBmp = Selected ? hPSelBm : hPBm;
	else 
	  hBmp = Selected ? hNSelBm : hNBm;
        
	DrawBitmap (lpdis->hDC, hBmp, (lpdis->rcItem.left)+4, lpdis->rcItem.top);
	/* If selected draw rectangle */
	if ((lpdis->itemState & ODS_SELECTED)&&(lpdis->itemState & ODS_FOCUS)) {
	  DrawFocusRect(lpdis->hDC, &(lpdis->rcItem));
	}

	return TRUE;
      }

    case WM_PAINT: {
      HDC 	   hDC;
      PAINTSTRUCT  Ps;

      BeginPaint(hDlg, &Ps);
      hDC = Ps.hdc;

      /* Paint classes Bitmap */
      GetWindowRect(hDlg, &DlgRect);
      GetWindowRect(GetDlgItem(hDlg, ID_PLACEBITMAP), &aRect);

      hBitmap = LoadMappedBitmap(hThisInstance, "NAMESDLGBMP");
      DrawBitmap(hDC, hBitmap,
		 aRect.left-DlgRect.left-GetSystemMetrics(SM_CXDLGFRAME),
		 aRect.top-DlgRect.top-GetSystemMetrics(SM_CYDLGFRAME)-GetSystemMetrics(SM_CYCAPTION));
      DeleteObject(hBitmap);
      EndPaint(hDlg, &Ps);
    }
    break;


    case WM_COMMAND:
      switch (wId) {
	case LB_NAMES:
	  switch(NotifyCode) {
	    case LBN_SELCHANGE:
	      /* Select a new name */
	      theName = (UINT) SendDlgItemMessage(hDlg, LB_NAMES ,LB_GETCURSEL, 0, 0L);
	      SetName(hDlg, theName, namesList);
	      break;

	    case LBN_DBLCLK: {
	      /* Open in text editor script file with name definition */
	      Name n;

	      /* Get the selected name */
	      theName = (UINT) SendDlgItemMessage(hDlg, LB_NAMES ,LB_GETCURSEL, 0, 0L);
	      n = nth(theName, namesList);      

	      if (!name(n).primDef) {
		setLastEdit(getScriptName(scriptThisName(n)), name(n).line);
		runEditor();
	      }
	      else {
		MessageBox(hDlg, "Primitive function:\nNo definition available.", appName, MB_ICONINFORMATION | MB_OK);
	      }
	  }
	  break;
	}
	break;

	case IDC_SEARCHNAME:  /* Search a name */
	  switch(HIBYTE(NotifyCode)) {
	    case HIBYTE(EN_CHANGE): {
	      CHAR    Buffer[300];

	      /* Get edit control contents */
	      SendDlgItemMessage(hDlg, IDC_SEARCHNAME, WM_GETTEXT, 300, (LPARAM) ((LPSTR) Buffer));
	      /* Search in names list box */
	      SendDlgItemMessage(hDlg, LB_NAMES, LB_SELECTSTRING, 0, (LPARAM) ((LPSTR) Buffer));
	      /* Update window contents */
	      DlgSendMessage(hDlg, WM_COMMAND, LB_NAMES, MAKELONG(0, LBN_SELCHANGE));
	    }
	    break;
	  }
	  break;

	case ID_EDITNAME: /* Pushed on Edit name button */
	  if (SendDlgItemMessage(hDlg, LB_NAMES, LB_GETCURSEL, 0, 0L) != LB_ERR)
	    DlgSendMessage(hDlg, WM_COMMAND, LB_NAMES, MAKELONG(0, LBN_DBLCLK));
	    break;

	case IDCANCEL: /* Close dialog */
	case IDOK:
	  EndDialog(hDlg, TRUE);
	  return TRUE;

	default:
	  return TRUE;
      }
  }
  return FALSE;
}