Changeset 968 for trunk/src


Ignore:
Timestamp:
Sep 18, 1999, 2:21:26 PM (26 years ago)
Author:
cbratschi
Message:

bugs fixed, hotkey: first version

Location:
trunk/src/comctl32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/header.c

    r496 r968  
    1 /* $Id: header.c,v 1.8 1999-08-14 16:13:10 cbratschi Exp $ */
     1/* $Id: header.c,v 1.9 1999-09-18 12:21:25 cbratschi Exp $ */
    22/*
    33 *  Header control
     
    422422    INT  oldRop;
    423423
    424     GetClientRect (hwnd, &rect);
    425 
     424    GetClientRect (hwnd, &rect); //CB: Odin bug!!!
    426425    hOldPen = SelectObject (hdc, GetStockObject (BLACK_PEN));
    427426    oldRop = SetROP2 (hdc, R2_XORPEN);
    428427    MoveToEx (hdc, x, rect.top, NULL);
    429     LineTo (hdc, x, rect.bottom);
     428    LineTo (hdc, x, rect.bottom-1);
    430429    SetROP2 (hdc, oldRop);
    431430    SelectObject (hdc, hOldPen);
     
    13031302    HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem);
    13041303
    1305     if ((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK)) {
     1304    if ((dwStyle & HDS_BUTTONS) && (dwStyle & HDS_HOTTRACK))
     1305    {
     1306        INT newItem;
     1307
    13061308        if (flags & (HHT_ONHEADER | HHT_ONDIVIDER | HHT_ONDIVOPEN))
    1307             infoPtr->iHotItem = nItem;
     1309            newItem = nItem;
    13081310        else
    1309             infoPtr->iHotItem = -1;
    1310         hdc = GetDC (hwnd);
    1311         HEADER_Refresh (hwnd, hdc);
    1312         ReleaseDC (hwnd, hdc);
     1311            newItem = -1;
     1312        if (newItem != infoPtr->iHotItem)
     1313        {
     1314          infoPtr->iHotItem = newItem;
     1315          hdc = GetDC (hwnd);
     1316          HEADER_Refresh (hwnd, hdc);
     1317          ReleaseDC (hwnd, hdc);
     1318        }
    13131319    }
    13141320
    13151321    if (infoPtr->bCaptured) {
    1316         if (infoPtr->bPressed) {
     1322        if (infoPtr->bPressed)
     1323        {
     1324            BOOL newDown;
     1325
    13171326            if ((nItem == infoPtr->iMoveItem) && (flags == HHT_ONHEADER))
    1318                 infoPtr->items[infoPtr->iMoveItem].bDown = TRUE;
     1327                newDown = TRUE;
    13191328            else
    1320                 infoPtr->items[infoPtr->iMoveItem].bDown = FALSE;
    1321             hdc = GetDC (hwnd);
    1322             HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
    1323             ReleaseDC (hwnd, hdc);
    1324 
     1329                newDown = FALSE;
     1330
     1331            if (newDown != infoPtr->items[infoPtr->iMoveItem].bDown)
     1332            {
     1333              infoPtr->items[infoPtr->iMoveItem].bDown = newDown;
     1334              hdc = GetDC (hwnd);
     1335              HEADER_RefreshItem (hwnd, hdc, infoPtr->iMoveItem);
     1336              ReleaseDC (hwnd, hdc);
     1337            }
    13251338//          TRACE (header, "Moving pressed item %d!\n", infoPtr->iMoveItem);
    13261339        }
  • trunk/src/comctl32/hotkey.c

    r496 r968  
    1 /* $Id: hotkey.c,v 1.4 1999-08-14 16:13:10 cbratschi Exp $ */
     1/* $Id: hotkey.c,v 1.5 1999-09-18 12:21:26 cbratschi Exp $ */
    22/*
    33 * Hotkey control
     
    55 * Copyright 1998, 1999 Eric Kohl
    66 * Copyright 1999 Achim Hasenmueller
     7 * Copyright 1999 Christoph Bratschi
    78 *
    89 * NOTES
    9  *   Development in progress. An author is needed! Any volunteers?
    10  *   I will only improve this control once in a while.
    11  *     Eric <ekohl@abo.rhein-zeitung.de>
     10 *   Development in progress.
     11 *   CB: difficult with new User32
    1212 *
    1313 * TODO:
    14  *   - Some messages.
    15  *   - Display code.
     14 *   - keyboard messages
    1615 */
    1716
     
    1918#include "commctrl.h"
    2019#include "hotkey.h"
    21 
    22 
    23 #define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongA (hwnd, 0))
    24 
    25 
    26 /* << HOTHEY_GetHotKey >> */
    27 /* << HOTHEY_SetHotKey >> */
    28 /* << HOTHEY_SetRules >> */
    29 
    30 
    31 
    32 /* << HOTKEY_Char >> */
     20#include <string.h>
     21
     22#define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO*)GetWindowLongA(hwnd,0))
     23
     24static VOID
     25HOTKEY_UpdateHotKey(HWND hwnd);
     26
     27static BYTE
     28HOTKEY_Check(HOTKEY_INFO *infoPtr,BYTE bfMods)
     29{
     30  if ((infoPtr->fwCombInv & HKCOMB_A && bfMods == HOTKEYF_ALT) ||
     31      (infoPtr->fwCombInv & HKCOMB_C && bfMods == HOTKEYF_CONTROL) ||
     32      (infoPtr->fwCombInv & HKCOMB_CA && bfMods == HOTKEYF_CONTROL | HOTKEYF_ALT) ||
     33      (infoPtr->fwCombInv & HKCOMB_NONE && bfMods == 0) ||
     34      (infoPtr->fwCombInv & HKCOMB_S && bfMods == HOTKEYF_SHIFT) ||
     35      (infoPtr->fwCombInv & HKCOMB_SA && bfMods == HOTKEYF_SHIFT | HOTKEYF_ALT) ||
     36      (infoPtr->fwCombInv & HKCOMB_SC && bfMods == HOTKEYF_SHIFT | HOTKEYF_CONTROL) ||
     37      (infoPtr->fwCombInv & HKCOMB_SCA && bfMods == HOTKEYF_SHIFT | HOTKEYF_CONTROL | HOTKEYF_ALT))
     38    return infoPtr->fwModInv;
     39  else
     40    return bfMods;
     41}
     42
     43
     44static LRESULT
     45HOTKEY_SetHotKey(HWND hwnd,WPARAM wParam,LPARAM lParam)
     46{
     47  HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr(hwnd);
     48
     49  infoPtr->bVKHotKey = wParam & 0xFF;
     50  infoPtr->bfMods = HOTKEY_Check(infoPtr,wParam & 0xFF00);
     51
     52  HOTKEY_UpdateHotKey(hwnd);
     53
     54  return 0;
     55}
     56
     57
     58static LRESULT
     59HOTKEY_GetHotKey(HWND hwnd,WPARAM wParam,LPARAM lParam)
     60{
     61  HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr(hwnd);
     62
     63  return MAKEWORD(infoPtr->bVKHotKey,infoPtr->bfMods);
     64}
     65
     66
     67static LRESULT
     68HOTKEY_SetRules(HWND hwnd,WPARAM wParam,LPARAM lParam)
     69{
     70  HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr(hwnd);
     71  BYTE oldMods = infoPtr->bfMods;
     72
     73  infoPtr->fwCombInv = wParam;
     74  infoPtr->fwModInv = lParam;
     75
     76  infoPtr->bfMods = HOTKEY_Check(infoPtr,infoPtr->bfMods);
     77  if (infoPtr->bfMods != oldMods) HOTKEY_UpdateHotKey(hwnd);
     78
     79  return 0;
     80}
     81
     82
     83static LRESULT
     84HOTKEY_Char(HWND hwnd,WPARAM wParam,LPARAM lParam)
     85{
     86 //CB:
     87  return 0;
     88}
     89
     90
     91static LRESULT
     92HOTKEY_SysChar(HWND hwnd,WPARAM wParam,LPARAM lParam)
     93{
     94 //CB:
     95  return 0;
     96}
    3397
    3498
     
    42106    /* allocate memory for info structure */
    43107    infoPtr = (HOTKEY_INFO *)COMCTL32_Alloc (sizeof(HOTKEY_INFO));
    44     SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
     108    SetWindowLongA(hwnd,0,(DWORD)infoPtr);
    45109
    46110    /* initialize info structure */
    47111
     112    infoPtr->hFont     = 0;
     113    infoPtr->bFocus    = FALSE;
     114    infoPtr->bVKHotKey = 0;
     115    infoPtr->bfMods    = 0;
     116    infoPtr->fwCombInv = 0;
     117    infoPtr->fwModInv  = 0;
    48118
    49119    /* get default font height */
     
    62132    HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd);
    63133
    64 
    65 
    66134    /* free hotkey info data */
    67135    COMCTL32_Free (infoPtr);
     
    74142HOTKEY_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
    75143{
    76     /* HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); */
    77144    HBRUSH hBrush;
    78145    RECT   rc;
    79146
    80     hBrush =
    81         (HBRUSH)SendMessageA (GetParent (hwnd), WM_CTLCOLOREDIT,
    82                                 wParam, (LPARAM)hwnd);
    83     if (hBrush)
    84         hBrush = (HBRUSH)GetStockObject (WHITE_BRUSH);
    85     GetClientRect (hwnd, &rc);
    86 
    87     FillRect ((HDC)wParam, &rc, hBrush);
     147    hBrush = (HBRUSH)SendMessageA(GetParent(hwnd),WM_CTLCOLOREDIT,wParam,(LPARAM)hwnd);
     148    if (!hBrush) hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
     149    GetClientRect(hwnd,&rc);
     150    FillRect((HDC)wParam,&rc,hBrush);
    88151
    89152    return -1;
     
    172235
    173236
    174 
    175 
     237static VOID
     238HOTKEY_Draw(HWND hwnd,HDC hdc)
     239{
     240  HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr(hwnd);
     241  RECT rect;
     242  char text[50];
     243  HFONT oldFont;
     244
     245  GetClientRect(hwnd,&rect);
     246  DrawEdge(hdc,&rect,EDGE_SUNKEN,BF_RECT | BF_ADJUST);
     247
     248  //draw string
     249  text[0] = 0;
     250  if (infoPtr->bfMods & HOTKEYF_ALT) strcat(text,"ALT");
     251  if (infoPtr->bfMods & HOTKEYF_CONTROL)
     252  {
     253    if (text[0]) strcat(text,"+");
     254    strcat(text,"CONTROL");
     255  }
     256  if (infoPtr->bfMods & HOTKEYF_SHIFT)
     257  {
     258    if (text[0]) strcat(text,"+");
     259    strcat(text,"SHIFT");
     260  }
     261
     262  if (infoPtr->bVKHotKey)
     263  {
     264    char char2[2];
     265
     266    if (text[0]) strcat(text,"+");
     267    char2[0] = (char)infoPtr->bVKHotKey;
     268    char2[1] = 0;
     269    strcat(text,char2);
     270  }
     271  if(infoPtr->hFont) oldFont = SelectObject(hdc,infoPtr->hFont);
     272  SetBkMode(hdc,TRANSPARENT);
     273  DrawTextA(hdc,text,strlen(text),&rect,DT_LEFT | DT_BOTTOM | DT_SINGLELINE);
     274  if (infoPtr->hFont) SelectObject(hdc,oldFont);
     275}
     276
     277
     278static LRESULT
     279HOTKEY_Paint(HWND hwnd,WPARAM wParam,LPARAM lParam)
     280{
     281  PAINTSTRUCT ps;
     282  HDC         hdc;
     283
     284  if (wParam == 0) hdc = BeginPaint(hwnd,&ps);
     285  else hdc = wParam;
     286
     287  HOTKEY_Draw(hwnd,hdc);
     288
     289  if (wParam == 0) EndPaint(hwnd,&ps);
     290
     291  return 0;
     292}
     293
     294
     295static VOID
     296HOTKEY_UpdateHotKey(HWND hwnd)
     297{
     298  HDC hdc;
     299  RECT rect;
     300  HBRUSH hBrush;
     301
     302  GetClientRect(hwnd,&rect);
     303  InflateRect(&rect,2,2);
     304  hdc = GetDC(hwnd);
     305  hBrush = (HBRUSH)SendMessageA(GetParent(hwnd),WM_CTLCOLOREDIT,hdc,(LPARAM)hwnd);
     306  if (!hBrush) hBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);
     307  FillRect(hdc,&rect,hBrush);
     308  HOTKEY_Draw(hwnd,hdc);
     309  ReleaseDC(hwnd,hdc);
     310}
    176311
    177312static LRESULT
     
    182317    infoPtr->bFocus = TRUE;
    183318
    184 
    185319    CreateCaret (hwnd, (HBITMAP)0, 1, infoPtr->nHeight);
    186 
    187     SetCaretPos (1, 1);
    188 
     320    SetCaretPos (3,3);
    189321    ShowCaret (hwnd);
    190 
    191322
    192323    return 0;
     
    215346    ReleaseDC (hwnd, hdc);
    216347
    217     if (LOWORD(lParam)) {
    218 
    219 //      FIXME (hotkey, "force redraw!\n");
    220 
    221     }
     348    if (LOWORD(lParam)) HOTKEY_UpdateHotKey(hwnd);
    222349
    223350    return 0;
     
    271398    switch (uMsg)
    272399    {
    273 /*      case HKM_GETHOTKEY: */
    274 /*      case HKM_SETHOTKEY: */
    275 /*      case HKM_SETRULES: */
    276 
    277 /*      case WM_CHAR: */
     400        case HKM_GETHOTKEY:
     401            return HOTKEY_GetHotKey(hwnd,wParam,lParam);
     402
     403        case HKM_SETHOTKEY:
     404            return HOTKEY_SetHotKey(hwnd,wParam,lParam);
     405
     406        case HKM_SETRULES:
     407            return HOTKEY_SetRules(hwnd,wParam,lParam);
     408
     409        case WM_CHAR:
     410            return HOTKEY_Char(hwnd,wParam,lParam);
    278411
    279412        case WM_CREATE:
     
    293426
    294427        case WM_KEYDOWN:
     428            return HOTKEY_KeyDown(hwnd,wParam,lParam);
     429
    295430        case WM_SYSKEYDOWN:
    296             return HOTKEY_KeyDown (hwnd, wParam, lParam);
     431            return HOTKEY_SysKeyDown (hwnd, wParam, lParam);
    297432
    298433        case WM_KEYUP:
     434            return HOTKEY_KeyUp(hwnd,wParam,lParam);
     435
    299436        case WM_SYSKEYUP:
    300             return HOTKEY_KeyUp (hwnd, wParam, lParam);
     437            return HOTKEY_SysKeyUp (hwnd, wParam, lParam);
    301438
    302439        case WM_KILLFOCUS:
     
    309446            return HOTKEY_NCCreate (hwnd, wParam, lParam);
    310447
    311 /*      case WM_PAINT: */
     448        case WM_PAINT:
     449            return HOTKEY_Paint(hwnd,wParam,lParam);
    312450
    313451        case WM_SETFOCUS:
     
    317455            return HOTKEY_SetFont (hwnd, wParam, lParam);
    318456
    319 /*      case WM_SYSCHAR: */
     457        case WM_SYSCHAR:
     458            return HOTKEY_SysChar(hwnd,wParam,lParam);
    320459
    321460        default:
  • trunk/src/comctl32/updown.c

    r942 r968  
    1 /* $Id: updown.c,v 1.8 1999-09-15 16:31:49 cbratschi Exp $ */
     1/* $Id: updown.c,v 1.9 1999-09-18 12:21:26 cbratschi Exp $ */
    22/*
    33 * Updown control
     
    1818 *     - listbox as buddy window
    1919 *     - acceleration
    20  *     - base 16 -> bug: 9->B (should be A)
    2120 *     - UDS_ALIGNLEFT, ~UDS_WRAP
    2221 *       (tested - they work)
     
    897896  if (wParam==10 || wParam==16)
    898897  {
     898    UPDOWN_GetBuddyInt(hwnd);
     899
    899900    temp = infoPtr->Base;
    900901    infoPtr->Base = wParam;
     902
     903    UPDOWN_SetBuddyInt(hwnd);
     904
    901905    return temp;       /* return the prev base */
    902906  }
Note: See TracChangeset for help on using the changeset viewer.