comparison win/dw.c @ 2626:401a3b9f21ba

Massive continuation of code style standardization. Only tested on Mac and iOS, may require follow up commits to get things building again as I test on various platforms.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 01 Aug 2021 12:17:07 +0000
parents 2e804b4db81e
children b0712a3debe2
comparison
equal deleted inserted replaced
2625:2e804b4db81e 2626:401a3b9f21ba
359 { 359 {
360 dw_window_redraw(redraw); 360 dw_window_redraw(redraw);
361 } 361 }
362 } 362 }
363 363
364 typedef struct _sighandler 364 typedef struct _dwsighandler
365 { 365 {
366 struct _sighandler *next; 366 struct _dwsighandler *next;
367 ULONG message; 367 ULONG message;
368 HWND window; 368 HWND window;
369 int id; 369 int id;
370 void *signalfunction; 370 void *signalfunction;
371 void *discfunction; 371 void *discfunction;
372 void *data; 372 void *data;
373 373
374 } SignalHandler; 374 } DWSignalHandler;
375 375
376 SignalHandler *Root = NULL; 376 DWSignalHandler *Root = NULL;
377 377
378 typedef struct 378 typedef struct
379 { 379 {
380 ULONG message; 380 ULONG message;
381 char name[30]; 381 char name[30];
1083 1083
1084 /* This function adds a signal handler callback into the linked list. 1084 /* This function adds a signal handler callback into the linked list.
1085 */ 1085 */
1086 void _dw_new_signal(ULONG message, HWND window, int id, void *signalfunction, void *discfunc, void *data) 1086 void _dw_new_signal(ULONG message, HWND window, int id, void *signalfunction, void *discfunc, void *data)
1087 { 1087 {
1088 SignalHandler *new = malloc(sizeof(SignalHandler)); 1088 DWSignalHandler *new = malloc(sizeof(DWSignalHandler));
1089 1089
1090 new->message = message; 1090 new->message = message;
1091 new->window = window; 1091 new->window = window;
1092 new->id = id; 1092 new->id = id;
1093 new->signalfunction = signalfunction; 1093 new->signalfunction = signalfunction;
1099 { 1099 {
1100 Root = new; 1100 Root = new;
1101 } 1101 }
1102 else 1102 else
1103 { 1103 {
1104 SignalHandler *prev = NULL, *tmp = Root; 1104 DWSignalHandler *prev = NULL, *tmp = Root;
1105 while(tmp) 1105 while(tmp)
1106 { 1106 {
1107 if(tmp->message == message && 1107 if(tmp->message == message &&
1108 tmp->window == window && 1108 tmp->window == window &&
1109 tmp->id == id && 1109 tmp->id == id &&
2149 2149
2150 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */ 2150 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */
2151 LRESULT CALLBACK _dw_wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2) 2151 LRESULT CALLBACK _dw_wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
2152 { 2152 {
2153 int result = -1, taskbar = FALSE; 2153 int result = -1, taskbar = FALSE;
2154 SignalHandler *tmp = Root; 2154 DWSignalHandler *tmp = Root;
2155 void (DWSIGNAL *windowfunc)(PVOID); 2155 void (DWSIGNAL *windowfunc)(PVOID);
2156 ULONG origmsg = msg; 2156 ULONG origmsg = msg;
2157 2157
2158 #ifdef DARK_MODE_TITLEBAR_MENU 2158 #ifdef DARK_MODE_TITLEBAR_MENU
2159 /* Expand the client area into the titlebar so we can draw our alternate dark mode button 2159 /* Expand the client area into the titlebar so we can draw our alternate dark mode button
3263 || _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0 3263 || _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0
3264 #endif 3264 #endif
3265 ) 3265 )
3266 { 3266 {
3267 /* Generate click on default item */ 3267 /* Generate click on default item */
3268 SignalHandler *tmp = Root; 3268 DWSignalHandler *tmp = Root;
3269 3269
3270 /* Find any callbacks for this function */ 3270 /* Find any callbacks for this function */
3271 while (tmp) 3271 while (tmp)
3272 { 3272 {
3273 if (tmp->message == WM_COMMAND) 3273 if (tmp->message == WM_COMMAND)
3691 ListView_GetItem(hWnd, &lvi); 3691 ListView_GetItem(hWnd, &lvi);
3692 params = (void **)lvi.lParam; 3692 params = (void **)lvi.lParam;
3693 } 3693 }
3694 3694
3695 { 3695 {
3696 SignalHandler *tmp = Root; 3696 DWSignalHandler *tmp = Root;
3697 3697
3698 while(tmp) 3698 while(tmp)
3699 { 3699 {
3700 if(tmp->message == NM_DBLCLK && tmp->window == hWnd) 3700 if(tmp->message == NM_DBLCLK && tmp->window == hWnd)
3701 { 3701 {
3710 } 3710 }
3711 } 3711 }
3712 break; 3712 break;
3713 case WM_CONTEXTMENU: 3713 case WM_CONTEXTMENU:
3714 { 3714 {
3715 SignalHandler *tmp = Root; 3715 DWSignalHandler *tmp = Root;
3716 void **params = NULL; 3716 void **params = NULL;
3717 while(tmp) 3717 while(tmp)
3718 { 3718 {
3719 if(tmp->message == NM_RCLICK && tmp->window == hWnd) 3719 if(tmp->message == NM_RCLICK && tmp->window == hWnd)
3720 { 3720 {
4400 case WM_SETFOCUS: 4400 case WM_SETFOCUS:
4401 _dw_wndproc(hwnd, msg, mp1, mp2); 4401 _dw_wndproc(hwnd, msg, mp1, mp2);
4402 break; 4402 break;
4403 case WM_LBUTTONUP: 4403 case WM_LBUTTONUP:
4404 { 4404 {
4405 SignalHandler *tmp = Root; 4405 DWSignalHandler *tmp = Root;
4406 4406
4407 /* Find any callbacks for this function */ 4407 /* Find any callbacks for this function */
4408 while(tmp) 4408 while(tmp)
4409 { 4409 {
4410 if(tmp->message == WM_COMMAND) 4410 if(tmp->message == WM_COMMAND)
4436 /* A button press should also occur for an ENTER or SPACE press 4436 /* A button press should also occur for an ENTER or SPACE press
4437 * while the button has the active input focus. 4437 * while the button has the active input focus.
4438 */ 4438 */
4439 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ') 4439 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ')
4440 { 4440 {
4441 SignalHandler *tmp = Root; 4441 DWSignalHandler *tmp = Root;
4442 4442
4443 /* Find any callbacks for this function */ 4443 /* Find any callbacks for this function */
4444 while(tmp) 4444 while(tmp)
4445 { 4445 {
4446 if(tmp->message == WM_COMMAND) 4446 if(tmp->message == WM_COMMAND)
6490 } 6490 }
6491 6491
6492 /* Internal function to make sure menu ID isn't in use */ 6492 /* Internal function to make sure menu ID isn't in use */
6493 int _dw_menuid_allocated(int id) 6493 int _dw_menuid_allocated(int id)
6494 { 6494 {
6495 SignalHandler *tmp = Root; 6495 DWSignalHandler *tmp = Root;
6496 6496
6497 while(tmp) 6497 while(tmp)
6498 { 6498 {
6499 if(tmp->id == id) 6499 if(tmp->id == id)
6500 return TRUE; 6500 return TRUE;
13598 * Parameters: 13598 * Parameters:
13599 * id: Timer ID returned by dw_timer_connect(). 13599 * id: Timer ID returned by dw_timer_connect().
13600 */ 13600 */
13601 void API dw_timer_disconnect(HTIMER id) 13601 void API dw_timer_disconnect(HTIMER id)
13602 { 13602 {
13603 SignalHandler *prev = NULL, *tmp = Root; 13603 DWSignalHandler *prev = NULL, *tmp = Root;
13604 13604
13605 /* 0 is an invalid timer ID */ 13605 /* 0 is an invalid timer ID */
13606 if(!id) 13606 if(!id)
13607 return; 13607 return;
13608 13608
13694 * Parameters: 13694 * Parameters:
13695 * window: Window handle of callback to be removed. 13695 * window: Window handle of callback to be removed.
13696 */ 13696 */
13697 void API dw_signal_disconnect_by_name(HWND window, const char *signame) 13697 void API dw_signal_disconnect_by_name(HWND window, const char *signame)
13698 { 13698 {
13699 SignalHandler *prev = NULL, *tmp = Root; 13699 DWSignalHandler *prev = NULL, *tmp = Root;
13700 ULONG message; 13700 ULONG message;
13701 13701
13702 if(!window || !signame || (message = _dw_findsigmessage(signame)) == 0) 13702 if(!window || !signame || (message = _dw_findsigmessage(signame)) == 0)
13703 return; 13703 return;
13704 13704
13739 * Parameters: 13739 * Parameters:
13740 * window: Window handle of callback to be removed. 13740 * window: Window handle of callback to be removed.
13741 */ 13741 */
13742 void API dw_signal_disconnect_by_window(HWND window) 13742 void API dw_signal_disconnect_by_window(HWND window)
13743 { 13743 {
13744 SignalHandler *prev = NULL, *tmp = Root; 13744 DWSignalHandler *prev = NULL, *tmp = Root;
13745 13745
13746 while(tmp) 13746 while(tmp)
13747 { 13747 {
13748 if((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) 13748 if((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window)
13749 { 13749 {
13781 * window: Window handle of callback to be removed. 13781 * window: Window handle of callback to be removed.
13782 * data: Pointer to the data to be compared against. 13782 * data: Pointer to the data to be compared against.
13783 */ 13783 */
13784 void API dw_signal_disconnect_by_data(HWND window, void *data) 13784 void API dw_signal_disconnect_by_data(HWND window, void *data)
13785 { 13785 {
13786 SignalHandler *prev = NULL, *tmp = Root; 13786 DWSignalHandler *prev = NULL, *tmp = Root;
13787 13787
13788 while(tmp) 13788 while(tmp)
13789 { 13789 {
13790 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->data == data) 13790 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->data == data)
13791 { 13791 {