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

📄 button.cpp

📁 做为linux下图形用户界面支持系统之一的MicroWindows采用C++设计
💻 CPP
字号:
//
// Micro Windows Implementation
// button.h
//
// $Revision: 1.3 $
// $Source: P:/MWINDOWS/LIB/rcs/button.cpp $
// $Date: 1993/11/27 09:53:32 $
//

// note: in Button class, the mouse handler function is
// inherited from Control class, which dispatches mouse messages
// to itself, not clientModel.

#include "button.h"
#include "global.h"
#include "model.h"

Button::Button (char *text, Rect *prect, View *pparent, Model *client,
                BOOL attach, BOOL killModel)
       :Control (prect, pparent, client, FALSE, killModel)
{
    buttonText = new Text (text, &clientRect);
    hitted = FALSE;

    if (attach && parent) parent->attachSubview (this);
}

Button::~Button ()
{
    delete buttonText;
}

void Button::selfDraw (Port *port, Rect *area)
{
    drawButton (port);
}

void Button::leftButtonDown (Point *pnt)
{
    if (hitted == TRUE) return;

    hitted = TRUE;
    drawButton (viewPort);
    mouse->lock (this);
}

void Button::leftButtonUp (Point *pnt)
{
    if (hitted == FALSE) return;

    hitted = FALSE;
    mouse->unlock ();
    drawButton (viewPort);

    if (clientRect.inside (pnt) == FALSE) return;
    clientModel->fromView (this);
}

void Button::drawButton (Port *port)
{
    port->setPenColor (PPC_Gray);
    port->draw (&FilledRectangle (&clientRect));
    port->setPenColor (PPC_Black);
    port->setBgColor (PPC_Gray);
    drawText (port);

    StereoType t = Convex;
    if (hitted == TRUE) t = Concave;

    port->draw (&StereoBorder (&clientRect, t, 1));
}

void Button::drawText (Port *port)
{
    port->draw (buttonText);
}

⌨️ 快捷键说明

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