diff options
author | akshay-c | 2019-05-07 10:50:36 +0530 |
---|---|---|
committer | akshay-c | 2019-05-07 10:50:36 +0530 |
commit | f6250bab468eadfc020922040966d6ba75edd341 (patch) | |
tree | 7facc6d3fd89c0c23bce197ca9eb67fd2b20a185 /ldmicro/lib | |
parent | 46fbe3ae31bb5687f31b17acac4c449699876f2f (diff) | |
download | LDmicroQt-f6250bab468eadfc020922040966d6ba75edd341.tar.gz LDmicroQt-f6250bab468eadfc020922040966d6ba75edd341.tar.bz2 LDmicroQt-f6250bab468eadfc020922040966d6ba75edd341.zip |
Uncommented Titlebar Update Calls at places; Code beautification and code cleaning
Diffstat (limited to 'ldmicro/lib')
-rw-r--r-- | ldmicro/lib/freezeLD/freezeLD.cpp | 28 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.cpp | 90 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxLD.h | 22 | ||||
-rw-r--r-- | ldmicro/lib/linuxUI/linuxUI.cpp | 113 |
4 files changed, 19 insertions, 234 deletions
diff --git a/ldmicro/lib/freezeLD/freezeLD.cpp b/ldmicro/lib/freezeLD/freezeLD.cpp index 25843fc..b2cdf24 100644 --- a/ldmicro/lib/freezeLD/freezeLD.cpp +++ b/ldmicro/lib/freezeLD/freezeLD.cpp @@ -15,7 +15,8 @@ #include <stdio.h> /* - * store a window's position in the registry, or fail silently if the registry calls don't work + * store a window's position in the registry, or fail silently + * if the registry calls don't work */ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) { @@ -31,9 +32,11 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) return; } - sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey); + sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), + FREEZE_REGISTER, subKey); system(moveToKeyLocatin); - sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey); + sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), + FREEZE_REGISTER, subKey); if (-1 == chdir(moveToKeyLocatin)) { free(Ld_CWD); @@ -61,7 +64,6 @@ void FreezeWindowPosF(HWID hwid, char *subKey, char *name) free(keyName); return; } - // gtk_window_get_size(GTK_WINDOW(hwid), &val, NULL); val = hwid->size(); Register.write((char*)&val, sizeof(val)); Register.close(); @@ -107,7 +109,8 @@ static void Clamp(LONG *v, LONG min, LONG max) } /* - * retrieve a window's position from the registry, or do nothing if there is no info saved + * retrieve a window's position from the registry, + * or do nothing if there is no info saved */ void ThawWindowPosF(HWID hwid, char *subKey, char *name) { @@ -124,7 +127,8 @@ void ThawWindowPosF(HWID hwid, char *subKey, char *name) return; } - sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey); + sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), + FREEZE_REGISTER, subKey); if (-1 == chdir(moveToKeyLocatin)) { free(Ld_CWD); @@ -216,9 +220,11 @@ void FreezeDWORDF(DWORD val, char *subKey, char *name) return; } - sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey); + sprintf(moveToKeyLocatin, "mkdir -p %s/%s/%s", getenv("HOME"), + FREEZE_REGISTER, subKey); system(moveToKeyLocatin); - sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey); + sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), + FREEZE_REGISTER, subKey); if (-1 == chdir(moveToKeyLocatin)) { free(Ld_CWD); @@ -237,7 +243,8 @@ void FreezeDWORDF(DWORD val, char *subKey, char *name) } /* - * retrieve a DWORD setting, or return the default if that setting is unavailable + * retrieve a DWORD setting, + * or return the default if that setting is unavailable */ DWORD ThawDWORDF(DWORD val, char *subKey, char *name) { @@ -254,7 +261,8 @@ DWORD ThawDWORDF(DWORD val, char *subKey, char *name) return val; } - sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), FREEZE_REGISTER, subKey); + sprintf(moveToKeyLocatin, "%s/%s/%s", getenv("HOME"), + FREEZE_REGISTER, subKey); if (-1 == chdir(moveToKeyLocatin)) { free(Ld_CWD); diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp index 9fa63c9..e43ed70 100644 --- a/ldmicro/lib/linuxUI/linuxLD.cpp +++ b/ldmicro/lib/linuxUI/linuxLD.cpp @@ -32,111 +32,21 @@ size_t max(size_t A, size_t B) LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes) { - // if (hHeap == NULL) - // { - // printf("Alloc**********NULL HEAP***************\n"); LPVOID p = malloc(dwBytes); return p; - // } - - // auto it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; }); - - // if (it == HeapRecords.end()) - // return NULL; - - // if ((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwSize) - // { - // if ((*it).dwMaximumSize != 0) - // if((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwMaximumSize) - // return NULL; - - // (*it).hHeap = realloc((*it).hHeap, (*it).dwAllocatedSizeOffset + dwBytes); - // hHeap = (*it).hHeap; - // } - - // /// HEAP_ZERO_MEMORY is set by default - // DWORD flags = MAP_ANONYMOUS; - - // // if ( !((dwFlags & HEAP_ZERO_MEMORY) == HEAP_ZERO_MEMORY) ) - // // flags = MAP_ANONYMOUS | MAP_UNINITIALIZED; - - // /* Use for setting a meamory chunck with some value - // * void * memset ( void * ptr, int value, size_t num ); - // */ - // LPVOID p = mmap(hHeap + (*it).dwAllocatedSizeOffset, dwBytes, PROT_EXEC, flags, -1, 0); - - // if (p == NULL) - // return NULL; - - // (*it).dwAllocatedSizeOffset += dwBytes; - // HEAPCHUNCK chunck; - // chunck.Chunck = p; - // chunck.dwSize = dwBytes; - // (*it).Element.push_back(chunck); - - // return p; } BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) { - /// if NULL free() - // if (hHeap == NULL) - // { - // printf("free*********NULL HEAP***************\n"); free(lpMem); return TRUE; - // } - // auto heap_it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; }); - - // if (heap_it == HeapRecords.end()) - // return FALSE; - - // auto chunck_it = std::find_if((*heap_it).Element.begin(), (*heap_it).Element.end(), [&lpMem](HEAPCHUNCK &Chunck) { return Chunck.Chunck == lpMem; }); - - // if (chunck_it == (*heap_it).Element.end()) - // return FALSE; - - // int result = munmap((*chunck_it).Chunck, (*chunck_it).dwSize); - - // if (result == 0) - // { - // (*heap_it).Element.erase(chunck_it); - // return TRUE; - // } - // else - // return FALSE; - } -/*HICON LoadImage(HINSTANCE hinst, LPCTSTR lpszName, UINT uType, int cxDesired, - int cyDesired, UINT fuLoad) -{ - HICON pixbuf; - GError *error = NULL; - pixbuf = gdk_pixbuf_new_from_file(lpszName, &error); - - if(!pixbuf) { - fprintf(stderr, "%s\n", error->message); - g_error_free(error); - } - - return pixbuf; -}*/ - - void OutputDebugString(char* str) { } -/*double GetTickCount(void) -{ -// timespec now; -// clock_gettime() -// if (clock_gettime(CLOCK_MONOTONIC, &now)) -// return 0; - return 10.2;//now.tv_sec * 1000.0 + now.tv_nsec / 1000000.0; -}*/ double GetTickCount(void) { timespec now; diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 46eb523..8b19538 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -28,16 +28,6 @@ #define IMAGE_ICON 1 #define LDMICRO_ICON "../ldmicro.ico" -/// Macro functions -// #define max(_A, _B) std::max(_A, _B) - -/*#define max(_A, _B) { \ - if((_A) > (_B)) \ - return (_A); \ - else \ - return (_B); \ - }*/ - /// Typedefs //typedef int64_t __int64; typedef bool BOOL; @@ -160,18 +150,7 @@ typedef struct { UINT mask; int iItem; int iSubItem; -// UINT state; -// UINT stateMask; LPTSTR pszText; -// int cchTextMax; -// int iImage; -// LPARAM lParam; -// int iIndent; -// int iGroupId; -// UINT cColumns; -// PUINT puColumns; -// int *piColFmt; -// int iGroup; } LVITEM, *LPLVITEM; typedef struct tagNMHDR { @@ -193,7 +172,6 @@ typedef struct FontTag { typedef struct tagLOGBRUSH { UINT lbStyle; COLORREF lbColor; -// ULONG_PTR lbHatch; } LOGBRUSH, *PLOGBRUSH; typedef struct _RECT { diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index e9ae716..5d2c78f 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -29,17 +29,12 @@ HWID view; /// Wraper function for gtk_window_has_toplevel_focus BOOL GetFocus(HWID window) { - // return (BOOL) gtk_window_has_toplevel_focus(GTK_WINDOW(window)); return TRUE; } COLORREF RGB(int red, int green, int blue) { COLORREF col(red, green, blue); - // col.red = red/255.0; - // col.green = green/255.0; - // col.blue = blue/255.0; - // col.alpha = 1.0; return col; } @@ -138,11 +133,9 @@ void EnableMenuItem(HMENU MenuName, QAction* MenuItem, UINT CheckEnabledItem) switch (CheckEnabledItem){ case MF_ENABLED : MenuItem->setEnabled(true); - // MenuItem->blockSignals(false); break; case MF_GRAYED : MenuItem->setEnabled(false); - // MenuItem->blockSignals(true); break; } } @@ -279,92 +272,20 @@ void TextOut(HWID hWid, HCRDC hcr, int nXStart, int nYStart, LPCTSTR lpString, i int height = hWid->height(); BOOL resize_flag = FALSE; QFont newFont= hcr->font(); - // newFont - /*if(nYStart+(extents.height/2.0) >= height) - { - height += extents.height + 50; - resize_flag = TRUE; - } - - if (nXStart+(extents.width/2.0) >= width) - { - width += extents.width; - resize_flag = TRUE; - }*/ char* text = (char*)malloc(cchString); strncpy(text, lpString, cchString); text[cchString] = '\0'; hcr->drawText(nXStart, nYStart, (QString)text); - // cairo_move_to(hcr, nXStart, nYStart); - // cairo_show_text(hcr, text); - - // cairo_fill (hcr); - - /*if (resize_flag) // To do later - hcr->setWindow();*/ - /*if (hcr == NULL) - return; - - nYStart += 30; - - cairo_text_extents_t extents; - cairo_text_extents (hcr, lpString, &extents); - int width = gtk_widget_get_allocated_width (hWid); - int height= gtk_widget_get_allocated_height (hWid); - BOOL resize_flag = FALSE; - - if(nYStart+(extents.height/2.0) >= height) - { - height += extents.height + 50; - resize_flag = TRUE; - } - - if (nXStart+(extents.width/2.0) >= width) - { - width += extents.width; - resize_flag = TRUE; - } - - if (resize_flag) - gtk_widget_set_size_request(hWid, width, height); - - char* text = (char*)malloc(cchString); - strncpy(text, lpString, cchString); - text[cchString] = '\0'; - - cairo_move_to(hcr, nXStart, nYStart); - cairo_show_text(hcr, text); - - cairo_fill (hcr);*/ } COLORREF GetTextColor(HCRDC Hdc) { - // COLORREF col; - // gtk_style_context_get_color (Hdc, - // gtk_style_context_get_state (Hdc), - // &col); - return HdcCurrentTextColor; } BOOL InvalidateRect(HWID hWid, const RECT *lpRect, BOOL bErase) { - /*if(!GDK_IS_WINDOW(hWid)) - return FALSE; - - if (lpRect == NULL) - { - gdk_window_invalidate_rect (gtk_widget_get_window (hWid), NULL, FALSE); - return TRUE; - } - - GDRECT Gdrect; - RECT_to_GDRECT(lpRect, &Gdrect); - // gtk_widget_queue_draw(hWid); - gdk_window_invalidate_rect (gtk_widget_get_window (hWid), &Gdrect, FALSE); - */ hWid->repaint(); return TRUE; } @@ -377,16 +298,7 @@ int FillRect(HCRDC hDC, const QRect *lprc, HBRUSH hbr) curbrush.setColor(*hbr); curbrush.setStyle(Qt::SolidPattern); hDC->setBrush(curbrush); - hDC->drawRect(*lprc); - /* - GDRECT gdrc; - RECT_to_GDRECT(lprc, &gdrc); - - cairo_set_source_rgb(hDC, hbr->red, hbr->green, hbr->blue); - cairo_rectangle(hDC, gdrc.x, gdrc.y, gdrc.width, gdrc.height); - cairo_stroke_preserve(hDC); - cairo_fill(hDC);*/ - + hDC->drawRect(*lprc); return 0; } @@ -414,35 +326,12 @@ UINT SetTimer(HWID hWid, UINT nIDEvent, UINT uElapse, UINT TimerID) } break; } - // if(hWid!=NULL) - // CursorObject->setVisible(TRUE); return TimerID; - // auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&nIDEvent](TimerRecord &Record) { return Record.ufID == nIDEvent; }); - - // if (record_it != timerRecords.end()) - // return 0; - - // TimerRecord tr; - // tr.pfun = lpTimerFunc; - // tr.ufID = nIDEvent; - // tr.utID = g_timeout_add(uElapse, (GSourceFunc)lpTimerFunc, FALSE); - - // timerRecords.push_back(tr); - // return tr.utID; } BOOL KillTimer(HWID hWid, UINT uIDEvent) { - /*auto record_it = std::find_if(timerRecords.begin(), timerRecords.end(), [&uIDEvent](TimerRecord &Record) { return Record.ufID == uIDEvent; }); - - if (record_it == timerRecords.end()) - return FALSE; - - record_it->pfun(TRUE); - g_source_remove (record_it->utID); - timerRecords.erase(record_it);*/ - // printf("KillTimer\n"); switch(uIDEvent) { case TIMER_BLINK_CURSOR: |