Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
Macros | Functions
WindowsHelpers.h File Reference

Interface for some helpful Windows-specific functions. More...

#include "Includes.h"
#include "RenderableComparatorNet.h"

Go to the source code of this file.

Macros

#define IDM_FILE_OPEN   1
 Menu id for Generate. More...
 
#define IDM_FILE_VERIFY   2
 Menu id for Verify. More...
 
#define IDM_FILE_EXPORT_PNG   3
 Menu id for Export PNG. More...
 
#define IDM_FILE_EXPORT_TEX   4
 Menu id for Export TeX. More...
 
#define IDM_FILE_EXPORT_SVG   5
 Menu id for Export SVG. More...
 
#define IDM_FILE_QUIT   6
 Menu id for Quit. More...
 
#define IDM_GENERATE_MINBUBBLE   7
 Menu id for Generate min-bubblesort. More...
 
#define IDM_GENERATE_MAXBUBBLE   8
 Menu id for Generate max-bubblesort. More...
 
#define IDM_GENERATE_BUBBLE   9
 Menu id for Generate min-bubblesort. More...
 
#define IDM_GENERATE_ODDEVEN   10
 Menu id for Generate odd-even. More...
 
#define IDM_GENERATE_BITONIC   11
 Menu id for Generate bitonic. More...
 
#define IDM_GENERATE_PAIRWISE   12
 Menu id for Generate pairwise. More...
 
#define IDM_VIEW_VERTICAL   13
 Menu id for vertical view. More...
 
#define IDM_VIEW_HORIZONTAL   14
 Menu id for horizontal view. More...
 
#define IDM_HELP_HELP   15
 Menu id for display help. More...
 
#define IDM_HELP_ABOUT   16
 Menu id for display About info. More...
 

Functions

void InitWindow (HINSTANCE, INT, WNDPROC)
 Initialize window. More...
 
ULONG_PTR InitGDIPlus ()
 Initialize GDI+. More...
 
HRESULT GetEncoderClsid (const WCHAR *, CLSID *)
 Get encoder CLSID. More...
 
HRESULT Load (HWND, CComparatorNetwork *, std::wstring &)
 Load comparator network. More...
 
HRESULT ExportImage (const eExport, HWND, CRenderableComparatorNet *, std::wstring &)
 Export. More...
 
void MinDragRect (HWND, WPARAM, RECT *, int, int)
 Enforce minimum drag rectangle. More...
 
void CreateFileMenu (HMENU hParent)
 Create File menu. More...
 
void CreateExportMenu (HMENU hParent)
 Create File menu. More...
 
void CreateGenerateMenu (HMENU hParent)
 Create Generate menu. More...
 
void CreateViewMenu (HMENU hParent)
 Create View menu. More...
 
void CreateHelpMenu (HMENU hParent)
 Create Help menu. More...
 

Detailed Description

These platform-dependent functions are hidden away so that the faint-of-heart don't have to see them if they're offended by them.

Definition in file WindowsHelpers.h.

Macro Definition Documentation

◆ IDM_FILE_EXPORT_PNG

#define IDM_FILE_EXPORT_PNG   3

Definition at line 42 of file WindowsHelpers.h.

◆ IDM_FILE_EXPORT_SVG

#define IDM_FILE_EXPORT_SVG   5

Definition at line 44 of file WindowsHelpers.h.

◆ IDM_FILE_EXPORT_TEX

#define IDM_FILE_EXPORT_TEX   4

Definition at line 43 of file WindowsHelpers.h.

◆ IDM_FILE_OPEN

#define IDM_FILE_OPEN   1

Definition at line 40 of file WindowsHelpers.h.

◆ IDM_FILE_QUIT

#define IDM_FILE_QUIT   6

Definition at line 45 of file WindowsHelpers.h.

◆ IDM_FILE_VERIFY

#define IDM_FILE_VERIFY   2

Definition at line 41 of file WindowsHelpers.h.

◆ IDM_GENERATE_BITONIC

#define IDM_GENERATE_BITONIC   11

Definition at line 51 of file WindowsHelpers.h.

◆ IDM_GENERATE_BUBBLE

#define IDM_GENERATE_BUBBLE   9

Definition at line 49 of file WindowsHelpers.h.

◆ IDM_GENERATE_MAXBUBBLE

#define IDM_GENERATE_MAXBUBBLE   8

Definition at line 48 of file WindowsHelpers.h.

◆ IDM_GENERATE_MINBUBBLE

#define IDM_GENERATE_MINBUBBLE   7

