/*
**
*    Application.h
*    Encapsule une app Win32
**
*/

#ifndef _APPLICATION_H_
#define _APPLICATION_H_

#include <windows.h>

#include "IconEdit.h"
#include "resource.h"

//
// commctrl
//

#define NOTOOLBAR
#define NOUPDOWN
#define NOSTATUSBAR
#define NOMENUHELP
#define NOTRACKBAR
#define NODRAGLIST
#define NOPROGRESS
#define NOHOTKEY
#define NOHEADER
#define NOLISTVIEW 
#define NOTREEVIEW
#define NOTABCONTROL
#define NOANIMATE
#define NOCOMBOBOX
#define NOSCROLLBAR
#include <commctrl.h>
#pragma comment(lib, "comctl32.lib")

//
// Constantes
//

#define MAX_WINTYPE 0xff
#define CX_BITMAP   24
#define USER_FILE   "TYPEDEF.dat\0"
#define app_msg        static

//
// Structure repr閟entant une info dans le fichier
//

typedef struct wintypeTag
{
    char szTypedef[32];            // type windows
    char szTypeIntegral[64];    // type integral correspondant
    int  nImage;                // indice img dans la liste
    char szInfos[192];            // quelques infos

}WINTYPE, *LPWINTYPE;

//
// Wrapper pour l'app Win32
//

class Application
{
private:
    // Attributs
    static WINTYPE      g_Types[MAX_WINTYPE];
    static HIMAGELIST g_hImageList;
    static UINT       g_nbrTypes;
    static int        g_nSelectItem;
    static HFONT      g_fontList;

    static IconEdit*  g_edNewType;
    static IconEdit*  g_edNewIntegral;
    static IconEdit*  g_edNewInfo;

    // M閠hodes d'utilit閑s
    static void InitListe(HWND);
    static bool LoadData(HWND);

public:
    // Events
    app_msg void   OnInitDialog(HINSTANCE, HWND);
    app_msg void   OnCleanUp(void);
    app_msg void   OnSelChange(HWND);
    app_msg void   OnAddNewTypedef(HWND);
    app_msg BOOL   OnDrawListItem(LPDRAWITEMSTRUCT);
    app_msg HBRUSH OnCtlColorStatic(HWND, WPARAM, LPARAM);
    app_msg HBRUSH OnCtlColorEdit(HWND, WPARAM, LPARAM);

    // Get/Set
    static int  GetSelItem() { return g_nSelectItem; }
    static void SetSelItem(int n) { g_nSelectItem = n; }
};


#endif//_APPLICATION_H_