summaryrefslogtreecommitdiff
path: root/common/basewnd.h
blob: f26f4f57f2ae00301367465ce9e76b5377d1fc4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef _BASEWND_H_
#define _BASEWND_H_

#include <string.h>

// FIXME: move this to another place
#ifdef WIN32
#include "stdafx.h"
typedef CWnd* BaseWndXID;
typedef struct
{
  CWnd* wnd;
  int index;
  UINT command;
} BaseMenuItem;
#endif

#ifdef LC_LINUX
#include <gtk/gtk.h>
typedef GtkWidget* BaseWndXID;
typedef struct
{
  GtkWidget* widget;
  GtkAccelGroup* accel;
} BaseMenuItem;
#endif

#ifdef LC_MACOSX
typedef void* BaseWndXID;
typedef struct
{
	void* Dummy;
} BaseMenuItem;
#endif

// =============================================================================
// Message Box constants

#define LC_OK           1
#define LC_CANCEL       2
#define LC_ABORT        3
#define LC_RETRY        4
#define LC_IGNORE       5
#define LC_YES          6
#define LC_NO           7
 
#define LC_MB_OK                 0x000
#define LC_MB_OKCANCEL           0x001
//#define LC_MB_ABORTRETRYIGNORE 0x002
#define LC_MB_YESNOCANCEL        0x003
#define LC_MB_YESNO              0x004
//#define LC_MB_RETRYCANCEL      0x005

#define LC_MB_ICONERROR          0x010
#define LC_MB_ICONQUESTION       0x020
#define LC_MB_ICONWARNING        0x030
#define LC_MB_ICONINFORMATION    0x040
 
#define LC_MB_TYPEMASK           0x00F
#define LC_MB_ICONMASK           0x0F0

// =============================================================================

class BaseWnd
{
 public:
  BaseWnd (BaseWnd *parent, int menu_count);
  virtual ~BaseWnd ();

  int MessageBox (const char* text, const char* caption="LeoCAD", int flags=LC_MB_OK|LC_MB_ICONINFORMATION);
  void BeginWait ();
  void EndWait ();
  void SetTitle (const char *title);

  void ShowMenuItem (int id, bool show);
  void EnableMenuItem (int id, bool enable);
  void CheckMenuItem (int id, bool check);
  void SetMenuItemText (int id, const char *text);

  BaseWndXID GetXID () const
    { return m_pXID; }
  void SetXID (BaseWndXID id)
    { m_pXID = id; }

#ifdef LC_LINUX 
  // FIXME: remove
  operator GtkWidget* () const
    { return m_pXID; }
#endif

  BaseMenuItem* GetMenuItem (int id) const
    { return &m_pMenuItems[id]; }
  void SetMenuItem (int id, BaseMenuItem* item)
    { memcpy (&m_pMenuItems[id], item, sizeof (BaseMenuItem)); }

 protected:
  BaseWnd* m_pParent;
  BaseWndXID m_pXID;
  BaseMenuItem* m_pMenuItems;
};

#endif // _BASEWND_H_