Definition at line 47 of file WindowsHelpers.h.

◆ IDM_GENERATE_ODDEVEN

#define IDM_GENERATE_ODDEVEN   10

Definition at line 50 of file WindowsHelpers.h.

◆ IDM_GENERATE_PAIRWISE

#define IDM_GENERATE_PAIRWISE   12

Definition at line 52 of file WindowsHelpers.h.

◆ IDM_HELP_ABOUT

#define IDM_HELP_ABOUT   16

Definition at line 58 of file WindowsHelpers.h.

◆ IDM_HELP_HELP

#define IDM_HELP_HELP   15

Definition at line 57 of file WindowsHelpers.h.

◆ IDM_VIEW_HORIZONTAL

#define IDM_VIEW_HORIZONTAL   14

Definition at line 55 of file WindowsHelpers.h.

◆ IDM_VIEW_VERTICAL

#define IDM_VIEW_VERTICAL   13

Definition at line 54 of file WindowsHelpers.h.

Function Documentation

◆ CreateExportMenu()

void CreateExportMenu ( HMENU  hParent)

Create the Export menu.

Parameters
hParentHandle to the parent menu.

Definition at line 374 of file WindowsHelpers.cpp.

◆ CreateFileMenu()

void CreateFileMenu ( HMENU  hParent)

Create the File menu.

Parameters
hParentHandle to the parent menu.

Definition at line 354 of file WindowsHelpers.cpp.

◆ CreateGenerateMenu()

void CreateGenerateMenu ( HMENU  hParent)

Create the Generate menu.

Parameters
hParentHandle to the parent menu.

Definition at line 387 of file WindowsHelpers.cpp.

◆ CreateHelpMenu()

void CreateHelpMenu ( HMENU  hParent)

Create the Help menu.

Parameters
hParentHandle to the parent menu.

Definition at line 417 of file WindowsHelpers.cpp.

◆ CreateViewMenu()

void CreateViewMenu ( HMENU  hParent)

Create the View menu.

Parameters
hParentHandle to the parent menu.

Definition at line 405 of file WindowsHelpers.cpp.

◆ ExportImage()

HRESULT ExportImage ( const eExport  t,
HWND  hwnd,
CRenderableComparatorNet pNet,
std::wstring &  wstrName 
)

Display a Save dialog box save an image of a comparator network to the file that the user selects. Export an image to a file.

Parameters
tExport file type.
hwndWindow handle.
pNetPointer to a renderable comparator network.
wstrNameDefault file name.
Returns
S_OK for success, E_FAIL for failure.

Definition at line 225 of file WindowsHelpers.cpp.

◆ GetEncoderClsid()

HRESULT GetEncoderClsid ( const WCHAR *  format,
CLSID *  pClsid 
)

Get an encoder clsid for an image file format.

Parameters
formatFile format using wide characters.
pClsid[OUT] Pointer to clsid.
Returns
S_OK for success, E_FAIL for failure.

Definition at line 193 of file WindowsHelpers.cpp.

◆ InitGDIPlus()

ULONG_PTR InitGDIPlus ( )

Initialize GDI+ and get a GDI+ token.

Returns
A GDI+ token.

Definition at line 174 of file WindowsHelpers.cpp.

◆ InitWindow()

void InitWindow ( HINSTANCE  hInst,
INT  nShow,
WNDPROC  WndProc 
)

Create and initialize a window.

Parameters
hInstInstance handle.
nShow1 to show window, 0 to hide.
WndProcWindow procedure.

Definition at line 131 of file WindowsHelpers.cpp.

◆ Load()

HRESULT Load ( HWND  hwnd,
CComparatorNetwork pNet,
std::wstring &  wstrName 
)

Pop up a Windows Open dialog box for the user to pick a text file and read the comparator network from there into a comparator network.

Parameters
hwndWindow handle.
pNet[OUT] Pointer to a renderable comparator network.
wstrName[IN, OUT] File name without extension.
Returns
S_OK for success, E_FAIL for failure.

Definition at line 303 of file WindowsHelpers.cpp.

◆ MinDragRect()

void MinDragRect ( HWND  hwnd,
WPARAM  wParam,
RECT *  pRect,
int  w,
int  h 
)

Resize the drag rectangle provided by a WM_SIZING message to ensure a minimum client area width and height.

Parameters
hwndWindow handle.
wParamWMSZ message telling us which edge is being dragged on.
pRect[IN, OUT] Pointer to drag rectangle.
wMinimum width of client area.
hMinimum height of client area.

Definition at line 63 of file WindowsHelpers.cpp.