Skip to content
This repository has been archived by the owner on Feb 13, 2021. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
calvincestari committed May 22, 2011
0 parents commit 5d27f36
Show file tree
Hide file tree
Showing 247 changed files with 52,635 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.DS_Store

*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.lib
*.sbr
*.scc
[Bb]in
[Dd]ebug*/
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
[Bb]uild[Ll]og.*
*.[Pp]ublish.xml
BuildProcessTemplates/*
Published/*
[Tt]humbs.db
[Uu]pgradeLog*.[Xx][Mm][Ll]
_[Uu]pgradeReport_Files*/
*.build.csdef
[Pp]ackage/*
ASPNETDB.MDF
aspnetdb_log.ldf
146 changes: 146 additions & 0 deletions AW_CMultiViewSplitter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// AW_CMultiViewSplitter.cpp: implementation of the AW_CMultiViewSplitter class.
//
// Written by Caroline Englebienne of AniWorld, Inc.
// Copyright (c) 2000 AniWorld, Inc.
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "AW_CMultiViewSplitter.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

AW_CMultiViewSplitter::AW_CMultiViewSplitter()
{
m_nIDCounter = 1;
}

AW_CMultiViewSplitter::~AW_CMultiViewSplitter()
{

}

int AW_CMultiViewSplitter::AddView(int nRow, int nCol, CRuntimeClass * pViewClass,
CCreateContext* pContext)
{
// hide the current view of the pane
int PreviousID = HideCurrentView(nRow, nCol);

// create the new view, if fail, set the previous view current
if (CreateView(nRow, nCol, pViewClass, CSize(10,10), pContext) == 0)
{
if (PreviousID != -1)
SetCurrentView(nRow, nCol, PreviousID);
return -1;
}

// get and store the new view
int NewViewID = m_nIDCounter;
CWnd* pNewWnd = GetPane(nRow, nCol);
CPoint pane(nRow, nCol);
long paneID = MAKELONG(pane.x,pane.y);
m_mapViewPane.insert(map<int, long>::value_type(NewViewID,paneID));
m_mapIDViews.insert(map<int, CWnd*>::value_type(NewViewID, pNewWnd));

// set the new view current
SetCurrentView(nRow, nCol, NewViewID);

RedrawWindow();
m_nIDCounter ++;
return NewViewID;
}

void AW_CMultiViewSplitter::ShowView(int nViewID)
{
if (GetView(nViewID) == NULL)
return;

// find the pane containing the view
CPoint pane;
GetPaneFromViewID(nViewID, &pane);

// switch views
HideCurrentView(pane.x, pane.y);
SetCurrentView(pane.x, pane.y, nViewID);

RecalcLayout();
}

CWnd* AW_CMultiViewSplitter::GetView(int nViewID)
{
map<int, CWnd*>::iterator itView;

itView = m_mapIDViews.find(nViewID);
if(itView==m_mapIDViews.end())
return NULL;
else
return (*itView).second;
}

CWnd* AW_CMultiViewSplitter::GetCurrentView(int nRow, int nCol, int * nCurID)
{
long paneID = MAKELONG(nRow,nCol);

map<long, int>::iterator itCur;
itCur = m_mapCurrentViews.find(paneID);
if (itCur == m_mapCurrentViews.end())
return NULL;
else
{
int PreviousID = (*itCur).second;
*nCurID = PreviousID;
return GetView(PreviousID);
}
}

void AW_CMultiViewSplitter::SetCurrentView(int nRow, int nCol, int nViewID)
{
long paneID = MAKELONG(nRow,nCol);

map<long, int>::iterator itCur;
itCur = m_mapCurrentViews.find(paneID);
if (itCur != m_mapCurrentViews.end())
(*itCur).second = nViewID;
else
m_mapCurrentViews.insert(map<long,int>::value_type(paneID,nViewID));

CWnd * pView = GetView(nViewID);
pView->SetDlgCtrlID(IdFromRowCol(nRow, nCol));
pView->ShowWindow(SW_SHOW);
}

int AW_CMultiViewSplitter::HideCurrentView(int nRow, int nCol)
{
int prevID;
CWnd * pCurView = GetCurrentView(nRow, nCol, &prevID);
if (pCurView == NULL)
return -1;
else
{
pCurView->SetDlgCtrlID(0);
pCurView->ShowWindow(SW_HIDE);
return prevID;
}
}

void AW_CMultiViewSplitter::GetPaneFromViewID(int nViewID, CPoint * pane)
{
map<int, long>::iterator itPane;
itPane = m_mapViewPane.find(nViewID);
if (itPane==m_mapViewPane.end())
{
pane = NULL;
return;
}
long paneID = (*itPane).second;
CPoint p(paneID);
pane->x = p.x;
pane->y = p.y;
}

43 changes: 43 additions & 0 deletions AW_CMultiViewSplitter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// AW_CMultiViewSplitter.h: interface for the AW_CMultiViewSplitter class.
//
// Written by Caroline Englebienne of AniWorld, Inc.
// Copyright (c) 2000 AniWorld, Inc.
/////////////////////////////////////////////////////////////////////////////


#if !defined(AFX_AW_CMULTIVIEWSPLITTER_H__464C08E9_8989_11D4_B4E3_005004D85AA1__INCLUDED_)
#define AFX_AW_CMULTIVIEWSPLITTER_H__464C08E9_8989_11D4_B4E3_005004D85AA1__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#pragma warning(disable:4786)
#include <map>
using namespace std;

class AW_CMultiViewSplitter : public CSplitterWnd
{

public:
AW_CMultiViewSplitter();
virtual ~AW_CMultiViewSplitter();
int AddView(int nRow, int nCol, CRuntimeClass * pViewClass,
CCreateContext* pContext);
void ShowView(int nViewID);
CWnd* GetView(int nViewID);

protected:
map<int, long> m_mapViewPane;
map<long, int> m_mapCurrentViews;
map<int, CWnd*> m_mapIDViews;

int m_nIDCounter;

CWnd* GetCurrentView(int nRow, int nCol, int * nCurID);
void SetCurrentView(int nRow, int nCol, int nViewID);
int HideCurrentView(int nRow, int nCol);
void GetPaneFromViewID(int nViewID, CPoint * pane);
};

#endif // !defined(AFX_AW_CMULTIVIEWSPLITTER_H__464C08E9_8989_11D4_B4E3_005004D85AA1__INCLUDED_)
122 changes: 122 additions & 0 deletions CellRange.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
// CellRange.h: interface for the CCellRange class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CELLRANGE_H__F86EF761_725A_11D1_ABBA_00A0243D1382__INCLUDED_)
#define AFX_CELLRANGE_H__F86EF761_725A_11D1_ABBA_00A0243D1382__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

// The code contained in this file is based on the original
// WorldCom Grid control written by Joe Willcoxson,
// mailto:[email protected]
// http://users.aol.com/chinajoe

class CCellID
{
// Attributes
public:
int row, col;

// Operations
public:
CCellID(int nRow = -1, int nCol = -1) : row(nRow), col(nCol) {}

int IsValid() const { return (row >= 0 && col >= 0); }
int operator==(const CCellID& rhs) { return (row == rhs.row && col == rhs.col); }
int operator!=(const CCellID& rhs) { return !operator==(rhs); }
};

class CCellRange
{
public:

CCellRange(int nMinRow = -1, int nMinCol = -1, int nMaxRow = -1, int nMaxCol = -1)
{
Set(nMinRow, nMinCol, nMaxRow, nMaxCol);
}

void Set(int nMinRow = -1, int nMinCol = -1, int nMaxRow = -1, int nMaxCol = -1);

int IsValid() const;
int InRange(int row, int col) const;
int InRange(const CCellID& cellID) const;
int Count() { return (m_nMaxRow - m_nMinRow + 1) * (m_nMaxCol - m_nMinCol + 1); }

CCellID GetTopLeft() const;
CCellRange Intersect(const CCellRange& rhs) const;

int GetMinRow() const {return m_nMinRow;}
void SetMinRow(int minRow) {m_nMinRow = minRow;}

int GetMinCol() const {return m_nMinCol;}
void SetMinCol(int minCol) {m_nMinCol = minCol;}

int GetMaxRow() const {return m_nMaxRow;}
void SetMaxRow(int maxRow) {m_nMaxRow = maxRow;}

int GetMaxCol() const {return m_nMaxCol;}
void SetMaxCol(int maxCol) {m_nMaxCol = maxCol;}

int GetRowSpan() const {return m_nMaxRow - m_nMinRow + 1;}
int GetColSpan() const {return m_nMaxCol - m_nMinCol + 1;}

int operator==(const CCellRange& rhs);
int operator!=(const CCellRange& rhs);

protected:
int m_nMinRow;
int m_nMinCol;
int m_nMaxRow;
int m_nMaxCol;
};

inline void CCellRange::Set(int minRow, int minCol, int maxRow, int maxCol)
{
m_nMinRow = minRow;
m_nMinCol = minCol;
m_nMaxRow = maxRow;
m_nMaxCol = maxCol;
}

inline int CCellRange::operator==(const CCellRange& rhs)
{
return ((m_nMinRow == rhs.m_nMinRow) && (m_nMinCol == rhs.m_nMinCol) &&
(m_nMaxRow == rhs.m_nMaxRow) && (m_nMaxCol == rhs.m_nMaxCol));
}

inline int CCellRange::operator!=(const CCellRange& rhs)
{
return !operator==(rhs);
}

inline int CCellRange::IsValid() const
{
return (m_nMinRow >= 0 && m_nMinCol >= 0 && m_nMaxRow >= 0 && m_nMaxCol >= 0 &&
m_nMinRow <= m_nMaxRow && m_nMinCol <= m_nMaxCol);
}

inline int CCellRange::InRange(int row, int col) const
{
return (row >= m_nMinRow && row <= m_nMaxRow && col >= m_nMinCol && col <= m_nMaxCol);
}

inline int CCellRange::InRange(const CCellID& cellID) const
{
return InRange(cellID.row, cellID.col);
}

inline CCellID CCellRange::GetTopLeft() const
{
return CCellID(m_nMinRow, m_nMinCol);
}

inline CCellRange CCellRange::Intersect(const CCellRange& rhs) const
{
return CCellRange(max(m_nMinRow,rhs.m_nMinRow), max(m_nMinCol,rhs.m_nMinCol),
min(m_nMaxRow,rhs.m_nMaxRow), min(m_nMaxCol,rhs.m_nMaxCol));
}

#endif // !defined(AFX_CELLRANGE_H__F86EF761_725A_11D1_ABBA_00A0243D1382__INCLUDED_)
Loading

0 comments on commit 5d27f36

Please sign in to comment.