home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HyperLib 1997 Winter - Disc 1
/
HYPERLIB-1997-Winter-CD1.ISO.7z
/
HYPERLIB-1997-Winter-CD1.ISO
/
オンラインウェア
/
PRG
/
ListPrint.sit
/
ListPrint
/
WindowSet.c
< prev
next >
Wrap
Text File
|
1995-02-10
|
13KB
|
515 lines
//******************************************************************************
//* *
//* Macintosh プログラム作成の勉強 *
//* This Program is lesson for Macintohs. *
//* *
//* 1994/ 4/26 By SAGAWA KAZUYOSHI *
//* 1994/ 9/20 By SAGAWA KAZUYOSHI *
//* *
//******************************************************************************
#include "Constants.h"
#include "ListPrint.h"
//**************************************************************************
//*
//* 本モジュールの中だけで使用されている関数プロトタイプ宣言
//*
//**************************************************************************
//#########################################################################
//#
//# FUC イベント実行の関数群
//#
//# IN 無し
//# OT 無し
//# EX 無し
//#
//##########################################################################
/**************************************************************************
*
* FUC ウィンドウ破棄
*
* IN ウィンドウポインター
* OT 無し
* EX 無し
*
*************************************************************************/
void TrashWindow(WindowPtr TargetWindow)
{
DisposeWindow(TargetWindow);
}
//extern TBHandle TextInputDialog();
/**************************************************************************
*
* FUC アクションイベント
*
* IN 無し
* OT 無し
* EX 無し
*
*************************************************************************/
void DoAction(void)
{
// SysBeep(0);
}
/**************************************************************************
*
* FUC タブ値入力
*
* IN 入力文字
* OT 無し
* EX TEHtab tabsItemNow
*
*************************************************************************/
void DoTab(char theChar)
{
CharsHandle hText;
short len, maxLen;
Point LocalMouse;
char *p;
static short pw[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};/* 10のべき乗TBL */
if ( theChar == 0x08 || theChar == 0x1c || theChar == 0x1d ||
(theChar >= '0' && theChar <= '9') ) /* delet ← → */
{
TEKey(theChar, TEHtab);
hText = TEGetText(TEHtab);
tabsItemNow = 0;
p = (char *)*hText + (*TEHtab)->teLength-1;
for (len = maxLen = (**TEHtab).teLength-1; len >= 0; len--) {
if (maxLen > 3) break; /* Guard */
tabsItemNow += (int)( *p & 0x0f ) * pw[maxLen-len];
p--;
}
if (tabsItemNow > 32) {
tabsItemNow = 32; /* Guard */
TESetText("32", 2, TEHtab);
TEUpdate(&viewRect, TEHtab);
}
}
else {
SysBeep(0);
}
}
/**************************************************************************
*
* FUC スクロールリスト
*
* IN 入力文字
* OT 無し
* EX listData.hList
*
*************************************************************************/
void DoScrollList(char theChar)
{
EventRecord event; /* Dummy Event */
CharsHandle hText;
short len;
Rect box;
Point LocalMouse;
if ( theChar == 0x1e ) { /* ↑ */
LocalMouse.h = (*listData.hList)->rView.right + 10;
LocalMouse.v = (*listData.hList)->rView.top + 10;
event.what = mouseDown;
// event.where.h = inContent;
event.modifiers = 0;
LClick(LocalMouse, event.modifiers, listData.hList);
}
else if ( theChar == 0x1f ) { /* ↓ */
LocalMouse.h = (*listData.hList)->rView.right + 10;
LocalMouse.v = (*listData.hList)->rView.bottom - 10;
event.what = mouseDown;
// event.where = inContent;
event.modifiers = 0;
LClick(LocalMouse, event.modifiers, listData.hList);
}
// //@@@@@ScrollListをカーソルキーで動かしたい@@@@@
// if ( ((*listData.hList)->lastClick.v >= 0) &&
// ((*listData.hList)->lastClick.v <= listData.CellNum) )
// {
// LocalMouse.h = (*listData.hList)->rView.left;
// LocalMouse.v = (*listData.hList)->rView.top;
// len = (*listData.hList)->lastClick.v * 32;
// LocalMouse.v += len;
// LClick(LocalMouse, event.modifiers, listData.hList);
// (*listData.hList)->lastClick.v++;
// }
// theCell = LLastClick(lP->hList);
// if ( (theCell.v >= 0) && (theCell.v <= lP->CellNum) ) {
// LDelRow(1, theCell.v, lP->hList);
// if (lP->CellNum >= 0) lP->CellNum--;
// (*lP->hList)->lastClick.v = -1;
// (*lP->hList)->lastClick.h = -1;
// }
// LAutoScroll(listData.hList);
// LocalMouse.h = event.where.h, LocalMouse.v = event.where.v;
// GlobalToLocal(&LocalMouse);
// box = (*listData.hList)->rView, box.right += scrollBarWidth;
// if ( PtInRect(LocalMouse, &(*listData.hList)->rView) ) {
// LClick(LocalMouse, event.modifiers, listData.hList);
// DoButtonHilite();
// }
}
/**************************************************************************
*
* FUC コンテント
*
* IN ウィンドウポインター
* OT 無し
* EX 無し
*
*************************************************************************/
void DoContent(WindowPtr TargetWindow)
{
int i;
int cntlCode;
ControlHandle theControl;
Point LocalMouse;
Rect box;
if(TargetWindow != FrontWindow()) SelectWindow(TargetWindow);
else {
LocalMouse.h = event.where.h;
LocalMouse.v = event.where.v;
GlobalToLocal(&LocalMouse);
if ( (cntlCode = FindControl(LocalMouse, TargetWindow, &theControl)) ) {
switch (cntlCode) {
case 1: /* PopUpMenu */
DoContentPopUpMenu(theControl);
break;
case inCheckBox:
DoContentCheckBox(theControl);
break;
case inButton:
DoContentButton(theControl);
break;
default:
box = (*listData.hList)->rView;
box.right += scrollBarWidth;
if ( PtInRect(LocalMouse, &box) ) {
i = LClick(LocalMouse, event.modifiers, listData.hList);
DoButtonHilite();
}
break;
}
}
else {
box = (*listData.hList)->rView;
box.right += scrollBarWidth;
if ( PtInRect(LocalMouse, &box) ) {
i = LClick(LocalMouse, event.modifiers, listData.hList);
DoButtonHilite();
}
TEDeactivate(TEHtab);
if ( PtInRect(LocalMouse, &(*TEHtab)->viewRect) ) {
TEActivate(TEHtab);
TEClick(LocalMouse, event.modifiers, TEHtab);
}
DoContentColorIconButton();
}
}
}
/**************************************************************************
*
* FUC ポップアップメニュー
*
* IN コントロールハンドル
* OT 無し
* EX 無し
*
*************************************************************************/
void DoContentPopUpMenu(ControlHandle theControl)
{
int on;
Point mouseLoc, Global;
long ItemID = false;
GetMouse(&mouseLoc);
on = PtInRect(mouseLoc, &(**hControl[fontCntlNumber]).contrlRect);
if ( on ) {
Global.v = (**hControl[fontCntlNumber]).contrlRect.top;
Global.h = (**hControl[fontCntlNumber]).contrlRect.left;
LocalToGlobal(&Global);
ItemID = PopUpMenuSelect(GetMHandle(fontMenuID), Global.v, Global.h, fontItemNow);
}
else {
on = PtInRect(mouseLoc, &(**hControl[sizeCntlNumber]).contrlRect);
if ( on ) {
Global.v = (**hControl[sizeCntlNumber]).contrlRect.top;
Global.h = (**hControl[sizeCntlNumber]).contrlRect.left;
LocalToGlobal(&Global);
ItemID = PopUpMenuSelect(GetMHandle(sizeMenuID),
Global.v, Global.h, sizeItemNow);
}
}
if (ItemID) {
DoMenu(ItemID);
SetCtlValue(theControl, ItemID); // PopUpMenu 表示変更
}
}
/**************************************************************************
*
* FUC チェックボックス
*
* IN コントロールハンドル
* OT 無し
* EX 無し
*
*************************************************************************/
void DoContentCheckBox(ControlHandle theControl)
{
int value, on, refCon;
Point mouseLoc;
TrackControl(theControl, event.where, (void*)-1); /* inButtonが返る */
GetMouse(&mouseLoc);
on = PtInRect(mouseLoc, &(**theControl).contrlRect);
if ( on ) {
value = GetCtlValue(theControl);
refCon = GetCRefCon(theControl); /* コントロールID値を入れておく*/
if (refCon == lineNumCntlID) {
value ^= 1;
SetCtlValue(theControl, value); /* Max=1 Min=0 */
}
else if ( !value ) {
if (refCon == lineSpaceNormalCntlID) { /* 普通 */
SetCtlValue(hControl[lineSpaceNarrowCntlNumber], 0); /* OFF */
SetCtlValue(theControl, 1); /* ON */
}
else if (refCon == lineSpaceNarrowCntlID) { /* 狭く */
SetCtlValue(hControl[lineSpaceNormalCntlNumber], 0);
SetCtlValue(theControl, 1);
}
}
}
}
/**************************************************************************
*
* FUC ボタン
*
* IN コントロールハンドル
* OT 無し
* EX 無し
*
*************************************************************************/
void DoContentButton(ControlHandle theControl)
{
int Value, on;
Point mouseLoc;
TrackControl(theControl, event.where, (void*)-1); /* inButtonが返る */
GetMouse(&mouseLoc);
on = PtInRect(mouseLoc, &(**theControl).contrlRect);
if ( on ) {
Value = GetCtlValue(theControl);
if (Value == removeCntlID) {
if ( ScrollListDelCell(&listData) )
SelectFileDelete(listData.DelCell.v, &listData);
DoButtonHilite();
}
else if (Value == printCntlID) {
DoPrintCommand();
}
}
}
/**************************************************************************
*
* FUC カラーアイコンボタン
*
* IN コントロールハンドル
* OT 無し
* EX hColorIcon[]
*
* 1995/02/09 新規作成
*
*************************************************************************/
void DoContentColorIconButton(void)
{
int i, on, mouseOn, iconNum;
Point mouseLoc;
EventRecord event; /* Self Loop Event */
Boolean isEvent;
iconNum = 0;
GetMouse(&mouseLoc);
on = PtInRect(mouseLoc, &cIconData[iconNum].rect);
if ( !on ) {
on = PtInRect(mouseLoc, &cIconData[++iconNum].rect);
}
if ( on ) {
mouseOn = false;
while ( true ) {
isEvent = WaitNextEvent(everyEvent, &event, 2, 0);
SystemTask(); /* DAに一定時間を配分する */
if (event.what == mouseUp) {
break; /* 終了 */
}
GetMouse(&mouseLoc);
on = PtInRect(mouseLoc, &cIconData[iconNum].rect);
if ( on ) {
if ( !mouseOn ) {
PlotCIcon(&cIconData[iconNum].rect,
cIconData[iconNum].ciHandle[1]);
mouseOn = true;
}
}
else {
if ( mouseOn ) {
PlotCIcon(&cIconData[iconNum].rect,
cIconData[iconNum].ciHandle[0]);
mouseOn = false;
}
}
};
PlotCIcon(&cIconData[iconNum].rect, cIconData[iconNum].ciHandle[0]);
}
}
//TrackControl()は、コントロール以外の場合にはダメのようだ
// TrackControl((ControlHandle)hColorIcon[0], event.where, (void*)ColorIconButton);
// TrackControl((ControlHandle)hColorIcon[0], event.where, (void*)-1); バクダン
// TrackControl((ControlHandle)hColorIcon[0], 終了は出来る
// TrackControl(hControl[removeCntlID], 落ちる
// TrackControl((ControlHandle)0, 落ちる
/**************************************************************************
*
* FUC ドラッグ
*
* IN ウィンドウポインター
* OT 無し
* EX 無し
*
*************************************************************************/
void DoDrag(WindowPtr TargetWindow)
{
Rect DragArea;
if(TargetWindow != FrontWindow())
SelectWindow(TargetWindow);
else {
DragArea = screenBits.bounds;
InsetRect(&DragArea,4,4);
DragWindow(TargetWindow, event.where, &DragArea);
}
}
/**************************************************************************
*
* FUC グロウ
*
* IN ウィンドウポインター
* OT 無し
* EX 無し
*
*************************************************************************/
void DoGrow(WindowPtr TargetWindow)
{
long Growth;
Rect GrowArea;
if(TargetWindow != FrontWindow())
SelectWindow(TargetWindow);
else {
GrowArea = screenBits.bounds;
GrowArea.left += 40; GrowArea.top += 40;
Growth = GrowWindow(TargetWindow, event.where, &GrowArea);
if(Growth != 0) {
EraseRect (&TargetWindow->portRect);
SizeWindow (TargetWindow, LoWord(Growth), HiWord(Growth), true);
// DrawGrowIcon (TargetWindow); /* サイズボックス・スクロールバー枠描画 */
InvalRect (&TargetWindow->portRect); /* UpDate領域に追加 */
ValidGrowArea (&TargetWindow->portRect); /* UpDate領域から削除 */
// DrawControls (TargetWindow); /* コントロールを全て描く */
}
}
}
/**************************************************************************
*
* FUC
*
* IN ウィンドウポインター
* OT 無し
* EX 無し
*
*************************************************************************/
void DoGoAway(WindowPtr TargetWindow, Point Click)
{
if(TargetWindow != FrontWindow())
SelectWindow(TargetWindow);
else if(TrackGoAway(TargetWindow, Click)) ;
//// DoCloseCommand();
}
/**************************************************************************
*
* FUC ズーム
*
* IN ウィンドウポインター
* OT 無し
* EX 無し
*
*************************************************************************/
void DoZoom(WindowPtr TargetWindow, Point Click, int Part)
{
if(TargetWindow != FrontWindow())
SelectWindow(TargetWindow);
else if(TrackBox(TargetWindow, Click, Part))
ZoomWindow(TargetWindow, Part, false);
}
/**************************************************************************
*
* FUC
*
* IN 箱形
* OT 無し
* EX 無し
*
*************************************************************************/
void ValidGrowArea(Rect * pRect)
{
Rect vRect;
SetRect(&vRect, pRect->right-scrollBarWidth, pRect->top, pRect->right, pRect->bottom);
ValidRect(&vRect);
SetRect(&vRect, pRect->left, pRect->bottom-scrollBarWidth, pRect->right, pRect->bottom);
ValidRect(&vRect);
}