⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 button.cpp

📁 计算器程序
💻 CPP
字号:
//****************************************************************
//This software may not be distributed further without permission from
// Sun Xueshi's Group
//      
//This software is distributed WITHOUT ANY WARRANTY. No claims are made
// as to its functionality or purpose.
// 
//Authors: 孙学诗
// Date: 12/4/03
// 
//****************************************************************

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "button.h"

using namespace std;

Button:: Button() {}

// Initialize -- load a button with two status down and up for this button object
void Button:: Initialize(SimpleWindow &CalcWindow, const string &UpFile, const string &DownFile, 
        const Position Posn) {
        //load down status button bitmap
        DownButton.SetWindow(CalcWindow);
	DownButton.SetPosition(Posn);
	DownButton.Load(DownFile);
	assert(DownButton.GetStatus() == BitMapOkay);
        //load down status button bitmap
	UpButton.SetWindow(CalcWindow);
	UpButton.SetPosition(Posn);
	UpButton.Load(UpFile);
	assert(UpButton.GetStatus() == BitMapOkay);
	SetStatus(Up);           //Set current button status Up
	Draw();
}

// SetStatus -- set the current button's status
void Button::SetStatus(const Status &s) {
	StatusShowing = s;
}


// GetStatus -- get the current button's status
Status Button::GetStatus() const {
	return StatusShowing;
}

// GetHeight -- get the height of the bitmap
float Button::GetHeight() const {
	return UpButton.GetHeight();
}

// GetWidth -- get the width of the bitmap
float Button::GetWidth() const {
	return UpButton.GetWidth();
}

// Flip -- flip the button and redraw it
void Button::Flip() {
	SetStatus(GetStatus() == Up ? Down : Up);
	Draw();
	return;
}

// IsInside -- determine if a mouse click falls in this object
bool Button::IsInside(const Position &p) const {
	return (UpButton.IsInside(p) || DownButton.IsInside(p));
}

// Draw -- draw the object to the window
void Button::Draw() {
	if (StatusShowing == Up)
		UpButton.Draw();
	else
		DownButton.Draw();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -