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

📄 static.c

📁 在ecos 下mingui 的移植开发
💻 C
字号:
// $Id: static.c,v 1.9 2000/11/23 06:26:38 ymwei Exp $//// static.c: the Static Control module.//// Copyright (C) 1999, 2000, Wei Yongming.// Current maitainer: Wei Yongming./***  This library is free software; you can redistribute it and/or**  modify it under the terms of the GNU Library General Public**  License as published by the Free Software Foundation; either**  version 2 of the License, or (at your option) any later version.****  This library is distributed in the hope that it will be useful,**  but WITHOUT ANY WARRANTY; without even the implied warranty of**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU**  Library General Public License for more details.****  You should have received a copy of the GNU Library General Public**  License along with this library; if not, write to the Free**  Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,**  MA 02111-1307, USA*//***  Alternatively, the contents of this file may be used under the terms **  of the Mozilla Public License (the "MPL License") in which case the**  provisions of the MPL License are applicable instead of those above.*/// Create date: 1999/5/22//// Modify records:////  Who             When        Where       For What                Status//-----------------------------------------------------------------------------//  WEI Yongming    1999/8/21   Tsinghua    Rearrangment            Finished//  WEI Yongming    1999/10/27  Tsinghua    SETTEXT bug             Finished//  WEI Yongming    1999/10/27  Tsinghua    SETTEXT bug             Finished//  WEI Yongming    2000/02/24  Tsinghua    Add MPL License         Finished//#include <stdio.h>#include <stdlib.h>#include <pthread.h>#include <semaphore.h>#include "common.h"#include "minigui.h"#include "gdi.h"#include "window.h"#include "control.h"#include "cliprect.h"#include "internals.h"#include "ctrlclass.h"#include "ctrlmisc.h"#include "static.h"#ifndef lintstatic char fileid[] = "$Id: static.c,v 1.9 2000/11/23 06:26:38 ymwei Exp $";#endifBOOL RegisterStaticControl (void){    WNDCLASS WndClass;    WndClass.spClassName = "static";    WndClass.dwStyle     = 0;    WndClass.hCursor     = GetSystemCursor (IDC_ARROW);    WndClass.iBkColor    = PIXEL_lightgray;    WndClass.WinProc     = StaticControlProc;    return AddNewControlClass (&WndClass) == ERR_OK;}void StaticControlCleanup (void){    // do nothing.    return;}int StaticControlProc (HWND hwnd, int message, WPARAM wParam, LPARAM lParam){    RECT        rcClient;    HDC         hdc;    HICON       hIcon;    const char* spCaption;    PCONTROL    pCtrl;    UINT        uFormat;    DWORD       dwStyle;                 pCtrl = Control (hwnd);                            switch (message) {        case MSG_CREATE:            return 0;                    case MSG_DESTROY:             break;        case STM_GETIMAGE:            return (int)(pCtrl->dwAddData);                 case STM_SETIMAGE:        {            int pOldValue;                        pOldValue  = (int)(pCtrl->dwAddData);            pCtrl->dwAddData = (DWORD)wParam;            InvalidateRect (hwnd, NULL, FALSE);            return pOldValue;        }                   case MSG_GETDLGCODE:            return DLGC_STATIC;        case MSG_GETFONT:            break;        case MSG_PAINT:            hdc = BeginPaint (hwnd);            GetClientRect (hwnd, &rcClient);            dwStyle = GetWindowStyle (hwnd);            switch (dwStyle & SS_TYPEMASK)            {                case SS_GRAYRECT:                    SetBrushColor (hdc, PIXEL_lightgray);                    FillBox(hdc, 0, 0, RECTW(rcClient), RECTH(rcClient));                 break;                                case SS_GRAYFRAME:                    Draw3DDownFrame (hdc,                             0, 0, rcClient.right, rcClient.bottom,                             PIXEL_darkgray);                break;                                case SS_BITMAP:                    FillBoxWithBitmap(hdc, 0, 0, 0, 0,                        (PBITMAP)(pCtrl->dwAddData));                break;                                case SS_ICON:                    hIcon = (HICON)(pCtrl->dwAddData);                    DrawIcon (hdc, 0, 0, 0, 0, hIcon);                break;                      case SS_SIMPLE:                    SetBrushColor (hdc, GetWindowBkColor (hwnd));                    FillBox (hdc, 0, 0, rcClient.right, rcClient.bottom);                            if (dwStyle & WS_DISABLED)                        SetTextColor (hdc, PIXEL_darkgray);                    else                        SetTextColor (hdc, PIXEL_black);                    SetBkColor (hdc, GetWindowBkColor (hwnd));                    spCaption = GetWindowCaption (hwnd);                    if (spCaption)                        TextOut (hdc, 0, 0, spCaption);                 break;                 case SS_LEFT:                case SS_CENTER:                case SS_RIGHT:                case SS_LEFTNOWORDWRAP:                    uFormat = DT_TOP;                    if ( (dwStyle & SS_TYPEMASK) == SS_LEFT)                        uFormat |= DT_LEFT | DT_WORDBREAK;                    else if ( (dwStyle & SS_TYPEMASK) == SS_CENTER)                        uFormat |= DT_CENTER | DT_WORDBREAK;                    else if ( (dwStyle & SS_TYPEMASK) == SS_RIGHT)                        uFormat |= DT_RIGHT | DT_WORDBREAK;                    else if ( (dwStyle & SS_TYPEMASK) == SS_LEFTNOWORDWRAP)                        uFormat |= DT_LEFT | DT_SINGLELINE | DT_EXPANDTABS;                                        if (dwStyle & WS_DISABLED)                        SetTextColor (hdc, PIXEL_darkgray);                    else                        SetTextColor (hdc, PIXEL_black);                    SetBkColor (hdc, GetWindowBkColor (hwnd));                    spCaption = GetWindowCaption (hwnd);                    if (dwStyle & SS_NOPREFIX)                        uFormat |= DT_NOPREFIX;                                            if (spCaption)                        DrawText (hdc, spCaption, -1, &rcClient, uFormat);                break;                case SS_GROUPBOX:                    Draw3DBorder (hdc,  rcClient.left,                                     rcClient.top + (GetSysCharHeight() >> 1),                                    rcClient.right,                                    rcClient.bottom);                                        if (dwStyle & WS_DISABLED)                        SetTextColor (hdc, PIXEL_darkgray);                    else                        SetTextColor (hdc, PIXEL_black);                    SetBkColor(hdc, GetWindowBkColor (GetParent (hwnd)));                    spCaption = GetWindowCaption (hwnd);                    if (spCaption)                        TextOut (hdc, GetSysCharWidth (), 2, spCaption);                break;            }            EndPaint (hwnd, hdc);            break;        case MSG_LBUTTONDBLCLK:            if (GetWindowStyle (hwnd) & SS_NOTIFY)                NotifyParent (hwnd, pCtrl->id, STN_DBLCLK);            break;        case MSG_LBUTTONDOWN:            if (GetWindowStyle (hwnd) & SS_NOTIFY)                NotifyParent (hwnd, pCtrl->id, STN_CLICKED);            break;        case MSG_NCLBUTTONDBLCLK:            break;        case MSG_NCLBUTTONDOWN:            break;        case MSG_HITTEST:            dwStyle = GetWindowStyle (hwnd);            if ((dwStyle & SS_TYPEMASK) == SS_GROUPBOX)                return HT_TRANSPARENT;            if (GetWindowStyle (hwnd) & SS_NOTIFY)                return HT_CLIENT;            else                return HT_OUT;        break;        case MSG_SETFONT:        break;        case MSG_SETTEXT:            SetWindowCaption (hwnd, (char*)lParam);            InvalidateRect (hwnd, NULL, TRUE);            break;                    default:            break;    }    return DefaultControlProc (hwnd, message, wParam, lParam);}#ifdef _DEBUG#endif

⌨️ 快捷键说明

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