mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
[qwaq] Add a title bar
The title bar is special in that it is always centered at the top of its owner, thus it takes no rect.
This commit is contained in:
parent
19a4efed16
commit
731a123b79
3 changed files with 58 additions and 0 deletions
|
@ -35,6 +35,7 @@ qwaq_app_dat_src= \
|
|||
qwaq-rect.r \
|
||||
qwaq-screen.r \
|
||||
qwaq-textcontext.r \
|
||||
qwaq-titlebar.r \
|
||||
qwaq-view.r \
|
||||
qwaq-window.r
|
||||
|
||||
|
|
16
ruamoko/qwaq/qwaq-titlebar.h
Normal file
16
ruamoko/qwaq/qwaq-titlebar.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef __qwaq_titlebar_h
|
||||
#define __qwaq_titlebar_h
|
||||
|
||||
#include "qwaq-view.h"
|
||||
|
||||
@interface TitleBar : View
|
||||
{
|
||||
string title;
|
||||
int length;
|
||||
}
|
||||
// title always centered at top of owner
|
||||
-initWithTitle:(string) title;
|
||||
-setTitle:(string) newTitle;
|
||||
@end
|
||||
|
||||
#endif//__qwaq_titlebar_h
|
41
ruamoko/qwaq/qwaq-titlebar.r
Normal file
41
ruamoko/qwaq/qwaq-titlebar.r
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "qwaq-group.h"
|
||||
#include "qwaq-titlebar.h"
|
||||
|
||||
@implementation TitleBar
|
||||
|
||||
-initWithTitle:(string) title
|
||||
{
|
||||
if (!(self = [super init])) {
|
||||
return nil;
|
||||
}
|
||||
self.title = title;
|
||||
length = strlen (title);
|
||||
growMode = gfGrowHiX;
|
||||
return self;
|
||||
}
|
||||
|
||||
-setTitle:(string) newTitle
|
||||
{
|
||||
title = newTitle;
|
||||
length = strlen (title);
|
||||
[self redraw];
|
||||
return self;
|
||||
}
|
||||
|
||||
-setOwner: (Group *) owner
|
||||
{
|
||||
[super setOwner: owner];
|
||||
size = [owner size];
|
||||
return self;
|
||||
}
|
||||
|
||||
-draw
|
||||
{
|
||||
[super draw];
|
||||
[self mvaddstr: { (xlen - length) / 2, 0}, title];
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in a new issue