Click here to Skip to main content
15,896,118 members
Articles / Desktop Programming / MFC

A Java Language IDE

Rate me:
Please Sign up or sign in to vote.
4.33/5 (26 votes)
13 May 2004CPOL3 min read 80.7K   3.4K   41  
This is a partially implemented IDE for the Java platform.
///////////////////////////////////////////////////////////////////////////
//  File:    statbar.cpp
//  Version: 1.1.0.4
//  Updated: 19-Jul-1998
//
//  Copyright:  Ferdinand Prantl, portions by Stcherbatchenko Andrei
//  E-mail:     prantl@ff.cuni.cz
//
//  Status bar extension
//
//  You are free to use or modify this code to the following restrictions:
//  - Acknowledge me somewhere in your about box, simple "Parts of code by.."
//  will be enough. If you can't (or don't want to), contact me personally.
//  - LEAVE THIS HEADER INTACT
////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "editcmd.h"
#include "bgstatbar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define ID_INDICATOR_TIME               37904

CStatusBarEx::CStatusBarEx()
    :CBaseStatusBar(), m_strClockFormat (_T("%d.%m. %H:%M:%S"))
{
}

CStatusBarEx:: ~ CStatusBarEx()
{
}

BOOL CStatusBarEx::Create (CWnd * pParentWnd, DWORD dwStyle, UINT nID)
{
  BOOL bCreatedOK = CStatusBar::Create (pParentWnd, dwStyle, nID);
  return bCreatedOK;
}

BOOL CStatusBarEx::SetPaneFormattedText (int nIndex, BOOL bUpdate, 
										 LPCTSTR lpszFmt,...)
{
  TCHAR buffer[256];
  va_list argptr;
  va_start (argptr, lpszFmt);
  _vstprintf (buffer, lpszFmt, argptr);
  va_end (argptr);
  BOOL bResult = SetPaneText (nIndex, buffer, bUpdate);
  UpdateWindow ();
  return bResult;
}

BOOL CStatusBarEx::SetPaneFormattedText (int nIndex, BOOL bUpdate, UINT nId,...)
{
  CString str;
  if (str.LoadString (nId))
    {
      va_list argptr;
      va_start (argptr, nId);
      BOOL bResult = SetPaneFormattedText (nIndex, bUpdate, str, argptr);
      va_end (argptr);
      return bResult;
    }
  SetPaneText (nIndex, _T (""), bUpdate);
  return FALSE;
}

BOOL CStatusBarEx::SetPaneText (int nIndex, LPCTSTR lpszNewText,
								BOOL bUpdate /*= TRUE*/ )
{
  return CBaseStatusBar::SetPaneText (nIndex, lpszNewText, bUpdate);
}

BOOL CStatusBarEx::SetPaneText (int nIndex, UINT nId, BOOL bUpdate /*= TRUE*/ )
{
  CString str;
  if (str.LoadString (nId))
    return SetPaneText (nIndex, str, bUpdate);
  SetPaneText (nIndex, _T (""), bUpdate);
  return FALSE;
}

void CStatusBarEx::SetClockFormat (LPCTSTR strClockFormat)
{
  m_strClockFormat = strClockFormat;
}

IMPLEMENT_DYNCREATE(CStatusBarEx,CBaseStatusBar)

BEGIN_MESSAGE_MAP(CStatusBarEx,CBaseStatusBar)
//{{AFX_MSG_MAP(CStatusBarEx)
ON_WM_CREATE ()
ON_WM_DESTROY ()
ON_UPDATE_COMMAND_UI (ID_INDICATOR_TIME, OnUpdateIndicatorTime)
//}}AFX_MSG_MAP
END_MESSAGE_MAP ()

int CStatusBarEx::OnCreate (LPCREATESTRUCT lpCreateStruct)
{
  // make sure time gets updated every second, even when idle
  if (CBaseStatusBar::OnCreate (lpCreateStruct) == -1)
    return -1;
  SetFont (CFont::FromHandle ((HFONT) GetStockObject (DEFAULT_GUI_FONT)));
  SetTimer (ID_INDICATOR_TIME, 1000, NULL);
  return 0;
}

void CStatusBarEx::OnUpdateIndicatorTime (CCmdUI * pCmdUI)
{
  pCmdUI->Enable (true);
  pCmdUI->SetText (CTime::GetCurrentTime ().Format (m_strClockFormat));
}

void CStatusBarEx::OnDestroy ()
{
  KillTimer (ID_INDICATOR_TIME);
  CBaseStatusBar::OnDestroy ();
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
biography? I am not that old yet.

Comments and Discussions