00001
00103 #ifndef INC_MGUI_SHELL_H
00104 #define INC_MGUI_SHELL_H
00105
00106 #ifndef INC_MI32_ICONID_H
00107 #include <mi32/iconid.h>
00108 #endif
00109
00110 #ifndef INC_MGUI_LAYOUT_H
00111 #include <mgui/layout.h>
00112 #endif
00113
00114 #ifndef INC_MI32_MISTRING_H
00115 #include <mi32/mistring.h>
00116 #endif
00117
00118 #ifndef INC_MI32_RECT_H
00119 #include <mi32/rect.h>
00120 #endif
00121
00122 #ifndef INC_MI32_MILIST_H
00123 #include <mi32/milist.h>
00124 #endif
00125
00126 #ifndef INC_MI32_CRITSEC_H
00127 #include <mi32/critsec.h>
00128 #endif
00129
00130 #if !defined(INC_MI32_XBASE_H) && defined(X_NATIVE)
00131 #include <mi32/xbase.h>
00132 #endif
00133
00134 #if !defined(X_H) && defined(X_NATIVE)
00135 #include <X11/X.h>
00136 #endif
00137
00138
00139 #ifndef GENERATING_DOXYGEN_OUTPUT
00140
00141 class SERIALIZERITEM;
00142 namespace MGUI {
00143 class CTRL_SEPARATOR;
00144 class CTRL_STATUSBAR;
00145 class DLGSHELL;
00146 class DLGWIZARD;
00147 class TOPSHELL;
00148 class MENU;
00149 }
00150 #endif
00151
00152
00153 namespace MGUI {
00154
00156 class SHELL {
00157 public:
00158
00159 class PLACEMENT;
00160
00161 #ifndef GENERATING_DOXYGEN_OUTPUT
00164 static SHELL* FindShell (
00165 Widget widget
00166 );
00167 #endif
00168
00170 static const COLOR& GetDftBackgroundColor ();
00171
00174 static MDLGPARENT GetDftDlgParent ();
00175
00178 static void SetDftDlgParent (
00179 MDLGPARENT dlgparent
00180 ) { s_DftDlgParent = dlgparent; }
00181
00184 void AddDelegateOnClose (
00185 DELEGATE_VOID_NOPARMS delegate
00186 );
00187
00192 void AttachMenuBar (
00193 MENU& menubar,
00194 bool AddSeparator = false
00195 );
00196
00198 void Destroy ();
00199
00201 void DlgShowHelp (
00202 ) const;
00203
00210 void ForceOnScreen (
00211 bool bResizeIfNecessary = false
00212 );
00213
00215 MDLGPARENT GetDlgParent () const;
00216
00218 HELPID GetHelpID (
00219 ) const { return (m_HelpID); }
00220
00222 LAYOUT_PANE& GetMainPane (
00223 ) { return (m_MainPane); }
00224
00226 void GetPlacement (
00227 PLACEMENT& placement
00228 ) const;
00229
00231 LAYOUT_PANE_SHELL& GetShellPane (
00232 ) { return (m_ShellPane); }
00233
00236 MGUI::LAYOUT_PANE& GetStatusBarPane ();
00237
00239 bool IsCreated () const
00240 { return (m_shell != 0); }
00241
00244 void NotifyActivate (
00245 bool activated
00246 );
00247
00250 void SetAllowTitleProcessID (
00251 bool allow
00252 ) { m_AllowTitleProcessID = allow; }
00253
00257 void SetIcon (
00258 ICONID iconid
00259 );
00260
00263 bool SetPlacement (
00264 const PLACEMENT& placement,
00265 const char *PlacementKey = 0
00266 );
00267
00271 void SetPlacementByKey (
00272 const char *PlacementKey
00273 );
00274
00276 void SetTitle (
00277 const MISTRING& title
00278 );
00279
00281 void Show ();
00282
00283 protected:
00284
00286 SHELL (
00287 HELPID helpid
00288 );
00289
00291 virtual ~SHELL ();
00292
00294 void CallOnCloseDelegates ();
00295
00298 void CreateStatusBarPane (
00299 LAYOUT_ORIENTATION orientation = LAYOUT_ORIENTATION_Horizontal,
00300 LAYOUT_SIZEALIGN sizealign = LAYOUT_SIZEALIGN_FixedHeight
00301 );
00302
00305 ICONID GetIcon (
00306 ) const { return m_IconID; }
00307
00309 const char* GetPlacementKey (
00310 ) const { return (m_PlacementKey); }
00311
00312 void UpdateTitle ();
00313
00314 private:
00315 #ifndef GENERATING_DOXYGEN_OUTPUT
00316
00317 friend class MGUI::TOPSHELL;
00318 friend class MGUI::DLGSHELL;
00319 friend class MGUI::DLGWIZARD;
00320
00321 static MDLGPARENT s_DftDlgParent;
00322 static bool s_ShowPIDInTitle;
00323 static bool s_ShowSizeInTitle;
00324 static UINT16 s_TestMaxWidth;
00325 static UINT16 s_TestMaxHeight;
00326
00327 Widget m_shell;
00328 LAYOUT_PANE m_MenuBarPane;
00329 CTRL_SEPARATOR *m_pMenuBarSeparator;
00330 LAYOUT_PANE_SHELL m_ShellPane;
00331 LAYOUT_PANE m_MainPane;
00332 LAYOUT_PANE m_StatusBarPane;
00333 HELPID m_HelpID;
00334 char *m_PlacementKey;
00335 bool m_AllowClose;
00336 bool m_AllowTitleProcessID;
00337 MISTRING m_Title;
00338 MENU *m_pMenuBar;
00339 ICONID m_IconID;
00340 bool m_bIconSent;
00341 MITHREAD::CRITICALSECTION m_CritSec;
00342 MILIST<DELEGATE_VOID_NOPARMS> m_DelegateListOnClose;
00343 MILIST<DELEGATE_VOID_NOPARMS> m_DelegateQueue;
00344
00345 void AttachShell (Widget shell, bool AllowClose=true);
00346 void DetachShell ();
00347 void OnCloseRequest () { v_OnCloseRequest(); }
00348 static void OnNotifyXDelete (Widget, SHELL*, void*);
00349 static void OnNotifyXDestroy (Widget, SHELL*, void*);
00350 static void OnNotifyXEvent (Widget, SHELL*, XEvent*);
00351
00352
00353 SHELL (const SHELL&);
00354 SHELL& operator= (const SHELL&);
00355
00356 #endif // GENERATING_DOXYGEN_OUTPUT
00357
00358
00359
00362 virtual int v_CreateContent () = 0;
00363
00365 virtual void v_Destroy () = 0;
00366
00369 virtual void v_OnCloseRequest () = 0;
00370
00373 virtual void v_OnActivate (
00374 bool activated
00375 );
00376
00377 };
00378
00379
00381 class SHELL::PLACEMENT {
00382 public:
00383
00385 static const SERIALIZERITEM* SerialGetItemDef (
00386 );
00387
00389 PLACEMENT ();
00390
00391 const LRECT2D& GetNormalPosition (
00392 ) const { return (m_NormalPosition); }
00393
00394 bool HasNormalPosition (
00395 ) const { return (m_NormalPosition.IsValid() && m_NormalPosition.xinit >= 0 && m_NormalPosition.yinit >= 0); }
00396
00397 bool HasNormalSize (
00398 ) const { return (m_NormalPosition.GetWidth() > 16 && m_NormalPosition.GetHeight() > 16); }
00399
00400 void IniRead (
00401 INIHANDLE IniHandle,
00402 const char *IniGroup,
00403 const char *IniName
00404 );
00405
00406 void IniWrite (
00407 INIHANDLE IniHandle,
00408 const char *IniGroup,
00409 const char *IniName
00410 ) const;
00411
00412 bool IsMaximized (
00413 ) const { return (m_IsMaximized); };
00414
00415 void SetMaximized (
00416 bool Maximized
00417 ) { m_IsMaximized = Maximized; }
00418
00419 void SetNormalPosition (
00420 const LRECT2D& NormalPosition
00421 ) { m_NormalPosition = NormalPosition; }
00422
00423 void SetPositionTopLeft (
00424 INT32 x,
00425 INT32 y
00426 ) { m_NormalPosition.Set(x,y,x,y); }
00427
00428 private:
00429 #ifndef GENERATING_DOXYGEN_OUTPUT
00430 bool m_IsMaximized;
00431 LRECT2D m_NormalPosition;
00432 #endif // GENERATING_DOXYGEN_OUTPUT
00433 };
00434
00435 }
00436
00437 #endif // INC_MGUI_SHELL_H